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-default-high-score 0
203 "*Default threshold for a high scored article.
204 An article will be highlighted as high scored if its score is greater
206 :group 'gnus-score-default
209 (defcustom gnus-summary-default-low-score 0
210 "*Default threshold for a low scored article.
211 An article will be highlighted as low scored if its score is smaller
213 :group 'gnus-score-default
216 (defcustom gnus-summary-zcore-fuzz 0
217 "*Fuzziness factor for the zcore in the summary buffer.
218 Articles with scores closer than this to `gnus-summary-default-score'
220 :group 'gnus-summary-format
223 (defcustom gnus-simplify-subject-fuzzy-regexp nil
224 "*Strings to be removed when doing fuzzy matches.
225 This can either be a regular expression or list of regular expressions
226 that will be removed from subject strings if fuzzy subject
227 simplification is selected."
229 :type '(repeat regexp))
231 (defcustom gnus-show-threads t
232 "*If non-nil, display threads in summary mode."
236 (defcustom gnus-thread-hide-subtree nil
237 "*If non-nil, hide all threads initially.
238 If threads are hidden, you have to run the command
239 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
240 to expose hidden threads."
244 (defcustom gnus-thread-hide-killed t
245 "*If non-nil, hide killed threads automatically."
249 (defcustom gnus-thread-ignore-subject t
250 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
251 If nil, articles that have different subjects from their parents will
252 start separate threads."
256 (defcustom gnus-thread-operation-ignore-subject t
257 "*If non-nil, subjects will be ignored when doing thread commands.
258 This affects commands like `gnus-summary-kill-thread' and
259 `gnus-summary-lower-thread'.
261 If this variable is nil, articles in the same thread with different
262 subjects will not be included in the operation in question. If this
263 variable is `fuzzy', only articles that have subjects that are fuzzily
264 equal will be included."
266 :type '(choice (const :tag "off" nil)
270 (defcustom gnus-thread-indent-level 4
271 "*Number that says how much each sub-thread should be indented."
275 (defcustom gnus-auto-extend-newsgroup t
276 "*If non-nil, extend newsgroup forward and backward when requested."
277 :group 'gnus-summary-choose
280 (defcustom gnus-auto-select-first t
281 "*If nil, don't select the first unread article when entering a group.
282 If this variable is `best', select the highest-scored unread article
283 in the group. If t, select the first unread article.
285 This variable can also be a function to place point on a likely
286 subject line. Useful values include `gnus-summary-first-unread-subject',
287 `gnus-summary-first-unread-article' and
288 `gnus-summary-best-unread-article'.
290 If you want to prevent automatic selection of the first unread article
291 in some newsgroups, set the variable to nil in
292 `gnus-select-group-hook'."
293 :group 'gnus-group-select
294 :type '(choice (const :tag "none" nil)
296 (sexp :menu-tag "first" t)
297 (function-item gnus-summary-first-unread-subject)
298 (function-item gnus-summary-first-unread-article)
299 (function-item gnus-summary-best-unread-article)))
301 (defcustom gnus-auto-select-next t
302 "*If non-nil, offer to go to the next group from the end of the previous.
303 If the value is t and the next newsgroup is empty, Gnus will exit
304 summary mode and go back to group mode. If the value is neither nil
305 nor t, Gnus will select the following unread newsgroup. In
306 particular, if the value is the symbol `quietly', the next unread
307 newsgroup will be selected without any confirmation, and if it is
308 `almost-quietly', the next group will be selected without any
309 confirmation if you are located on the last article in the group.
310 Finally, if this variable is `slightly-quietly', the `Z n' command
311 will go to the next group without confirmation."
312 :group 'gnus-summary-maneuvering
313 :type '(choice (const :tag "off" nil)
315 (const almost-quietly)
316 (const slightly-quietly)
317 (sexp :menu-tag "on" t)))
319 (defcustom gnus-auto-select-same nil
320 "*If non-nil, select the next article with the same subject.
321 If there are no more articles with the same subject, go to
322 the first unread article."
323 :group 'gnus-summary-maneuvering
326 (defcustom gnus-summary-check-current nil
327 "*If non-nil, consider the current article when moving.
328 The \"unread\" movement commands will stay on the same line if the
329 current article is unread."
330 :group 'gnus-summary-maneuvering
333 (defcustom gnus-auto-center-summary t
334 "*If non-nil, always center the current summary buffer.
335 In particular, if `vertical' do only vertical recentering. If non-nil
336 and non-`vertical', do both horizontal and vertical recentering."
337 :group 'gnus-summary-maneuvering
338 :type '(choice (const :tag "none" nil)
340 (integer :tag "height")
341 (sexp :menu-tag "both" t)))
343 (defcustom gnus-show-all-headers nil
344 "*If non-nil, don't hide any headers."
345 :group 'gnus-article-hiding
346 :group 'gnus-article-headers
349 (defcustom gnus-summary-ignore-duplicates nil
350 "*If non-nil, ignore articles with identical Message-ID headers."
354 (defcustom gnus-single-article-buffer t
355 "*If non-nil, display all articles in the same buffer.
356 If nil, each group will get its own article buffer."
357 :group 'gnus-article-various
360 (defcustom gnus-break-pages t
361 "*If non-nil, do page breaking on articles.
362 The page delimiter is specified by the `gnus-page-delimiter'
364 :group 'gnus-article-various
367 (defcustom gnus-move-split-methods nil
368 "*Variable used to suggest where articles are to be moved to.
369 It uses the same syntax as the `gnus-split-methods' variable.
370 However, whereas `gnus-split-methods' specifies file names as targets,
371 this variable specifies group names."
372 :group 'gnus-summary-mail
373 :type '(repeat (choice (list :value (fun) function)
374 (cons :value ("" "") regexp (repeat string))
377 (defcustom gnus-unread-mark ? ;Whitespace
378 "*Mark used for unread articles."
379 :group 'gnus-summary-marks
382 (defcustom gnus-ticked-mark ?!
383 "*Mark used for ticked articles."
384 :group 'gnus-summary-marks
387 (defcustom gnus-dormant-mark ??
388 "*Mark used for dormant articles."
389 :group 'gnus-summary-marks
392 (defcustom gnus-del-mark ?r
393 "*Mark used for del'd articles."
394 :group 'gnus-summary-marks
397 (defcustom gnus-read-mark ?R
398 "*Mark used for read articles."
399 :group 'gnus-summary-marks
402 (defcustom gnus-expirable-mark ?E
403 "*Mark used for expirable articles."
404 :group 'gnus-summary-marks
407 (defcustom gnus-killed-mark ?K
408 "*Mark used for killed articles."
409 :group 'gnus-summary-marks
412 (defcustom gnus-souped-mark ?F
413 "*Mark used for souped articles."
414 :group 'gnus-summary-marks
417 (defcustom gnus-kill-file-mark ?X
418 "*Mark used for articles killed by kill files."
419 :group 'gnus-summary-marks
422 (defcustom gnus-low-score-mark ?Y
423 "*Mark used for articles with a low score."
424 :group 'gnus-summary-marks
427 (defcustom gnus-catchup-mark ?C
428 "*Mark used for articles that are caught up."
429 :group 'gnus-summary-marks
432 (defcustom gnus-replied-mark ?A
433 "*Mark used for articles that have been replied to."
434 :group 'gnus-summary-marks
437 (defcustom gnus-forwarded-mark ?O
438 "*Mark used for articles that have been forwarded."
439 :group 'gnus-summary-marks
442 (defcustom gnus-cached-mark ?*
443 "*Mark used for articles that are in the cache."
444 :group 'gnus-summary-marks
447 (defcustom gnus-saved-mark ?S
448 "*Mark used for articles that have been saved to."
449 :group 'gnus-summary-marks
452 (defcustom gnus-no-mark ? ;Whitespace
453 "*Mark used for articles that have no other secondary mark."
454 :group 'gnus-summary-marks
457 (defcustom gnus-ancient-mark ?O
458 "*Mark used for ancient articles."
459 :group 'gnus-summary-marks
462 (defcustom gnus-sparse-mark ?Q
463 "*Mark used for sparsely reffed articles."
464 :group 'gnus-summary-marks
467 (defcustom gnus-canceled-mark ?G
468 "*Mark used for canceled articles."
469 :group 'gnus-summary-marks
472 (defcustom gnus-duplicate-mark ?M
473 "*Mark used for duplicate articles."
474 :group 'gnus-summary-marks
477 (defcustom gnus-undownloaded-mark ?@
478 "*Mark used for articles that weren't downloaded."
479 :group 'gnus-summary-marks
482 (defcustom gnus-downloadable-mark ?%
483 "*Mark used for articles that are to be downloaded."
484 :group 'gnus-summary-marks
487 (defcustom gnus-unsendable-mark ?=
488 "*Mark used for articles that won't be sent."
489 :group 'gnus-summary-marks
492 (defcustom gnus-score-over-mark ?+
493 "*Score mark used for articles with high scores."
494 :group 'gnus-summary-marks
497 (defcustom gnus-score-below-mark ?-
498 "*Score mark used for articles with low scores."
499 :group 'gnus-summary-marks
502 (defcustom gnus-empty-thread-mark ? ;Whitespace
503 "*There is no thread under the article."
504 :group 'gnus-summary-marks
507 (defcustom gnus-not-empty-thread-mark ?=
508 "*There is a thread under the article."
509 :group 'gnus-summary-marks
512 (defcustom gnus-view-pseudo-asynchronously nil
513 "*If non-nil, Gnus will view pseudo-articles asynchronously."
514 :group 'gnus-extract-view
517 (defcustom gnus-auto-expirable-marks
518 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
519 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
520 gnus-souped-mark gnus-duplicate-mark)
521 "*The list of marks converted into expiration if a group is auto-expirable."
524 :type '(repeat character))
526 (defcustom gnus-inhibit-user-auto-expire t
527 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
532 (defcustom gnus-view-pseudos nil
533 "*If `automatic', pseudo-articles will be viewed automatically.
534 If `not-confirm', pseudos will be viewed automatically, and the user
535 will not be asked to confirm the command."
536 :group 'gnus-extract-view
537 :type '(choice (const :tag "off" nil)
539 (const not-confirm)))
541 (defcustom gnus-view-pseudos-separately t
542 "*If non-nil, one pseudo-article will be created for each file to be viewed.
543 If nil, all files that use the same viewing command will be given as a
544 list of parameters to that command."
545 :group 'gnus-extract-view
548 (defcustom gnus-insert-pseudo-articles t
549 "*If non-nil, insert pseudo-articles when decoding articles."
550 :group 'gnus-extract-view
553 (defcustom gnus-summary-dummy-line-format
555 "*The format specification for the dummy roots in the summary buffer.
556 It works along the same lines as a normal formatting string,
557 with some simple extensions.
560 :group 'gnus-threading
563 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
564 "*The format specification for the summary mode line.
565 It works along the same lines as a normal formatting string,
566 with some simple extensions:
569 %p Unprefixed group name
570 %A Current article number
571 %z Current article score
573 %U Number of unread articles in the group
574 %e Number of unselected articles in the group
575 %Z A string with unread/unselected article counts
576 %g Shortish group name
577 %S Subject of the current article
579 %s Current score file name
580 %d Number of dormant articles
581 %r Number of articles that have been marked as read in this session
582 %E Number of articles expunged by the score files"
583 :group 'gnus-summary-format
586 (defcustom gnus-list-identifiers nil
587 "Regexp that matches list identifiers to be removed from subject.
588 This can also be a list of regexps."
590 :group 'gnus-summary-format
591 :group 'gnus-article-hiding
592 :type '(choice (const :tag "none" nil)
594 (repeat :value (".*") regexp)))
596 (defcustom gnus-summary-mark-below 0
597 "*Mark all articles with a score below this variable as read.
598 This variable is local to each summary buffer and usually set by the
600 :group 'gnus-score-default
603 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
604 "*List of functions used for sorting articles in the summary buffer.
606 Each function takes two articles and returns non-nil if the first
607 article should be sorted before the other. If you use more than one
608 function, the primary sort function should be the last. You should
609 probably always include `gnus-article-sort-by-number' in the list of
610 sorting functions -- preferably first. Also note that sorting by date
611 is often much slower than sorting by number, and the sorting order is
612 very similar. (Sorting by date means sorting by the time the message
613 was sent, sorting by number means sorting by arrival time.)
615 Ready-made functions include `gnus-article-sort-by-number',
616 `gnus-article-sort-by-author', `gnus-article-sort-by-subject',
617 `gnus-article-sort-by-date' and `gnus-article-sort-by-score'.
619 When threading is turned on, the variable `gnus-thread-sort-functions'
620 controls how articles are sorted."
621 :group 'gnus-summary-sort
622 :type '(repeat (choice (function-item gnus-article-sort-by-number)
623 (function-item gnus-article-sort-by-author)
624 (function-item gnus-article-sort-by-subject)
625 (function-item gnus-article-sort-by-date)
626 (function-item gnus-article-sort-by-score)
627 (function :tag "other"))))
629 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
630 "*List of functions used for sorting threads in the summary buffer.
631 By default, threads are sorted by article number.
633 Each function takes two threads and returns non-nil if the first
634 thread should be sorted before the other. If you use more than one
635 function, the primary sort function should be the last. You should
636 probably always include `gnus-thread-sort-by-number' in the list of
637 sorting functions -- preferably first. Also note that sorting by date
638 is often much slower than sorting by number, and the sorting order is
639 very similar. (Sorting by date means sorting by the time the message
640 was sent, sorting by number means sorting by arrival time.)
642 Ready-made functions include `gnus-thread-sort-by-number',
643 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
644 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
645 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').
647 When threading is turned off, the variable
648 `gnus-article-sort-functions' controls how articles are sorted."
649 :group 'gnus-summary-sort
650 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
651 (function-item gnus-thread-sort-by-author)
652 (function-item gnus-thread-sort-by-subject)
653 (function-item gnus-thread-sort-by-date)
654 (function-item gnus-thread-sort-by-score)
655 (function-item gnus-thread-sort-by-total-score)
656 (function :tag "other"))))
658 (defcustom gnus-thread-score-function '+
659 "*Function used for calculating the total score of a thread.
661 The function is called with the scores of the article and each
662 subthread and should then return the score of the thread.
664 Some functions you can use are `+', `max', or `min'."
665 :group 'gnus-summary-sort
668 (defcustom gnus-summary-expunge-below nil
669 "All articles that have a score less than this variable will be expunged.
670 This variable is local to the summary buffers."
671 :group 'gnus-score-default
672 :type '(choice (const :tag "off" nil)
675 (defcustom gnus-thread-expunge-below nil
676 "All threads that have a total score less than this variable will be expunged.
677 See `gnus-thread-score-function' for en explanation of what a
680 This variable is local to the summary buffers."
681 :group 'gnus-threading
682 :group 'gnus-score-default
683 :type '(choice (const :tag "off" nil)
686 (defcustom gnus-summary-mode-hook nil
687 "*A hook for Gnus summary mode.
688 This hook is run before any variables are set in the summary buffer."
689 :options '(turn-on-gnus-mailing-list-mode)
690 :group 'gnus-summary-various
693 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
694 (when (featurep 'xemacs)
695 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
696 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
697 (add-hook 'gnus-summary-mode-hook
698 'gnus-xmas-switch-horizontal-scrollbar-off))
700 (defcustom gnus-summary-menu-hook nil
701 "*Hook run after the creation of the summary mode menu."
702 :group 'gnus-summary-visual
705 (defcustom gnus-summary-exit-hook nil
706 "*A hook called on exit from the summary buffer.
707 It will be called with point in the group buffer."
708 :group 'gnus-summary-exit
711 (defcustom gnus-summary-prepare-hook nil
712 "*A hook called after the summary buffer has been generated.
713 If you want to modify the summary buffer, you can use this hook."
714 :group 'gnus-summary-various
717 (defcustom gnus-summary-prepared-hook nil
718 "*A hook called as the last thing after the summary buffer has been generated."
719 :group 'gnus-summary-various
722 (defcustom gnus-summary-generate-hook nil
723 "*A hook run just before generating the summary buffer.
724 This hook is commonly used to customize threading variables and the
726 :group 'gnus-summary-various
729 (defcustom gnus-select-group-hook nil
730 "*A hook called when a newsgroup is selected.
732 If you'd like to simplify subjects like the
733 `gnus-summary-next-same-subject' command does, you can use the
736 (setq gnus-select-group-hook
739 (mapcar (lambda (header)
740 (mail-header-set-subject
742 (gnus-simplify-subject
743 (mail-header-subject header) 're-only)))
744 gnus-newsgroup-headers))))"
745 :group 'gnus-group-select
748 (defcustom gnus-select-article-hook nil
749 "*A hook called when an article is selected."
750 :group 'gnus-summary-choose
753 (defcustom gnus-visual-mark-article-hook
754 (list 'gnus-highlight-selected-summary)
755 "*Hook run after selecting an article in the summary buffer.
756 It is meant to be used for highlighting the article in some way. It
757 is not run if `gnus-visual' is nil."
758 :group 'gnus-summary-visual
761 (defcustom gnus-parse-headers-hook nil
762 "*A hook called before parsing the headers."
766 (defcustom gnus-exit-group-hook nil
767 "*A hook called when exiting summary mode.
768 This hook is not called from the non-updating exit commands like `Q'."
772 (defcustom gnus-summary-update-hook
773 (list 'gnus-summary-highlight-line)
774 "*A hook called when a summary line is changed.
775 The hook will not be called if `gnus-visual' is nil.
777 The default function `gnus-summary-highlight-line' will
778 highlight the line according to the `gnus-summary-highlight'
780 :group 'gnus-summary-visual
783 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
784 "*A hook called when an article is selected for the first time.
785 The hook is intended to mark an article as read (or unread)
786 automatically when it is selected."
787 :group 'gnus-summary-choose
790 (defcustom gnus-group-no-more-groups-hook nil
791 "*A hook run when returning to group mode having no more (unread) groups."
792 :group 'gnus-group-select
795 (defcustom gnus-ps-print-hook nil
796 "*A hook run before ps-printing something from Gnus."
800 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
801 "Face used for highlighting the current article in the summary buffer."
802 :group 'gnus-summary-visual
805 (defcustom gnus-summary-highlight
806 '(((= mark gnus-canceled-mark)
807 . gnus-summary-cancelled-face)
808 ((and (> score default-high)
809 (or (= mark gnus-dormant-mark)
810 (= mark gnus-ticked-mark)))
811 . gnus-summary-high-ticked-face)
812 ((and (< score default-low)
813 (or (= mark gnus-dormant-mark)
814 (= mark gnus-ticked-mark)))
815 . gnus-summary-low-ticked-face)
816 ((or (= mark gnus-dormant-mark)
817 (= mark gnus-ticked-mark))
818 . gnus-summary-normal-ticked-face)
819 ((and (> score default-high) (= mark gnus-ancient-mark))
820 . gnus-summary-high-ancient-face)
821 ((and (< score default-low) (= mark gnus-ancient-mark))
822 . gnus-summary-low-ancient-face)
823 ((= mark gnus-ancient-mark)
824 . gnus-summary-normal-ancient-face)
825 ((and (> score default-high) (= mark gnus-unread-mark))
826 . gnus-summary-high-unread-face)
827 ((and (< score default-low) (= mark gnus-unread-mark))
828 . gnus-summary-low-unread-face)
829 ((= mark gnus-unread-mark)
830 . gnus-summary-normal-unread-face)
831 ((and (> score default-high) (memq mark (list gnus-downloadable-mark
832 gnus-undownloaded-mark)))
833 . gnus-summary-high-unread-face)
834 ((and (< score default-low) (memq mark (list gnus-downloadable-mark
835 gnus-undownloaded-mark)))
836 . gnus-summary-low-unread-face)
837 ((and (memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
838 (memq article gnus-newsgroup-unreads))
839 . gnus-summary-normal-unread-face)
840 ((memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
841 . gnus-summary-normal-read-face)
842 ((> score default-high)
843 . gnus-summary-high-read-face)
844 ((< score default-low)
845 . gnus-summary-low-read-face)
847 . gnus-summary-normal-read-face))
848 "*Controls the highlighting of summary buffer lines.
850 A list of (FORM . FACE) pairs. When deciding how a a particular
851 summary line should be displayed, each form is evaluated. The content
852 of the face field after the first true form is used. You can change
853 how those summary lines are displayed, by editing the face field.
855 You can use the following variables in the FORM field.
857 score: The article's score
858 default: The default article score.
859 default-high: The default score for high scored articles.
860 default-low: The default score for low scored articles.
861 below: The score below which articles are automatically marked as read.
862 mark: The articles mark."
863 :group 'gnus-summary-visual
864 :type '(repeat (cons (sexp :tag "Form" nil)
867 (defcustom gnus-alter-header-function nil
868 "Function called to allow alteration of article header structures.
869 The function is called with one parameter, the article header vector,
870 which it may alter in any way.")
872 (defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string
873 "Variable that says which function should be used to decode a string with encoded words.")
875 (defcustom gnus-extra-headers nil
876 "*Extra headers to parse."
879 :type '(repeat symbol))
881 (defcustom gnus-ignored-from-addresses
882 (and user-mail-address (regexp-quote user-mail-address))
883 "*Regexp of From headers that may be suppressed in favor of To headers."
888 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
889 "List of charsets that should be ignored.
890 When these charsets are used in the \"charset\" parameter, the
891 default charset will be used instead."
893 :type '(repeat symbol)
894 :group 'gnus-charset)
896 (gnus-define-group-parameter
900 "Return the ignored charsets of GROUP."
901 :variable gnus-group-ignored-charsets-alist
903 '(("alt\\.chinese\\.text" iso-8859-1))
905 "Alist of regexps (to match group names) and charsets that should be ignored.
906 When these charsets are used in the \"charset\" parameter, the
907 default charset will be used instead."
908 :variable-group gnus-charset
909 :variable-type '(repeat (cons (regexp :tag "Group")
911 :parameter-type '(choice :tag "Ignored charsets"
914 :parameter-document "\
915 List of charsets that should be ignored.
917 When these charsets are used in the \"charset\" parameter, the
918 default charset will be used instead.")
920 (defcustom gnus-group-highlight-words-alist nil
921 "Alist of group regexps and highlight regexps.
922 This variable uses the same syntax as `gnus-emphasis-alist'."
924 :type '(repeat (cons (regexp :tag "Group")
925 (repeat (list (regexp :tag "Highlight regexp")
926 (number :tag "Group for entire word" 0)
927 (number :tag "Group for displayed part" 0)
929 gnus-emphasis-highlight-words)))))
930 :group 'gnus-summary-visual)
932 (defcustom gnus-summary-show-article-charset-alist
934 "Alist of number and charset.
935 The article will be shown with the charset corresponding to the
937 For example: ((1 . cn-gb-2312) (2 . big5))."
939 :type '(repeat (cons (number :tag "Argument" 1)
940 (symbol :tag "Charset")))
941 :group 'gnus-charset)
943 (defcustom gnus-preserve-marks t
944 "Whether marks are preserved when moving, copying and respooling messages."
947 :group 'gnus-summary-marks)
949 (defcustom gnus-alter-articles-to-read-function nil
950 "Function to be called to alter the list of articles to be selected."
951 :type '(choice (const nil) function)
952 :group 'gnus-summary)
954 (defcustom gnus-orphan-score nil
955 "*All orphans get this score added. Set in the score file."
956 :group 'gnus-score-default
957 :type '(choice (const nil)
960 (defcustom gnus-summary-save-parts-default-mime "image/.*"
961 "*A regexp to match MIME parts when saving multiple parts of a message
962 with gnus-summary-save-parts (X m). This regexp will be used by default
963 when prompting the user for which type of files to save."
968 (defcustom gnus-summary-save-parts-default-mime "image/.*"
969 "*A regexp to match MIME parts when saving multiple parts of a message
970 with gnus-summary-save-parts (X m). This regexp will be used by default
971 when prompting the user for which type of files to save."
975 (defcustom gnus-read-all-available-headers nil
976 "Whether Gnus should parse all headers made available to it.
977 This is mostly relevant for slow backends where the user may
978 wish to widen the summary buffer to include all headers
979 that were fetched. Say, for nnultimate groups."
981 :type '(choice boolean regexp))
983 ;;; Internal variables
985 (defvar gnus-article-mime-handles nil)
986 (defvar gnus-article-decoded-p nil)
987 (defvar gnus-article-charset nil)
988 (defvar gnus-article-ignored-charsets nil)
989 (defvar gnus-scores-exclude-files nil)
990 (defvar gnus-page-broken nil)
991 (defvar gnus-inhibit-mime-unbuttonizing nil)
993 (defvar gnus-original-article nil)
994 (defvar gnus-article-internal-prepare-hook nil)
995 (defvar gnus-newsgroup-process-stack nil)
997 (defvar gnus-thread-indent-array nil)
998 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
999 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1000 "Function called to sort the articles within a thread after it has been gathered together.")
1002 (defvar gnus-summary-save-parts-type-history nil)
1003 (defvar gnus-summary-save-parts-last-directory nil)
1005 (defvar gnus-summary-save-parts-type-history nil)
1006 (defvar gnus-summary-save-parts-last-directory nil)
1008 ;; Avoid highlighting in kill files.
1009 (defvar gnus-summary-inhibit-highlight nil)
1010 (defvar gnus-newsgroup-selected-overlay nil)
1011 (defvar gnus-inhibit-limiting nil)
1012 (defvar gnus-newsgroup-adaptive-score-file nil)
1013 (defvar gnus-current-score-file nil)
1014 (defvar gnus-current-move-group nil)
1015 (defvar gnus-current-copy-group nil)
1016 (defvar gnus-current-crosspost-group nil)
1018 (defvar gnus-newsgroup-dependencies nil)
1019 (defvar gnus-newsgroup-adaptive nil)
1020 (defvar gnus-summary-display-article-function nil)
1021 (defvar gnus-summary-highlight-line-function nil
1022 "Function called after highlighting a summary line.")
1024 (defvar gnus-summary-line-format-alist
1025 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1026 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1027 (?s gnus-tmp-subject-or-nil ?s)
1028 (?n gnus-tmp-name ?s)
1029 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1031 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1033 (?F gnus-tmp-from ?s)
1034 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1035 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1036 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1037 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1038 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1039 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1040 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1041 (?L gnus-tmp-lines ?s)
1042 (?I gnus-tmp-indentation ?s)
1043 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1044 (?R gnus-tmp-replied ?c)
1045 (?\[ gnus-tmp-opening-bracket ?c)
1046 (?\] gnus-tmp-closing-bracket ?c)
1047 (?\> (make-string gnus-tmp-level ? ) ?s)
1048 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1049 (?i gnus-tmp-score ?d)
1050 (?z gnus-tmp-score-char ?c)
1051 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1052 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1053 (?U gnus-tmp-unread ?c)
1054 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header) ?s)
1055 (?t (gnus-summary-number-of-articles-in-thread
1056 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1058 (?e (gnus-summary-number-of-articles-in-thread
1059 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1061 (?u gnus-tmp-user-defined ?s)
1062 (?P (gnus-pick-line-number) ?d))
1063 "An alist of format specifications that can appear in summary lines.
1064 These are paired with what variables they correspond with, along with
1065 the type of the variable (string, integer, character, etc).")
1067 (defvar gnus-summary-dummy-line-format-alist
1068 `((?S gnus-tmp-subject ?s)
1069 (?N gnus-tmp-number ?d)
1070 (?u gnus-tmp-user-defined ?s)))
1072 (defvar gnus-summary-mode-line-format-alist
1073 `((?G gnus-tmp-group-name ?s)
1074 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1075 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1076 (?A gnus-tmp-article-number ?d)
1077 (?Z gnus-tmp-unread-and-unselected ?s)
1078 (?V gnus-version ?s)
1079 (?U gnus-tmp-unread-and-unticked ?d)
1080 (?S gnus-tmp-subject ?s)
1081 (?e gnus-tmp-unselected ?d)
1082 (?u gnus-tmp-user-defined ?s)
1083 (?d (length gnus-newsgroup-dormant) ?d)
1084 (?t (length gnus-newsgroup-marked) ?d)
1085 (?r (length gnus-newsgroup-reads) ?d)
1086 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1087 (?E gnus-newsgroup-expunged-tally ?d)
1088 (?s (gnus-current-score-file-nondirectory) ?s)))
1090 (defvar gnus-last-search-regexp nil
1091 "Default regexp for article search command.")
1093 (defvar gnus-last-shell-command nil
1094 "Default shell command on article.")
1096 (defvar gnus-newsgroup-begin nil)
1097 (defvar gnus-newsgroup-end nil)
1098 (defvar gnus-newsgroup-last-rmail nil)
1099 (defvar gnus-newsgroup-last-mail nil)
1100 (defvar gnus-newsgroup-last-folder nil)
1101 (defvar gnus-newsgroup-last-file nil)
1102 (defvar gnus-newsgroup-auto-expire nil)
1103 (defvar gnus-newsgroup-active nil)
1105 (defvar gnus-newsgroup-data nil)
1106 (defvar gnus-newsgroup-data-reverse nil)
1107 (defvar gnus-newsgroup-limit nil)
1108 (defvar gnus-newsgroup-limits nil)
1110 (defvar gnus-newsgroup-unreads nil
1111 "List of unread articles in the current newsgroup.")
1113 (defvar gnus-newsgroup-unselected nil
1114 "List of unselected unread articles in the current newsgroup.")
1116 (defvar gnus-newsgroup-reads nil
1117 "Alist of read articles and article marks in the current newsgroup.")
1119 (defvar gnus-newsgroup-expunged-tally nil)
1121 (defvar gnus-newsgroup-marked nil
1122 "List of ticked articles in the current newsgroup (a subset of unread art).")
1124 (defvar gnus-newsgroup-killed nil
1125 "List of ranges of articles that have been through the scoring process.")
1127 (defvar gnus-newsgroup-cached nil
1128 "List of articles that come from the article cache.")
1130 (defvar gnus-newsgroup-saved nil
1131 "List of articles that have been saved.")
1133 (defvar gnus-newsgroup-kill-headers nil)
1135 (defvar gnus-newsgroup-replied nil
1136 "List of articles that have been replied to in the current newsgroup.")
1138 (defvar gnus-newsgroup-forwarded nil
1139 "List of articles that have been forwarded in the current newsgroup.")
1141 (defvar gnus-newsgroup-expirable nil
1142 "List of articles in the current newsgroup that can be expired.")
1144 (defvar gnus-newsgroup-processable nil
1145 "List of articles in the current newsgroup that can be processed.")
1147 (defvar gnus-newsgroup-downloadable nil
1148 "List of articles in the current newsgroup that can be processed.")
1150 (defvar gnus-newsgroup-undownloaded nil
1151 "List of articles in the current newsgroup that haven't been downloaded..")
1153 (defvar gnus-newsgroup-unsendable nil
1154 "List of articles in the current newsgroup that won't be sent.")
1156 (defvar gnus-newsgroup-bookmarks nil
1157 "List of articles in the current newsgroup that have bookmarks.")
1159 (defvar gnus-newsgroup-dormant nil
1160 "List of dormant articles in the current newsgroup.")
1162 (defvar gnus-newsgroup-scored nil
1163 "List of scored articles in the current newsgroup.")
1165 (defvar gnus-newsgroup-headers nil
1166 "List of article headers in the current newsgroup.")
1168 (defvar gnus-newsgroup-threads nil)
1170 (defvar gnus-newsgroup-prepared nil
1171 "Whether the current group has been prepared properly.")
1173 (defvar gnus-newsgroup-ancient nil
1174 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1176 (defvar gnus-newsgroup-sparse nil)
1178 (defvar gnus-current-article nil)
1179 (defvar gnus-article-current nil)
1180 (defvar gnus-current-headers nil)
1181 (defvar gnus-have-all-headers nil)
1182 (defvar gnus-last-article nil)
1183 (defvar gnus-newsgroup-history nil)
1184 (defvar gnus-newsgroup-charset nil)
1185 (defvar gnus-newsgroup-ephemeral-charset nil)
1186 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1188 (defvar gnus-article-before-search nil)
1190 (defconst gnus-summary-local-variables
1191 '(gnus-newsgroup-name
1192 gnus-newsgroup-begin gnus-newsgroup-end
1193 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1194 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1195 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1196 gnus-newsgroup-unselected gnus-newsgroup-marked
1197 gnus-newsgroup-reads gnus-newsgroup-saved
1198 gnus-newsgroup-replied gnus-newsgroup-forwarded
1199 gnus-newsgroup-expirable
1200 gnus-newsgroup-processable gnus-newsgroup-killed
1201 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1202 gnus-newsgroup-unsendable
1203 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1204 gnus-newsgroup-headers gnus-newsgroup-threads
1205 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1206 gnus-current-article gnus-current-headers gnus-have-all-headers
1207 gnus-last-article gnus-article-internal-prepare-hook
1208 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1209 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1210 gnus-thread-expunge-below
1211 gnus-score-alist gnus-current-score-file
1212 (gnus-summary-expunge-below . global)
1213 (gnus-summary-mark-below . global)
1214 (gnus-orphan-score . global)
1215 gnus-newsgroup-active gnus-scores-exclude-files
1216 gnus-newsgroup-history gnus-newsgroup-ancient
1217 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1218 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1219 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1220 (gnus-newsgroup-expunged-tally . 0)
1221 gnus-cache-removable-articles gnus-newsgroup-cached
1222 gnus-newsgroup-data gnus-newsgroup-data-reverse
1223 gnus-newsgroup-limit gnus-newsgroup-limits
1224 gnus-newsgroup-charset)
1225 "Variables that are buffer-local to the summary buffers.")
1227 (defvar gnus-newsgroup-variables nil
1228 "Variables that have separate values in the newsgroups.")
1230 ;; Byte-compiler warning.
1231 (eval-when-compile (defvar gnus-article-mode-map))
1235 (defvar gnus-decode-encoded-word-methods
1236 '(mail-decode-encoded-word-string)
1237 "List of methods used to decode encoded words.
1239 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item is
1240 FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1241 (REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
1242 whose names match REGEXP.
1245 ((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
1246 mail-decode-encoded-word-string
1247 (\"chinese\" . rfc1843-decode-string))")
1249 (defvar gnus-decode-encoded-word-methods-cache nil)
1251 (defun gnus-multi-decode-encoded-word-string (string)
1252 "Apply the functions from `gnus-encoded-word-methods' that match."
1253 (unless (and gnus-decode-encoded-word-methods-cache
1254 (eq gnus-newsgroup-name
1255 (car gnus-decode-encoded-word-methods-cache)))
1256 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
1259 (nconc gnus-decode-encoded-word-methods-cache (list x))
1260 (if (and gnus-newsgroup-name
1261 (string-match (car x) gnus-newsgroup-name))
1262 (nconc gnus-decode-encoded-word-methods-cache
1264 gnus-decode-encoded-word-methods))
1265 (let ((xlist gnus-decode-encoded-word-methods-cache))
1268 (setq string (funcall (pop xlist) string))))
1271 ;; Subject simplification.
1273 (defun gnus-simplify-whitespace (str)
1274 "Remove excessive whitespace from STR."
1277 (while (string-match "[ \t][ \t]+" mystr)
1278 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1280 (substring mystr (match-end 0)))))
1282 (when (string-match "^[ \t]+" mystr)
1283 (setq mystr (substring mystr (match-end 0))))
1285 (when (string-match "[ \t]+$" mystr)
1286 (setq mystr (substring mystr 0 (match-beginning 0))))
1289 (defsubst gnus-simplify-subject-re (subject)
1290 "Remove \"Re:\" from subject lines."
1291 (if (string-match message-subject-re-regexp subject)
1292 (substring subject (match-end 0))
1295 (defun gnus-simplify-subject (subject &optional re-only)
1296 "Remove `Re:' and words in parentheses.
1297 If RE-ONLY is non-nil, strip leading `Re:'s only."
1298 (let ((case-fold-search t)) ;Ignore case.
1299 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1300 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1301 (setq subject (substring subject (match-end 0))))
1302 ;; Remove uninteresting prefixes.
1303 (when (and (not re-only)
1304 gnus-simplify-ignored-prefixes
1305 (string-match gnus-simplify-ignored-prefixes subject))
1306 (setq subject (substring subject (match-end 0))))
1307 ;; Remove words in parentheses from end.
1309 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1310 (setq subject (substring subject 0 (match-beginning 0)))))
1311 ;; Return subject string.
1314 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1316 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1317 (goto-char (point-min))
1318 (while (re-search-forward regexp nil t)
1319 (replace-match (or newtext ""))))
1321 (defun gnus-simplify-buffer-fuzzy ()
1322 "Simplify string in the buffer fuzzily.
1323 The string in the accessible portion of the current buffer is simplified.
1324 It is assumed to be a single-line subject.
1325 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1326 matter is removed. Additional things can be deleted by setting
1327 `gnus-simplify-subject-fuzzy-regexp'."
1328 (let ((case-fold-search t)
1330 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1332 (while (not (eq modified-tick (buffer-modified-tick)))
1333 (setq modified-tick (buffer-modified-tick))
1335 ((listp gnus-simplify-subject-fuzzy-regexp)
1336 (mapcar 'gnus-simplify-buffer-fuzzy-step
1337 gnus-simplify-subject-fuzzy-regexp))
1338 (gnus-simplify-subject-fuzzy-regexp
1339 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1340 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1341 (gnus-simplify-buffer-fuzzy-step
1342 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1343 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1345 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1346 (gnus-simplify-buffer-fuzzy-step " +" " ")
1347 (gnus-simplify-buffer-fuzzy-step " $")
1348 (gnus-simplify-buffer-fuzzy-step "^ +")))
1350 (defun gnus-simplify-subject-fuzzy (subject)
1351 "Simplify a subject string fuzzily.
1352 See `gnus-simplify-buffer-fuzzy' for details."
1354 (gnus-set-work-buffer)
1355 (let ((case-fold-search t))
1356 ;; Remove uninteresting prefixes.
1357 (when (and gnus-simplify-ignored-prefixes
1358 (string-match gnus-simplify-ignored-prefixes subject))
1359 (setq subject (substring subject (match-end 0))))
1361 (inline (gnus-simplify-buffer-fuzzy))
1364 (defsubst gnus-simplify-subject-fully (subject)
1365 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1367 (gnus-simplify-subject-functions
1368 (gnus-map-function gnus-simplify-subject-functions subject))
1369 ((null gnus-summary-gather-subject-limit)
1370 (gnus-simplify-subject-re subject))
1371 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1372 (gnus-simplify-subject-fuzzy subject))
1373 ((numberp gnus-summary-gather-subject-limit)
1374 (gnus-limit-string (gnus-simplify-subject-re subject)
1375 gnus-summary-gather-subject-limit))
1379 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1380 "Check whether two subjects are equal.
1381 If optional argument simple-first is t, first argument is already
1384 ((null simple-first)
1385 (equal (gnus-simplify-subject-fully s1)
1386 (gnus-simplify-subject-fully s2)))
1389 (gnus-simplify-subject-fully s2)))))
1391 (defun gnus-summary-bubble-group ()
1392 "Increase the score of the current group.
1393 This is a handy function to add to `gnus-summary-exit-hook' to
1394 increase the score of each group you read."
1395 (gnus-group-add-score gnus-newsgroup-name))
1399 ;;; Gnus summary mode
1402 (put 'gnus-summary-mode 'mode-class 'special)
1404 (defvar gnus-article-commands-menu)
1407 ;; Non-orthogonal keys
1409 (gnus-define-keys gnus-summary-mode-map
1410 " " gnus-summary-next-page
1411 "\177" gnus-summary-prev-page
1412 [delete] gnus-summary-prev-page
1413 [backspace] gnus-summary-prev-page
1414 "\r" gnus-summary-scroll-up
1415 "\M-\r" gnus-summary-scroll-down
1416 "n" gnus-summary-next-unread-article
1417 "p" gnus-summary-prev-unread-article
1418 "N" gnus-summary-next-article
1419 "P" gnus-summary-prev-article
1420 "\M-\C-n" gnus-summary-next-same-subject
1421 "\M-\C-p" gnus-summary-prev-same-subject
1422 "\M-n" gnus-summary-next-unread-subject
1423 "\M-p" gnus-summary-prev-unread-subject
1424 "." gnus-summary-first-unread-article
1425 "," gnus-summary-best-unread-article
1426 "\M-s" gnus-summary-search-article-forward
1427 "\M-r" gnus-summary-search-article-backward
1428 "<" gnus-summary-beginning-of-article
1429 ">" gnus-summary-end-of-article
1430 "j" gnus-summary-goto-article
1431 "^" gnus-summary-refer-parent-article
1432 "\M-^" gnus-summary-refer-article
1433 "u" gnus-summary-tick-article-forward
1434 "!" gnus-summary-tick-article-forward
1435 "U" gnus-summary-tick-article-backward
1436 "d" gnus-summary-mark-as-read-forward
1437 "D" gnus-summary-mark-as-read-backward
1438 "E" gnus-summary-mark-as-expirable
1439 "\M-u" gnus-summary-clear-mark-forward
1440 "\M-U" gnus-summary-clear-mark-backward
1441 "k" gnus-summary-kill-same-subject-and-select
1442 "\C-k" gnus-summary-kill-same-subject
1443 "\M-\C-k" gnus-summary-kill-thread
1444 "\M-\C-l" gnus-summary-lower-thread
1445 "e" gnus-summary-edit-article
1446 "#" gnus-summary-mark-as-processable
1447 "\M-#" gnus-summary-unmark-as-processable
1448 "\M-\C-t" gnus-summary-toggle-threads
1449 "\M-\C-s" gnus-summary-show-thread
1450 "\M-\C-h" gnus-summary-hide-thread
1451 "\M-\C-f" gnus-summary-next-thread
1452 "\M-\C-b" gnus-summary-prev-thread
1453 [(meta down)] gnus-summary-next-thread
1454 [(meta up)] gnus-summary-prev-thread
1455 "\M-\C-u" gnus-summary-up-thread
1456 "\M-\C-d" gnus-summary-down-thread
1457 "&" gnus-summary-execute-command
1458 "c" gnus-summary-catchup-and-exit
1459 "\C-w" gnus-summary-mark-region-as-read
1460 "\C-t" gnus-summary-toggle-truncation
1461 "?" gnus-summary-mark-as-dormant
1462 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1463 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1464 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1465 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1466 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1467 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1468 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1469 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1470 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1471 "=" gnus-summary-expand-window
1472 "\C-x\C-s" gnus-summary-reselect-current-group
1473 "\M-g" gnus-summary-rescan-group
1474 "w" gnus-summary-stop-page-breaking
1475 "\C-c\C-r" gnus-summary-caesar-message
1476 "f" gnus-summary-followup
1477 "F" gnus-summary-followup-with-original
1478 "C" gnus-summary-cancel-article
1479 "r" gnus-summary-reply
1480 "R" gnus-summary-reply-with-original
1481 "\C-c\C-f" gnus-summary-mail-forward
1482 "o" gnus-summary-save-article
1483 "\C-o" gnus-summary-save-article-mail
1484 "|" gnus-summary-pipe-output
1485 "\M-k" gnus-summary-edit-local-kill
1486 "\M-K" gnus-summary-edit-global-kill
1488 "\C-c\C-d" gnus-summary-describe-group
1489 "q" gnus-summary-exit
1490 "Q" gnus-summary-exit-no-update
1491 "\C-c\C-i" gnus-info-find-node
1492 gnus-mouse-2 gnus-mouse-pick-article
1493 "m" gnus-summary-mail-other-window
1494 "a" gnus-summary-post-news
1495 "x" gnus-summary-limit-to-unread
1496 "s" gnus-summary-isearch-article
1497 "t" gnus-summary-toggle-header
1498 "g" gnus-summary-show-article
1499 "l" gnus-summary-goto-last-article
1500 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1501 "\C-d" gnus-summary-enter-digest-group
1502 "\M-\C-d" gnus-summary-read-document
1503 "\M-\C-e" gnus-summary-edit-parameters
1504 "\M-\C-a" gnus-summary-customize-parameters
1506 "*" gnus-cache-enter-article
1507 "\M-*" gnus-cache-remove-article
1508 "\M-&" gnus-summary-universal-argument
1509 "\C-l" gnus-recenter
1510 "I" gnus-summary-increase-score
1511 "L" gnus-summary-lower-score
1512 "\M-i" gnus-symbolic-argument
1513 "h" gnus-summary-select-article-buffer
1515 "b" gnus-article-view-part
1516 "\M-t" gnus-summary-toggle-display-buttonized
1518 "V" gnus-summary-score-map
1519 "X" gnus-uu-extract-map
1520 "S" gnus-summary-send-map)
1522 ;; Sort of orthogonal keymap
1523 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1524 "t" gnus-summary-tick-article-forward
1525 "!" gnus-summary-tick-article-forward
1526 "d" gnus-summary-mark-as-read-forward
1527 "r" gnus-summary-mark-as-read-forward
1528 "c" gnus-summary-clear-mark-forward
1529 " " gnus-summary-clear-mark-forward
1530 "e" gnus-summary-mark-as-expirable
1531 "x" gnus-summary-mark-as-expirable
1532 "?" gnus-summary-mark-as-dormant
1533 "b" gnus-summary-set-bookmark
1534 "B" gnus-summary-remove-bookmark
1535 "#" gnus-summary-mark-as-processable
1536 "\M-#" gnus-summary-unmark-as-processable
1537 "S" gnus-summary-limit-include-expunged
1538 "C" gnus-summary-catchup
1539 "H" gnus-summary-catchup-to-here
1540 "h" gnus-summary-catchup-from-here
1541 "\C-c" gnus-summary-catchup-all
1542 "k" gnus-summary-kill-same-subject-and-select
1543 "K" gnus-summary-kill-same-subject
1544 "P" gnus-uu-mark-map)
1546 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1547 "c" gnus-summary-clear-above
1548 "u" gnus-summary-tick-above
1549 "m" gnus-summary-mark-above
1550 "k" gnus-summary-kill-below)
1552 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1553 "/" gnus-summary-limit-to-subject
1554 "n" gnus-summary-limit-to-articles
1555 "w" gnus-summary-pop-limit
1556 "s" gnus-summary-limit-to-subject
1557 "a" gnus-summary-limit-to-author
1558 "u" gnus-summary-limit-to-unread
1559 "m" gnus-summary-limit-to-marks
1560 "M" gnus-summary-limit-exclude-marks
1561 "v" gnus-summary-limit-to-score
1562 "*" gnus-summary-limit-include-cached
1563 "D" gnus-summary-limit-include-dormant
1564 "T" gnus-summary-limit-include-thread
1565 "d" gnus-summary-limit-exclude-dormant
1566 "t" gnus-summary-limit-to-age
1567 "x" gnus-summary-limit-to-extra
1568 "E" gnus-summary-limit-include-expunged
1569 "c" gnus-summary-limit-exclude-childless-dormant
1570 "C" gnus-summary-limit-mark-excluded-as-read
1571 "o" gnus-summary-insert-old-articles
1572 "N" gnus-summary-insert-new-articles)
1574 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1575 "n" gnus-summary-next-unread-article
1576 "p" gnus-summary-prev-unread-article
1577 "N" gnus-summary-next-article
1578 "P" gnus-summary-prev-article
1579 "\C-n" gnus-summary-next-same-subject
1580 "\C-p" gnus-summary-prev-same-subject
1581 "\M-n" gnus-summary-next-unread-subject
1582 "\M-p" gnus-summary-prev-unread-subject
1583 "f" gnus-summary-first-unread-article
1584 "b" gnus-summary-best-unread-article
1585 "j" gnus-summary-goto-article
1586 "g" gnus-summary-goto-subject
1587 "l" gnus-summary-goto-last-article
1588 "o" gnus-summary-pop-article)
1590 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1591 "k" gnus-summary-kill-thread
1592 "l" gnus-summary-lower-thread
1593 "i" gnus-summary-raise-thread
1594 "T" gnus-summary-toggle-threads
1595 "t" gnus-summary-rethread-current
1596 "^" gnus-summary-reparent-thread
1597 "s" gnus-summary-show-thread
1598 "S" gnus-summary-show-all-threads
1599 "h" gnus-summary-hide-thread
1600 "H" gnus-summary-hide-all-threads
1601 "n" gnus-summary-next-thread
1602 "p" gnus-summary-prev-thread
1603 "u" gnus-summary-up-thread
1604 "o" gnus-summary-top-thread
1605 "d" gnus-summary-down-thread
1606 "#" gnus-uu-mark-thread
1607 "\M-#" gnus-uu-unmark-thread)
1609 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1610 "g" gnus-summary-prepare
1611 "c" gnus-summary-insert-cached-articles)
1613 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1614 "c" gnus-summary-catchup-and-exit
1615 "C" gnus-summary-catchup-all-and-exit
1616 "E" gnus-summary-exit-no-update
1617 "Q" gnus-summary-exit
1618 "Z" gnus-summary-exit
1619 "n" gnus-summary-catchup-and-goto-next-group
1620 "R" gnus-summary-reselect-current-group
1621 "G" gnus-summary-rescan-group
1622 "N" gnus-summary-next-group
1623 "s" gnus-summary-save-newsrc
1624 "P" gnus-summary-prev-group)
1626 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1627 " " gnus-summary-next-page
1628 "n" gnus-summary-next-page
1629 "\177" gnus-summary-prev-page
1630 [delete] gnus-summary-prev-page
1631 "p" gnus-summary-prev-page
1632 "\r" gnus-summary-scroll-up
1633 "\M-\r" gnus-summary-scroll-down
1634 "<" gnus-summary-beginning-of-article
1635 ">" gnus-summary-end-of-article
1636 "b" gnus-summary-beginning-of-article
1637 "e" gnus-summary-end-of-article
1638 "^" gnus-summary-refer-parent-article
1639 "r" gnus-summary-refer-parent-article
1640 "D" gnus-summary-enter-digest-group
1641 "R" gnus-summary-refer-references
1642 "T" gnus-summary-refer-thread
1643 "g" gnus-summary-show-article
1644 "s" gnus-summary-isearch-article
1645 "P" gnus-summary-print-article
1646 "M" gnus-mailing-list-insinuate
1647 "t" gnus-article-babel)
1649 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1650 "b" gnus-article-add-buttons
1651 "B" gnus-article-add-buttons-to-head
1652 "o" gnus-article-treat-overstrike
1653 "e" gnus-article-emphasize
1654 "w" gnus-article-fill-cited-article
1655 "Q" gnus-article-fill-long-lines
1656 "C" gnus-article-capitalize-sentences
1657 "c" gnus-article-remove-cr
1658 "q" gnus-article-de-quoted-unreadable
1659 "6" gnus-article-de-base64-unreadable
1660 "Z" gnus-article-decode-HZ
1661 "h" gnus-article-wash-html
1662 "s" gnus-summary-force-verify-and-decrypt
1663 "f" gnus-article-display-x-face
1664 "l" gnus-summary-stop-page-breaking
1665 "r" gnus-summary-caesar-message
1666 "t" gnus-summary-toggle-header
1667 "v" gnus-summary-verbose-headers
1668 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
1669 "p" gnus-article-verify-x-pgp-sig
1670 "d" gnus-article-treat-dumbquotes)
1672 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1673 "a" gnus-article-hide
1674 "h" gnus-article-hide-headers
1675 "b" gnus-article-hide-boring-headers
1676 "s" gnus-article-hide-signature
1677 "c" gnus-article-hide-citation
1678 "C" gnus-article-hide-citation-in-followups
1679 "l" gnus-article-hide-list-identifiers
1680 "p" gnus-article-hide-pgp
1681 "B" gnus-article-strip-banner
1682 "P" gnus-article-hide-pem
1683 "\C-c" gnus-article-hide-citation-maybe)
1685 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1686 "a" gnus-article-highlight
1687 "h" gnus-article-highlight-headers
1688 "c" gnus-article-highlight-citation
1689 "s" gnus-article-highlight-signature)
1691 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
1692 "w" gnus-article-decode-mime-words
1693 "c" gnus-article-decode-charset
1694 "v" gnus-mime-view-all-parts
1695 "b" gnus-article-view-part)
1697 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1698 "z" gnus-article-date-ut
1699 "u" gnus-article-date-ut
1700 "l" gnus-article-date-local
1701 "p" gnus-article-date-english
1702 "e" gnus-article-date-lapsed
1703 "o" gnus-article-date-original
1704 "i" gnus-article-date-iso8601
1705 "s" gnus-article-date-user)
1707 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1708 "t" gnus-article-remove-trailing-blank-lines
1709 "l" gnus-article-strip-leading-blank-lines
1710 "m" gnus-article-strip-multiple-blank-lines
1711 "a" gnus-article-strip-blank-lines
1712 "A" gnus-article-strip-all-blank-lines
1713 "s" gnus-article-strip-leading-space
1714 "e" gnus-article-strip-trailing-space
1715 "w" gnus-article-remove-leading-whitespace)
1717 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1719 "f" gnus-summary-fetch-faq
1720 "d" gnus-summary-describe-group
1721 "h" gnus-summary-describe-briefly
1722 "i" gnus-info-find-node)
1724 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1725 "e" gnus-summary-expire-articles
1726 "\M-\C-e" gnus-summary-expire-articles-now
1727 "\177" gnus-summary-delete-article
1728 [delete] gnus-summary-delete-article
1729 [backspace] gnus-summary-delete-article
1730 "m" gnus-summary-move-article
1731 "r" gnus-summary-respool-article
1732 "w" gnus-summary-edit-article
1733 "c" gnus-summary-copy-article
1734 "B" gnus-summary-crosspost-article
1735 "q" gnus-summary-respool-query
1736 "t" gnus-summary-respool-trace
1737 "i" gnus-summary-import-article
1738 "I" gnus-summary-create-article
1739 "p" gnus-summary-article-posted-p)
1741 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1742 "o" gnus-summary-save-article
1743 "m" gnus-summary-save-article-mail
1744 "F" gnus-summary-write-article-file
1745 "r" gnus-summary-save-article-rmail
1746 "f" gnus-summary-save-article-file
1747 "b" gnus-summary-save-article-body-file
1748 "h" gnus-summary-save-article-folder
1749 "v" gnus-summary-save-article-vm
1750 "p" gnus-summary-pipe-output
1751 "s" gnus-soup-add-article)
1753 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
1754 "b" gnus-summary-display-buttonized
1755 "m" gnus-summary-repair-multipart
1756 "v" gnus-article-view-part
1757 "o" gnus-article-save-part
1758 "c" gnus-article-copy-part
1759 "C" gnus-article-view-part-as-charset
1760 "e" gnus-article-externalize-part
1761 "E" gnus-article-encrypt-body
1762 "i" gnus-article-inline-part
1763 "|" gnus-article-pipe-part))
1765 (defvar gnus-article-post-menu nil)
1767 (defun gnus-summary-make-menu-bar ()
1768 (gnus-turn-off-edit-menu 'summary)
1770 (unless (boundp 'gnus-summary-misc-menu)
1773 gnus-summary-kill-menu gnus-summary-mode-map ""
1778 ["Customize" gnus-score-customize t])
1779 (gnus-make-score-map 'increase)
1780 (gnus-make-score-map 'lower)
1782 ["Kill below" gnus-summary-kill-below t]
1783 ["Mark above" gnus-summary-mark-above t]
1784 ["Tick above" gnus-summary-tick-above t]
1785 ["Clear above" gnus-summary-clear-above t])
1786 ["Current score" gnus-summary-current-score t]
1787 ["Set score" gnus-summary-set-score t]
1788 ["Switch current score file..." gnus-score-change-score-file t]
1789 ["Set mark below..." gnus-score-set-mark-below t]
1790 ["Set expunge below..." gnus-score-set-expunge-below t]
1791 ["Edit current score file" gnus-score-edit-current-scores t]
1792 ["Edit score file" gnus-score-edit-file t]
1793 ["Trace score" gnus-score-find-trace t]
1794 ["Find words" gnus-score-find-favourite-words t]
1795 ["Rescore buffer" gnus-summary-rescore t]
1796 ["Increase score..." gnus-summary-increase-score t]
1797 ["Lower score..." gnus-summary-lower-score t]))))
1799 ;; Define both the Article menu in the summary buffer and the equivalent
1800 ;; Commands menu in the article buffer here for consistency.
1803 ["All" gnus-article-hide t]
1804 ["Headers" gnus-article-hide-headers t]
1805 ["Signature" gnus-article-hide-signature t]
1806 ["Citation" gnus-article-hide-citation t]
1807 ["List identifiers" gnus-article-hide-list-identifiers t]
1808 ["PGP" gnus-article-hide-pgp t]
1809 ["Banner" gnus-article-strip-banner t]
1810 ["Boring headers" gnus-article-hide-boring-headers t])
1812 ["All" gnus-article-highlight t]
1813 ["Headers" gnus-article-highlight-headers t]
1814 ["Signature" gnus-article-highlight-signature t]
1815 ["Citation" gnus-article-highlight-citation t])
1817 ["Words" gnus-article-decode-mime-words t]
1818 ["Charset" gnus-article-decode-charset t]
1819 ["QP" gnus-article-de-quoted-unreadable t]
1820 ["Base64" gnus-article-de-base64-unreadable t]
1821 ["View all" gnus-mime-view-all-parts t]
1822 ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t]
1823 ["Encrypt body" gnus-article-encrypt-body t])
1825 ["Local" gnus-article-date-local t]
1826 ["ISO8601" gnus-article-date-iso8601 t]
1827 ["UT" gnus-article-date-ut t]
1828 ["Original" gnus-article-date-original t]
1829 ["Lapsed" gnus-article-date-lapsed t]
1830 ["User-defined" gnus-article-date-user t])
1833 ["Leading" gnus-article-strip-leading-blank-lines t]
1834 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1835 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1836 ["All of the above" gnus-article-strip-blank-lines t]
1837 ["All" gnus-article-strip-all-blank-lines t]
1838 ["Leading space" gnus-article-strip-leading-space t]
1839 ["Trailing space" gnus-article-strip-trailing-space t]
1840 ["Leading space in headers"
1841 gnus-article-remove-leading-whitespace t])
1842 ["Overstrike" gnus-article-treat-overstrike t]
1843 ["Dumb quotes" gnus-article-treat-dumbquotes t]
1844 ["Emphasis" gnus-article-emphasize t]
1845 ["Word wrap" gnus-article-fill-cited-article t]
1846 ["Fill long lines" gnus-article-fill-long-lines t]
1847 ["Capitalize sentences" gnus-article-capitalize-sentences t]
1848 ["CR" gnus-article-remove-cr t]
1849 ["Show X-Face" gnus-article-display-x-face t]
1850 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
1851 ["Base64" gnus-article-de-base64-unreadable t]
1852 ["Rot 13" gnus-summary-caesar-message
1853 ,@(if (featurep 'xemacs) '(t)
1854 '(:help "\"Caesar rotate\" article by 13"))]
1855 ["Unix pipe" gnus-summary-pipe-message t]
1856 ["Add buttons" gnus-article-add-buttons t]
1857 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1858 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1859 ["Verbose header" gnus-summary-verbose-headers t]
1860 ["Toggle header" gnus-summary-toggle-header t]
1861 ["Html" gnus-article-wash-html t]
1862 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
1863 ["HZ" gnus-article-decode-HZ t])
1865 ["Save in default format" gnus-summary-save-article
1866 ,@(if (featurep 'xemacs) '(t)
1867 '(:help "Save article using default method"))]
1868 ["Save in file" gnus-summary-save-article-file
1869 ,@(if (featurep 'xemacs) '(t)
1870 '(:help "Save article in file"))]
1871 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1872 ["Save in MH folder" gnus-summary-save-article-folder t]
1873 ["Save in VM folder" gnus-summary-save-article-vm t]
1874 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1875 ["Save body in file" gnus-summary-save-article-body-file t]
1876 ["Pipe through a filter" gnus-summary-pipe-output t]
1877 ["Add to SOUP packet" gnus-soup-add-article t]
1878 ["Print" gnus-summary-print-article t])
1880 ["Respool article..." gnus-summary-respool-article t]
1881 ["Move article..." gnus-summary-move-article
1882 (gnus-check-backend-function
1883 'request-move-article gnus-newsgroup-name)]
1884 ["Copy article..." gnus-summary-copy-article t]
1885 ["Crosspost article..." gnus-summary-crosspost-article
1886 (gnus-check-backend-function
1887 'request-replace-article gnus-newsgroup-name)]
1888 ["Import file..." gnus-summary-import-article t]
1889 ["Create article..." gnus-summary-create-article t]
1890 ["Check if posted" gnus-summary-article-posted-p t]
1891 ["Edit article" gnus-summary-edit-article
1892 (not (gnus-group-read-only-p))]
1893 ["Delete article" gnus-summary-delete-article
1894 (gnus-check-backend-function
1895 'request-expire-articles gnus-newsgroup-name)]
1896 ["Query respool" gnus-summary-respool-query t]
1897 ["Trace respool" gnus-summary-respool-trace t]
1898 ["Delete expirable articles" gnus-summary-expire-articles-now
1899 (gnus-check-backend-function
1900 'request-expire-articles gnus-newsgroup-name)])
1902 ["Uudecode" gnus-uu-decode-uu
1903 ,@(if (featurep 'xemacs) '(t)
1904 '(:help "Decode uuencoded article(s)"))]
1905 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1906 ["Unshar" gnus-uu-decode-unshar t]
1907 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1908 ["Save" gnus-uu-decode-save t]
1909 ["Binhex" gnus-uu-decode-binhex t]
1910 ["Postscript" gnus-uu-decode-postscript t])
1912 ["Enter article" gnus-cache-enter-article t]
1913 ["Remove article" gnus-cache-remove-article t])
1914 ["Translate" gnus-article-babel t]
1915 ["Select article buffer" gnus-summary-select-article-buffer t]
1916 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1917 ["Isearch article..." gnus-summary-isearch-article t]
1918 ["Beginning of the article" gnus-summary-beginning-of-article t]
1919 ["End of the article" gnus-summary-end-of-article t]
1920 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1921 ["Fetch referenced articles" gnus-summary-refer-references t]
1922 ["Fetch current thread" gnus-summary-refer-thread t]
1923 ["Fetch article with id..." gnus-summary-refer-article t]
1924 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
1925 ["Redisplay" gnus-summary-show-article t]
1926 ["Raw article" gnus-summary-show-raw-article t])))
1928 gnus-summary-article-menu gnus-summary-mode-map ""
1929 (cons "Article" innards))
1931 (if (not (keymapp gnus-summary-article-menu))
1933 gnus-article-commands-menu gnus-article-mode-map ""
1934 (cons "Commands" innards))
1935 ;; in Emacs, don't share menu.
1936 (setq gnus-article-commands-menu
1937 (copy-keymap gnus-summary-article-menu))
1938 (define-key gnus-article-mode-map [menu-bar commands]
1939 (cons "Commands" gnus-article-commands-menu))))
1942 gnus-summary-thread-menu gnus-summary-mode-map ""
1944 ["Toggle threading" gnus-summary-toggle-threads t]
1945 ["Hide threads" gnus-summary-hide-all-threads t]
1946 ["Show threads" gnus-summary-show-all-threads t]
1947 ["Hide thread" gnus-summary-hide-thread t]
1948 ["Show thread" gnus-summary-show-thread t]
1949 ["Go to next thread" gnus-summary-next-thread t]
1950 ["Go to previous thread" gnus-summary-prev-thread t]
1951 ["Go down thread" gnus-summary-down-thread t]
1952 ["Go up thread" gnus-summary-up-thread t]
1953 ["Top of thread" gnus-summary-top-thread t]
1954 ["Mark thread as read" gnus-summary-kill-thread t]
1955 ["Lower thread score" gnus-summary-lower-thread t]
1956 ["Raise thread score" gnus-summary-raise-thread t]
1957 ["Rethread current" gnus-summary-rethread-current t]))
1960 gnus-summary-post-menu gnus-summary-mode-map ""
1962 ["Post an article" gnus-summary-post-news
1963 ,@(if (featurep 'xemacs) '(t)
1964 '(:help "Post an article"))]
1965 ["Followup" gnus-summary-followup
1966 ,@(if (featurep 'xemacs) '(t)
1967 '(:help "Post followup to this article"))]
1968 ["Followup and yank" gnus-summary-followup-with-original
1969 ,@(if (featurep 'xemacs) '(t)
1970 '(:help "Post followup to this article, quoting its contents"))]
1971 ["Supersede article" gnus-summary-supersede-article t]
1972 ["Cancel article" gnus-summary-cancel-article
1973 ,@(if (featurep 'xemacs) '(t)
1974 '(:help "Cancel an article you posted"))]
1975 ["Reply" gnus-summary-reply t]
1976 ["Reply and yank" gnus-summary-reply-with-original t]
1977 ["Wide reply" gnus-summary-wide-reply t]
1978 ["Wide reply and yank" gnus-summary-wide-reply-with-original
1979 ,@(if (featurep 'xemacs) '(t)
1980 '(:help "Mail a reply, quoting this article"))]
1981 ["Mail forward" gnus-summary-mail-forward t]
1982 ["Post forward" gnus-summary-post-forward t]
1983 ["Digest and mail" gnus-uu-digest-mail-forward t]
1984 ["Digest and post" gnus-uu-digest-post-forward t]
1985 ["Resend message" gnus-summary-resend-message t]
1986 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
1987 ["Send a mail" gnus-summary-mail-other-window t]
1988 ["Uuencode and post" gnus-uu-post-news
1989 ,@(if (featurep 'xemacs) '(t)
1990 '(:help "Post a uuencoded article"))]
1991 ["Followup via news" gnus-summary-followup-to-mail t]
1992 ["Followup via news and yank"
1993 gnus-summary-followup-to-mail-with-original t]
1995 ;;["Send" gnus-summary-send-draft t]
1996 ;;["Send bounced" gnus-resend-bounced-mail t])
2000 ((not (keymapp gnus-summary-post-menu))
2001 (setq gnus-article-post-menu gnus-summary-post-menu))
2002 ((not gnus-article-post-menu)
2003 ;; Don't share post menu.
2004 (setq gnus-article-post-menu
2005 (copy-keymap gnus-summary-post-menu))))
2006 (define-key gnus-article-mode-map [menu-bar post]
2007 (cons "Post" gnus-article-post-menu))
2010 gnus-summary-misc-menu gnus-summary-mode-map ""
2013 ["Mark as read" gnus-summary-mark-as-read-forward t]
2014 ["Mark same subject and select"
2015 gnus-summary-kill-same-subject-and-select t]
2016 ["Mark same subject" gnus-summary-kill-same-subject t]
2017 ["Catchup" gnus-summary-catchup
2018 ,@(if (featurep 'xemacs) '(t)
2019 '(:help "Mark unread articles in this group as read"))]
2020 ["Catchup all" gnus-summary-catchup-all t]
2021 ["Catchup to here" gnus-summary-catchup-to-here t]
2022 ["Catchup from here" gnus-summary-catchup-from-here t]
2023 ["Catchup region" gnus-summary-mark-region-as-read t]
2024 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2026 ["Tick" gnus-summary-tick-article-forward t]
2027 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2028 ["Remove marks" gnus-summary-clear-mark-forward t]
2029 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2030 ["Set bookmark" gnus-summary-set-bookmark t]
2031 ["Remove bookmark" gnus-summary-remove-bookmark t])
2033 ["Marks..." gnus-summary-limit-to-marks t]
2034 ["Subject..." gnus-summary-limit-to-subject t]
2035 ["Author..." gnus-summary-limit-to-author t]
2036 ["Age..." gnus-summary-limit-to-age t]
2037 ["Extra..." gnus-summary-limit-to-extra t]
2038 ["Score" gnus-summary-limit-to-score t]
2039 ["Unread" gnus-summary-limit-to-unread t]
2040 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2041 ["Articles" gnus-summary-limit-to-articles t]
2042 ["Pop limit" gnus-summary-pop-limit t]
2043 ["Show dormant" gnus-summary-limit-include-dormant t]
2044 ["Hide childless dormant"
2045 gnus-summary-limit-exclude-childless-dormant t]
2046 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2047 ["Hide marked" gnus-summary-limit-exclude-marks t]
2048 ["Show expunged" gnus-summary-limit-include-expunged t])
2050 ["Set mark" gnus-summary-mark-as-processable t]
2051 ["Remove mark" gnus-summary-unmark-as-processable t]
2052 ["Remove all marks" gnus-summary-unmark-all-processable t]
2053 ["Mark above" gnus-uu-mark-over t]
2054 ["Mark series" gnus-uu-mark-series t]
2055 ["Mark region" gnus-uu-mark-region t]
2056 ["Unmark region" gnus-uu-unmark-region t]
2057 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2058 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2059 ["Mark all" gnus-uu-mark-all t]
2060 ["Mark buffer" gnus-uu-mark-buffer t]
2061 ["Mark sparse" gnus-uu-mark-sparse t]
2062 ["Mark thread" gnus-uu-mark-thread t]
2063 ["Unmark thread" gnus-uu-unmark-thread t]
2064 ("Process Mark Sets"
2065 ["Kill" gnus-summary-kill-process-mark t]
2066 ["Yank" gnus-summary-yank-process-mark
2067 gnus-newsgroup-process-stack]
2068 ["Save" gnus-summary-save-process-mark t]))
2070 ["Page forward" gnus-summary-next-page
2071 ,@(if (featurep 'xemacs) '(t)
2072 '(:help "Show next page of article"))]
2073 ["Page backward" gnus-summary-prev-page
2074 ,@(if (featurep 'xemacs) '(t)
2075 '(:help "Show previous page of article"))]
2076 ["Line forward" gnus-summary-scroll-up t])
2078 ["Next unread article" gnus-summary-next-unread-article t]
2079 ["Previous unread article" gnus-summary-prev-unread-article t]
2080 ["Next article" gnus-summary-next-article t]
2081 ["Previous article" gnus-summary-prev-article t]
2082 ["Next unread subject" gnus-summary-next-unread-subject t]
2083 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2084 ["Next article same subject" gnus-summary-next-same-subject t]
2085 ["Previous article same subject" gnus-summary-prev-same-subject t]
2086 ["First unread article" gnus-summary-first-unread-article t]
2087 ["Best unread article" gnus-summary-best-unread-article t]
2088 ["Go to subject number..." gnus-summary-goto-subject t]
2089 ["Go to article number..." gnus-summary-goto-article t]
2090 ["Go to the last article" gnus-summary-goto-last-article t]
2091 ["Pop article off history" gnus-summary-pop-article t])
2093 ["Sort by number" gnus-summary-sort-by-number t]
2094 ["Sort by author" gnus-summary-sort-by-author t]
2095 ["Sort by subject" gnus-summary-sort-by-subject t]
2096 ["Sort by date" gnus-summary-sort-by-date t]
2097 ["Sort by score" gnus-summary-sort-by-score t]
2098 ["Sort by lines" gnus-summary-sort-by-lines t]
2099 ["Sort by characters" gnus-summary-sort-by-chars t]
2100 ["Original sort" gnus-summary-sort-by-original t])
2102 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2103 ["Describe group" gnus-summary-describe-group t]
2104 ["Read manual" gnus-info-find-node t])
2106 ["Pick and read" gnus-pick-mode t]
2107 ["Binary" gnus-binary-mode t])
2109 ["Regenerate" gnus-summary-prepare t]
2110 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2111 ["Toggle threading" gnus-summary-toggle-threads t])
2112 ["See old articles" gnus-summary-insert-old-articles t]
2113 ["See new articles" gnus-summary-insert-new-articles t]
2114 ["Filter articles..." gnus-summary-execute-command t]
2115 ["Run command on subjects..." gnus-summary-universal-argument t]
2116 ["Search articles forward..." gnus-summary-search-article-forward t]
2117 ["Search articles backward..." gnus-summary-search-article-backward t]
2118 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2119 ["Expand window" gnus-summary-expand-window t]
2120 ["Expire expirable articles" gnus-summary-expire-articles
2121 (gnus-check-backend-function
2122 'request-expire-articles gnus-newsgroup-name)]
2123 ["Edit local kill file" gnus-summary-edit-local-kill t]
2124 ["Edit main kill file" gnus-summary-edit-global-kill t]
2125 ["Edit group parameters" gnus-summary-edit-parameters t]
2126 ["Customize group parameters" gnus-summary-customize-parameters t]
2127 ["Send a bug report" gnus-bug t]
2129 ["Catchup and exit" gnus-summary-catchup-and-exit
2130 ,@(if (featurep 'xemacs) '(t)
2131 '(:help "Mark unread articles in this group as read, then exit"))]
2132 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2133 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2134 ["Exit group" gnus-summary-exit
2135 ,@(if (featurep 'xemacs) '(t)
2136 '(:help "Exit current group, return to group selection mode"))]
2137 ["Exit group without updating" gnus-summary-exit-no-update t]
2138 ["Exit and goto next group" gnus-summary-next-group t]
2139 ["Exit and goto prev group" gnus-summary-prev-group t]
2140 ["Reselect group" gnus-summary-reselect-current-group t]
2141 ["Rescan group" gnus-summary-rescan-group t]
2142 ["Update dribble" gnus-summary-save-newsrc t])))
2144 (gnus-run-hooks 'gnus-summary-menu-hook)))
2146 (defvar gnus-summary-tool-bar-map nil)
2148 ;; Emacs 21 tool bar. Should be no-op otherwise.
2149 (defun gnus-summary-make-tool-bar ()
2150 (if (and (fboundp 'tool-bar-add-item-from-menu)
2151 (default-value 'tool-bar-mode)
2152 (not gnus-summary-tool-bar-map))
2153 (setq gnus-summary-tool-bar-map
2154 (let ((tool-bar-map (make-sparse-keymap))
2155 (load-path (mm-image-load-path)))
2156 (tool-bar-add-item-from-menu
2157 'gnus-summary-prev-unread "prev-ur" gnus-summary-mode-map)
2158 (tool-bar-add-item-from-menu
2159 'gnus-summary-next-unread "next-ur" gnus-summary-mode-map)
2160 (tool-bar-add-item-from-menu
2161 'gnus-summary-post-news "post" gnus-summary-mode-map)
2162 (tool-bar-add-item-from-menu
2163 'gnus-summary-followup-with-original "fuwo" gnus-summary-mode-map)
2164 (tool-bar-add-item-from-menu
2165 'gnus-summary-followup "followup" gnus-summary-mode-map)
2166 (tool-bar-add-item-from-menu
2167 'gnus-summary-reply-with-original "reply-wo" gnus-summary-mode-map)
2168 (tool-bar-add-item-from-menu
2169 'gnus-summary-reply "reply" gnus-summary-mode-map)
2170 (tool-bar-add-item-from-menu
2171 'gnus-summary-caesar-message "rot13" gnus-summary-mode-map)
2172 (tool-bar-add-item-from-menu
2173 'gnus-uu-decode-uu "uu-decode" gnus-summary-mode-map)
2174 (tool-bar-add-item-from-menu
2175 'gnus-summary-save-article-file "save-aif" gnus-summary-mode-map)
2176 (tool-bar-add-item-from-menu
2177 'gnus-summary-save-article "save-art" gnus-summary-mode-map)
2178 (tool-bar-add-item-from-menu
2179 'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2180 (tool-bar-add-item-from-menu
2181 'gnus-summary-catchup "catchup" gnus-summary-mode-map)
2182 (tool-bar-add-item-from-menu
2183 'gnus-summary-catchup-and-exit "cu-exit" gnus-summary-mode-map)
2184 (tool-bar-add-item-from-menu
2185 'gnus-summary-exit "exit-summ" gnus-summary-mode-map)
2187 (if gnus-summary-tool-bar-map
2188 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
2190 (defun gnus-score-set-default (var value)
2191 "A version of set that updates the GNU Emacs menu-bar."
2193 ;; It is the message that forces the active status to be updated.
2196 (defun gnus-make-score-map (type)
2197 "Make a summary score map of type TYPE."
2200 (let ((headers '(("author" "from" string)
2201 ("subject" "subject" string)
2202 ("article body" "body" string)
2203 ("article head" "head" string)
2204 ("xref" "xref" string)
2205 ("extra header" "extra" string)
2206 ("lines" "lines" number)
2207 ("followups to author" "followup" string)))
2208 (types '((number ("less than" <)
2211 (string ("substring" s)
2215 (perms '(("temporary" (current-time-string))
2223 (if (eq type 'lower)
2228 (setq header (car headers))
2234 (let ((ts (cdr (assoc (nth 2 header) types)))
2250 'gnus-summary-score-entry
2252 (if (or (string= (nth 1 header)
2254 (string= (nth 1 header)
2257 (list 'gnus-summary-header
2259 (list 'quote (nth 1 (car ts)))
2260 (list 'gnus-score-delta-default
2267 (list (nreverse outp))))
2270 (list (nreverse outt))))
2272 (setq headers (cdr headers)))
2273 (list (nreverse outh))))))))
2277 (defun gnus-summary-mode (&optional group)
2278 "Major mode for reading articles.
2280 All normal editing commands are switched off.
2281 \\<gnus-summary-mode-map>
2282 Each line in this buffer represents one article. To read an
2283 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2284 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2287 You can also post articles and send mail from this buffer. To
2288 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2289 of an article, type `\\[gnus-summary-reply]'.
2291 There are approx. one gazillion commands you can execute in this
2292 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2294 The following commands are available:
2296 \\{gnus-summary-mode-map}"
2298 (kill-all-local-variables)
2299 (when (gnus-visual-p 'summary-menu 'menu)
2300 (gnus-summary-make-menu-bar)
2301 (gnus-summary-make-tool-bar))
2302 (gnus-summary-make-local-variables)
2303 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2304 (gnus-summary-make-local-variables))
2305 (gnus-make-thread-indent-array)
2306 (gnus-simplify-mode-line)
2307 (setq major-mode 'gnus-summary-mode)
2308 (setq mode-name "Summary")
2309 (make-local-variable 'minor-mode-alist)
2310 (use-local-map gnus-summary-mode-map)
2311 (buffer-disable-undo)
2312 (setq buffer-read-only t) ;Disable modification
2313 (setq truncate-lines t)
2314 (setq selective-display t)
2315 (setq selective-display-ellipses t) ;Display `...'
2316 (gnus-summary-set-display-table)
2317 (gnus-set-default-directory)
2318 (setq gnus-newsgroup-name group)
2319 (make-local-variable 'gnus-summary-line-format)
2320 (make-local-variable 'gnus-summary-line-format-spec)
2321 (make-local-variable 'gnus-summary-dummy-line-format)
2322 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2323 (make-local-variable 'gnus-summary-mark-positions)
2324 (make-local-hook 'pre-command-hook)
2325 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2326 (gnus-run-hooks 'gnus-summary-mode-hook)
2327 (turn-on-gnus-mailing-list-mode)
2328 (mm-enable-multibyte-mule4)
2329 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2330 (gnus-update-summary-mark-positions))
2332 (defun gnus-summary-make-local-variables ()
2333 "Make all the local summary buffer variables."
2335 (dolist (local gnus-summary-local-variables)
2338 (if (eq (cdr local) 'global)
2339 ;; Copy the global value of the variable.
2340 (setq global (symbol-value (car local)))
2341 ;; Use the value from the list.
2342 (setq global (eval (cdr local))))
2343 (set (make-local-variable (car local)) global))
2344 ;; Simple nil-valued local variable.
2345 (set (make-local-variable local) nil)))))
2347 (defun gnus-summary-clear-local-variables ()
2348 (let ((locals gnus-summary-local-variables))
2350 (if (consp (car locals))
2351 (and (vectorp (caar locals))
2352 (set (caar locals) nil))
2353 (and (vectorp (car locals))
2354 (set (car locals) nil)))
2355 (setq locals (cdr locals)))))
2357 ;; Summary data functions.
2359 (defmacro gnus-data-number (data)
2362 (defmacro gnus-data-set-number (data number)
2363 `(setcar ,data ,number))
2365 (defmacro gnus-data-mark (data)
2368 (defmacro gnus-data-set-mark (data mark)
2369 `(setcar (nthcdr 1 ,data) ,mark))
2371 (defmacro gnus-data-pos (data)
2374 (defmacro gnus-data-set-pos (data pos)
2375 `(setcar (nthcdr 2 ,data) ,pos))
2377 (defmacro gnus-data-header (data)
2380 (defmacro gnus-data-set-header (data header)
2381 `(setf (nth 3 ,data) ,header))
2383 (defmacro gnus-data-level (data)
2386 (defmacro gnus-data-unread-p (data)
2387 `(= (nth 1 ,data) gnus-unread-mark))
2389 (defmacro gnus-data-read-p (data)
2390 `(/= (nth 1 ,data) gnus-unread-mark))
2392 (defmacro gnus-data-pseudo-p (data)
2393 `(consp (nth 3 ,data)))
2395 (defmacro gnus-data-find (number)
2396 `(assq ,number gnus-newsgroup-data))
2398 (defmacro gnus-data-find-list (number &optional data)
2399 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2400 (memq (assq ,number bdata)
2403 (defmacro gnus-data-make (number mark pos header level)
2404 `(list ,number ,mark ,pos ,header ,level))
2406 (defun gnus-data-enter (after-article number mark pos header level offset)
2407 (let ((data (gnus-data-find-list after-article)))
2409 (error "No such article: %d" after-article))
2410 (setcdr data (cons (gnus-data-make number mark pos header level)
2412 (setq gnus-newsgroup-data-reverse nil)
2413 (gnus-data-update-list (cddr data) offset)))
2415 (defun gnus-data-enter-list (after-article list &optional offset)
2417 (let ((data (and after-article (gnus-data-find-list after-article)))
2421 (let ((odata gnus-newsgroup-data))
2422 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2424 (gnus-data-update-list odata offset)))
2425 ;; Find the last element in the list to be spliced into the main
2428 (setq list (cdr list)))
2431 (setcdr list gnus-newsgroup-data)
2432 (setq gnus-newsgroup-data ilist)
2434 (gnus-data-update-list (cdr list) offset)))
2435 (setcdr list (cdr data))
2438 (gnus-data-update-list (cdr list) offset))))
2439 (setq gnus-newsgroup-data-reverse nil))))
2441 (defun gnus-data-remove (article &optional offset)
2442 (let ((data gnus-newsgroup-data))
2443 (if (= (gnus-data-number (car data)) article)
2445 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2446 gnus-newsgroup-data-reverse nil)
2448 (gnus-data-update-list gnus-newsgroup-data offset)))
2450 (when (= (gnus-data-number (cadr data)) article)
2451 (setcdr data (cddr data))
2453 (gnus-data-update-list (cdr data) offset))
2455 gnus-newsgroup-data-reverse nil))
2456 (setq data (cdr data))))))
2458 (defmacro gnus-data-list (backward)
2460 (or gnus-newsgroup-data-reverse
2461 (setq gnus-newsgroup-data-reverse
2462 (reverse gnus-newsgroup-data)))
2463 gnus-newsgroup-data))
2465 (defun gnus-data-update-list (data offset)
2466 "Add OFFSET to the POS of all data entries in DATA."
2467 (setq gnus-newsgroup-data-reverse nil)
2469 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2470 (setq data (cdr data))))
2472 (defun gnus-summary-article-pseudo-p (article)
2473 "Say whether this article is a pseudo article or not."
2474 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2476 (defmacro gnus-summary-article-sparse-p (article)
2477 "Say whether this article is a sparse article or not."
2478 `(memq ,article gnus-newsgroup-sparse))
2480 (defmacro gnus-summary-article-ancient-p (article)
2481 "Say whether this article is a sparse article or not."
2482 `(memq ,article gnus-newsgroup-ancient))
2484 (defun gnus-article-parent-p (number)
2485 "Say whether this article is a parent or not."
2486 (let ((data (gnus-data-find-list number)))
2487 (and (cdr data) ; There has to be an article after...
2488 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2489 (gnus-data-level (nth 1 data))))))
2491 (defun gnus-article-children (number)
2492 "Return a list of all children to NUMBER."
2493 (let* ((data (gnus-data-find-list number))
2494 (level (gnus-data-level (car data)))
2496 (setq data (cdr data))
2498 (= (gnus-data-level (car data)) (1+ level)))
2499 (push (gnus-data-number (car data)) children)
2500 (setq data (cdr data)))
2503 (defmacro gnus-summary-skip-intangible ()
2504 "If the current article is intangible, then jump to a different article."
2505 '(let ((to (get-text-property (point) 'gnus-intangible)))
2506 (and to (gnus-summary-goto-subject to))))
2508 (defmacro gnus-summary-article-intangible-p ()
2509 "Say whether this article is intangible or not."
2510 '(get-text-property (point) 'gnus-intangible))
2512 (defun gnus-article-read-p (article)
2513 "Say whether ARTICLE is read or not."
2514 (not (or (memq article gnus-newsgroup-marked)
2515 (memq article gnus-newsgroup-unreads)
2516 (memq article gnus-newsgroup-unselected)
2517 (memq article gnus-newsgroup-dormant))))
2519 ;; Some summary mode macros.
2521 (defmacro gnus-summary-article-number ()
2522 "The article number of the article on the current line.
2523 If there isn's an article number here, then we return the current
2526 (gnus-summary-skip-intangible)
2527 (or (get-text-property (point) 'gnus-number)
2528 (gnus-summary-last-subject))))
2530 (defmacro gnus-summary-article-header (&optional number)
2531 "Return the header of article NUMBER."
2532 `(gnus-data-header (gnus-data-find
2533 ,(or number '(gnus-summary-article-number)))))
2535 (defmacro gnus-summary-thread-level (&optional number)
2536 "Return the level of thread that starts with article NUMBER."
2537 `(if (and (eq gnus-summary-make-false-root 'dummy)
2538 (get-text-property (point) 'gnus-intangible))
2540 (gnus-data-level (gnus-data-find
2541 ,(or number '(gnus-summary-article-number))))))
2543 (defmacro gnus-summary-article-mark (&optional number)
2544 "Return the mark of article NUMBER."
2545 `(gnus-data-mark (gnus-data-find
2546 ,(or number '(gnus-summary-article-number)))))
2548 (defmacro gnus-summary-article-pos (&optional number)
2549 "Return the position of the line of article NUMBER."
2550 `(gnus-data-pos (gnus-data-find
2551 ,(or number '(gnus-summary-article-number)))))
2553 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2554 (defmacro gnus-summary-article-subject (&optional number)
2555 "Return current subject string or nil if nothing."
2558 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2559 '(gnus-data-header (assq (gnus-summary-article-number)
2560 gnus-newsgroup-data)))))
2563 (mail-header-subject headers))))
2565 (defmacro gnus-summary-article-score (&optional number)
2566 "Return current article score."
2567 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2568 gnus-newsgroup-scored))
2569 gnus-summary-default-score 0))
2571 (defun gnus-summary-article-children (&optional number)
2572 "Return a list of article numbers that are children of article NUMBER."
2573 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2574 (level (gnus-data-level (car data)))
2576 (while (and (setq data (cdr data))
2577 (> (setq l (gnus-data-level (car data))) level))
2578 (and (= (1+ level) l)
2579 (push (gnus-data-number (car data))
2581 (nreverse children)))
2583 (defun gnus-summary-article-parent (&optional number)
2584 "Return the article number of the parent of article NUMBER."
2585 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2586 (gnus-data-list t)))
2587 (level (gnus-data-level (car data))))
2589 () ; This is a root.
2590 ;; We search until we find an article with a level less than
2591 ;; this one. That function has to be the parent.
2592 (while (and (setq data (cdr data))
2593 (not (< (gnus-data-level (car data)) level))))
2594 (and data (gnus-data-number (car data))))))
2596 (defun gnus-unread-mark-p (mark)
2597 "Say whether MARK is the unread mark."
2598 (= mark gnus-unread-mark))
2600 (defun gnus-read-mark-p (mark)
2601 "Say whether MARK is one of the marks that mark as read.
2602 This is all marks except unread, ticked, dormant, and expirable."
2603 (not (or (= mark gnus-unread-mark)
2604 (= mark gnus-ticked-mark)
2605 (= mark gnus-dormant-mark)
2606 (= mark gnus-expirable-mark))))
2608 (defmacro gnus-article-mark (number)
2609 "Return the MARK of article NUMBER.
2610 This macro should only be used when computing the mark the \"first\"
2611 time; i.e., when generating the summary lines. After that,
2612 `gnus-summary-article-mark' should be used to examine the
2615 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2616 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2617 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2618 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2619 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2620 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2621 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2622 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2623 gnus-ancient-mark))))
2625 ;; Saving hidden threads.
2627 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2628 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2630 (defmacro gnus-save-hidden-threads (&rest forms)
2631 "Save hidden threads, eval FORMS, and restore the hidden threads."
2632 (let ((config (make-symbol "config")))
2633 `(let ((,config (gnus-hidden-threads-configuration)))
2637 (gnus-restore-hidden-threads-configuration ,config)))))
2639 (defun gnus-data-compute-positions ()
2640 "Compute the positions of all articles."
2641 (setq gnus-newsgroup-data-reverse nil)
2642 (let ((data gnus-newsgroup-data))
2644 (gnus-save-hidden-threads
2645 (gnus-summary-show-all-threads)
2646 (goto-char (point-min))
2648 (while (get-text-property (point) 'gnus-intangible)
2650 (gnus-data-set-pos (car data) (+ (point) 3))
2651 (setq data (cdr data))
2652 (forward-line 1))))))
2654 (defun gnus-hidden-threads-configuration ()
2655 "Return the current hidden threads configuration."
2658 (goto-char (point-min))
2659 (while (search-forward "\r" nil t)
2660 (push (1- (point)) config))
2663 (defun gnus-restore-hidden-threads-configuration (config)
2664 "Restore hidden threads configuration from CONFIG."
2666 (let (point buffer-read-only)
2667 (while (setq point (pop config))
2668 (when (and (< point (point-max))
2670 (eq (char-after) ?\n))
2671 (subst-char-in-region point (1+ point) ?\n ?\r))))))
2673 ;; Various summary mode internalish functions.
2675 (defun gnus-mouse-pick-article (e)
2678 (gnus-summary-next-page nil t))
2680 (defun gnus-summary-set-display-table ()
2681 "Change the display table.
2682 Odd characters have a tendency to mess
2683 up nicely formatted displays - we make all possible glyphs
2684 display only a single character."
2686 ;; We start from the standard display table, if any.
2687 (let ((table (or (copy-sequence standard-display-table)
2688 (make-display-table)))
2690 ;; Nix out all the control chars...
2691 (while (>= (setq i (1- i)) 0)
2692 (aset table i [??]))
2693 ;; ... but not newline and cr, of course. (cr is necessary for the
2694 ;; selective display).
2695 (aset table ?\n nil)
2696 (aset table ?\r nil)
2697 ;; We keep TAB as well.
2698 (aset table ?\t nil)
2699 ;; We nix out any glyphs over 126 that are not set already.
2701 (while (>= (setq i (1- i)) 127)
2702 ;; Only modify if the entry is nil.
2703 (unless (aref table i)
2704 (aset table i [??]))))
2705 (setq buffer-display-table table)))
2707 (defun gnus-summary-buffer-name (group)
2708 "Return the summary buffer name of GROUP."
2709 (concat "*Summary " group "*"))
2711 (defun gnus-summary-setup-buffer (group)
2712 "Initialize summary buffer."
2713 (let ((buffer (gnus-summary-buffer-name group)))
2714 (if (get-buffer buffer)
2717 (setq gnus-summary-buffer (current-buffer))
2718 (not gnus-newsgroup-prepared))
2719 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2720 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
2721 (gnus-summary-mode group)
2723 (gnus-carpal-setup-buffer 'summary))
2724 (unless gnus-single-article-buffer
2725 (make-local-variable 'gnus-article-buffer)
2726 (make-local-variable 'gnus-article-current)
2727 (make-local-variable 'gnus-original-article-buffer))
2728 (setq gnus-newsgroup-name group)
2729 ;; Set any local variables in the group parameters.
2730 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2733 (defun gnus-set-global-variables ()
2734 "Set the global equivalents of the buffer-local variables.
2735 They are set to the latest values they had. These reflect the summary
2736 buffer that was in action when the last article was fetched."
2737 (when (eq major-mode 'gnus-summary-mode)
2738 (setq gnus-summary-buffer (current-buffer))
2739 (let ((name gnus-newsgroup-name)
2740 (marked gnus-newsgroup-marked)
2741 (unread gnus-newsgroup-unreads)
2742 (headers gnus-current-headers)
2743 (data gnus-newsgroup-data)
2744 (summary gnus-summary-buffer)
2745 (article-buffer gnus-article-buffer)
2746 (original gnus-original-article-buffer)
2747 (gac gnus-article-current)
2748 (reffed gnus-reffed-article-number)
2749 (score-file gnus-current-score-file)
2750 (default-charset gnus-newsgroup-charset)
2752 (let ((locals gnus-newsgroup-variables))
2754 (if (consp (car locals))
2755 (push (eval (caar locals)) vlist)
2756 (push (eval (car locals)) vlist))
2757 (setq locals (cdr locals)))
2758 (setq vlist (nreverse vlist)))
2760 (set-buffer gnus-group-buffer)
2761 (setq gnus-newsgroup-name name
2762 gnus-newsgroup-marked marked
2763 gnus-newsgroup-unreads unread
2764 gnus-current-headers headers
2765 gnus-newsgroup-data data
2766 gnus-article-current gac
2767 gnus-summary-buffer summary
2768 gnus-article-buffer article-buffer
2769 gnus-original-article-buffer original
2770 gnus-reffed-article-number reffed
2771 gnus-current-score-file score-file
2772 gnus-newsgroup-charset default-charset)
2773 (let ((locals gnus-newsgroup-variables))
2775 (if (consp (car locals))
2776 (set (caar locals) (pop vlist))
2777 (set (car locals) (pop vlist)))
2778 (setq locals (cdr locals))))
2779 ;; The article buffer also has local variables.
2780 (when (gnus-buffer-live-p gnus-article-buffer)
2781 (set-buffer gnus-article-buffer)
2782 (setq gnus-summary-buffer summary))))))
2784 (defun gnus-summary-article-unread-p (article)
2785 "Say whether ARTICLE is unread or not."
2786 (memq article gnus-newsgroup-unreads))
2788 (defun gnus-summary-first-article-p (&optional article)
2789 "Return whether ARTICLE is the first article in the buffer."
2790 (if (not (setq article (or article (gnus-summary-article-number))))
2792 (eq article (caar gnus-newsgroup-data))))
2794 (defun gnus-summary-last-article-p (&optional article)
2795 "Return whether ARTICLE is the last article in the buffer."
2796 (if (not (setq article (or article (gnus-summary-article-number))))
2797 ;; All non-existent numbers are the last article. :-)
2799 (not (cdr (gnus-data-find-list article)))))
2801 (defun gnus-make-thread-indent-array ()
2803 (unless (and gnus-thread-indent-array
2804 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2805 (setq gnus-thread-indent-array (make-vector 201 "")
2806 gnus-thread-indent-array-level gnus-thread-indent-level)
2808 (aset gnus-thread-indent-array n
2809 (make-string (* n gnus-thread-indent-level) ? ))
2812 (defun gnus-update-summary-mark-positions ()
2813 "Compute where the summary marks are to go."
2815 (when (gnus-buffer-exists-p gnus-summary-buffer)
2816 (set-buffer gnus-summary-buffer))
2817 (let ((gnus-replied-mark 129)
2818 (gnus-score-below-mark 130)
2819 (gnus-score-over-mark 130)
2820 (gnus-download-mark 131)
2821 (spec gnus-summary-line-format-spec)
2824 (gnus-set-work-buffer)
2825 (let ((gnus-summary-line-format-spec spec)
2826 (gnus-newsgroup-downloadable '((0 . t))))
2827 (gnus-summary-insert-line
2828 [0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil]
2829 0 nil 128 t nil "" nil 1)
2830 (goto-char (point-min))
2831 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2833 (goto-char (point-min))
2834 (push (cons 'replied (and (search-forward "\201" nil t)
2837 (goto-char (point-min))
2838 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2840 (goto-char (point-min))
2841 (push (cons 'download
2842 (and (search-forward "\203" nil t) (- (point) 2)))
2844 (setq gnus-summary-mark-positions pos))))
2846 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2847 "Insert a dummy root in the summary buffer."
2849 (gnus-add-text-properties
2850 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2851 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2853 (defun gnus-summary-from-or-to-or-newsgroups (header)
2854 (let ((to (cdr (assq 'To (mail-header-extra header))))
2855 (newsgroups (cdr (assq 'Newsgroups (mail-header-extra header))))
2856 (mail-parse-charset gnus-newsgroup-charset)
2857 (mail-parse-ignored-charsets
2858 (save-excursion (set-buffer gnus-summary-buffer)
2859 gnus-newsgroup-ignored-charsets)))
2862 gnus-ignored-from-addresses
2863 (string-match gnus-ignored-from-addresses
2864 (mail-header-from header)))
2866 (or (car (funcall gnus-extract-address-components
2868 gnus-decode-encoded-word-function to)))
2869 (funcall gnus-decode-encoded-word-function to))))
2871 gnus-ignored-from-addresses
2872 (string-match gnus-ignored-from-addresses
2873 (mail-header-from header)))
2874 (concat "=> " newsgroups))
2876 (or (car (funcall gnus-extract-address-components
2877 (mail-header-from header)))
2878 (mail-header-from header))))))
2880 (defun gnus-summary-insert-line (gnus-tmp-header
2881 gnus-tmp-level gnus-tmp-current
2882 gnus-tmp-unread gnus-tmp-replied
2883 gnus-tmp-expirable gnus-tmp-subject-or-nil
2884 &optional gnus-tmp-dummy gnus-tmp-score
2886 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2887 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2888 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2889 (gnus-tmp-score-char
2890 (if (or (null gnus-summary-default-score)
2891 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2892 gnus-summary-zcore-fuzz))
2894 (if (< gnus-tmp-score gnus-summary-default-score)
2895 gnus-score-below-mark gnus-score-over-mark)))
2897 (cond (gnus-tmp-process gnus-process-mark)
2898 ((memq gnus-tmp-current gnus-newsgroup-cached)
2900 (gnus-tmp-replied gnus-replied-mark)
2901 ((memq gnus-tmp-current gnus-newsgroup-saved)
2904 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2907 ((string-match "<[^>]+> *$" gnus-tmp-from)
2908 (let ((beg (match-beginning 0)))
2909 (or (and (string-match "^\".+\"" gnus-tmp-from)
2910 (substring gnus-tmp-from 1 (1- (match-end 0))))
2911 (substring gnus-tmp-from 0 beg))))
2912 ((string-match "(.+)" gnus-tmp-from)
2913 (substring gnus-tmp-from
2914 (1+ (match-beginning 0)) (1- (match-end 0))))
2916 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2917 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2918 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2919 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
2920 (buffer-read-only nil))
2921 (when (string= gnus-tmp-name "")
2922 (setq gnus-tmp-name gnus-tmp-from))
2923 (unless (numberp gnus-tmp-lines)
2924 (setq gnus-tmp-lines -1))
2925 (when (= gnus-tmp-lines -1)
2926 (setq gnus-tmp-lines "?"))
2927 (gnus-put-text-property
2929 (progn (eval gnus-summary-line-format-spec) (point))
2930 'gnus-number gnus-tmp-number)
2931 (when (gnus-visual-p 'summary-highlight 'highlight)
2933 (gnus-run-hooks 'gnus-summary-update-hook)
2936 (defun gnus-summary-update-line (&optional dont-update)
2937 "Update summary line after change."
2938 (when (and gnus-summary-default-score
2939 (not gnus-summary-inhibit-highlight))
2940 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
2941 (article (gnus-summary-article-number))
2942 (score (gnus-summary-article-score article)))
2944 (if (and gnus-summary-mark-below
2945 (< (gnus-summary-article-score)
2946 gnus-summary-mark-below))
2947 ;; This article has a low score, so we mark it as read.
2948 (when (memq article gnus-newsgroup-unreads)
2949 (gnus-summary-mark-article-as-read gnus-low-score-mark))
2950 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
2951 ;; This article was previously marked as read on account
2952 ;; of a low score, but now it has risen, so we mark it as
2954 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
2955 (gnus-summary-update-mark
2956 (if (or (null gnus-summary-default-score)
2957 (<= (abs (- score gnus-summary-default-score))
2958 gnus-summary-zcore-fuzz))
2960 (if (< score gnus-summary-default-score)
2961 gnus-score-below-mark gnus-score-over-mark))
2963 ;; Do visual highlighting.
2964 (when (gnus-visual-p 'summary-highlight 'highlight)
2965 (gnus-run-hooks 'gnus-summary-update-hook)))))
2967 (defvar gnus-tmp-new-adopts nil)
2969 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
2970 "Return the number of articles in THREAD.
2971 This may be 0 in some cases -- if none of the articles in
2972 the thread are to be displayed."
2974 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
2976 ((not (listp thread))
2978 ((and (consp thread) (cdr thread))
2981 'gnus-summary-number-of-articles-in-thread (cdr thread))))
2984 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
2987 (when (and level (zerop level) gnus-tmp-new-adopts)
2990 'gnus-summary-number-of-articles-in-thread
2991 gnus-tmp-new-adopts))))
2993 (if (> number 1) gnus-not-empty-thread-mark
2994 gnus-empty-thread-mark)
2997 (defun gnus-summary-set-local-parameters (group)
2998 "Go through the local params of GROUP and set all variable specs in that list."
2999 (let ((params (gnus-group-find-parameter group))
3000 (vars '(quit-config)) ; Ignore quit-config.
3003 (setq elem (car params)
3004 params (cdr params))
3005 (and (consp elem) ; Has to be a cons.
3006 (consp (cdr elem)) ; The cdr has to be a list.
3007 (symbolp (car elem)) ; Has to be a symbol in there.
3008 (not (memq (car elem) vars))
3009 (ignore-errors ; So we set it.
3010 (push (car elem) vars)
3011 (make-local-variable (car elem))
3012 (set (car elem) (eval (nth 1 elem))))))))
3014 (defun gnus-summary-read-group (group &optional show-all no-article
3015 kill-buffer no-display backward
3017 "Start reading news in newsgroup GROUP.
3018 If SHOW-ALL is non-nil, already read articles are also listed.
3019 If NO-ARTICLE is non-nil, no article is selected initially.
3020 If NO-DISPLAY, don't generate a summary buffer."
3024 (let ((gnus-auto-select-next nil))
3025 (or (gnus-summary-read-group-1
3026 group show-all no-article
3027 kill-buffer no-display
3030 select-articles nil)))))
3031 (eq gnus-auto-select-next 'quietly))
3032 (set-buffer gnus-group-buffer)
3033 ;; The entry function called above goes to the next
3034 ;; group automatically, so we go two groups back
3035 ;; if we are searching for the previous group.
3037 (gnus-group-prev-unread-group 2))
3038 (if (not (equal group (gnus-group-group-name)))
3039 (setq group (gnus-group-group-name))
3043 (defun gnus-summary-read-group-1 (group show-all no-article
3044 kill-buffer no-display
3045 &optional select-articles)
3046 ;; Killed foreign groups can't be entered.
3047 ;; (when (and (not (gnus-group-native-p group))
3048 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3049 ;; (error "Dead non-native groups can't be entered"))
3050 (gnus-message 5 "Retrieving newsgroup: %s..."
3051 (gnus-group-decoded-name group))
3052 (let* ((new-group (gnus-summary-setup-buffer group))
3053 (quit-config (gnus-group-quit-config group))
3054 (did-select (and new-group (gnus-select-newsgroup
3055 group show-all select-articles))))
3057 ;; This summary buffer exists already, so we just select it.
3059 (gnus-set-global-variables)
3061 (gnus-kill-or-deaden-summary kill-buffer))
3062 (gnus-configure-windows 'summary 'force)
3063 (gnus-set-mode-line 'summary)
3064 (gnus-summary-position-point)
3067 ;; We couldn't select this group.
3069 (when (and (eq major-mode 'gnus-summary-mode)
3070 (not (equal (current-buffer) kill-buffer)))
3071 (kill-buffer (current-buffer))
3072 (if (not quit-config)
3074 ;; Update the info -- marks might need to be removed,
3076 (gnus-summary-update-info)
3077 (set-buffer gnus-group-buffer)
3078 (gnus-group-jump-to-group group)
3079 (gnus-group-next-unread-group 1))
3080 (gnus-handle-ephemeral-exit quit-config)))
3081 (let ((grpinfo (gnus-get-info group)))
3082 (if (null (gnus-info-read grpinfo))
3083 (gnus-message 3 "Group %s contains no messages"
3084 (gnus-group-decoded-name group))
3085 (gnus-message 3 "Can't select group")))
3087 ;; The user did a `C-g' while prompting for number of articles,
3088 ;; so we exit this group.
3089 ((eq did-select 'quit)
3090 (and (eq major-mode 'gnus-summary-mode)
3091 (not (equal (current-buffer) kill-buffer))
3092 (kill-buffer (current-buffer)))
3094 (gnus-kill-or-deaden-summary kill-buffer))
3095 (if (not quit-config)
3097 (set-buffer gnus-group-buffer)
3098 (gnus-group-jump-to-group group)
3099 (gnus-group-next-unread-group 1)
3100 (gnus-configure-windows 'group 'force))
3101 (gnus-handle-ephemeral-exit quit-config))
3102 ;; Finally signal the quit.
3104 ;; The group was successfully selected.
3106 (gnus-set-global-variables)
3107 ;; Save the active value in effect when the group was entered.
3108 (setq gnus-newsgroup-active
3110 (gnus-active gnus-newsgroup-name)))
3111 ;; You can change the summary buffer in some way with this hook.
3112 (gnus-run-hooks 'gnus-select-group-hook)
3113 (gnus-update-format-specifications
3114 nil 'summary 'summary-mode 'summary-dummy)
3115 (gnus-update-summary-mark-positions)
3116 ;; Do score processing.
3117 (when gnus-use-scoring
3118 (gnus-possibly-score-headers))
3119 ;; Check whether to fill in the gaps in the threads.
3120 (when gnus-build-sparse-threads
3121 (gnus-build-sparse-threads))
3122 ;; Find the initial limit.
3123 (if gnus-show-threads
3125 (let ((gnus-newsgroup-dormant nil))
3126 (gnus-summary-initial-limit show-all))
3127 (gnus-summary-initial-limit show-all))
3128 ;; When untreaded, all articles are always shown.
3129 (setq gnus-newsgroup-limit
3131 (lambda (header) (mail-header-number header))
3132 gnus-newsgroup-headers)))
3133 ;; Generate the summary buffer.
3135 (gnus-summary-prepare))
3136 (when gnus-use-trees
3137 (gnus-tree-open group)
3138 (setq gnus-summary-highlight-line-function
3139 'gnus-tree-highlight-article))
3140 ;; If the summary buffer is empty, but there are some low-scored
3141 ;; articles or some excluded dormants, we include these in the
3143 (when (and (zerop (buffer-size))
3145 (cond (gnus-newsgroup-dormant
3146 (gnus-summary-limit-include-dormant))
3147 ((and gnus-newsgroup-scored show-all)
3148 (gnus-summary-limit-include-expunged t))))
3149 ;; Function `gnus-apply-kill-file' must be called in this hook.
3150 (gnus-run-hooks 'gnus-apply-kill-hook)
3151 (if (and (zerop (buffer-size))
3154 ;; This newsgroup is empty.
3155 (gnus-summary-catchup-and-exit nil t)
3156 (gnus-message 6 "No unread news")
3158 (gnus-kill-or-deaden-summary kill-buffer))
3159 ;; Return nil from this function.
3161 ;; Hide conversation thread subtrees. We cannot do this in
3162 ;; gnus-summary-prepare-hook since kill processing may not
3163 ;; work with hidden articles.
3164 (and gnus-show-threads
3165 gnus-thread-hide-subtree
3166 (gnus-summary-hide-all-threads))
3168 (gnus-kill-or-deaden-summary kill-buffer))
3169 ;; Show first unread article if requested.
3170 (if (and (not no-article)
3172 gnus-newsgroup-unreads
3173 gnus-auto-select-first)
3175 (gnus-configure-windows 'summary)
3177 ((eq gnus-auto-select-first 'best)
3178 (gnus-summary-best-unread-article))
3179 ((eq gnus-auto-select-first t)
3180 (gnus-summary-first-unread-article))
3181 ((gnus-functionp gnus-auto-select-first)
3182 (funcall gnus-auto-select-first))))
3183 ;; Don't select any articles, just move point to the first
3184 ;; article in the group.
3185 (goto-char (point-min))
3186 (gnus-summary-position-point)
3187 (gnus-configure-windows 'summary 'force)
3188 (gnus-set-mode-line 'summary))
3189 (when (get-buffer-window gnus-group-buffer t)
3190 ;; Gotta use windows, because recenter does weird stuff if
3191 ;; the current buffer ain't the displayed window.
3192 (let ((owin (selected-window)))
3193 (select-window (get-buffer-window gnus-group-buffer t))
3194 (when (gnus-group-goto-group group)
3196 (select-window owin)))
3197 ;; Mark this buffer as "prepared".
3198 (setq gnus-newsgroup-prepared t)
3199 (gnus-run-hooks 'gnus-summary-prepared-hook)
3202 (defun gnus-summary-prepare ()
3203 "Generate the summary buffer."
3205 (let ((buffer-read-only nil))
3207 (setq gnus-newsgroup-data nil
3208 gnus-newsgroup-data-reverse nil)
3209 (gnus-run-hooks 'gnus-summary-generate-hook)
3210 ;; Generate the buffer, either with threads or without.
3211 (when gnus-newsgroup-headers
3212 (gnus-summary-prepare-threads
3213 (if gnus-show-threads
3214 (gnus-sort-gathered-threads
3215 (funcall gnus-summary-thread-gathering-function
3217 (gnus-cut-threads (gnus-make-threads)))))
3218 ;; Unthreaded display.
3219 (gnus-sort-articles gnus-newsgroup-headers))))
3220 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3221 ;; Call hooks for modifying summary buffer.
3222 (goto-char (point-min))
3223 (gnus-run-hooks 'gnus-summary-prepare-hook)))
3225 (defsubst gnus-general-simplify-subject (subject)
3226 "Simply subject by the same rules as gnus-gather-threads-by-subject."
3229 ;; Truncate the subject.
3230 (gnus-simplify-subject-functions
3231 (gnus-map-function gnus-simplify-subject-functions subject))
3232 ((numberp gnus-summary-gather-subject-limit)
3233 (setq subject (gnus-simplify-subject-re subject))
3234 (if (> (length subject) gnus-summary-gather-subject-limit)
3235 (substring subject 0 gnus-summary-gather-subject-limit)
3237 ;; Fuzzily simplify it.
3238 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3239 (gnus-simplify-subject-fuzzy subject))
3240 ;; Just remove the leading "Re:".
3242 (gnus-simplify-subject-re subject))))
3244 (if (and gnus-summary-gather-exclude-subject
3245 (string-match gnus-summary-gather-exclude-subject subject))
3246 nil ; This article shouldn't be gathered
3249 (defun gnus-summary-simplify-subject-query ()
3250 "Query where the respool algorithm would put this article."
3252 (gnus-summary-select-article)
3253 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
3255 (defun gnus-gather-threads-by-subject (threads)
3256 "Gather threads by looking at Subject headers."
3257 (if (not gnus-summary-make-false-root)
3259 (let ((hashtb (gnus-make-hashtable 1024))
3262 subject hthread whole-subject)
3264 (setq subject (gnus-general-simplify-subject
3265 (setq whole-subject (mail-header-subject
3268 (if (setq hthread (gnus-gethash subject hashtb))
3270 ;; We enter a dummy root into the thread, if we
3271 ;; haven't done that already.
3272 (unless (stringp (caar hthread))
3273 (setcar hthread (list whole-subject (car hthread))))
3274 ;; We add this new gathered thread to this gathered
3276 (setcdr (car hthread)
3277 (nconc (cdar hthread) (list (car threads))))
3278 ;; Remove it from the list of threads.
3279 (setcdr prev (cdr threads))
3280 (setq threads prev))
3281 ;; Enter this thread into the hash table.
3282 (gnus-sethash subject threads hashtb)))
3284 (setq threads (cdr threads)))
3287 (defun gnus-gather-threads-by-references (threads)
3288 "Gather threads by looking at References headers."
3289 (let ((idhashtb (gnus-make-hashtable 1024))
3290 (thhashtb (gnus-make-hashtable 1024))
3293 ids references id gthread gid entered ref)
3295 (when (setq references (mail-header-references (caar threads)))
3296 (setq id (mail-header-id (caar threads))
3297 ids (gnus-split-references references)
3299 (while (setq ref (pop ids))
3300 (setq ids (delete ref ids))
3301 (if (not (setq gid (gnus-gethash ref idhashtb)))
3303 (gnus-sethash ref id idhashtb)
3304 (gnus-sethash id threads thhashtb))
3305 (setq gthread (gnus-gethash gid thhashtb))
3307 ;; We enter a dummy root into the thread, if we
3308 ;; haven't done that already.
3309 (unless (stringp (caar gthread))
3310 (setcar gthread (list (mail-header-subject (caar gthread))
3312 ;; We add this new gathered thread to this gathered
3314 (setcdr (car gthread)
3315 (nconc (cdar gthread) (list (car threads)))))
3316 ;; Add it into the thread hash table.
3317 (gnus-sethash id gthread thhashtb)
3319 ;; Remove it from the list of threads.
3320 (setcdr prev (cdr threads))
3321 (setq threads prev))))
3323 (setq threads (cdr threads)))
3326 (defun gnus-sort-gathered-threads (threads)
3327 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
3328 (let ((result threads))
3330 (when (stringp (caar threads))
3331 (setcdr (car threads)
3332 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3333 (setq threads (cdr threads)))
3336 (defun gnus-thread-loop-p (root thread)
3337 "Say whether ROOT is in THREAD."
3338 (let ((stack (list thread))
3341 (while (setq thread (pop stack))
3342 (setq th (cdr thread))
3344 (not (eq (caar th) root)))
3347 ;; We have found a loop.
3349 (setcdr thread (delq (car th) (cdr thread)))
3350 (if (boundp (setq ref-dep (intern "none"
3351 gnus-newsgroup-dependencies)))
3352 (setcdr (symbol-value ref-dep)
3353 (nconc (cdr (symbol-value ref-dep))
3355 (set ref-dep (list nil (car th))))
3358 ;; Push all the subthreads onto the stack.
3359 (push (cdr thread) stack)))
3362 (defun gnus-make-threads ()
3363 "Go through the dependency hashtb and find the roots. Return all threads."
3365 (while (catch 'infloop
3368 ;; Deal with self-referencing References loops.
3369 (when (and (car (symbol-value refs))
3376 (car (symbol-value refs)) thread))
3377 (cdr (symbol-value refs)))))))
3380 (unless (car (symbol-value refs))
3381 ;; These threads do not refer back to any other articles,
3382 ;; so they're roots.
3383 (setq threads (append (cdr (symbol-value refs)) threads))))
3384 gnus-newsgroup-dependencies)))
3387 ;; Build the thread tree.
3388 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3389 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3391 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3392 if it was already present.
3394 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3395 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3396 Message-IDs will be renamed be renamed to a unique Message-ID before
3399 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3400 (let* ((id (mail-header-id header))
3401 (id-dep (and id (intern id dependencies)))
3402 ref ref-dep ref-header)
3403 ;; Enter this `header' in the `dependencies' table.
3407 ;; The first two cases do the normal part: enter a new `header'
3408 ;; in the `dependencies' table.
3409 ((not (boundp id-dep))
3410 (set id-dep (list header)))
3411 ((null (car (symbol-value id-dep)))
3412 (setcar (symbol-value id-dep) header))
3414 ;; From here the `header' was already present in the
3415 ;; `dependencies' table.
3417 ;; Overrides an existing entry;
3418 ;; just set the header part of the entry.
3419 (setcar (symbol-value id-dep) header))
3421 ;; Renames the existing `header' to a unique Message-ID.
3422 ((not gnus-summary-ignore-duplicates)
3423 ;; An article with this Message-ID has already been seen.
3424 ;; We rename the Message-ID.
3425 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3427 (mail-header-set-id header id))
3429 ;; The last case ignores an existing entry, except it adds any
3430 ;; additional Xrefs (in case the two articles came from different
3432 ;; Also sets `header' to `nil' meaning that the `dependencies'
3433 ;; table was *not* modified.
3435 (mail-header-set-xref
3436 (car (symbol-value id-dep))
3437 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3439 (or (mail-header-xref header) "")))
3443 ;; First check if that we are not creating a References loop.
3444 (setq ref (gnus-parent-id (mail-header-references header)))
3446 (setq ref-dep (intern-soft ref dependencies))
3448 (setq ref-header (car (symbol-value ref-dep))))
3449 (if (string= id ref)
3450 ;; Yuk! This is a reference loop. Make the article be a
3453 (mail-header-set-references (car (symbol-value id-dep)) "none")
3455 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3456 (setq ref (gnus-parent-id (mail-header-references header)))
3457 (setq ref-dep (intern (or ref "none") dependencies))
3458 (if (boundp ref-dep)
3459 (setcdr (symbol-value ref-dep)
3460 (nconc (cdr (symbol-value ref-dep))
3461 (list (symbol-value id-dep))))
3462 (set ref-dep (list nil (symbol-value id-dep)))))
3465 (defun gnus-build-sparse-threads ()
3466 (let ((headers gnus-newsgroup-headers)
3467 (mail-parse-charset gnus-newsgroup-charset)
3468 (gnus-summary-ignore-duplicates t)
3469 header references generation relations
3470 subject child end new-child date)
3471 ;; First we create an alist of generations/relations, where
3472 ;; generations is how much we trust the relation, and the relation
3474 (gnus-message 7 "Making sparse threads...")
3476 (nnheader-set-temp-buffer " *gnus sparse threads*")
3477 (while (setq header (pop headers))
3478 (when (and (setq references (mail-header-references header))
3479 (not (string= references "")))
3481 (setq child (mail-header-id header)
3482 subject (mail-header-subject header)
3483 date (mail-header-date header)
3485 (while (search-backward ">" nil t)
3486 (setq end (1+ (point)))
3487 (when (search-backward "<" nil t)
3488 (setq new-child (buffer-substring (point) end))
3489 (push (list (incf generation)
3490 child (setq child new-child)
3494 (push (list (1+ generation) child nil subject) relations))
3496 (kill-buffer (current-buffer)))
3497 ;; Sort over trustworthiness.
3500 (when (gnus-dependencies-add-header
3501 (make-full-mail-header
3502 gnus-reffed-article-number
3503 (nth 3 relation) "" (or (nth 4 relation) "")
3505 (or (nth 2 relation) "") 0 0 "")
3506 gnus-newsgroup-dependencies nil)
3507 (push gnus-reffed-article-number gnus-newsgroup-limit)
3508 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3509 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3510 gnus-newsgroup-reads)
3511 (decf gnus-reffed-article-number)))
3512 (sort relations 'car-less-than-car))
3513 (gnus-message 7 "Making sparse threads...done")))
3515 (defun gnus-build-old-threads ()
3516 ;; Look at all the articles that refer back to old articles, and
3517 ;; fetch the headers for the articles that aren't there. This will
3518 ;; build complete threads - if the roots haven't been expired by the
3520 (let ((mail-parse-charset gnus-newsgroup-charset)
3524 (when (not (car (symbol-value refs)))
3525 (setq heads (cdr (symbol-value refs)))
3527 (if (memq (mail-header-number (caar heads))
3528 gnus-newsgroup-dormant)
3529 (setq heads (cdr heads))
3530 (setq id (symbol-name refs))
3531 (while (and (setq id (gnus-build-get-header id))
3532 (not (car (gnus-id-to-thread id)))))
3533 (setq heads nil)))))
3534 gnus-newsgroup-dependencies)))
3536 ;; This function has to be called with point after the article number
3537 ;; on the beginning of the line.
3538 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3539 (let ((eol (gnus-point-at-eol))
3540 (buffer (current-buffer))
3543 ;; overview: [num subject from date id refs chars lines misc]
3546 (narrow-to-region (point) eol)
3551 (make-full-mail-header
3553 (funcall gnus-decode-encoded-word-function
3554 (nnheader-nov-field)) ; subject
3555 (funcall gnus-decode-encoded-word-function
3556 (nnheader-nov-field)) ; from
3557 (nnheader-nov-field) ; date
3558 (nnheader-nov-read-message-id) ; id
3559 (nnheader-nov-field) ; refs
3560 (nnheader-nov-read-integer) ; chars
3561 (nnheader-nov-read-integer) ; lines
3563 (if (looking-at "Xref: ")
3564 (goto-char (match-end 0)))
3565 (nnheader-nov-field)) ; Xref
3566 (nnheader-nov-parse-extra)))) ; extra
3570 (when gnus-alter-header-function
3571 (funcall gnus-alter-header-function header))
3572 (gnus-dependencies-add-header header dependencies force-new)))
3574 (defun gnus-build-get-header (id)
3575 "Look through the buffer of NOV lines and find the header to ID.
3576 Enter this line into the dependencies hash table, and return
3577 the id of the parent article (if any)."
3578 (let ((deps gnus-newsgroup-dependencies)
3582 (set-buffer nntp-server-buffer)
3583 (let ((case-fold-search nil))
3584 (goto-char (point-min))
3585 (while (and (not found)
3586 (search-forward id nil t))
3588 (setq found (looking-at
3589 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3590 (regexp-quote id))))
3591 (or found (beginning-of-line 2)))
3595 (setq header (gnus-nov-parse-line
3596 (read (current-buffer)) deps))
3597 (gnus-parent-id (mail-header-references header))))))
3599 (let ((number (mail-header-number header)))
3600 (push number gnus-newsgroup-limit)
3601 (push header gnus-newsgroup-headers)
3602 (if (memq number gnus-newsgroup-unselected)
3604 (push number gnus-newsgroup-unreads)
3605 (setq gnus-newsgroup-unselected
3606 (delq number gnus-newsgroup-unselected)))
3607 (push number gnus-newsgroup-ancient)))))))
3609 (defun gnus-build-all-threads ()
3610 "Read all the headers."
3611 (let ((gnus-summary-ignore-duplicates t)
3612 (mail-parse-charset gnus-newsgroup-charset)
3613 (dependencies gnus-newsgroup-dependencies)
3616 (set-buffer nntp-server-buffer)
3617 (let ((case-fold-search nil))
3618 (goto-char (point-min))
3621 (setq article (read (current-buffer))
3622 header (gnus-nov-parse-line article dependencies)))
3625 (set-buffer gnus-summary-buffer)
3626 (push header gnus-newsgroup-headers)
3627 (if (memq (setq article (mail-header-number header))
3628 gnus-newsgroup-unselected)
3630 (push article gnus-newsgroup-unreads)
3631 (setq gnus-newsgroup-unselected
3632 (delq article gnus-newsgroup-unselected)))
3633 (push article gnus-newsgroup-ancient)))
3634 (forward-line 1)))))))
3636 (defun gnus-summary-update-article-line (article header)
3637 "Update the line for ARTICLE using HEADERS."
3638 (let* ((id (mail-header-id header))
3639 (thread (gnus-id-to-thread id)))
3641 (error "Article in no thread"))
3642 ;; Update the thread.
3643 (setcar thread header)
3644 (gnus-summary-goto-subject article)
3645 (let* ((datal (gnus-data-find-list article))
3647 (length (when (cdr datal)
3648 (- (gnus-data-pos data)
3649 (gnus-data-pos (cadr datal)))))
3650 (buffer-read-only nil)
3651 (level (gnus-summary-thread-level)))
3653 (gnus-summary-insert-line
3654 header level nil (gnus-article-mark article)
3655 (memq article gnus-newsgroup-replied)
3656 (memq article gnus-newsgroup-expirable)
3657 ;; Only insert the Subject string when it's different
3658 ;; from the previous Subject string.
3663 (mail-header-subject
3666 (gnus-data-find-list
3668 (gnus-data-list t)))))
3669 ;; Error on the side of excessive subjects.
3671 (mail-header-subject header)))
3673 (mail-header-subject header))
3674 nil (cdr (assq article gnus-newsgroup-scored))
3675 (memq article gnus-newsgroup-processable))
3677 (gnus-data-update-list
3678 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3680 (defun gnus-summary-update-article (article &optional iheader)
3681 "Update ARTICLE in the summary buffer."
3682 (set-buffer gnus-summary-buffer)
3683 (let* ((header (gnus-summary-article-header article))
3684 (id (mail-header-id header))
3685 (data (gnus-data-find article))
3686 (thread (gnus-id-to-thread id))
3687 (references (mail-header-references header))
3691 (when (and references
3692 (not (equal "" references)))
3695 (buffer-read-only nil)
3701 (delq thread parent)))
3702 (if (gnus-summary-insert-subject id header)
3703 ;; Set the (possibly) new article number in the data structure.
3704 (gnus-data-set-number data (gnus-id-to-article id))
3708 (defun gnus-rebuild-thread (id &optional line)
3709 "Rebuild the thread containing ID.
3710 If LINE, insert the rebuilt thread starting on line LINE."
3711 (let ((buffer-read-only nil)
3712 old-pos current thread data)
3713 (if (not gnus-show-threads)
3714 (setq thread (list (car (gnus-id-to-thread id))))
3715 ;; Get the thread this article is part of.
3716 (setq thread (gnus-remove-thread id)))
3717 (setq old-pos (gnus-point-at-bol))
3718 (setq current (save-excursion
3719 (and (re-search-backward "[\r\n]" nil t)
3720 (gnus-summary-article-number))))
3721 ;; If this is a gathered thread, we have to go some re-gathering.
3722 (when (stringp (car thread))
3723 (let ((subject (car thread))
3725 (setq thread (cdr thread))
3727 (unless (memq (setq thr (gnus-id-to-thread
3729 (mail-header-id (caar thread)))))
3732 (setq thread (cdr thread)))
3733 ;; We now have all (unique) roots.
3734 (if (= (length roots) 1)
3735 ;; All the loose roots are now one solid root.
3736 (setq thread (car roots))
3737 (setq thread (cons subject (gnus-sort-threads roots))))))
3739 ;; We then insert this thread into the summary buffer.
3741 (goto-char (point-min))
3742 (forward-line (1- line)))
3743 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3744 (if gnus-show-threads
3745 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3746 (gnus-summary-prepare-unthreaded thread))
3747 (setq data (nreverse gnus-newsgroup-data))
3748 (setq threads gnus-newsgroup-threads))
3749 ;; We splice the new data into the data structure.
3750 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
3751 ;;!!! then we want to insert at the beginning of the buffer.
3752 ;;!!! That happens to be true with Gnus now, but that may
3753 ;;!!! change in the future. Perhaps.
3754 (gnus-data-enter-list
3755 (if line nil current) data (- (point) old-pos))
3756 (setq gnus-newsgroup-threads
3757 (nconc threads gnus-newsgroup-threads))
3758 (gnus-data-compute-positions))))
3760 (defun gnus-number-to-header (number)
3761 "Return the header for article NUMBER."
3762 (let ((headers gnus-newsgroup-headers))
3764 (not (= number (mail-header-number (car headers)))))
3769 (defun gnus-parent-headers (in-headers &optional generation)
3770 "Return the headers of the GENERATIONeth parent of HEADERS."
3772 (setq generation 1))
3774 (headers in-headers)
3777 (not (zerop generation))
3778 (setq references (mail-header-references headers)))
3779 (setq headers (if (and references
3780 (setq parent (gnus-parent-id references)))
3781 (car (gnus-id-to-thread parent))
3784 (and (not (eq headers in-headers))
3787 (defun gnus-id-to-thread (id)
3788 "Return the (sub-)thread where ID appears."
3789 (gnus-gethash id gnus-newsgroup-dependencies))
3791 (defun gnus-id-to-article (id)
3792 "Return the article number of ID."
3793 (let ((thread (gnus-id-to-thread id)))
3796 (mail-header-number (car thread)))))
3798 (defun gnus-id-to-header (id)
3799 "Return the article headers of ID."
3800 (car (gnus-id-to-thread id)))
3802 (defun gnus-article-displayed-root-p (article)
3803 "Say whether ARTICLE is a root(ish) article."
3804 (let ((level (gnus-summary-thread-level article))
3805 (refs (mail-header-references (gnus-summary-article-header article)))
3811 ((null (gnus-parent-id refs)) t)
3813 (null (setq particle (gnus-id-to-article
3814 (gnus-parent-id refs))))
3815 (null (gnus-summary-thread-level particle)))))))
3817 (defun gnus-root-id (id)
3818 "Return the id of the root of the thread where ID appears."
3820 (while (and id (setq prev (car (gnus-id-to-thread id))))
3822 id (gnus-parent-id (mail-header-references prev))))
3825 (defun gnus-articles-in-thread (thread)
3826 "Return the list of articles in THREAD."
3827 (cons (mail-header-number (car thread))
3828 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
3830 (defun gnus-remove-thread (id &optional dont-remove)
3831 "Remove the thread that has ID in it."
3832 (let (headers thread last-id)
3833 ;; First go up in this thread until we find the root.
3834 (setq last-id (gnus-root-id id)
3835 headers (message-flatten-list (gnus-id-to-thread last-id)))
3836 ;; We have now found the real root of this thread. It might have
3837 ;; been gathered into some loose thread, so we have to search
3838 ;; through the threads to find the thread we wanted.
3839 (let ((threads gnus-newsgroup-threads)
3842 (setq sub (car threads))
3843 (if (stringp (car sub))
3844 ;; This is a gathered thread, so we look at the roots
3845 ;; below it to find whether this article is in this
3848 (setq sub (cdr sub))
3850 (when (member (caar sub) headers)
3851 (setq thread (car threads)
3854 (setq sub (cdr sub))))
3855 ;; It's an ordinary thread, so we check it.
3856 (when (eq (car sub) (car headers))
3859 (setq threads (cdr threads)))
3860 ;; If this article is in no thread, then it's a root.
3863 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
3864 (setq thread (gnus-id-to-thread last-id)))
3867 thread ; We return this thread.
3869 (if (stringp (car thread))
3871 ;; If we use dummy roots, then we have to remove the
3872 ;; dummy root as well.
3873 (when (eq gnus-summary-make-false-root 'dummy)
3874 ;; We go to the dummy root by going to
3875 ;; the first sub-"thread", and then one line up.
3876 (gnus-summary-goto-article
3877 (mail-header-number (caadr thread)))
3880 (gnus-data-compute-positions))
3881 (setq thread (cdr thread))
3883 (gnus-remove-thread-1 (car thread))
3884 (setq thread (cdr thread))))
3885 (gnus-remove-thread-1 thread))))))))
3887 (defun gnus-remove-thread-1 (thread)
3888 "Remove the thread THREAD recursively."
3889 (let ((number (mail-header-number (pop thread)))
3891 (setq thread (reverse thread))
3893 (gnus-remove-thread-1 (pop thread)))
3894 (when (setq d (gnus-data-find number))
3895 (goto-char (gnus-data-pos d))
3896 (gnus-summary-show-thread)
3899 (- (gnus-point-at-bol)
3901 (1+ (gnus-point-at-eol))
3902 (gnus-delete-line)))))))
3904 (defun gnus-sort-threads-1 (threads func)
3905 (sort (mapcar (lambda (thread)
3908 (gnus-sort-threads-1 (cdr thread) func))))
3911 (defun gnus-sort-threads (threads)
3913 (if (not gnus-thread-sort-functions)
3915 (gnus-message 8 "Sorting threads...")
3917 (gnus-sort-threads-1
3919 (gnus-make-sort-function gnus-thread-sort-functions))
3920 (gnus-message 8 "Sorting threads...done"))))
3922 (defun gnus-sort-articles (articles)
3924 (when gnus-article-sort-functions
3925 (gnus-message 7 "Sorting articles...")
3927 (setq gnus-newsgroup-headers
3928 (sort articles (gnus-make-sort-function
3929 gnus-article-sort-functions)))
3930 (gnus-message 7 "Sorting articles...done"))))
3932 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3933 (defmacro gnus-thread-header (thread)
3934 "Return header of first article in THREAD.
3935 Note that THREAD must never, ever be anything else than a variable -
3936 using some other form will lead to serious barfage."
3937 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
3938 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
3939 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
3942 (defsubst gnus-article-sort-by-number (h1 h2)
3943 "Sort articles by article number."
3944 (< (mail-header-number h1)
3945 (mail-header-number h2)))
3947 (defun gnus-thread-sort-by-number (h1 h2)
3948 "Sort threads by root article number."
3949 (gnus-article-sort-by-number
3950 (gnus-thread-header h1) (gnus-thread-header h2)))
3952 (defsubst gnus-article-sort-by-lines (h1 h2)
3953 "Sort articles by article Lines header."
3954 (< (mail-header-lines h1)
3955 (mail-header-lines h2)))
3957 (defun gnus-thread-sort-by-lines (h1 h2)
3958 "Sort threads by root article Lines header."
3959 (gnus-article-sort-by-lines
3960 (gnus-thread-header h1) (gnus-thread-header h2)))
3962 (defsubst gnus-article-sort-by-chars (h1 h2)
3963 "Sort articles by octet length."
3964 (< (mail-header-chars h1)
3965 (mail-header-chars h2)))
3967 (defun gnus-thread-sort-by-chars (h1 h2)
3968 "Sort threads by root article octet length."
3969 (gnus-article-sort-by-chars
3970 (gnus-thread-header h1) (gnus-thread-header h2)))
3972 (defsubst gnus-article-sort-by-author (h1 h2)
3973 "Sort articles by root author."
3975 (let ((extract (funcall
3976 gnus-extract-address-components
3977 (mail-header-from h1))))
3978 (or (car extract) (cadr extract) ""))
3979 (let ((extract (funcall
3980 gnus-extract-address-components
3981 (mail-header-from h2))))
3982 (or (car extract) (cadr extract) ""))))
3984 (defun gnus-thread-sort-by-author (h1 h2)
3985 "Sort threads by root author."
3986 (gnus-article-sort-by-author
3987 (gnus-thread-header h1) (gnus-thread-header h2)))
3989 (defsubst gnus-article-sort-by-subject (h1 h2)
3990 "Sort articles by root subject."
3992 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
3993 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
3995 (defun gnus-thread-sort-by-subject (h1 h2)
3996 "Sort threads by root subject."
3997 (gnus-article-sort-by-subject
3998 (gnus-thread-header h1) (gnus-thread-header h2)))
4000 (defsubst gnus-article-sort-by-date (h1 h2)
4001 "Sort articles by root article date."
4003 (gnus-date-get-time (mail-header-date h1))
4004 (gnus-date-get-time (mail-header-date h2))))
4006 (defun gnus-thread-sort-by-date (h1 h2)
4007 "Sort threads by root article date."
4008 (gnus-article-sort-by-date
4009 (gnus-thread-header h1) (gnus-thread-header h2)))
4011 (defsubst gnus-article-sort-by-score (h1 h2)
4012 "Sort articles by root article score.
4013 Unscored articles will be counted as having a score of zero."
4014 (> (or (cdr (assq (mail-header-number h1)
4015 gnus-newsgroup-scored))
4016 gnus-summary-default-score 0)
4017 (or (cdr (assq (mail-header-number h2)
4018 gnus-newsgroup-scored))
4019 gnus-summary-default-score 0)))
4021 (defun gnus-thread-sort-by-score (h1 h2)
4022 "Sort threads by root article score."
4023 (gnus-article-sort-by-score
4024 (gnus-thread-header h1) (gnus-thread-header h2)))
4026 (defun gnus-thread-sort-by-total-score (h1 h2)
4027 "Sort threads by the sum of all scores in the thread.
4028 Unscored articles will be counted as having a score of zero."
4029 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4031 (defun gnus-thread-total-score (thread)
4032 ;; This function find the total score of THREAD.
4033 (cond ((null thread)
4036 (if (stringp (car thread))
4037 (apply gnus-thread-score-function 0
4038 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4039 (gnus-thread-total-score-1 thread)))
4041 (gnus-thread-total-score-1 (list thread)))))
4043 (defun gnus-thread-total-score-1 (root)
4044 ;; This function find the total score of the thread below ROOT.
4045 (setq root (car root))
4046 (apply gnus-thread-score-function
4048 (mapcar 'gnus-thread-total-score
4049 (cdr (gnus-id-to-thread (mail-header-id root))))
4050 (when (> (mail-header-number root) 0)
4051 (list (or (cdr (assq (mail-header-number root)
4052 gnus-newsgroup-scored))
4053 gnus-summary-default-score 0))))
4054 (list gnus-summary-default-score)
4057 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
4058 (defvar gnus-tmp-prev-subject nil)
4059 (defvar gnus-tmp-false-parent nil)
4060 (defvar gnus-tmp-root-expunged nil)
4061 (defvar gnus-tmp-dummy-line nil)
4063 (eval-when-compile (defvar gnus-tmp-header))
4064 (defun gnus-extra-header (type &optional header)
4065 "Return the extra header of TYPE."
4066 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
4069 (defun gnus-summary-prepare-threads (threads)
4070 "Prepare summary buffer from THREADS and indentation LEVEL.
4071 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
4072 or a straight list of headers."
4073 (gnus-message 7 "Generating summary...")
4075 (setq gnus-newsgroup-threads threads)
4078 (let ((gnus-tmp-level 0)
4079 (default-score (or gnus-summary-default-score 0))
4080 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
4081 thread number subject stack state gnus-tmp-gathered beg-match
4082 new-roots gnus-tmp-new-adopts thread-end
4083 gnus-tmp-header gnus-tmp-unread
4084 gnus-tmp-replied gnus-tmp-subject-or-nil
4085 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
4086 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
4087 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
4089 (setq gnus-tmp-prev-subject nil)
4091 (if (vectorp (car threads))
4092 ;; If this is a straight (sic) list of headers, then a
4093 ;; threaded summary display isn't required, so we just create
4094 ;; an unthreaded one.
4095 (gnus-summary-prepare-unthreaded threads)
4097 ;; Do the threaded display.
4099 (while (or threads stack gnus-tmp-new-adopts new-roots)
4101 (if (and (= gnus-tmp-level 0)
4104 (not gnus-tmp-false-parent)
4105 (or gnus-tmp-new-adopts new-roots))
4106 (if gnus-tmp-new-adopts
4107 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
4108 thread (list (car gnus-tmp-new-adopts))
4109 gnus-tmp-header (caar thread)
4110 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
4112 (setq thread (list (car new-roots))
4113 gnus-tmp-header (caar thread)
4114 new-roots (cdr new-roots))))
4117 ;; If there are some threads, we do them before the
4118 ;; threads on the stack.
4119 (setq thread threads
4120 gnus-tmp-header (caar thread))
4121 ;; There were no current threads, so we pop something off
4123 (setq state (car stack)
4124 gnus-tmp-level (car state)
4127 gnus-tmp-header (caar thread))))
4129 (setq gnus-tmp-false-parent nil)
4130 (setq gnus-tmp-root-expunged nil)
4131 (setq thread-end nil)
4133 (if (stringp gnus-tmp-header)
4134 ;; The header is a dummy root.
4136 ((eq gnus-summary-make-false-root 'adopt)
4137 ;; We let the first article adopt the rest.
4138 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
4140 (setq gnus-tmp-gathered
4142 (lambda (h) (mail-header-number (car h)))
4145 (setq thread (cons (list (caar thread)
4148 (setq gnus-tmp-level -1
4149 gnus-tmp-false-parent t))
4150 ((eq gnus-summary-make-false-root 'empty)
4151 ;; We print adopted articles with empty subject fields.
4152 (setq gnus-tmp-gathered
4154 (lambda (h) (mail-header-number (car h)))
4157 (setq gnus-tmp-level -1))
4158 ((eq gnus-summary-make-false-root 'dummy)
4159 ;; We remember that we probably want to output a dummy
4161 (setq gnus-tmp-dummy-line gnus-tmp-header)
4162 (setq gnus-tmp-prev-subject gnus-tmp-header))
4164 ;; We do not make a root for the gathered
4165 ;; sub-threads at all.
4166 (setq gnus-tmp-level -1)))
4168 (setq number (mail-header-number gnus-tmp-header)
4169 subject (mail-header-subject gnus-tmp-header))
4172 ;; If the thread has changed subject, we might want to make
4173 ;; this subthread into a root.
4174 ((and (null gnus-thread-ignore-subject)
4175 (not (zerop gnus-tmp-level))
4176 gnus-tmp-prev-subject
4178 (gnus-subject-equal gnus-tmp-prev-subject subject))))
4179 (setq new-roots (nconc new-roots (list (car thread)))
4181 gnus-tmp-header nil))
4182 ;; If the article lies outside the current limit,
4183 ;; then we do not display it.
4184 ((not (memq number gnus-newsgroup-limit))
4185 (setq gnus-tmp-gathered
4187 (lambda (h) (mail-header-number (car h)))
4190 (setq gnus-tmp-new-adopts (if (cdar thread)
4191 (append gnus-tmp-new-adopts
4193 gnus-tmp-new-adopts)
4195 gnus-tmp-header nil)
4196 (when (zerop gnus-tmp-level)
4197 (setq gnus-tmp-root-expunged t)))
4198 ;; Perhaps this article is to be marked as read?
4199 ((and gnus-summary-mark-below
4200 (< (or (cdr (assq number gnus-newsgroup-scored))
4202 gnus-summary-mark-below)
4203 ;; Don't touch sparse articles.
4204 (not (gnus-summary-article-sparse-p number))
4205 (not (gnus-summary-article-ancient-p number)))
4206 (setq gnus-newsgroup-unreads
4207 (delq number gnus-newsgroup-unreads))
4208 (if gnus-newsgroup-auto-expire
4209 (push number gnus-newsgroup-expirable)
4210 (push (cons number gnus-low-score-mark)
4211 gnus-newsgroup-reads))))
4213 (when gnus-tmp-header
4214 ;; We may have an old dummy line to output before this
4216 (when (and gnus-tmp-dummy-line
4219 (mail-header-subject gnus-tmp-header)))
4220 (gnus-summary-insert-dummy-line
4221 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
4222 (setq gnus-tmp-dummy-line nil))
4224 ;; Compute the mark.
4225 (setq gnus-tmp-unread (gnus-article-mark number))
4227 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
4228 gnus-tmp-header gnus-tmp-level)
4229 gnus-newsgroup-data)
4231 ;; Actually insert the line.
4233 gnus-tmp-subject-or-nil
4235 ((and gnus-thread-ignore-subject
4236 gnus-tmp-prev-subject
4237 (not (inline (gnus-subject-equal
4238 gnus-tmp-prev-subject subject))))
4240 ((zerop gnus-tmp-level)
4241 (if (and (eq gnus-summary-make-false-root 'empty)
4242 (memq number gnus-tmp-gathered)
4243 gnus-tmp-prev-subject
4244 (inline (gnus-subject-equal
4245 gnus-tmp-prev-subject subject)))
4246 gnus-summary-same-subject
4248 (t gnus-summary-same-subject)))
4249 (if (and (eq gnus-summary-make-false-root 'adopt)
4250 (= gnus-tmp-level 1)
4251 (memq number gnus-tmp-gathered))
4252 (setq gnus-tmp-opening-bracket ?\<
4253 gnus-tmp-closing-bracket ?\>)
4254 (setq gnus-tmp-opening-bracket ?\[
4255 gnus-tmp-closing-bracket ?\]))
4257 gnus-tmp-indentation
4258 (aref gnus-thread-indent-array gnus-tmp-level)
4259 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4260 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4261 gnus-summary-default-score 0)
4263 (if (or (null gnus-summary-default-score)
4264 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
4265 gnus-summary-zcore-fuzz))
4267 (if (< gnus-tmp-score gnus-summary-default-score)
4268 gnus-score-below-mark gnus-score-over-mark))
4270 (cond ((memq number gnus-newsgroup-processable)
4272 ((memq number gnus-newsgroup-cached)
4274 ((memq number gnus-newsgroup-replied)
4276 ((memq number gnus-newsgroup-forwarded)
4277 gnus-forwarded-mark)
4278 ((memq number gnus-newsgroup-saved)
4281 gnus-tmp-from (mail-header-from gnus-tmp-header)
4284 ((string-match "<[^>]+> *$" gnus-tmp-from)
4285 (setq beg-match (match-beginning 0))
4286 (or (and (string-match "^\".+\"" gnus-tmp-from)
4287 (substring gnus-tmp-from 1 (1- (match-end 0))))
4288 (substring gnus-tmp-from 0 beg-match)))
4289 ((string-match "(.+)" gnus-tmp-from)
4290 (substring gnus-tmp-from
4291 (1+ (match-beginning 0)) (1- (match-end 0))))
4293 (when (string= gnus-tmp-name "")
4294 (setq gnus-tmp-name gnus-tmp-from))
4295 (unless (numberp gnus-tmp-lines)
4296 (setq gnus-tmp-lines -1))
4297 (when (= gnus-tmp-lines -1)
4298 (setq gnus-tmp-lines "?"))
4299 (gnus-put-text-property
4301 (progn (eval gnus-summary-line-format-spec) (point))
4302 'gnus-number number)
4305 (gnus-run-hooks 'gnus-summary-update-hook)
4308 (setq gnus-tmp-prev-subject subject)))
4310 (when (nth 1 thread)
4311 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
4312 (incf gnus-tmp-level)
4313 (setq threads (if thread-end nil (cdar thread)))
4315 (setq gnus-tmp-level 0)))))
4316 (gnus-message 7 "Generating summary...done"))
4318 (defun gnus-summary-prepare-unthreaded (headers)
4319 "Generate an unthreaded summary buffer based on HEADERS."
4320 (let (header number mark)
4325 ;; We may have to root out some bad articles...
4326 (when (memq (setq number (mail-header-number
4327 (setq header (pop headers))))
4328 gnus-newsgroup-limit)
4329 ;; Mark article as read when it has a low score.
4330 (when (and gnus-summary-mark-below
4331 (< (or (cdr (assq number gnus-newsgroup-scored))
4332 gnus-summary-default-score 0)
4333 gnus-summary-mark-below)
4334 (not (gnus-summary-article-ancient-p number)))
4335 (setq gnus-newsgroup-unreads
4336 (delq number gnus-newsgroup-unreads))
4337 (if gnus-newsgroup-auto-expire
4338 (push number gnus-newsgroup-expirable)
4339 (push (cons number gnus-low-score-mark)
4340 gnus-newsgroup-reads)))
4342 (setq mark (gnus-article-mark number))
4343 (push (gnus-data-make number mark (1+ (point)) header 0)
4344 gnus-newsgroup-data)
4345 (gnus-summary-insert-line
4347 mark (memq number gnus-newsgroup-replied)
4348 (memq number gnus-newsgroup-expirable)
4349 (mail-header-subject header) nil
4350 (cdr (assq number gnus-newsgroup-scored))
4351 (memq number gnus-newsgroup-processable))))))
4353 (defun gnus-summary-remove-list-identifiers ()
4354 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
4355 (let ((regexp (if (consp gnus-list-identifiers)
4356 (mapconcat 'identity gnus-list-identifiers " *\\|")
4357 gnus-list-identifiers))
4360 (dolist (header gnus-newsgroup-headers)
4361 (setq subject (mail-header-subject header)
4363 (while (string-match
4364 (concat "^\\(R[Ee]: +\\)*\\(" regexp " *\\)")
4367 (concat (substring subject 0 (match-beginning 2))
4368 (substring subject (match-end 0)))
4372 "^\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" subject))
4374 (concat (substring subject 0 (match-beginning 1))
4375 (substring subject (match-end 1)))))
4377 (mail-header-set-subject header subject))))))
4379 (defun gnus-fetch-headers (articles)
4380 "Fetch headers of ARTICLES."
4381 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
4382 (gnus-message 5 "Fetching headers for %s..." name)
4385 (setq gnus-headers-retrieved-by
4386 (gnus-retrieve-headers
4387 articles gnus-newsgroup-name
4388 ;; We might want to fetch old headers, but
4389 ;; not if there is only 1 article.
4391 (not (eq gnus-fetch-old-headers 'some))
4392 (not (numberp gnus-fetch-old-headers)))
4393 (> (length articles) 1))
4394 gnus-fetch-old-headers))))
4395 (gnus-get-newsgroup-headers-xover
4396 articles nil nil gnus-newsgroup-name t)
4397 (gnus-get-newsgroup-headers))
4398 (gnus-message 5 "Fetching headers for %s...done" name))))
4400 (defun gnus-select-newsgroup (group &optional read-all select-articles)
4401 "Select newsgroup GROUP.
4402 If READ-ALL is non-nil, all articles in the group are selected.
4403 If SELECT-ARTICLES, only select those articles from GROUP."
4404 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4405 ;;!!! Dirty hack; should be removed.
4406 (gnus-summary-ignore-duplicates
4407 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
4409 gnus-summary-ignore-duplicates))
4410 (info (nth 2 entry))
4411 articles fetched-articles cached)
4413 (unless (gnus-check-server
4414 (setq gnus-current-select-method
4415 (gnus-find-method-for-group group)))
4416 (error "Couldn't open server"))
4418 (or (and entry (not (eq (car entry) t))) ; Either it's active...
4419 (gnus-activate-group group) ; Or we can activate it...
4420 (progn ; Or we bug out.
4421 (when (equal major-mode 'gnus-summary-mode)
4422 (kill-buffer (current-buffer)))
4423 (error "Couldn't activate group %s: %s"
4424 group (gnus-status-message group))))
4426 (unless (gnus-request-group group t)
4427 (when (equal major-mode 'gnus-summary-mode)
4428 (kill-buffer (current-buffer)))
4429 (error "Couldn't request group %s: %s"
4430 group (gnus-status-message group)))
4432 (setq gnus-newsgroup-name group)
4433 (setq gnus-newsgroup-unselected nil)
4434 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
4435 (gnus-summary-setup-default-charset)
4437 ;; Adjust and set lists of article marks.
4439 (gnus-adjust-marked-articles info))
4441 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4442 (when (gnus-virtual-group-p group)
4443 (setq cached gnus-newsgroup-cached))
4445 (setq gnus-newsgroup-unreads
4446 (gnus-set-difference
4447 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
4448 gnus-newsgroup-dormant))
4450 (setq gnus-newsgroup-processable nil)
4452 (gnus-update-read-articles group gnus-newsgroup-unreads)
4454 (if (setq articles select-articles)
4455 (setq gnus-newsgroup-unselected
4456 (gnus-sorted-intersection
4457 gnus-newsgroup-unreads
4458 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4459 (setq articles (gnus-articles-to-read group read-all)))
4463 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
4465 ((eq articles 0) nil)
4467 ;; Init the dependencies hash table.
4468 (setq gnus-newsgroup-dependencies
4469 (gnus-make-hashtable (length articles)))
4470 (gnus-set-global-variables)
4471 ;; Retrieve the headers and read them in.
4472 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
4474 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4476 (setq gnus-newsgroup-cached cached))
4478 ;; Suppress duplicates?
4479 (when gnus-suppress-duplicates
4480 (gnus-dup-suppress-articles))
4482 ;; Set the initial limit.
4483 (setq gnus-newsgroup-limit (copy-sequence articles))
4484 ;; Remove canceled articles from the list of unread articles.
4485 (setq gnus-newsgroup-unreads
4486 (gnus-set-sorted-intersection
4487 gnus-newsgroup-unreads
4488 (setq fetched-articles
4489 (mapcar (lambda (headers) (mail-header-number headers))
4490 gnus-newsgroup-headers))))
4491 ;; Removed marked articles that do not exist.
4492 (gnus-update-missing-marks
4493 (gnus-sorted-complement fetched-articles articles))
4494 ;; We might want to build some more threads first.
4495 (when (and gnus-fetch-old-headers
4496 (eq gnus-headers-retrieved-by 'nov))
4497 (if (eq gnus-fetch-old-headers 'invisible)
4498 (gnus-build-all-threads)
4499 (gnus-build-old-threads)))
4500 ;; Let the Gnus agent mark articles as read.
4502 (gnus-agent-get-undownloaded-list))
4503 ;; Remove list identifiers from subject
4504 (when gnus-list-identifiers
4505 (gnus-summary-remove-list-identifiers))
4506 ;; Check whether auto-expire is to be done in this group.
4507 (setq gnus-newsgroup-auto-expire
4508 (gnus-group-auto-expirable-p group))
4509 ;; Set up the article buffer now, if necessary.
4510 (unless gnus-single-article-buffer
4511 (gnus-article-setup-buffer))
4512 ;; First and last article in this newsgroup.
4513 (when gnus-newsgroup-headers
4514 (setq gnus-newsgroup-begin
4515 (mail-header-number (car gnus-newsgroup-headers))
4518 (gnus-last-element gnus-newsgroup-headers))))
4519 ;; GROUP is successfully selected.
4520 (or gnus-newsgroup-headers t)))))
4522 (defun gnus-articles-to-read (group &optional read-all)
4523 "Find out what articles the user wants to read."
4525 ;; Select all articles if `read-all' is non-nil, or if there
4526 ;; are no unread articles.
4528 (and (zerop (length gnus-newsgroup-marked))
4529 (zerop (length gnus-newsgroup-unreads)))
4530 (eq (gnus-group-find-parameter group 'display)
4533 (gnus-uncompress-range (gnus-active group))
4534 (gnus-cache-articles-in-group group))
4535 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
4536 (copy-sequence gnus-newsgroup-unreads))
4538 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
4539 (scored (length scored-list))
4540 (number (length articles))
4541 (marked (+ (length gnus-newsgroup-marked)
4542 (length gnus-newsgroup-dormant)))
4550 ((and (or (<= scored marked) (= scored number))
4551 (numberp gnus-large-newsgroup)
4552 (> number gnus-large-newsgroup))
4556 "How many articles from %s (default %d): "
4557 (gnus-limit-string gnus-newsgroup-name 35)
4559 (if (string-match "^[ \t]*$" input) number input)))
4560 ((and (> scored marked) (< scored number)
4561 (> (- scored number) 20))
4564 (format "%s %s (%d scored, %d total): "
4565 "How many articles from"
4566 group scored number))))
4567 (if (string-match "^[ \t]*$" input)
4571 (message "Quit getting the articles to read")
4573 (setq select (if (stringp select) (string-to-number select) select))
4574 (if (or (null select) (zerop select))
4576 (if (and (not (zerop scored)) (<= (abs select) scored))
4578 (setq articles (sort scored-list '<))
4579 (setq number (length articles)))
4580 (setq articles (copy-sequence articles)))
4582 (when (< (abs select) number)
4584 ;; Select the N oldest articles.
4585 (setcdr (nthcdr (1- (abs select)) articles) nil)
4586 ;; Select the N most recent articles.
4587 (setq articles (nthcdr (- number select) articles))))
4588 (setq gnus-newsgroup-unselected
4589 (gnus-sorted-intersection
4590 gnus-newsgroup-unreads
4591 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4592 (when gnus-alter-articles-to-read-function
4593 (setq gnus-newsgroup-unreads
4595 (funcall gnus-alter-articles-to-read-function
4596 gnus-newsgroup-name gnus-newsgroup-unreads)
4600 (defun gnus-killed-articles (killed articles)
4603 (when (inline (gnus-member-of-range (car articles) killed))
4604 (push (car articles) out))
4605 (setq articles (cdr articles)))
4608 (defun gnus-uncompress-marks (marks)
4609 "Uncompress the mark ranges in MARKS."
4610 (let ((uncompressed '(score bookmark))
4613 (if (memq (caar marks) uncompressed)
4614 (push (car marks) out)
4615 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
4616 (setq marks (cdr marks)))
4619 (defun gnus-adjust-marked-articles (info)
4620 "Set all article lists and remove all marks that are no longer valid."
4621 (let* ((marked-lists (gnus-info-marks info))
4622 (active (gnus-active (gnus-info-group info)))
4625 (types gnus-article-mark-lists)
4626 (uncompressed '(score bookmark killed))
4627 marks var articles article mark)
4630 (setq marks (pop marked-lists))
4631 (set (setq var (intern (format "gnus-newsgroup-%s"
4632 (car (rassq (setq mark (car marks))
4634 (if (memq (car marks) uncompressed) (cdr marks)
4635 (gnus-uncompress-range (cdr marks))))
4637 (setq articles (symbol-value var))
4639 ;; All articles have to be subsets of the active articles.
4641 ;; Adjust "simple" lists.
4642 ((memq mark '(tick dormant expire reply save))
4644 (when (or (< (setq article (pop articles)) min) (> article max))
4645 (set var (delq article (symbol-value var))))))
4647 ((memq mark uncompressed)
4648 (when (not (listp (cdr (symbol-value var))))
4649 (set var (list (symbol-value var))))
4650 (when (not (listp (cdr articles)))
4651 (setq articles (list articles)))
4653 (when (or (not (consp (setq article (pop articles))))
4654 (< (car article) min)
4655 (> (car article) max))
4656 (set var (delq article (symbol-value var))))))))))
4658 (defun gnus-update-missing-marks (missing)
4659 "Go through the list of MISSING articles and remove them from the mark lists."
4661 (let ((types gnus-article-mark-lists)
4663 ;; Go through all types.
4665 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
4666 (when (symbol-value var)
4667 ;; This list has articles. So we delete all missing articles
4671 (set var (delq (pop m) (symbol-value var)))))))))
4673 (defun gnus-update-marks ()
4674 "Enter the various lists of marked articles into the newsgroup info list."
4675 (let ((types gnus-article-mark-lists)
4676 (info (gnus-get-info gnus-newsgroup-name))
4677 (uncompressed '(score bookmark killed))
4678 type list newmarked symbol delta-marks)
4680 ;; Add all marks lists to the list of marks lists.
4681 (while (setq type (pop types))
4682 (setq list (symbol-value
4684 (intern (format "gnus-newsgroup-%s"
4688 ;; Get rid of the entries of the articles that have the
4690 (when (and (eq (cdr type) 'score)
4694 (prev (cons nil list))
4697 (if (or (not (consp (car arts)))
4698 (= (cdar arts) gnus-summary-default-score))
4699 (setcdr prev (cdr arts))
4701 (setq arts (cdr arts)))
4702 (setq list (cdr all)))))
4704 (unless (memq (cdr type) uncompressed)
4705 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
4707 (when (gnus-check-backend-function
4708 'request-set-mark gnus-newsgroup-name)
4709 ;; propagate flags to server, with the following exceptions:
4710 ;; uncompressed:s are not proper flags (they are cons cells)
4711 ;; cache is a internal gnus flag
4712 ;; download are local to one gnus installation (well)
4713 ;; unsend are for nndraft groups only
4714 ;; xxx: generality of this? this suits nnimap anyway
4715 (unless (memq (cdr type) (append '(cache download unsend)
4717 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
4718 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
4719 (add (gnus-remove-from-range
4720 (gnus-copy-sequence list) old)))
4722 (push (list add 'add (list (cdr type))) delta-marks))
4724 (push (list del 'del (list (cdr type))) delta-marks)))))
4727 (push (cons (cdr type) list) newmarked)))
4730 (unless (gnus-check-group gnus-newsgroup-name)
4731 (error "Can't open server for %s" gnus-newsgroup-name))
4732 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
4734 ;; Enter these new marks into the info of the group.
4736 (setcar (nthcdr 3 info) newmarked)
4737 ;; Add the marks lists to the end of the info.
4739 (setcdr (nthcdr 2 info) (list newmarked))))
4741 ;; Cut off the end of the info if there's nothing else there.
4745 (when (nthcdr (decf i) info)
4746 (setcdr (nthcdr i info) nil)))))))
4748 (defun gnus-set-mode-line (where)
4749 "Set the mode line of the article or summary buffers.
4750 If WHERE is `summary', the summary mode line format will be used."
4751 ;; Is this mode line one we keep updated?
4752 (when (and (memq where gnus-updated-mode-lines)
4754 (intern (format "gnus-%s-mode-line-format-spec" where))))
4757 ;; We evaluate this in the summary buffer since these
4758 ;; variables are buffer-local to that buffer.
4759 (set-buffer gnus-summary-buffer)
4760 ;; We bind all these variables that are used in the `eval' form
4762 (let* ((mformat (symbol-value
4764 (format "gnus-%s-mode-line-format-spec" where))))
4765 (gnus-tmp-group-name (gnus-group-decoded-name
4766 gnus-newsgroup-name))
4767 (gnus-tmp-article-number (or gnus-current-article 0))
4768 (gnus-tmp-unread gnus-newsgroup-unreads)
4769 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
4770 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
4771 (gnus-tmp-unread-and-unselected
4772 (cond ((and (zerop gnus-tmp-unread-and-unticked)
4773 (zerop gnus-tmp-unselected))
4775 ((zerop gnus-tmp-unselected)
4776 (format "{%d more}" gnus-tmp-unread-and-unticked))
4777 (t (format "{%d(+%d) more}"
4778 gnus-tmp-unread-and-unticked
4779 gnus-tmp-unselected))))
4781 (if (and gnus-current-headers
4782 (vectorp gnus-current-headers))
4783 (gnus-mode-string-quote
4784 (mail-header-subject gnus-current-headers))
4786 bufname-length max-len
4787 gnus-tmp-header);; passed as argument to any user-format-funcs
4788 (setq mode-string (eval mformat))
4789 (setq bufname-length (if (string-match "%b" mode-string)
4792 (if (eq where 'summary)
4794 (get-buffer gnus-article-buffer))))
4797 (setq max-len (max 4 (if gnus-mode-non-string-length
4799 gnus-mode-non-string-length
4801 (length mode-string))))
4802 ;; We might have to chop a bit of the string off...
4803 (when (> (length mode-string) max-len)
4805 (concat (truncate-string-to-width mode-string (- max-len 3))
4807 ;; Pad the mode string a bit.
4808 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
4809 ;; Update the mode line.
4810 (setq mode-line-buffer-identification
4811 (gnus-mode-line-buffer-identification (list mode-string)))
4812 (set-buffer-modified-p t))))
4814 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
4815 "Go through the HEADERS list and add all Xrefs to a hash table.
4816 The resulting hash table is returned, or nil if no Xrefs were found."
4817 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
4818 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
4819 (xref-hashtb (gnus-make-hashtable))
4820 start group entry number xrefs header)
4822 (setq header (pop headers))
4823 (when (and (setq xrefs (mail-header-xref header))
4824 (not (memq (setq number (mail-header-number header))
4827 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
4828 (setq start (match-end 0))
4829 (setq group (if prefix
4830 (concat prefix (substring xrefs (match-beginning 1)
4832 (substring xrefs (match-beginning 1) (match-end 1))))
4834 (string-to-int (substring xrefs (match-beginning 2)
4836 (if (setq entry (gnus-gethash group xref-hashtb))
4837 (setcdr entry (cons number (cdr entry)))
4838 (gnus-sethash group (cons number nil) xref-hashtb)))))
4839 (and start xref-hashtb)))
4841 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
4842 "Look through all the headers and mark the Xrefs as read."
4843 (let ((virtual (gnus-virtual-group-p from-newsgroup))
4844 name entry info xref-hashtb idlist method nth4)
4846 (set-buffer gnus-group-buffer)
4847 (when (setq xref-hashtb
4848 (gnus-create-xref-hashtb from-newsgroup headers unreads))
4851 (unless (string= from-newsgroup (setq name (symbol-name group)))
4852 (setq idlist (symbol-value group))
4853 ;; Dead groups are not updated.
4855 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
4857 (when (stringp (setq nth4 (gnus-info-method info)))
4858 (setq nth4 (gnus-server-to-method nth4))))
4859 ;; Only do the xrefs if the group has the same
4860 ;; select method as the group we have just read.
4861 (or (gnus-methods-equal-p
4862 nth4 (gnus-find-method-for-group from-newsgroup))
4864 (equal nth4 (setq method (gnus-find-method-for-group
4866 (and (equal (car nth4) (car method))
4867 (equal (nth 1 nth4) (nth 1 method))))
4868 gnus-use-cross-reference
4869 (or (not (eq gnus-use-cross-reference t))
4871 ;; Only do cross-references on subscribed
4872 ;; groups, if that is what is wanted.
4873 (<= (gnus-info-level info) gnus-level-subscribed))
4874 (gnus-group-make-articles-read name idlist))))
4877 (defun gnus-compute-read-articles (group articles)
4878 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4879 (info (nth 2 entry))
4880 (active (gnus-active group))
4883 ;; First peel off all invalid article numbers.
4885 (let ((ids articles)
4887 (while (setq id (pop ids))
4888 (when (and first (> id (cdr active)))
4889 ;; We'll end up in this situation in one particular
4890 ;; obscure situation. If you re-scan a group and get
4891 ;; a new article that is cross-posted to a different
4892 ;; group that has not been re-scanned, you might get
4893 ;; crossposted article that has a higher number than
4894 ;; Gnus believes possible. So we re-activate this
4895 ;; group as well. This might mean doing the
4896 ;; crossposting thingy will *increase* the number
4897 ;; of articles in some groups. Tsk, tsk.
4898 (setq active (or (gnus-activate-group group) active)))
4899 (when (or (> id (cdr active))
4900 (< id (car active)))
4901 (setq articles (delq id articles))))))
4902 ;; If the read list is nil, we init it.
4904 (null (gnus-info-read info))
4906 (setq ninfo (cons 1 (1- (car active))))
4907 (setq ninfo (gnus-info-read info)))
4908 ;; Then we add the read articles to the range.
4910 ninfo (setq articles (sort articles '<))))))
4912 (defun gnus-group-make-articles-read (group articles)
4913 "Update the info of GROUP to say that ARTICLES are read."
4915 (entry (gnus-gethash group gnus-newsrc-hashtb))
4916 (info (nth 2 entry))
4917 (active (gnus-active group))
4920 (setq range (gnus-compute-read-articles group articles))
4922 (set-buffer gnus-group-buffer)
4925 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
4926 (gnus-info-set-read ',info ',(gnus-info-read info))
4927 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
4928 (gnus-group-update-group ,group t))))
4929 ;; Add the read articles to the range.
4930 (gnus-info-set-read info range)
4931 ;; Then we have to re-compute how many unread
4932 ;; articles there are in this group.
4936 (setq num (- (1+ (cdr active)) (car active))))
4937 ((not (listp (cdr range)))
4938 (setq num (- (cdr active) (- (1+ (cdr range))
4942 (if (numberp (car range))
4944 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
4945 (setq range (cdr range)))
4946 (setq num (- (cdr active) num))))
4947 ;; Update the number of unread articles.
4949 ;; Update the group buffer.
4950 (gnus-group-update-group group t)))))
4952 (defvar gnus-newsgroup-none-id 0)
4954 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
4955 (let ((cur nntp-server-buffer)
4958 (save-excursion (set-buffer gnus-summary-buffer)
4959 gnus-newsgroup-dependencies)))
4961 (mail-parse-charset gnus-newsgroup-charset)
4962 (mail-parse-ignored-charsets
4963 (save-excursion (condition-case nil
4964 (set-buffer gnus-summary-buffer)
4966 gnus-newsgroup-ignored-charsets)))
4968 (set-buffer nntp-server-buffer)
4969 ;; Translate all TAB characters into SPACE characters.
4970 (subst-char-in-region (point-min) (point-max) ?\t ? t)
4971 (subst-char-in-region (point-min) (point-max) ?\r ? t)
4972 (gnus-run-hooks 'gnus-parse-headers-hook)
4973 (let ((case-fold-search t)
4974 in-reply-to header p lines chars)
4975 (goto-char (point-min))
4976 ;; Search to the beginning of the next header. Error messages
4977 ;; do not begin with 2 or 3.
4978 (while (re-search-forward "^[23][0-9]+ " nil t)
4981 ;; This implementation of this function, with nine
4982 ;; search-forwards instead of the one re-search-forward and
4983 ;; a case (which basically was the old function) is actually
4984 ;; about twice as fast, even though it looks messier. You
4985 ;; can't have everything, I guess. Speed and elegance
4986 ;; doesn't always go hand in hand.
4995 (narrow-to-region (point)
4996 (or (and (search-forward "\n.\n" nil t)
5002 (if (search-forward "\nsubject:" nil t)
5003 (funcall gnus-decode-encoded-word-function
5004 (nnheader-header-value))
5009 (if (search-forward "\nfrom:" nil t)
5010 (funcall gnus-decode-encoded-word-function
5011 (nnheader-header-value))
5016 (if (search-forward "\ndate:" nil t)
5017 (nnheader-header-value) ""))
5021 (setq id (if (re-search-forward
5022 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
5023 ;; We do it this way to make sure the Message-ID
5024 ;; is (somewhat) syntactically valid.
5025 (buffer-substring (match-beginning 1)
5027 ;; If there was no message-id, we just fake one
5028 ;; to make subsequent routines simpler.
5029 (nnheader-generate-fake-message-id))))
5033 (if (search-forward "\nreferences:" nil t)
5037 (nnheader-header-value)
5042 (search-backward ">" end t)
5045 (search-backward "<" end t)
5047 ;; Get the references from the in-reply-to header if there
5048 ;; were no references and the in-reply-to header looks
5050 (if (and (search-forward "\nin-reply-to:" nil t)
5051 (setq in-reply-to (nnheader-header-value))
5052 (string-match "<[^>]+>" in-reply-to))
5054 (setq ref (substring in-reply-to (match-beginning 0)
5056 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
5057 (setq ref2 (substring in-reply-to (match-beginning 0)
5059 (when (> (length ref2) (length ref))
5066 (if (search-forward "\nchars: " nil t)
5067 (if (numberp (setq chars (ignore-errors (read cur))))
5073 (if (search-forward "\nlines: " nil t)
5074 (if (numberp (setq lines (ignore-errors (read cur))))
5080 (and (search-forward "\nxref:" nil t)
5081 (nnheader-header-value)))
5083 (when gnus-extra-headers
5084 (let ((extra gnus-extra-headers)
5088 (when (search-forward
5089 (concat "\n" (symbol-name (car extra)) ":") nil t)
5090 (push (cons (car extra) (nnheader-header-value))
5094 (when (equal id ref)
5097 (when gnus-alter-header-function
5098 (funcall gnus-alter-header-function header)
5099 (setq id (mail-header-id header)
5100 ref (gnus-parent-id (mail-header-references header))))
5103 (gnus-dependencies-add-header
5104 header dependencies force-new))
5105 (push header headers))
5106 (goto-char (point-max))
5108 (nreverse headers)))))
5110 ;; Goes through the xover lines and returns a list of vectors
5111 (defun gnus-get-newsgroup-headers-xover (sequence &optional
5112 force-new dependencies
5113 group also-fetch-heads)
5114 "Parse the news overview data in the server buffer.
5115 Return a list of headers that match SEQUENCE (see
5116 `nntp-retrieve-headers')."
5117 ;; Get the Xref when the users reads the articles since most/some
5118 ;; NNTP servers do not include Xrefs when using XOVER.
5119 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
5120 (let ((mail-parse-charset gnus-newsgroup-charset)
5121 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
5122 (cur nntp-server-buffer)
5123 (dependencies (or dependencies gnus-newsgroup-dependencies))
5125 ((eq gnus-read-all-available-headers t)
5127 ((stringp gnus-read-all-available-headers)
5128 (string-match gnus-read-all-available-headers group))
5131 number headers header)
5133 (set-buffer nntp-server-buffer)
5134 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5135 ;; Allow the user to mangle the headers before parsing them.
5136 (gnus-run-hooks 'gnus-parse-headers-hook)
5137 (goto-char (point-min))
5140 (while (and (or sequence allp)
5142 (setq number (read cur))
5144 (while (and sequence
5145 (< (car sequence) number))
5146 (setq sequence (cdr sequence))))
5149 (eq number (car sequence))))
5151 (setq sequence (cdr sequence))
5152 (setq header (inline
5153 (gnus-nov-parse-line
5154 number dependencies force-new)))))
5155 (push header headers))
5158 (gnus-error 4 "Strange nov line (%d)"
5159 (count-lines (point-min) (point)))))
5161 ;; A common bug in inn is that if you have posted an article and
5162 ;; then retrieves the active file, it will answer correctly --
5163 ;; the new article is included. However, a NOV entry for the
5164 ;; article may not have been generated yet, so this may fail.
5165 ;; We work around this problem by retrieving the last few
5166 ;; headers using HEAD.
5167 (if (or (not also-fetch-heads)
5169 ;; We (probably) got all the headers.
5171 (let ((gnus-nov-is-evil t))
5174 (when (eq (gnus-retrieve-headers sequence group) 'headers)
5175 (gnus-get-newsgroup-headers))))))))
5177 (defun gnus-article-get-xrefs ()
5178 "Fill in the Xref value in `gnus-current-headers', if necessary.
5179 This is meant to be called in `gnus-article-internal-prepare-hook'."
5180 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
5181 gnus-current-headers)))
5182 (or (not gnus-use-cross-reference)
5184 (and (mail-header-xref headers)
5185 (not (string= (mail-header-xref headers) "")))
5186 (let ((case-fold-search t)
5189 (nnheader-narrow-to-headers)
5190 (goto-char (point-min))
5191 (when (or (and (not (eobp))
5192 (eq (downcase (char-after)) ?x)
5193 (looking-at "Xref:"))
5194 (search-forward "\nXref:" nil t))
5195 (goto-char (1+ (match-end 0)))
5196 (setq xref (buffer-substring (point)
5197 (progn (end-of-line) (point))))
5198 (mail-header-set-xref headers xref)))))))
5200 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
5201 "Find article ID and insert the summary line for that article.
5202 OLD-HEADER can either be a header or a line number to insert
5203 the subject line on."
5204 (let* ((line (and (numberp old-header) old-header))
5205 (old-header (and (vectorp old-header) old-header))
5206 (header (cond ((and old-header use-old-header)
5209 (gnus-number-to-header id))
5210 (gnus-number-to-header id))
5212 (gnus-read-header id))))
5213 (number (and (numberp id) id))
5216 ;; Rebuild the thread that this article is part of and go to the
5217 ;; article we have fetched.
5218 (when (and (not gnus-show-threads)
5221 (setq d (gnus-data-find (mail-header-number old-header))))
5222 (goto-char (gnus-data-pos d))
5225 (- (gnus-point-at-bol)
5227 (1+ (gnus-point-at-eol))
5228 (gnus-delete-line))))))
5230 (mail-header-set-number header (mail-header-number old-header)))
5231 (setq gnus-newsgroup-sparse
5232 (delq (setq number (mail-header-number header))
5233 gnus-newsgroup-sparse))
5234 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
5235 (push number gnus-newsgroup-limit)
5236 (gnus-rebuild-thread (mail-header-id header) line)
5237 (gnus-summary-goto-subject number nil t))
5238 (when (and (numberp number)
5240 ;; We have to update the boundaries even if we can't fetch the
5241 ;; article if ID is a number -- so that the next `P' or `N'
5242 ;; command will fetch the previous (or next) article even
5243 ;; if the one we tried to fetch this time has been canceled.
5244 (when (> number gnus-newsgroup-end)
5245 (setq gnus-newsgroup-end number))
5246 (when (< number gnus-newsgroup-begin)
5247 (setq gnus-newsgroup-begin number))
5248 (setq gnus-newsgroup-unselected
5249 (delq number gnus-newsgroup-unselected)))
5250 ;; Report back a success?
5251 (and header (mail-header-number header))))
5253 ;;; Process/prefix in the summary buffer
5255 (defun gnus-summary-work-articles (n)
5256 "Return a list of articles to be worked upon.
5257 The prefix argument, the list of process marked articles, and the
5258 current article will be taken into consideration."
5260 (set-buffer gnus-summary-buffer)
5263 ;; A numerical prefix has been given.
5264 (setq n (prefix-numeric-value n))
5265 (let ((backward (< n 0))
5266 (n (abs (prefix-numeric-value n)))
5271 (push (setq article (gnus-summary-article-number))
5274 (gnus-summary-find-prev nil article)
5275 (gnus-summary-find-next nil article)))
5277 (nreverse articles)))
5278 ((and (gnus-region-active-p) (mark))
5279 (message "region active")
5280 ;; Work on the region between point and mark.
5281 (let ((max (max (point) (mark)))
5284 (goto-char (min (min (point) (mark))))
5287 (push (setq article (gnus-summary-article-number)) articles)
5288 (gnus-summary-find-next nil article)
5290 (nreverse articles))))
5291 (gnus-newsgroup-processable
5292 ;; There are process-marked articles present.
5293 ;; Save current state.
5294 (gnus-summary-save-process-mark)
5296 (reverse gnus-newsgroup-processable))
5298 ;; Just return the current article.
5299 (list (gnus-summary-article-number))))))
5301 (defmacro gnus-summary-iterate (arg &rest forms)
5302 "Iterate over the process/prefixed articles and do FORMS.
5303 ARG is the interactive prefix given to the command. FORMS will be
5304 executed with point over the summary line of the articles."
5305 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
5306 `(let ((,articles (gnus-summary-work-articles ,arg)))
5308 (gnus-summary-goto-subject (car ,articles))
5312 (put 'gnus-summary-iterate 'lisp-indent-function 1)
5313 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
5315 (defun gnus-summary-save-process-mark ()
5316 "Push the current set of process marked articles on the stack."
5318 (push (copy-sequence gnus-newsgroup-processable)
5319 gnus-newsgroup-process-stack))
5321 (defun gnus-summary-kill-process-mark ()
5322 "Push the current set of process marked articles on the stack and unmark."
5324 (gnus-summary-save-process-mark)
5325 (gnus-summary-unmark-all-processable))
5327 (defun gnus-summary-yank-process-mark ()
5328 "Pop the last process mark state off the stack and restore it."
5330 (unless gnus-newsgroup-process-stack
5331 (error "Empty mark stack"))
5332 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
5334 (defun gnus-summary-process-mark-set (set)
5335 "Make SET into the current process marked articles."
5336 (gnus-summary-unmark-all-processable)
5338 (gnus-summary-set-process-mark (pop set))))
5340 ;;; Searching and stuff
5342 (defun gnus-summary-search-group (&optional backward use-level)
5343 "Search for next unread newsgroup.
5344 If optional argument BACKWARD is non-nil, search backward instead."
5346 (set-buffer gnus-group-buffer)
5347 (when (gnus-group-search-forward
5348 backward nil (if use-level (gnus-group-group-level) nil))
5349 (gnus-group-group-name))))
5351 (defun gnus-summary-best-group (&optional exclude-group)
5352 "Find the name of the best unread group.
5353 If EXCLUDE-GROUP, do not go to this group."
5355 (set-buffer gnus-group-buffer)
5357 (gnus-group-best-unread-group exclude-group))))
5359 (defun gnus-summary-find-next (&optional unread article backward undownloaded)
5360 (if backward (gnus-summary-find-prev)
5361 (let* ((dummy (gnus-summary-article-intangible-p))
5362 (article (or article (gnus-summary-article-number)))
5363 (arts (gnus-data-find-list article))
5365 (when (and (not dummy)
5366 (or (not gnus-summary-check-current)
5368 (not (gnus-data-unread-p (car arts)))))
5369 (setq arts (cdr arts)))
5374 (when (or (and undownloaded
5375 (eq gnus-undownloaded-mark
5376 (gnus-data-mark (car arts))))
5377 (gnus-data-unread-p (car arts)))
5378 (setq result (car arts)
5380 (setq arts (cdr arts)))
5383 (goto-char (gnus-data-pos result))
5384 (gnus-data-number result)))))
5386 (defun gnus-summary-find-prev (&optional unread article)
5387 (let* ((eobp (eobp))
5388 (article (or article (gnus-summary-article-number)))
5389 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
5391 (when (and (not eobp)
5392 (or (not gnus-summary-check-current)
5394 (not (gnus-data-unread-p (car arts)))))
5395 (setq arts (cdr arts)))
5400 (when (gnus-data-unread-p (car arts))
5401 (setq result (car arts)
5403 (setq arts (cdr arts)))
5406 (goto-char (gnus-data-pos result))
5407 (gnus-data-number result))))
5409 (defun gnus-summary-find-subject (subject &optional unread backward article)
5410 (let* ((simp-subject (gnus-simplify-subject-fully subject))
5411 (article (or article (gnus-summary-article-number)))
5412 (articles (gnus-data-list backward))
5413 (arts (gnus-data-find-list article articles))
5415 (when (or (not gnus-summary-check-current)
5417 (not (gnus-data-unread-p (car arts))))
5418 (setq arts (cdr arts)))
5420 (and (or (not unread)
5421 (gnus-data-unread-p (car arts)))
5422 (vectorp (gnus-data-header (car arts)))
5424 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
5425 (setq result (car arts)
5427 (setq arts (cdr arts)))
5429 (goto-char (gnus-data-pos result))
5430 (gnus-data-number result))))
5432 (defun gnus-summary-search-forward (&optional unread subject backward)
5433 "Search forward for an article.
5434 If UNREAD, look for unread articles. If SUBJECT, look for
5435 articles with that subject. If BACKWARD, search backward instead."
5436 (cond (subject (gnus-summary-find-subject subject unread backward))
5437 (backward (gnus-summary-find-prev unread))
5438 (t (gnus-summary-find-next unread))))
5440 (defun gnus-recenter (&optional n)
5441 "Center point in window and redisplay frame.
5442 Also do horizontal recentering."
5444 (when (and gnus-auto-center-summary
5445 (not (eq gnus-auto-center-summary 'vertical)))
5446 (gnus-horizontal-recenter))
5449 (defun gnus-summary-recenter ()
5450 "Center point in the summary window.
5451 If `gnus-auto-center-summary' is nil, or the article buffer isn't
5452 displayed, no centering will be performed."
5453 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
5454 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
5456 (let* ((top (cond ((< (window-height) 4) 0)
5457 ((< (window-height) 7) 1)
5458 (t (if (numberp gnus-auto-center-summary)
5459 gnus-auto-center-summary
5461 (height (1- (window-height)))
5462 (bottom (save-excursion (goto-char (point-max))
5463 (forward-line (- height))
5465 (window (get-buffer-window (current-buffer))))
5466 ;; The user has to want it.
5467 (when gnus-auto-center-summary
5468 (when (get-buffer-window gnus-article-buffer)
5469 ;; Only do recentering when the article buffer is displayed,
5470 ;; Set the window start to either `bottom', which is the biggest
5471 ;; possible valid number, or the second line from the top,
5472 ;; whichever is the least.
5473 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
5474 (if (> bottom top-pos)
5475 ;; Keep the second line from the top visible
5476 (set-window-start window top-pos t)
5477 ;; Try to keep the bottom line visible; if it's partially
5478 ;; obscured, either scroll one more line to make it fully
5479 ;; visible, or revert to using TOP-POS.
5481 (goto-char (point-max))
5483 (let ((last-line-start (point)))
5485 (set-window-start window (point) t)
5486 (when (not (pos-visible-in-window-p last-line-start window))
5488 (set-window-start window (min (point) top-pos) t)))))))
5489 ;; Do horizontal recentering while we're at it.
5490 (when (and (get-buffer-window (current-buffer) t)
5491 (not (eq gnus-auto-center-summary 'vertical)))
5492 (let ((selected (selected-window)))
5493 (select-window (get-buffer-window (current-buffer) t))
5494 (gnus-summary-position-point)
5495 (gnus-horizontal-recenter)
5496 (select-window selected))))))
5498 (defun gnus-summary-jump-to-group (newsgroup)
5499 "Move point to NEWSGROUP in group mode buffer."
5500 ;; Keep update point of group mode buffer if visible.
5501 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
5502 (save-window-excursion
5503 ;; Take care of tree window mode.
5504 (when (get-buffer-window gnus-group-buffer)
5505 (pop-to-buffer gnus-group-buffer))
5506 (gnus-group-jump-to-group newsgroup))
5508 ;; Take care of tree window mode.
5509 (if (get-buffer-window gnus-group-buffer)
5510 (pop-to-buffer gnus-group-buffer)
5511 (set-buffer gnus-group-buffer))
5512 (gnus-group-jump-to-group newsgroup))))
5514 ;; This function returns a list of article numbers based on the
5515 ;; difference between the ranges of read articles in this group and
5516 ;; the range of active articles.
5517 (defun gnus-list-of-unread-articles (group)
5518 (let* ((read (gnus-info-read (gnus-get-info group)))
5519 (active (or (gnus-active group) (gnus-activate-group group)))
5522 ;; If none are read, then all are unread.
5524 (setq first (car active))
5525 ;; If the range of read articles is a single range, then the
5526 ;; first unread article is the article after the last read
5527 ;; article. Sounds logical, doesn't it?
5528 (if (and (not (listp (cdr read)))
5529 (or (< (car read) (car active))
5530 (progn (setq read (list read))
5532 (setq first (max (car active) (1+ (cdr read))))
5533 ;; `read' is a list of ranges.
5534 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
5537 (setq first (car active)))
5540 (while (< first nlast)
5542 (setq first (1+ first))))
5543 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
5544 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
5545 (setq read (cdr read)))))
5546 ;; And add the last unread articles.
5547 (while (<= first last)
5549 (setq first (1+ first)))
5550 ;; Return the list of unread articles.
5551 (delq 0 (nreverse unread))))
5553 (defun gnus-list-of-read-articles (group)
5554 "Return a list of unread, unticked and non-dormant articles."
5555 (let* ((info (gnus-get-info group))
5556 (marked (gnus-info-marks info))
5557 (active (gnus-active group)))
5559 (gnus-set-difference
5560 (gnus-sorted-complement
5561 (gnus-uncompress-range active)
5562 (gnus-list-of-unread-articles group))
5564 (gnus-uncompress-range (cdr (assq 'dormant marked)))
5565 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
5567 ;; Various summary commands
5569 (defun gnus-summary-select-article-buffer ()
5570 "Reconfigure windows to show article buffer."
5572 (if (not (gnus-buffer-live-p gnus-article-buffer))
5573 (error "There is no article buffer for this summary buffer")
5574 (gnus-configure-windows 'article)
5575 (select-window (get-buffer-window gnus-article-buffer))))
5577 (defun gnus-summary-universal-argument (arg)
5578 "Perform any operation on all articles that are process/prefixed."
5580 (let ((articles (gnus-summary-work-articles arg))
5587 (substitute-command-keys
5588 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
5590 (gnus-error 1 "Undefined key")
5593 (gnus-summary-goto-subject (setq article (pop articles)))
5594 (let (gnus-newsgroup-processable)
5595 (command-execute func))
5596 (gnus-summary-remove-process-mark article)))))
5597 (gnus-summary-position-point))
5599 (defun gnus-summary-toggle-truncation (&optional arg)
5600 "Toggle truncation of summary lines.
5601 With arg, turn line truncation on iff arg is positive."
5603 (setq truncate-lines
5604 (if (null arg) (not truncate-lines)
5605 (> (prefix-numeric-value arg) 0)))
5608 (defun gnus-summary-reselect-current-group (&optional all rescan)
5609 "Exit and then reselect the current newsgroup.
5610 The prefix argument ALL means to select all articles."
5612 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
5613 (error "Ephemeral groups can't be reselected"))
5614 (let ((current-subject (gnus-summary-article-number))
5615 (group gnus-newsgroup-name))
5616 (setq gnus-newsgroup-begin nil)
5618 ;; We have to adjust the point of group mode buffer because
5619 ;; point was moved to the next unread newsgroup by exiting.
5620 (gnus-summary-jump-to-group group)
5623 (gnus-group-get-new-news-this-group 1)))
5624 (gnus-group-read-group all t)
5625 (gnus-summary-goto-subject current-subject nil t)))
5627 (defun gnus-summary-rescan-group (&optional all)
5628 "Exit the newsgroup, ask for new articles, and select the newsgroup."
5630 (gnus-summary-reselect-current-group all t))
5632 (defun gnus-summary-update-info (&optional non-destructive)
5634 (let ((group gnus-newsgroup-name))
5636 (when gnus-newsgroup-kill-headers
5637 (setq gnus-newsgroup-killed
5638 (gnus-compress-sequence
5640 (gnus-set-sorted-intersection
5641 (gnus-uncompress-range gnus-newsgroup-killed)
5642 (setq gnus-newsgroup-unselected
5643 (sort gnus-newsgroup-unselected '<)))
5644 (setq gnus-newsgroup-unreads
5645 (sort gnus-newsgroup-unreads '<)))
5647 (unless (listp (cdr gnus-newsgroup-killed))
5648 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
5649 (let ((headers gnus-newsgroup-headers))
5650 ;; Set the new ranges of read articles.
5652 (set-buffer gnus-group-buffer)
5653 (gnus-undo-force-boundary))
5654 (gnus-update-read-articles
5655 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
5656 ;; Set the current article marks.
5657 (let ((gnus-newsgroup-scored
5658 (if (and (not gnus-save-score)
5659 (not non-destructive))
5661 gnus-newsgroup-scored)))
5663 (gnus-update-marks)))
5664 ;; Do the cross-ref thing.
5665 (when gnus-use-cross-reference
5666 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
5667 ;; Do not switch windows but change the buffer to work.
5668 (set-buffer gnus-group-buffer)
5669 (unless (gnus-ephemeral-group-p group)
5670 (gnus-group-update-group group)))))))
5672 (defun gnus-summary-save-newsrc (&optional force)
5673 "Save the current number of read/marked articles in the dribble buffer.
5674 The dribble buffer will then be saved.
5675 If FORCE (the prefix), also save the .newsrc file(s)."
5677 (gnus-summary-update-info t)
5679 (gnus-save-newsrc-file)
5680 (gnus-dribble-save)))
5682 (defun gnus-summary-exit (&optional temporary)
5683 "Exit reading current newsgroup, and then return to group selection mode.
5684 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
5686 (gnus-set-global-variables)
5687 (when (gnus-buffer-live-p gnus-article-buffer)
5689 (set-buffer gnus-article-buffer)
5690 (mm-destroy-parts gnus-article-mime-handles)
5691 ;; Set it to nil for safety reason.
5692 (setq gnus-article-mime-handle-alist nil)
5693 (setq gnus-article-mime-handles nil)))
5694 (gnus-kill-save-kill-buffer)
5695 (gnus-async-halt-prefetch)
5696 (let* ((group gnus-newsgroup-name)
5697 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
5700 (buf (current-buffer)))
5702 ;; Do adaptive scoring, and possibly save score files.
5703 (when gnus-newsgroup-adaptive
5704 (gnus-score-adaptive))
5705 (when gnus-use-scoring
5707 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
5708 ;; If we have several article buffers, we kill them at exit.
5709 (unless gnus-single-article-buffer
5710 (gnus-kill-buffer gnus-original-article-buffer)
5711 (setq gnus-article-current nil))
5712 (when gnus-use-cache
5713 (gnus-cache-possibly-remove-articles)
5714 (gnus-cache-save-buffers))
5715 (gnus-async-prefetch-remove-group group)
5716 (when gnus-suppress-duplicates
5717 (gnus-dup-enter-articles))
5718 (when gnus-use-trees
5719 (gnus-tree-close group))
5720 (when gnus-use-cache
5721 (gnus-cache-write-active))
5722 ;; Remove entries for this group.
5723 (nnmail-purge-split-history (gnus-group-real-name group))
5724 ;; Make all changes in this group permanent.
5726 (gnus-run-hooks 'gnus-exit-group-hook)
5727 (gnus-summary-update-info))
5728 (gnus-close-group group)
5729 ;; Make sure where we were, and go to next newsgroup.
5730 (set-buffer gnus-group-buffer)
5732 (gnus-group-jump-to-group group))
5733 (gnus-run-hooks 'gnus-summary-exit-hook)
5734 (unless (or quit-config
5735 ;; If this group has disappeared from the summary
5736 ;; buffer, don't skip forwards.
5737 (not (string= group (gnus-group-group-name))))
5738 (gnus-group-next-unread-group 1))
5739 (setq group-point (point))
5742 ;; If we have several article buffers, we kill them at exit.
5743 (unless gnus-single-article-buffer
5744 (gnus-kill-buffer gnus-article-buffer)
5745 (gnus-kill-buffer gnus-original-article-buffer)
5746 (setq gnus-article-current nil))
5748 (if (not gnus-kill-summary-on-exit)
5750 (gnus-deaden-summary)
5752 ;; We set all buffer-local variables to nil. It is unclear why
5753 ;; this is needed, but if we don't, buffer-local variables are
5754 ;; not garbage-collected, it seems. This would the lead to en
5755 ;; ever-growing Emacs.
5756 (gnus-summary-clear-local-variables)
5757 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
5758 (gnus-summary-clear-local-variables))
5759 (when (get-buffer gnus-article-buffer)
5760 (bury-buffer gnus-article-buffer))
5761 ;; We clear the global counterparts of the buffer-local
5762 ;; variables as well, just to be on the safe side.
5763 (set-buffer gnus-group-buffer)
5764 (gnus-summary-clear-local-variables)
5765 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
5766 (gnus-summary-clear-local-variables)))
5767 (setq gnus-current-select-method gnus-select-method)
5768 (pop-to-buffer gnus-group-buffer)
5769 (if (not quit-config)
5771 (goto-char group-point)
5772 (gnus-configure-windows 'group 'force))
5773 (gnus-handle-ephemeral-exit quit-config))
5774 ;; Return to group mode buffer.
5775 (when (eq mode 'gnus-summary-mode)
5776 (gnus-kill-buffer buf))
5777 ;; Clear the current group name.
5779 (setq gnus-newsgroup-name nil)))))
5781 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
5782 (defun gnus-summary-exit-no-update (&optional no-questions)
5783 "Quit reading current newsgroup without updating read article info."
5785 (let* ((group gnus-newsgroup-name)
5786 (quit-config (gnus-group-quit-config group)))
5787 (when (or no-questions
5789 (gnus-y-or-n-p "Discard changes to this group and exit? "))
5790 (gnus-async-halt-prefetch)
5792 (delq 'gnus-summary-expire-articles
5793 (copy-sequence gnus-summary-prepare-exit-hook)))
5794 (when (gnus-buffer-live-p gnus-article-buffer)
5796 (set-buffer gnus-article-buffer)
5797 (mm-destroy-parts gnus-article-mime-handles)
5798 ;; Set it to nil for safety reason.
5799 (setq gnus-article-mime-handle-alist nil)
5800 (setq gnus-article-mime-handles nil)))
5801 ;; If we have several article buffers, we kill them at exit.
5802 (unless gnus-single-article-buffer
5803 (gnus-kill-buffer gnus-article-buffer)
5804 (gnus-kill-buffer gnus-original-article-buffer)
5805 (setq gnus-article-current nil))
5806 (if (not gnus-kill-summary-on-exit)
5807 (gnus-deaden-summary)
5808 (gnus-close-group group)
5809 (gnus-summary-clear-local-variables)
5810 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
5811 (gnus-summary-clear-local-variables))
5812 (set-buffer gnus-group-buffer)
5813 (gnus-summary-clear-local-variables)
5814 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
5815 (gnus-summary-clear-local-variables))
5816 (when (get-buffer gnus-summary-buffer)
5817 (kill-buffer gnus-summary-buffer)))
5818 (unless gnus-single-article-buffer
5819 (setq gnus-article-current nil))
5820 (when gnus-use-trees
5821 (gnus-tree-close group))
5822 (gnus-async-prefetch-remove-group group)
5823 (when (get-buffer gnus-article-buffer)
5824 (bury-buffer gnus-article-buffer))
5825 ;; Return to the group buffer.
5826 (gnus-configure-windows 'group 'force)
5827 ;; Clear the current group name.
5828 (setq gnus-newsgroup-name nil)
5829 (when (equal (gnus-group-group-name) group)
5830 (gnus-group-next-unread-group 1))
5832 (gnus-handle-ephemeral-exit quit-config)))))
5834 (defun gnus-handle-ephemeral-exit (quit-config)
5835 "Handle movement when leaving an ephemeral group.
5836 The state which existed when entering the ephemeral is reset."
5837 (if (not (buffer-name (car quit-config)))
5838 (gnus-configure-windows 'group 'force)
5839 (set-buffer (car quit-config))
5840 (cond ((eq major-mode 'gnus-summary-mode)
5841 (gnus-set-global-variables))
5842 ((eq major-mode 'gnus-article-mode)
5844 ;; The `gnus-summary-buffer' variable may point
5845 ;; to the old summary buffer when using a single
5847 (unless (gnus-buffer-live-p gnus-summary-buffer)
5848 (set-buffer gnus-group-buffer))
5849 (set-buffer gnus-summary-buffer)
5850 (gnus-set-global-variables))))
5851 (if (or (eq (cdr quit-config) 'article)
5852 (eq (cdr quit-config) 'pick))
5854 ;; The current article may be from the ephemeral group
5855 ;; thus it is best that we reload this article
5856 (gnus-summary-show-article)
5857 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
5858 (gnus-configure-windows 'pick 'force)
5859 (gnus-configure-windows (cdr quit-config) 'force)))
5860 (gnus-configure-windows (cdr quit-config) 'force))
5861 (when (eq major-mode 'gnus-summary-mode)
5862 (gnus-summary-next-subject 1 nil t)
5863 (gnus-summary-recenter)
5864 (gnus-summary-position-point))))
5868 (defvar gnus-dead-summary-mode-map nil)
5870 (unless gnus-dead-summary-mode-map
5871 (setq gnus-dead-summary-mode-map (make-keymap))
5872 (suppress-keymap gnus-dead-summary-mode-map)
5873 (substitute-key-definition
5874 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
5875 (let ((keys '("\C-d" "\r" "\177" [delete])))
5877 (define-key gnus-dead-summary-mode-map
5878 (pop keys) 'gnus-summary-wake-up-the-dead))))
5880 (defvar gnus-dead-summary-mode nil
5881 "Minor mode for Gnus summary buffers.")
5883 (defun gnus-dead-summary-mode (&optional arg)
5884 "Minor mode for Gnus summary buffers."
5886 (when (eq major-mode 'gnus-summary-mode)
5887 (make-local-variable 'gnus-dead-summary-mode)
5888 (setq gnus-dead-summary-mode
5889 (if (null arg) (not gnus-dead-summary-mode)
5890 (> (prefix-numeric-value arg) 0)))
5891 (when gnus-dead-summary-mode
5892 (gnus-add-minor-mode
5893 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
5895 (defun gnus-deaden-summary ()
5896 "Make the current summary buffer into a dead summary buffer."
5897 ;; Kill any previous dead summary buffer.
5898 (when (and gnus-dead-summary
5899 (buffer-name gnus-dead-summary))
5901 (set-buffer gnus-dead-summary)
5902 (when gnus-dead-summary-mode
5903 (kill-buffer (current-buffer)))))
5904 ;; Make this the current dead summary.
5905 (setq gnus-dead-summary (current-buffer))
5906 (gnus-dead-summary-mode 1)
5907 (let ((name (buffer-name)))
5908 (when (string-match "Summary" name)
5910 (concat (substring name 0 (match-beginning 0)) "Dead "
5911 (substring name (match-beginning 0)))
5915 (defun gnus-kill-or-deaden-summary (buffer)
5916 "Kill or deaden the summary BUFFER."
5918 (when (and (buffer-name buffer)
5919 (not gnus-single-article-buffer))
5922 (gnus-kill-buffer gnus-article-buffer)
5923 (gnus-kill-buffer gnus-original-article-buffer)))
5924 (cond (gnus-kill-summary-on-exit
5925 (when (and gnus-use-trees
5926 (gnus-buffer-exists-p buffer))
5929 (gnus-tree-close gnus-newsgroup-name)))
5930 (gnus-kill-buffer buffer))
5931 ((gnus-buffer-exists-p buffer)
5934 (gnus-deaden-summary))))))
5936 (defun gnus-summary-wake-up-the-dead (&rest args)
5937 "Wake up the dead summary buffer."
5939 (gnus-dead-summary-mode -1)
5940 (let ((name (buffer-name)))
5941 (when (string-match "Dead " name)
5943 (concat (substring name 0 (match-beginning 0))
5944 (substring name (match-end 0)))
5946 (gnus-message 3 "This dead summary is now alive again"))
5948 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
5949 (defun gnus-summary-fetch-faq (&optional faq-dir)
5950 "Fetch the FAQ for the current group.
5951 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
5955 (when current-prefix-arg
5957 "Faq dir: " (and (listp gnus-group-faq-directory)
5958 (mapcar (lambda (file) (list file))
5959 gnus-group-faq-directory))))))
5960 (let (gnus-faq-buffer)
5961 (when (setq gnus-faq-buffer
5962 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
5963 (gnus-configure-windows 'summary-faq))))
5965 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
5966 (defun gnus-summary-describe-group (&optional force)
5967 "Describe the current newsgroup."
5969 (gnus-group-describe-group force gnus-newsgroup-name))
5971 (defun gnus-summary-describe-briefly ()
5972 "Describe summary mode commands briefly."
5974 (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")))
5976 ;; Walking around group mode buffer from summary mode.
5978 (defun gnus-summary-next-group (&optional no-article target-group backward)
5979 "Exit current newsgroup and then select next unread newsgroup.
5980 If prefix argument NO-ARTICLE is non-nil, no article is selected
5981 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
5982 previous group instead."
5984 ;; Stop pre-fetching.
5985 (gnus-async-halt-prefetch)
5986 (let ((current-group gnus-newsgroup-name)
5987 (current-buffer (current-buffer))
5989 ;; First we semi-exit this group to update Xrefs and all variables.
5990 ;; We can't do a real exit, because the window conf must remain
5991 ;; the same in case the user is prompted for info, and we don't
5992 ;; want the window conf to change before that...
5993 (gnus-summary-exit t)
5994 (while (not entered)
5995 ;; Then we find what group we are supposed to enter.
5996 (set-buffer gnus-group-buffer)
5997 (gnus-group-jump-to-group current-group)
6000 (if (eq gnus-keep-same-level 'best)
6001 (gnus-summary-best-group gnus-newsgroup-name)
6002 (gnus-summary-search-group backward gnus-keep-same-level))))
6003 (if (not target-group)
6004 ;; There are no further groups, so we return to the group
6007 (gnus-message 5 "Returning to the group buffer")
6009 (when (gnus-buffer-live-p current-buffer)
6010 (set-buffer current-buffer)
6011 (gnus-summary-exit))
6012 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
6013 ;; We try to enter the target group.
6014 (gnus-group-jump-to-group target-group)
6015 (let ((unreads (gnus-group-group-unread)))
6016 (if (and (or (eq t unreads)
6017 (and unreads (not (zerop unreads))))
6018 (gnus-summary-read-group
6019 target-group nil no-article
6020 (and (buffer-name current-buffer) current-buffer)
6023 (setq current-group target-group
6024 target-group nil)))))))
6026 (defun gnus-summary-prev-group (&optional no-article)
6027 "Exit current newsgroup and then select previous unread newsgroup.
6028 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
6030 (gnus-summary-next-group no-article nil t))
6032 ;; Walking around summary lines.
6034 (defun gnus-summary-first-subject (&optional unread undownloaded)
6035 "Go to the first unread subject.
6036 If UNREAD is non-nil, go to the first unread article.
6037 Returns the article selected or nil if there are no unread articles."
6042 ((null gnus-newsgroup-data)
6043 (gnus-message 3 "No articles in the group")
6045 ;; Pick the first article.
6047 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
6048 (gnus-data-number (car gnus-newsgroup-data)))
6049 ;; No unread articles.
6050 ((null gnus-newsgroup-unreads)
6051 (gnus-message 3 "No more unread articles")
6053 ;; Find the first unread article.
6055 (let ((data gnus-newsgroup-data))
6057 (and (not (and undownloaded
6058 (eq gnus-undownloaded-mark
6059 (gnus-data-mark (car data)))))
6060 (not (gnus-data-unread-p (car data)))))
6061 (setq data (cdr data)))
6063 (goto-char (gnus-data-pos (car data)))
6064 (gnus-data-number (car data))))))
6065 (gnus-summary-position-point)))
6067 (defun gnus-summary-next-subject (n &optional unread dont-display)
6068 "Go to next N'th summary line.
6069 If N is negative, go to the previous N'th subject line.
6070 If UNREAD is non-nil, only unread articles are selected.
6071 The difference between N and the actual number of steps taken is
6074 (let ((backward (< n 0))
6078 (gnus-summary-find-prev unread)
6079 (gnus-summary-find-next unread)))
6080 (unless (zerop (setq n (1- n)))
6081 (gnus-summary-show-thread)))
6083 (gnus-message 7 "No more%s articles"
6084 (if unread " unread" "")))
6085 (unless dont-display
6086 (gnus-summary-recenter)
6087 (gnus-summary-position-point))
6090 (defun gnus-summary-next-unread-subject (n)
6091 "Go to next N'th unread summary line."
6093 (gnus-summary-next-subject n t))
6095 (defun gnus-summary-prev-subject (n &optional unread)
6096 "Go to previous N'th summary line.
6097 If optional argument UNREAD is non-nil, only unread article is selected."
6099 (gnus-summary-next-subject (- n) unread))
6101 (defun gnus-summary-prev-unread-subject (n)
6102 "Go to previous N'th unread summary line."
6104 (gnus-summary-next-subject (- n) t))
6106 (defun gnus-summary-goto-subject (article &optional force silent)
6107 "Go the subject line of ARTICLE.
6108 If FORCE, also allow jumping to articles not currently shown."
6109 (interactive "nArticle number: ")
6111 (data (gnus-data-find article)))
6112 ;; We read in the article if we have to.
6115 (gnus-summary-insert-subject
6117 (if (or (numberp force) (vectorp force)) force)
6119 (setq data (gnus-data-find article)))
6124 (gnus-message 3 "Can't find article %d" article))
6126 (goto-char (gnus-data-pos data))
6127 (gnus-summary-position-point)
6130 ;; Walking around summary lines with displaying articles.
6132 (defun gnus-summary-expand-window (&optional arg)
6133 "Make the summary buffer take up the entire Emacs frame.
6134 Given a prefix, will force an `article' buffer configuration."
6137 (gnus-configure-windows 'article 'force)
6138 (gnus-configure-windows 'summary 'force)))
6140 (defun gnus-summary-display-article (article &optional all-header)
6141 "Display ARTICLE in article buffer."
6142 (when (gnus-buffer-live-p gnus-article-buffer)
6143 (with-current-buffer gnus-article-buffer
6144 (mm-enable-multibyte-mule4)))
6145 (gnus-set-global-variables)
6146 (when (gnus-buffer-live-p gnus-article-buffer)
6147 (with-current-buffer gnus-article-buffer
6148 (setq gnus-article-charset gnus-newsgroup-charset)
6149 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
6150 (mm-enable-multibyte-mule4)))
6154 (if gnus-summary-display-article-function
6155 (funcall gnus-summary-display-article-function article all-header)
6156 (gnus-article-prepare article all-header))
6157 (gnus-run-hooks 'gnus-select-article-hook)
6158 (when (and gnus-current-article
6159 (not (zerop gnus-current-article)))
6160 (gnus-summary-goto-subject gnus-current-article))
6161 (gnus-summary-recenter)
6162 (when (and gnus-use-trees gnus-show-threads)
6163 (gnus-possibly-generate-tree article)
6164 (gnus-highlight-selected-tree article))
6165 ;; Successfully display article.
6166 (gnus-article-set-window-start
6167 (cdr (assq article gnus-newsgroup-bookmarks))))))
6169 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
6170 "Select the current article.
6171 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
6172 non-nil, the article will be re-fetched even if it already present in
6173 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
6175 ;; Make sure we are in the summary buffer to work around bbdb bug.
6176 (unless (eq major-mode 'gnus-summary-mode)
6177 (set-buffer gnus-summary-buffer))
6178 (let ((article (or article (gnus-summary-article-number)))
6179 (all-headers (not (not all-headers))) ;Must be T or NIL.
6180 gnus-summary-display-article-function)
6182 (gnus-summary-article-pseudo-p article)
6183 (error "This is a pseudo-article"))
6185 (set-buffer gnus-summary-buffer)
6186 (if (or (and gnus-single-article-buffer
6187 (or (null gnus-current-article)
6188 (null gnus-article-current)
6189 (null (get-buffer gnus-article-buffer))
6190 (not (eq article (cdr gnus-article-current)))
6191 (not (equal (car gnus-article-current)
6192 gnus-newsgroup-name))))
6193 (and (not gnus-single-article-buffer)
6194 (or (null gnus-current-article)
6195 (not (eq gnus-current-article article))))
6197 ;; The requested article is different from the current article.
6199 (gnus-summary-display-article article all-headers)
6200 (when (gnus-buffer-live-p gnus-article-buffer)
6201 (with-current-buffer gnus-article-buffer
6202 (if (not gnus-article-decoded-p) ;; a local variable
6203 (mm-disable-multibyte-mule4))))
6204 (when (or all-headers gnus-show-all-headers)
6205 (gnus-article-show-all-headers))
6206 (gnus-article-set-window-start
6207 (cdr (assq article gnus-newsgroup-bookmarks)))
6209 (when (or all-headers gnus-show-all-headers)
6210 (gnus-article-show-all-headers))
6213 (defun gnus-summary-force-verify-and-decrypt ()
6215 (let ((mm-verify-option 'known)
6216 (mm-decrypt-option 'known))
6217 (gnus-summary-select-article nil 'force)))
6219 (defun gnus-summary-set-current-mark (&optional current-mark)
6220 "Obsolete function."
6223 (defun gnus-summary-next-article (&optional unread subject backward push)
6224 "Select the next article.
6225 If UNREAD, only unread articles are selected.
6226 If SUBJECT, only articles with SUBJECT are selected.
6227 If BACKWARD, the previous article is selected instead of the next."
6230 ;; Is there such an article?
6231 ((and (gnus-summary-search-forward unread subject backward)
6232 (or (gnus-summary-display-article (gnus-summary-article-number))
6233 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
6234 (gnus-summary-position-point))
6235 ;; If not, we try the first unread, if that is wanted.
6237 gnus-auto-select-same
6238 (gnus-summary-first-unread-article))
6239 (gnus-summary-position-point)
6240 (gnus-message 6 "Wrapped"))
6241 ;; Try to get next/previous article not displayed in this group.
6242 ((and gnus-auto-extend-newsgroup
6243 (not unread) (not subject))
6244 (gnus-summary-goto-article
6245 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
6246 nil (count-lines (point-min) (point))))
6247 ;; Go to next/previous group.
6249 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
6250 (gnus-summary-jump-to-group gnus-newsgroup-name))
6251 (let ((cmd last-command-char)
6254 (set-buffer gnus-group-buffer)
6257 (if (eq gnus-keep-same-level 'best)
6258 (gnus-summary-best-group gnus-newsgroup-name)
6259 (gnus-summary-search-group backward gnus-keep-same-level))))
6260 ;; For some reason, the group window gets selected. We change
6262 (select-window (get-buffer-window (current-buffer)))
6263 ;; Select next unread newsgroup automagically.
6265 ((or (not gnus-auto-select-next)
6267 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
6268 ((or (eq gnus-auto-select-next 'quietly)
6269 (and (eq gnus-auto-select-next 'slightly-quietly)
6271 (and (eq gnus-auto-select-next 'almost-quietly)
6272 (gnus-summary-last-article-p)))
6274 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
6276 (gnus-message 7 "No more%s articles (%s)..."
6277 (if unread " unread" "")
6278 (if group (concat "selecting " group)
6280 (gnus-summary-next-group nil group backward)))
6282 (when (gnus-key-press-event-p last-input-event)
6283 (gnus-summary-walk-group-buffer
6284 gnus-newsgroup-name cmd unread backward point))))))))
6286 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
6287 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
6288 (?\C-p (gnus-group-prev-unread-group 1))))
6289 (cursor-in-echo-area t)
6290 keve key group ended)
6292 (set-buffer gnus-group-buffer)
6295 (if (eq gnus-keep-same-level 'best)
6296 (gnus-summary-best-group gnus-newsgroup-name)
6297 (gnus-summary-search-group backward gnus-keep-same-level))))
6300 5 "No more%s articles%s" (if unread " unread" "")
6302 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
6303 (format " (Type %s for %s [%s])"
6304 (single-key-description cmd) group
6305 (car (gnus-gethash group gnus-newsrc-hashtb)))
6306 (format " (Type %s to exit %s)"
6307 (single-key-description cmd)
6308 gnus-newsgroup-name)))
6309 ;; Confirm auto selection.
6310 (setq key (car (setq keve (gnus-read-event-char))))
6313 ((assq key keystrokes)
6314 (let ((obuf (current-buffer)))
6315 (switch-to-buffer gnus-group-buffer)
6317 (gnus-group-jump-to-group group))
6318 (eval (cadr (assq key keystrokes)))
6319 (setq group (gnus-group-group-name))
6320 (switch-to-buffer obuf))
6324 (gnus-ephemeral-group-p gnus-newsgroup-name))
6326 (gnus-summary-next-group nil group backward)))
6328 (push (cdr keve) unread-command-events))))))
6330 (defun gnus-summary-next-unread-article ()
6331 "Select unread article after current one."
6333 (gnus-summary-next-article
6334 (or (not (eq gnus-summary-goto-unread 'never))
6335 (gnus-summary-last-article-p (gnus-summary-article-number)))
6336 (and gnus-auto-select-same
6337 (gnus-summary-article-subject))))
6339 (defun gnus-summary-prev-article (&optional unread subject)
6340 "Select the article after the current one.
6341 If UNREAD is non-nil, only unread articles are selected."
6343 (gnus-summary-next-article unread subject t))
6345 (defun gnus-summary-prev-unread-article ()
6346 "Select unread article before current one."
6348 (gnus-summary-prev-article
6349 (or (not (eq gnus-summary-goto-unread 'never))
6350 (gnus-summary-first-article-p (gnus-summary-article-number)))
6351 (and gnus-auto-select-same
6352 (gnus-summary-article-subject))))
6354 (defun gnus-summary-next-page (&optional lines circular)
6355 "Show next page of the selected article.
6356 If at the end of the current article, select the next article.
6357 LINES says how many lines should be scrolled up.
6359 If CIRCULAR is non-nil, go to the start of the article instead of
6360 selecting the next article when reaching the end of the current
6363 (setq gnus-summary-buffer (current-buffer))
6364 (gnus-set-global-variables)
6365 (let ((article (gnus-summary-article-number))
6366 (article-window (get-buffer-window gnus-article-buffer t))
6368 ;; If the buffer is empty, we have no article.
6370 (error "No article to select"))
6371 (gnus-configure-windows 'article)
6372 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
6373 (if (and (eq gnus-summary-goto-unread 'never)
6374 (not (gnus-summary-last-article-p article)))
6375 (gnus-summary-next-article)
6376 (gnus-summary-next-unread-article))
6377 (if (or (null gnus-current-article)
6378 (null gnus-article-current)
6379 (/= article (cdr gnus-article-current))
6380 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6381 ;; Selected subject is different from current article's.
6382 (gnus-summary-display-article article)
6383 (when article-window
6384 (gnus-eval-in-buffer-window gnus-article-buffer
6385 (setq endp (gnus-article-next-page lines)))
6388 (gnus-summary-beginning-of-article))
6390 (gnus-message 3 "End of message"))
6392 (if (and (eq gnus-summary-goto-unread 'never)
6393 (not (gnus-summary-last-article-p article)))
6394 (gnus-summary-next-article)
6395 (gnus-summary-next-unread-article))))))))
6396 (gnus-summary-recenter)
6397 (gnus-summary-position-point)))
6399 (defun gnus-summary-prev-page (&optional lines move)
6400 "Show previous page of selected article.
6401 Argument LINES specifies lines to be scrolled down.
6402 If MOVE, move to the previous unread article if point is at
6403 the beginning of the buffer."
6405 (let ((article (gnus-summary-article-number))
6406 (article-window (get-buffer-window gnus-article-buffer t))
6408 (gnus-configure-windows 'article)
6409 (if (or (null gnus-current-article)
6410 (null gnus-article-current)
6411 (/= article (cdr gnus-article-current))
6412 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6413 ;; Selected subject is different from current article's.
6414 (gnus-summary-display-article article)
6415 (gnus-summary-recenter)
6416 (when article-window
6417 (gnus-eval-in-buffer-window gnus-article-buffer
6418 (setq endp (gnus-article-prev-page lines)))
6419 (when (and move endp)
6421 (gnus-message 3 "Beginning of message"))
6423 (if (and (eq gnus-summary-goto-unread 'never)
6424 (not (gnus-summary-first-article-p article)))
6425 (gnus-summary-prev-article)
6426 (gnus-summary-prev-unread-article))))))))
6427 (gnus-summary-position-point))
6429 (defun gnus-summary-prev-page-or-article (&optional lines)
6430 "Show previous page of selected article.
6431 Argument LINES specifies lines to be scrolled down.
6432 If at the beginning of the article, go to the next article."
6434 (gnus-summary-prev-page lines t))
6436 (defun gnus-summary-scroll-up (lines)
6437 "Scroll up (or down) one line current article.
6438 Argument LINES specifies lines to be scrolled up (or down if negative)."
6440 (gnus-configure-windows 'article)
6441 (gnus-summary-show-thread)
6442 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
6443 (gnus-eval-in-buffer-window gnus-article-buffer
6445 (when (gnus-article-next-page lines)
6446 (gnus-message 3 "End of message")))
6448 (gnus-article-prev-page (- lines))))))
6449 (gnus-summary-recenter)
6450 (gnus-summary-position-point))
6452 (defun gnus-summary-scroll-down (lines)
6453 "Scroll down (or up) one line current article.
6454 Argument LINES specifies lines to be scrolled down (or up if negative)."
6456 (gnus-summary-scroll-up (- lines)))
6458 (defun gnus-summary-next-same-subject ()
6459 "Select next article which has the same subject as current one."
6461 (gnus-summary-next-article nil (gnus-summary-article-subject)))
6463 (defun gnus-summary-prev-same-subject ()
6464 "Select previous article which has the same subject as current one."
6466 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
6468 (defun gnus-summary-next-unread-same-subject ()
6469 "Select next unread article which has the same subject as current one."
6471 (gnus-summary-next-article t (gnus-summary-article-subject)))
6473 (defun gnus-summary-prev-unread-same-subject ()
6474 "Select previous unread article which has the same subject as current one."
6476 (gnus-summary-prev-article t (gnus-summary-article-subject)))
6478 (defun gnus-summary-first-unread-article ()
6479 "Select the first unread article.
6480 Return nil if there are no unread articles."
6483 (when (gnus-summary-first-subject t)
6484 (gnus-summary-show-thread)
6485 (gnus-summary-first-subject t)
6486 (gnus-summary-display-article (gnus-summary-article-number)))
6487 (gnus-summary-position-point)))
6489 (defun gnus-summary-first-unread-subject ()
6490 "Place the point on the subject line of the first unread article.
6491 Return nil if there are no unread articles."
6494 (when (gnus-summary-first-subject t)
6495 (gnus-summary-show-thread)
6496 (gnus-summary-first-subject t))
6497 (gnus-summary-position-point)))
6499 (defun gnus-summary-first-article ()
6500 "Select the first article.
6501 Return nil if there are no articles."
6504 (when (gnus-summary-first-subject)
6505 (gnus-summary-show-thread)
6506 (gnus-summary-first-subject)
6507 (gnus-summary-display-article (gnus-summary-article-number)))
6508 (gnus-summary-position-point)))
6510 (defun gnus-summary-best-unread-article ()
6511 "Select the unread article with the highest score."
6513 (let ((best -1000000)
6514 (data gnus-newsgroup-data)
6517 (and (gnus-data-unread-p (car data))
6519 (gnus-summary-article-score (gnus-data-number (car data))))
6522 article (gnus-data-number (car data))))
6523 (setq data (cdr data)))
6526 (gnus-summary-goto-article article)
6527 (error "No unread articles"))
6528 (gnus-summary-position-point))))
6530 (defun gnus-summary-last-subject ()
6531 "Go to the last displayed subject line in the group."
6532 (let ((article (gnus-data-number (car (gnus-data-list t)))))
6534 (gnus-summary-goto-subject article))))
6536 (defun gnus-summary-goto-article (article &optional all-headers force)
6537 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
6538 If ALL-HEADERS is non-nil, no header lines are hidden.
6539 If FORCE, go to the article even if it isn't displayed. If FORCE
6540 is a number, it is the line the article is to be displayed on."
6544 "Article number or Message-ID: "
6545 (mapcar (lambda (number) (list (int-to-string number)))
6546 gnus-newsgroup-limit))
6550 (if (and (stringp article)
6551 (string-match "@" article))
6552 (gnus-summary-refer-article article)
6553 (when (stringp article)
6554 (setq article (string-to-number article)))
6555 (if (gnus-summary-goto-subject article force)
6556 (gnus-summary-display-article article all-headers)
6557 (gnus-message 4 "Couldn't go to article %s" article) nil))
6558 (gnus-summary-position-point)))
6560 (defun gnus-summary-goto-last-article ()
6561 "Go to the previously read article."
6564 (when gnus-last-article
6565 (gnus-summary-goto-article gnus-last-article nil t))
6566 (gnus-summary-position-point)))
6568 (defun gnus-summary-pop-article (number)
6569 "Pop one article off the history and go to the previous.
6570 NUMBER articles will be popped off."
6573 (setq gnus-newsgroup-history
6574 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
6576 (gnus-summary-goto-article (car to) nil t)
6577 (error "Article history empty")))
6578 (gnus-summary-position-point))
6580 ;; Summary commands and functions for limiting the summary buffer.
6582 (defun gnus-summary-limit-to-articles (n)
6583 "Limit the summary buffer to the next N articles.
6584 If not given a prefix, use the process marked articles instead."
6587 (let ((articles (gnus-summary-work-articles n)))
6588 (setq gnus-newsgroup-processable nil)
6589 (gnus-summary-limit articles))
6590 (gnus-summary-position-point)))
6592 (defun gnus-summary-pop-limit (&optional total)
6593 "Restore the previous limit.
6594 If given a prefix, remove all limits."
6597 (setq gnus-newsgroup-limits
6598 (list (mapcar (lambda (h) (mail-header-number h))
6599 gnus-newsgroup-headers))))
6600 (unless gnus-newsgroup-limits
6601 (error "No limit to pop"))
6603 (gnus-summary-limit nil 'pop)
6604 (gnus-summary-position-point)))
6606 (defun gnus-summary-limit-to-subject (subject &optional header)
6607 "Limit the summary buffer to articles that have subjects that match a regexp."
6608 (interactive "sLimit to subject (regexp): ")
6610 (setq header "subject"))
6611 (when (not (equal "" subject))
6613 (let ((articles (gnus-summary-find-matching
6614 (or header "subject") subject 'all)))
6616 (error "Found no matches for \"%s\"" subject))
6617 (gnus-summary-limit articles))
6618 (gnus-summary-position-point))))
6620 (defun gnus-summary-limit-to-author (from)
6621 "Limit the summary buffer to articles that have authors that match a regexp."
6622 (interactive "sLimit to author (regexp): ")
6623 (gnus-summary-limit-to-subject from "from"))
6625 (defun gnus-summary-limit-to-age (age &optional younger-p)
6626 "Limit the summary buffer to articles that are older than (or equal) AGE days.
6627 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
6628 articles that are younger than AGE days."
6630 (let ((younger current-prefix-arg)
6633 (while (not days-got)
6634 (setq days (if younger
6635 (read-string "Limit to articles within (in days): ")
6636 (read-string "Limit to articles older than (in days): ")))
6637 (when (> (length days) 0)
6638 (setq days (read days)))
6641 (message "Please enter a number.")
6643 (list days younger)))
6645 (let ((data gnus-newsgroup-data)
6646 (cutoff (days-to-time age))
6647 articles d date is-younger)
6648 (while (setq d (pop data))
6649 (when (and (vectorp (gnus-data-header d))
6650 (setq date (mail-header-date (gnus-data-header d))))
6651 (setq is-younger (time-less-p
6652 (time-since (condition-case ()
6659 (push (gnus-data-number d) articles))))
6660 (gnus-summary-limit (nreverse articles)))
6661 (gnus-summary-position-point)))
6663 (defun gnus-summary-limit-to-extra (header regexp)
6664 "Limit the summary buffer to articles that match an 'extra' header."
6668 (gnus-completing-read
6669 (symbol-name (car gnus-extra-headers))
6670 "Limit extra header:"
6672 (cons (symbol-name x) x))
6677 (read-string (format "Limit to header %s (regexp): " header)))))
6678 (when (not (equal "" regexp))
6680 (let ((articles (gnus-summary-find-matching
6681 (cons 'extra header) regexp 'all)))
6683 (error "Found no matches for \"%s\"" regexp))
6684 (gnus-summary-limit articles))
6685 (gnus-summary-position-point))))
6687 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6689 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6691 (defun gnus-summary-limit-to-unread (&optional all)
6692 "Limit the summary buffer to articles that are not marked as read.
6693 If ALL is non-nil, limit strictly to unread articles."
6696 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
6697 (gnus-summary-limit-to-marks
6698 ;; Concat all the marks that say that an article is read and have
6700 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
6701 gnus-killed-mark gnus-kill-file-mark
6702 gnus-low-score-mark gnus-expirable-mark
6703 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
6704 gnus-duplicate-mark gnus-souped-mark)
6707 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
6708 (make-obsolete 'gnus-summary-delete-marked-with
6709 'gnus-summary-limit-exlude-marks)
6711 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
6712 "Exclude articles that are marked with MARKS (e.g. \"DK\").
6713 If REVERSE, limit the summary buffer to articles that are marked
6714 with MARKS. MARKS can either be a string of marks or a list of marks.
6715 Returns how many articles were removed."
6716 (interactive "sMarks: ")
6717 (gnus-summary-limit-to-marks marks t))
6719 (defun gnus-summary-limit-to-marks (marks &optional reverse)
6720 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
6721 If REVERSE (the prefix), limit the summary buffer to articles that are
6722 not marked with MARKS. MARKS can either be a string of marks or a
6724 Returns how many articles were removed."
6725 (interactive "sMarks: \nP")
6727 (let ((data gnus-newsgroup-data)
6728 (marks (if (listp marks) marks
6729 (append marks nil))) ; Transform to list.
6732 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
6733 (memq (gnus-data-mark (car data)) marks))
6734 (push (gnus-data-number (car data)) articles))
6735 (setq data (cdr data)))
6736 (gnus-summary-limit articles))
6737 (gnus-summary-position-point)))
6739 (defun gnus-summary-limit-to-score (&optional score)
6740 "Limit to articles with score at or above SCORE."
6742 (setq score (if score
6743 (prefix-numeric-value score)
6744 (or gnus-summary-default-score 0)))
6745 (let ((data gnus-newsgroup-data)
6748 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
6750 (push (gnus-data-number (car data)) articles))
6751 (setq data (cdr data)))
6753 (gnus-summary-limit articles)
6754 (gnus-summary-position-point))))
6756 (defun gnus-summary-limit-include-thread (id)
6757 "Display all the hidden articles that is in the thread with ID in it.
6758 When called interactively, ID is the Message-ID of the current
6760 (interactive (list (mail-header-id (gnus-summary-article-header))))
6761 (let ((articles (gnus-articles-in-thread
6762 (gnus-id-to-thread (gnus-root-id id)))))
6764 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
6765 (gnus-summary-limit-include-matching-articles
6767 (regexp-quote (gnus-simplify-subject-re
6768 (mail-header-subject (gnus-id-to-header id)))))
6769 (gnus-summary-position-point))))
6771 (defun gnus-summary-limit-include-matching-articles (header regexp)
6772 "Display all the hidden articles that have HEADERs that match REGEXP."
6773 (interactive (list (read-string "Match on header: ")
6774 (read-string "Regexp: ")))
6775 (let ((articles (gnus-find-matching-articles header regexp)))
6777 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
6778 (gnus-summary-position-point))))
6780 (defun gnus-summary-limit-include-dormant ()
6781 "Display all the hidden articles that are marked as dormant.
6782 Note that this command only works on a subset of the articles currently
6783 fetched for this group."
6785 (unless gnus-newsgroup-dormant
6786 (error "There are no dormant articles in this group"))
6788 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
6789 (gnus-summary-position-point)))
6791 (defun gnus-summary-limit-exclude-dormant ()
6792 "Hide all dormant articles."
6795 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
6796 (gnus-summary-position-point)))
6798 (defun gnus-summary-limit-exclude-childless-dormant ()
6799 "Hide all dormant articles that have no children."
6801 (let ((data (gnus-data-list t))
6802 articles d children)
6803 ;; Find all articles that are either not dormant or have
6805 (while (setq d (pop data))
6806 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
6808 (gnus-article-children (gnus-data-number d)))
6811 (when (memq (car children) articles)
6816 (push (gnus-data-number d) articles)))
6819 (gnus-summary-limit articles)
6820 (gnus-summary-position-point))))
6822 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
6823 "Mark all unread excluded articles as read.
6824 If ALL, mark even excluded ticked and dormants as read."
6826 (let ((articles (gnus-sorted-complement
6828 (mapcar (lambda (h) (mail-header-number h))
6829 gnus-newsgroup-headers)
6831 (sort gnus-newsgroup-limit '<)))
6833 (setq gnus-newsgroup-unreads
6834 (gnus-intersection gnus-newsgroup-unreads gnus-newsgroup-limit))
6836 (setq gnus-newsgroup-dormant nil
6837 gnus-newsgroup-marked nil
6838 gnus-newsgroup-reads
6840 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
6841 gnus-newsgroup-reads))
6842 (while (setq article (pop articles))
6843 (unless (or (memq article gnus-newsgroup-dormant)
6844 (memq article gnus-newsgroup-marked))
6845 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
6847 (defun gnus-summary-limit (articles &optional pop)
6849 ;; We pop the previous limit off the stack and use that.
6850 (setq articles (car gnus-newsgroup-limits)
6851 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
6852 ;; We use the new limit, so we push the old limit on the stack.
6853 (push gnus-newsgroup-limit gnus-newsgroup-limits))
6855 (setq gnus-newsgroup-limit articles)
6856 (let ((total (length gnus-newsgroup-data))
6857 (data (gnus-data-find-list (gnus-summary-article-number)))
6858 (gnus-summary-mark-below nil) ; Inhibit this.
6860 ;; This will do all the work of generating the new summary buffer
6861 ;; according to the new limit.
6862 (gnus-summary-prepare)
6863 ;; Hide any threads, possibly.
6864 (and gnus-show-threads
6865 gnus-thread-hide-subtree
6866 (gnus-summary-hide-all-threads))
6867 ;; Try to return to the article you were at, or one in the
6870 ;; We try to find some article after the current one.
6872 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
6875 (setq data (cdr data))))
6877 ;; If there is no data, that means that we were after the last
6878 ;; article. The same goes when we can't find any articles
6879 ;; after the current one.
6880 (goto-char (point-max))
6881 (gnus-summary-find-prev))
6882 (gnus-set-mode-line 'summary)
6883 ;; We return how many articles were removed from the summary
6884 ;; buffer as a result of the new limit.
6885 (- total (length gnus-newsgroup-data))))
6887 (defsubst gnus-invisible-cut-children (threads)
6890 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
6895 (defsubst gnus-cut-thread (thread)
6896 "Go forwards in the thread until we find an article that we want to display."
6897 (when (or (eq gnus-fetch-old-headers 'some)
6898 (eq gnus-fetch-old-headers 'invisible)
6899 (numberp gnus-fetch-old-headers)
6900 (eq gnus-build-sparse-threads 'some)
6901 (eq gnus-build-sparse-threads 'more))
6902 ;; Deal with old-fetched headers and sparse threads.
6906 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
6907 (gnus-summary-article-ancient-p
6908 (mail-header-number (car thread))))
6909 (if (or (<= (length (cdr thread)) 1)
6910 (eq gnus-fetch-old-headers 'invisible))
6911 (setq gnus-newsgroup-limit
6912 (delq (mail-header-number (car thread))
6913 gnus-newsgroup-limit)
6914 thread (cadr thread))
6915 (when (gnus-invisible-cut-children (cdr thread))
6916 (let ((th (cdr thread)))
6918 (if (memq (mail-header-number (caar th))
6919 gnus-newsgroup-limit)
6920 (setq thread (car th)
6922 (setq th (cdr th))))))))))
6925 (defun gnus-cut-threads (threads)
6926 "Cut off all uninteresting articles from the beginning of threads."
6927 (when (or (eq gnus-fetch-old-headers 'some)
6928 (eq gnus-fetch-old-headers 'invisible)
6929 (numberp gnus-fetch-old-headers)
6930 (eq gnus-build-sparse-threads 'some)
6931 (eq gnus-build-sparse-threads 'more))
6934 (setcar th (gnus-cut-thread (car th)))
6935 (setq th (cdr th)))))
6936 ;; Remove nixed out threads.
6939 (defun gnus-summary-initial-limit (&optional show-if-empty)
6940 "Figure out what the initial limit is supposed to be on group entry.
6941 This entails weeding out unwanted dormants, low-scored articles,
6942 fetch-old-headers verbiage, and so on."
6943 ;; Most groups have nothing to remove.
6944 (if (or gnus-inhibit-limiting
6945 (and (null gnus-newsgroup-dormant)
6946 (not (eq gnus-fetch-old-headers 'some))
6947 (not (numberp gnus-fetch-old-headers))
6948 (not (eq gnus-fetch-old-headers 'invisible))
6949 (null gnus-summary-expunge-below)
6950 (not (eq gnus-build-sparse-threads 'some))
6951 (not (eq gnus-build-sparse-threads 'more))
6952 (null gnus-thread-expunge-below)
6953 (not gnus-use-nocem)))
6955 (push gnus-newsgroup-limit gnus-newsgroup-limits)
6956 (setq gnus-newsgroup-limit nil)
6959 (unless (car (symbol-value node))
6960 ;; These threads have no parents -- they are roots.
6961 (let ((nodes (cdr (symbol-value node)))
6964 (if (and gnus-thread-expunge-below
6965 (< (gnus-thread-total-score (car nodes))
6966 gnus-thread-expunge-below))
6967 (gnus-expunge-thread (pop nodes))
6968 (setq thread (pop nodes))
6969 (gnus-summary-limit-children thread))))))
6970 gnus-newsgroup-dependencies)
6971 ;; If this limitation resulted in an empty group, we might
6972 ;; pop the previous limit and use it instead.
6973 (when (and (not gnus-newsgroup-limit)
6975 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
6976 gnus-newsgroup-limit))
6978 (defun gnus-summary-limit-children (thread)
6979 "Return 1 if this subthread is visible and 0 if it is not."
6980 ;; First we get the number of visible children to this thread. This
6981 ;; is done by recursing down the thread using this function, so this
6982 ;; will really go down to a leaf article first, before slowly
6983 ;; working its way up towards the root.
6987 (apply '+ (mapcar 'gnus-summary-limit-children
6990 (number (mail-header-number (car thread)))
6993 (not (memq number gnus-newsgroup-marked))
6995 ;; If this article is dormant and has absolutely no visible
6996 ;; children, then this article isn't visible.
6997 (and (memq number gnus-newsgroup-dormant)
6999 ;; If this is "fetch-old-headered" and there is no
7000 ;; visible children, then we don't want this article.
7001 (and (or (eq gnus-fetch-old-headers 'some)
7002 (numberp gnus-fetch-old-headers))
7003 (gnus-summary-article-ancient-p number)
7005 ;; If this is "fetch-old-headered" and `invisible', then
7006 ;; we don't want this article.
7007 (and (eq gnus-fetch-old-headers 'invisible)
7008 (gnus-summary-article-ancient-p number))
7009 ;; If this is a sparsely inserted article with no children,
7010 ;; we don't want it.
7011 (and (eq gnus-build-sparse-threads 'some)
7012 (gnus-summary-article-sparse-p number)
7014 ;; If we use expunging, and this article is really
7015 ;; low-scored, then we don't want this article.
7016 (when (and gnus-summary-expunge-below
7018 (or (cdr (assq number gnus-newsgroup-scored))
7019 gnus-summary-default-score))
7020 gnus-summary-expunge-below))
7021 ;; We increase the expunge-tally here, but that has
7022 ;; nothing to do with the limits, really.
7023 (incf gnus-newsgroup-expunged-tally)
7024 ;; We also mark as read here, if that's wanted.
7025 (when (and gnus-summary-mark-below
7026 (< score gnus-summary-mark-below))
7027 (setq gnus-newsgroup-unreads
7028 (delq number gnus-newsgroup-unreads))
7029 (if gnus-newsgroup-auto-expire
7030 (push number gnus-newsgroup-expirable)
7031 (push (cons number gnus-low-score-mark)
7032 gnus-newsgroup-reads)))
7034 ;; Check NoCeM things.
7035 (if (and gnus-use-nocem
7036 (gnus-nocem-unwanted-article-p
7037 (mail-header-id (car thread))))
7039 (setq gnus-newsgroup-unreads
7040 (delq number gnus-newsgroup-unreads))
7042 ;; Nope, invisible article.
7044 ;; Ok, this article is to be visible, so we add it to the limit
7046 (push number gnus-newsgroup-limit)
7049 (defun gnus-expunge-thread (thread)
7050 "Mark all articles in THREAD as read."
7051 (let* ((number (mail-header-number (car thread))))
7052 (incf gnus-newsgroup-expunged-tally)
7053 ;; We also mark as read here, if that's wanted.
7054 (setq gnus-newsgroup-unreads
7055 (delq number gnus-newsgroup-unreads))
7056 (if gnus-newsgroup-auto-expire
7057 (push number gnus-newsgroup-expirable)
7058 (push (cons number gnus-low-score-mark)
7059 gnus-newsgroup-reads)))
7060 ;; Go recursively through all subthreads.
7061 (mapcar 'gnus-expunge-thread (cdr thread)))
7063 ;; Summary article oriented commands
7065 (defun gnus-summary-refer-parent-article (n)
7066 "Refer parent article N times.
7067 If N is negative, go to ancestor -N instead.
7068 The difference between N and the number of articles fetched is returned."
7072 (when (not (natnump n))
7077 (setq header (gnus-summary-article-header))
7078 (if (and (eq (mail-header-number header)
7079 (cdr gnus-article-current))
7080 (equal gnus-newsgroup-name
7081 (car gnus-article-current)))
7082 ;; If we try to find the parent of the currently
7083 ;; displayed article, then we take a look at the actual
7084 ;; References header, since this is slightly more
7085 ;; reliable than the References field we got from the
7088 (set-buffer gnus-original-article-buffer)
7089 (nnheader-narrow-to-headers)
7090 (unless (setq ref (message-fetch-field "references"))
7091 (setq ref (message-fetch-field "in-reply-to")))
7094 ;; It's not the current article, so we take a bet on
7095 ;; the value we got from the server.
7096 (mail-header-references header)))
7098 (not (equal ref "")))
7099 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
7100 (gnus-message 1 "Couldn't find parent"))
7101 (gnus-message 1 "No references in article %d"
7102 (gnus-summary-article-number))
7105 (gnus-summary-position-point)
7108 (defun gnus-summary-refer-references ()
7109 "Fetch all articles mentioned in the References header.
7110 Return the number of articles fetched."
7112 (let ((ref (mail-header-references (gnus-summary-article-header)))
7113 (current (gnus-summary-article-number))
7117 (error "No References in the current article")
7118 ;; For each Message-ID in the References header...
7119 (while (string-match "<[^>]*>" ref)
7121 ;; ... fetch that article.
7122 (gnus-summary-refer-article
7123 (prog1 (match-string 0 ref)
7124 (setq ref (substring ref (match-end 0))))))
7125 (gnus-summary-goto-subject current)
7126 (gnus-summary-position-point)
7129 (defun gnus-summary-refer-thread (&optional limit)
7130 "Fetch all articles in the current thread.
7131 If LIMIT (the numerical prefix), fetch that many old headers instead
7132 of what's specified by the `gnus-refer-thread-limit' variable."
7134 (let ((id (mail-header-id (gnus-summary-article-header)))
7135 (limit (if limit (prefix-numeric-value limit)
7136 gnus-refer-thread-limit)))
7137 ;; We want to fetch LIMIT *old* headers, but we also have to
7138 ;; re-fetch all the headers in the current buffer, because many of
7139 ;; them may be undisplayed. So we adjust LIMIT.
7140 (when (numberp limit)
7141 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
7142 (unless (eq gnus-fetch-old-headers 'invisible)
7143 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
7144 ;; Retrieve the headers and read them in.
7145 (if (eq (gnus-retrieve-headers
7146 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
7148 (gnus-build-all-threads)
7149 (error "Can't fetch thread from backends that don't support NOV"))
7150 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
7151 (gnus-summary-limit-include-thread id)))
7153 (defun gnus-summary-refer-article (message-id)
7154 "Fetch an article specified by MESSAGE-ID."
7155 (interactive "sMessage-ID: ")
7156 (when (and (stringp message-id)
7157 (not (zerop (length message-id))))
7158 ;; Construct the correct Message-ID if necessary.
7159 ;; Suggested by tale@pawl.rpi.edu.
7160 (unless (string-match "^<" message-id)
7161 (setq message-id (concat "<" message-id)))
7162 (unless (string-match ">$" message-id)
7163 (setq message-id (concat message-id ">")))
7164 (let* ((header (gnus-id-to-header message-id))
7166 (gnus-summary-article-sparse-p
7167 (mail-header-number header))
7168 (memq (mail-header-number header)
7169 gnus-newsgroup-limit)))
7172 ;; If the article is present in the buffer we just go to it.
7174 (or (not (gnus-summary-article-sparse-p
7175 (mail-header-number header)))
7178 (gnus-summary-goto-article
7179 (mail-header-number header) nil t)
7181 (gnus-summary-update-article (mail-header-number header)))))
7183 ;; We fetch the article.
7185 (dolist (gnus-override-method (gnus-refer-article-methods))
7186 (gnus-check-server gnus-override-method)
7187 ;; Fetch the header, and display the article.
7188 (when (setq number (gnus-summary-insert-subject message-id))
7189 (gnus-summary-select-article nil nil nil number)
7191 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
7193 (defun gnus-refer-article-methods ()
7194 "Return a list of referrable methods."
7196 ;; No method, so we default to current and native.
7197 ((null gnus-refer-article-method)
7198 (list gnus-current-select-method gnus-select-method))
7200 ((eq 'current gnus-refer-article-method)
7201 (list gnus-current-select-method))
7202 ;; List of select methods.
7203 ((not (and (symbolp (car gnus-refer-article-method))
7204 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
7206 (dolist (method gnus-refer-article-method)
7207 (push (if (eq 'current method)
7208 gnus-current-select-method
7212 ;; One single select method.
7214 (list gnus-refer-article-method))))
7216 (defun gnus-summary-edit-parameters ()
7217 "Edit the group parameters of the current group."
7219 (gnus-group-edit-group gnus-newsgroup-name 'params))
7221 (defun gnus-summary-customize-parameters ()
7222 "Customize the group parameters of the current group."
7224 (gnus-group-customize gnus-newsgroup-name))
7226 (defun gnus-summary-enter-digest-group (&optional force)
7227 "Enter an nndoc group based on the current article.
7228 If FORCE, force a digest interpretation. If not, try
7229 to guess what the document format is."
7231 (let ((conf gnus-current-window-configuration))
7233 (gnus-summary-select-article))
7234 (setq gnus-current-window-configuration conf)
7235 (let* ((name (format "%s-%d"
7236 (gnus-group-prefixed-name
7237 gnus-newsgroup-name (list 'nndoc ""))
7239 (set-buffer gnus-summary-buffer)
7240 gnus-current-article)))
7241 (ogroup gnus-newsgroup-name)
7242 (params (append (gnus-info-params (gnus-get-info ogroup))
7243 (list (cons 'to-group ogroup))
7244 (list (cons 'save-article-group ogroup))))
7245 (case-fold-search t)
7246 (buf (current-buffer))
7249 (set-buffer gnus-original-article-buffer)
7250 ;; Have the digest group inherit the main mail address of
7251 ;; the parent article.
7252 (when (setq to-address (or (message-fetch-field "reply-to")
7253 (message-fetch-field "from")))
7254 (setq params (append
7255 (list (cons 'to-address
7256 (funcall gnus-decode-encoded-word-function
7258 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
7259 (insert-buffer-substring gnus-original-article-buffer)
7260 ;; Remove lines that may lead nndoc to misinterpret the
7263 (goto-char (point-min))
7264 (or (search-forward "\n\n" nil t) (point)))
7265 (goto-char (point-min))
7266 (delete-matching-lines "^Path:\\|^From ")
7269 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
7270 (gnus-newsgroup-ephemeral-ignored-charsets
7271 gnus-newsgroup-ignored-charsets))
7272 (gnus-group-read-ephemeral-group
7273 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
7275 ,(if force 'mbox 'guess))) t))
7276 ;; Make all postings to this group go to the parent group.
7277 (nconc (gnus-info-params (gnus-get-info name))
7279 ;; Couldn't select this doc group.
7280 (switch-to-buffer buf)
7281 (gnus-set-global-variables)
7282 (gnus-configure-windows 'summary)
7283 (gnus-message 3 "Article couldn't be entered?"))
7284 (kill-buffer dig)))))
7286 (defun gnus-summary-read-document (n)
7287 "Open a new group based on the current article(s).
7288 This will allow you to read digests and other similar
7289 documents as newsgroups.
7290 Obeys the standard process/prefix convention."
7292 (let* ((articles (gnus-summary-work-articles n))
7293 (ogroup gnus-newsgroup-name)
7294 (params (append (gnus-info-params (gnus-get-info ogroup))
7295 (list (cons 'to-group ogroup))))
7296 article group egroup groups vgroup)
7297 (while (setq article (pop articles))
7298 (setq group (format "%s-%d" gnus-newsgroup-name article))
7299 (gnus-summary-remove-process-mark article)
7300 (when (gnus-summary-display-article article)
7303 (insert-buffer-substring gnus-original-article-buffer)
7304 ;; Remove some headers that may lead nndoc to make
7306 (message-narrow-to-head)
7307 (goto-char (point-min))
7308 (delete-matching-lines "^\\(Path\\):\\|^From ")
7311 (gnus-group-read-ephemeral-group
7312 group `(nndoc ,group (nndoc-address ,(current-buffer))
7313 (nndoc-article-type guess))
7316 ;; Make all postings to this group go to the parent group.
7317 (nconc (gnus-info-params (gnus-get-info egroup))
7319 (push egroup groups))
7320 ;; Couldn't select this doc group.
7321 (gnus-error 3 "Article couldn't be entered"))))))
7322 ;; Now we have selected all the documents.
7325 (error "None of the articles could be interpreted as documents"))
7326 ((gnus-group-read-ephemeral-group
7327 (setq vgroup (format
7328 "nnvirtual:%s-%s" gnus-newsgroup-name
7329 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
7330 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
7332 (cons (current-buffer) 'summary)))
7334 (error "Couldn't select virtual nndoc group")))))
7336 (defun gnus-summary-isearch-article (&optional regexp-p)
7337 "Do incremental search forward on the current article.
7338 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
7340 (gnus-summary-select-article)
7341 (gnus-configure-windows 'article)
7342 (gnus-eval-in-buffer-window gnus-article-buffer
7345 (isearch-forward regexp-p))))
7347 (defun gnus-summary-search-article-forward (regexp &optional backward)
7348 "Search for an article containing REGEXP forward.
7349 If BACKWARD, search backward instead."
7352 (format "Search article %s (regexp%s): "
7353 (if current-prefix-arg "backward" "forward")
7354 (if gnus-last-search-regexp
7355 (concat ", default " gnus-last-search-regexp)
7357 current-prefix-arg))
7358 (if (string-equal regexp "")
7359 (setq regexp (or gnus-last-search-regexp ""))
7360 (setq gnus-last-search-regexp regexp)
7361 (setq gnus-article-before-search gnus-current-article))
7362 ;; Intentionally set gnus-last-article.
7363 (setq gnus-last-article gnus-article-before-search)
7364 (let ((gnus-last-article gnus-last-article))
7365 (if (gnus-summary-search-article regexp backward)
7366 (gnus-summary-show-thread)
7367 (error "Search failed: \"%s\"" regexp))))
7369 (defun gnus-summary-search-article-backward (regexp)
7370 "Search for an article containing REGEXP backward."
7373 (format "Search article backward (regexp%s): "
7374 (if gnus-last-search-regexp
7375 (concat ", default " gnus-last-search-regexp)
7377 (gnus-summary-search-article-forward regexp 'backward))
7379 (defun gnus-summary-search-article (regexp &optional backward)
7380 "Search for an article containing REGEXP.
7381 Optional argument BACKWARD means do search for backward.
7382 `gnus-select-article-hook' is not called during the search."
7383 ;; We have to require this here to make sure that the following
7384 ;; dynamic binding isn't shadowed by autoloading.
7385 (require 'gnus-async)
7387 (let ((gnus-select-article-hook nil) ;Disable hook.
7388 (gnus-article-prepare-hook nil)
7389 (gnus-mark-article-hook nil) ;Inhibit marking as read.
7390 (gnus-use-article-prefetch nil)
7391 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
7392 (gnus-use-trees nil) ;Inhibit updating tree buffer.
7393 (sum (current-buffer))
7394 (gnus-display-mime-function nil)
7397 (gnus-save-hidden-threads
7398 (gnus-summary-select-article)
7399 (set-buffer gnus-article-buffer)
7400 (goto-char (window-point (get-buffer-window (current-buffer))))
7404 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
7406 (re-search-backward regexp nil t)
7407 (re-search-forward regexp nil t))
7408 ;; We found the regexp.
7413 (get-buffer-window (current-buffer))
7417 (get-buffer-window (current-buffer))
7420 (setq point (point)))
7421 ;; We didn't find it, so we go to the next article.
7424 (while (eq found 'not)
7425 (if (not (if backward (gnus-summary-find-prev)
7426 (gnus-summary-find-next)))
7427 ;; No more articles.
7429 ;; Select the next article and adjust point.
7430 (unless (gnus-summary-article-sparse-p
7431 (gnus-summary-article-number))
7433 (gnus-summary-select-article)
7434 (set-buffer gnus-article-buffer)
7436 (goto-char (if backward (point-max) (point-min))))))))
7437 (gnus-message 7 ""))
7438 ;; Return whether we found the regexp.
7439 (when (eq found 'found)
7441 (gnus-summary-show-thread)
7442 (gnus-summary-goto-subject gnus-current-article)
7443 (gnus-summary-position-point)
7446 (defun gnus-find-matching-articles (header regexp)
7447 "Return a list of all articles that match REGEXP on HEADER.
7448 This search includes all articles in the current group that Gnus has
7449 fetched headers for, whether they are displayed or not."
7450 (let ((articles nil)
7451 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
7452 (case-fold-search t))
7453 (dolist (header gnus-newsgroup-headers)
7454 (when (string-match regexp (funcall func header))
7455 (push (mail-header-number header) articles)))
7456 (nreverse articles)))
7458 (defun gnus-summary-find-matching (header regexp &optional backward unread
7460 "Return a list of all articles that match REGEXP on HEADER.
7461 The search stars on the current article and goes forwards unless
7462 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
7463 If UNREAD is non-nil, only unread articles will
7464 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
7465 in the comparisons."
7466 (let ((case-fold-search (not not-case-fold))
7469 (if (eq (car header) 'extra)
7472 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
7474 (error "%s is an invalid header" header))
7475 (unless (fboundp (intern (concat "mail-header-" header)))
7476 (error "%s is not a valid header" header))
7477 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
7478 (dolist (d (if (eq backward 'all)
7480 (gnus-data-find-list
7481 (gnus-summary-article-number)
7482 (gnus-data-list backward))))
7483 (when (and (or (not unread) ; We want all articles...
7484 (gnus-data-unread-p d)) ; Or just unreads.
7485 (vectorp (gnus-data-header d)) ; It's not a pseudo.
7486 (string-match regexp
7487 (funcall func (gnus-data-header d)))) ; Match.
7488 (push (gnus-data-number d) articles))) ; Success!
7489 (nreverse articles)))
7491 (defun gnus-summary-execute-command (header regexp command &optional backward)
7492 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
7493 If HEADER is an empty string (or nil), the match is done on the entire
7494 article. If BACKWARD (the prefix) is non-nil, search backward instead."
7496 (list (let ((completion-ignore-case t))
7499 (mapcar (lambda (header) (list (format "%s" header)))
7501 '("Number" "Subject" "From" "Lines" "Date"
7502 "Message-ID" "Xref" "References" "Body")
7503 gnus-extra-headers))
7504 nil 'require-match))
7505 (read-string "Regexp: ")
7506 (read-key-sequence "Command: ")
7507 current-prefix-arg))
7508 (when (equal header "Body")
7510 ;; Hidden thread subtrees must be searched as well.
7511 (gnus-summary-show-all-threads)
7512 ;; We don't want to change current point nor window configuration.
7514 (save-window-excursion
7515 (gnus-message 6 "Executing %s..." (key-description command))
7516 ;; We'd like to execute COMMAND interactively so as to give arguments.
7517 (gnus-execute header regexp
7518 `(call-interactively ',(key-binding command))
7520 (gnus-message 6 "Executing %s...done" (key-description command)))))
7522 (defun gnus-summary-beginning-of-article ()
7523 "Scroll the article back to the beginning."
7525 (gnus-summary-select-article)
7526 (gnus-configure-windows 'article)
7527 (gnus-eval-in-buffer-window gnus-article-buffer
7529 (goto-char (point-min))
7530 (when gnus-page-broken
7531 (gnus-narrow-to-page))))
7533 (defun gnus-summary-end-of-article ()
7534 "Scroll to the end of the article."
7536 (gnus-summary-select-article)
7537 (gnus-configure-windows 'article)
7538 (gnus-eval-in-buffer-window gnus-article-buffer
7540 (goto-char (point-max))
7542 (when gnus-page-broken
7543 (gnus-narrow-to-page))))
7545 (defun gnus-summary-print-article (&optional filename n)
7546 "Generate and print a PostScript image of the N next (mail) articles.
7548 If N is negative, print the N previous articles. If N is nil and articles
7549 have been marked with the process mark, print these instead.
7551 If the optional first argument FILENAME is nil, send the image to the
7552 printer. If FILENAME is a string, save the PostScript image in a file with
7553 that name. If FILENAME is a number, prompt the user for the name of the file
7555 (interactive (list (ps-print-preprint current-prefix-arg)))
7556 (dolist (article (gnus-summary-work-articles n))
7557 (gnus-summary-select-article nil nil 'pseudo article)
7558 (gnus-eval-in-buffer-window gnus-article-buffer
7559 (let ((buffer (generate-new-buffer " *print*")))
7562 (copy-to-buffer buffer (point-min) (point-max))
7564 (gnus-article-delete-invisible-text)
7565 (when (gnus-visual-p 'article-highlight 'highlight)
7566 ;; Copy-to-buffer doesn't copy overlay. So redo
7568 (let ((gnus-article-buffer buffer))
7569 (gnus-article-highlight-citation t)
7570 (gnus-article-highlight-signature)))
7571 (let ((ps-left-header
7574 (mail-header-subject gnus-current-headers) ")")
7576 (mail-header-from gnus-current-headers) ")")))
7579 "/pagenumberstring load"
7581 (mail-header-date gnus-current-headers) ")"))))
7582 (gnus-run-hooks 'gnus-ps-print-hook)
7585 (ps-spool-buffer-with-faces)
7586 (ps-spool-buffer)))))
7587 (kill-buffer buffer))))
7588 (gnus-summary-remove-process-mark article))
7589 (ps-despool filename))
7591 (defun gnus-summary-show-article (&optional arg)
7592 "Force re-fetching of the current article.
7593 If ARG (the prefix) is a number, show the article with the charset
7594 defined in `gnus-summary-show-article-charset-alist', or the charset
7596 If ARG (the prefix) is non-nil and not a number, show the raw article
7597 without any article massaging functions being run."
7601 (let ((gnus-newsgroup-charset
7602 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
7603 (read-coding-system "Charset: ")))
7604 (gnus-newsgroup-ignored-charsets 'gnus-all))
7605 (gnus-summary-select-article nil 'force)
7606 (let ((deps gnus-newsgroup-dependencies)
7609 (set-buffer gnus-original-article-buffer)
7611 (message-narrow-to-head)
7612 (setq head (buffer-string)))
7614 (insert (format "211 %d Article retrieved.\n"
7615 (cdr gnus-article-current)))
7618 (let ((nntp-server-buffer (current-buffer)))
7619 (setq header (car (gnus-get-newsgroup-headers deps t))))))
7620 (gnus-data-set-header
7621 (gnus-data-find (cdr gnus-article-current))
7623 (gnus-summary-update-article-line
7624 (cdr gnus-article-current) header))))
7626 ;; Select the article the normal way.
7627 (gnus-summary-select-article nil 'force))
7629 ;; We have to require this here to make sure that the following
7630 ;; dynamic binding isn't shadowed by autoloading.
7631 (require 'gnus-async)
7633 ;; Bind the article treatment functions to nil.
7634 (let ((gnus-have-all-headers t)
7635 gnus-article-prepare-hook
7636 gnus-article-decode-hook
7637 gnus-display-mime-function
7639 ;; Destroy any MIME parts.
7640 (when (gnus-buffer-live-p gnus-article-buffer)
7642 (set-buffer gnus-article-buffer)
7643 (mm-destroy-parts gnus-article-mime-handles)
7644 ;; Set it to nil for safety reason.
7645 (setq gnus-article-mime-handle-alist nil)
7646 (setq gnus-article-mime-handles nil)))
7647 (gnus-summary-select-article nil 'force))))
7648 (gnus-summary-goto-subject gnus-current-article)
7649 (gnus-summary-position-point))
7651 (defun gnus-summary-show-raw-article ()
7652 "Show the raw article without any article massaging functions being run."
7654 (gnus-summary-show-article t))
7656 (defun gnus-summary-verbose-headers (&optional arg)
7657 "Toggle permanent full header display.
7658 If ARG is a positive number, turn header display on.
7659 If ARG is a negative number, turn header display off."
7661 (setq gnus-show-all-headers
7662 (cond ((or (not (numberp arg))
7664 (not gnus-show-all-headers))
7667 (gnus-summary-show-article))
7669 (defun gnus-summary-toggle-header (&optional arg)
7670 "Show the headers if they are hidden, or hide them if they are shown.
7671 If ARG is a positive number, show the entire header.
7672 If ARG is a negative number, hide the unwanted header lines."
7675 (set-buffer gnus-article-buffer)
7677 (let* ((buffer-read-only nil)
7678 (inhibit-point-motion-hooks t)
7684 (article-narrow-to-head)
7685 (gnus-article-hidden-text-p 'headers))))
7686 (goto-char (point-min))
7687 (when (search-forward "\n\n" nil t)
7688 (delete-region (point-min) (1- (point))))
7689 (goto-char (point-min))
7691 (set-buffer gnus-original-article-buffer)
7692 (goto-char (point-min))
7693 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
7694 (insert-buffer-substring gnus-original-article-buffer 1 e)
7696 (narrow-to-region (point-min) (point))
7697 (article-decode-encoded-words)
7699 (let ((gnus-treat-hide-headers nil)
7700 (gnus-treat-hide-boring-headers nil))
7701 (setq gnus-article-wash-types
7702 (delq 'headers gnus-article-wash-types))
7703 (gnus-treat-article 'head))
7704 (gnus-treat-article 'head)))
7705 (gnus-set-mode-line 'article)))))
7707 (defun gnus-summary-show-all-headers ()
7708 "Make all header lines visible."
7710 (gnus-summary-toggle-header 1))
7712 (defun gnus-summary-caesar-message (&optional arg)
7713 "Caesar rotate the current article by 13.
7714 The numerical prefix specifies how many places to rotate each letter
7717 (gnus-summary-select-article)
7718 (let ((mail-header-separator ""))
7719 (gnus-eval-in-buffer-window gnus-article-buffer
7722 (let ((start (window-start))
7724 (message-caesar-buffer-body arg)
7725 (set-window-start (get-buffer-window (current-buffer)) start))))))
7727 (defun gnus-summary-stop-page-breaking ()
7728 "Stop page breaking in the current article."
7730 (gnus-summary-select-article)
7731 (gnus-eval-in-buffer-window gnus-article-buffer
7733 (when (gnus-visual-p 'page-marker)
7734 (let ((buffer-read-only nil))
7735 (gnus-remove-text-with-property 'gnus-prev)
7736 (gnus-remove-text-with-property 'gnus-next))
7737 (setq gnus-page-broken nil))))
7739 (defun gnus-summary-move-article (&optional n to-newsgroup
7740 select-method action)
7741 "Move the current article to a different newsgroup.
7742 If N is a positive number, move the N next articles.
7743 If N is a negative number, move the N previous articles.
7744 If N is nil and any articles have been marked with the process mark,
7745 move those articles instead.
7746 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7747 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7748 re-spool using this method.
7750 For this function to work, both the current newsgroup and the
7751 newsgroup that you want to move to have to support the `request-move'
7752 and `request-accept' functions.
7754 ACTION can be either `move' (the default), `crosspost' or `copy'."
7757 (setq action 'move))
7758 ;; Disable marking as read.
7759 (let (gnus-mark-article-hook)
7760 (save-window-excursion
7761 (gnus-summary-select-article)))
7762 ;; Check whether the source group supports the required functions.
7763 (cond ((and (eq action 'move)
7764 (not (gnus-check-backend-function
7765 'request-move-article gnus-newsgroup-name)))
7766 (error "The current group does not support article moving"))
7767 ((and (eq action 'crosspost)
7768 (not (gnus-check-backend-function
7769 'request-replace-article gnus-newsgroup-name)))
7770 (error "The current group does not support article editing")))
7771 (let ((articles (gnus-summary-work-articles n))
7772 (prefix (if (gnus-check-backend-function
7773 'request-move-article gnus-newsgroup-name)
7774 (gnus-group-real-prefix gnus-newsgroup-name)
7776 (names '((move "Move" "Moving")
7777 (copy "Copy" "Copying")
7778 (crosspost "Crosspost" "Crossposting")))
7779 (copy-buf (save-excursion
7780 (nnheader-set-temp-buffer " *copy article*")))
7781 art-group to-method new-xref article to-groups)
7782 (unless (assq action names)
7783 (error "Unknown action %s" action))
7784 ;; Read the newsgroup name.
7785 (when (and (not to-newsgroup)
7786 (not select-method))
7788 (gnus-read-move-group-name
7789 (cadr (assq action names))
7790 (symbol-value (intern (format "gnus-current-%s-group" action)))
7792 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
7793 (setq to-method (or select-method
7794 (gnus-server-to-method
7795 (gnus-group-method to-newsgroup))))
7796 ;; Check the method we are to move this article to...
7797 (unless (gnus-check-backend-function
7798 'request-accept-article (car to-method))
7799 (error "%s does not support article copying" (car to-method)))
7800 (unless (gnus-check-server to-method)
7801 (error "Can't open server %s" (car to-method)))
7802 (gnus-message 6 "%s to %s: %s..."
7803 (caddr (assq action names))
7804 (or (car select-method) to-newsgroup) articles)
7806 (setq article (pop articles))
7810 ;; Move the article.
7812 ;; Remove this article from future suppression.
7813 (gnus-dup-unsuppress-article article)
7814 (gnus-request-move-article
7815 article ; Article to move
7816 gnus-newsgroup-name ; From newsgroup
7817 (nth 1 (gnus-find-method-for-group
7818 gnus-newsgroup-name)) ; Server
7819 (list 'gnus-request-accept-article
7820 to-newsgroup (list 'quote select-method)
7821 (not articles) t) ; Accept form
7822 (not articles))) ; Only save nov last time
7823 ;; Copy the article.
7826 (set-buffer copy-buf)
7827 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
7828 (gnus-request-accept-article
7829 to-newsgroup select-method (not articles) t))))
7830 ;; Crosspost the article.
7831 ((eq action 'crosspost)
7832 (let ((xref (message-tokenize-header
7833 (mail-header-xref (gnus-summary-article-header article))
7835 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
7838 (setq xref (list (system-name))))
7841 (mapconcat 'identity
7842 (delete "Xref:" (delete new-xref xref))
7846 (set-buffer copy-buf)
7847 ;; First put the article in the destination group.
7848 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7849 (when (consp (setq art-group
7850 (gnus-request-accept-article
7851 to-newsgroup select-method (not articles))))
7852 (setq new-xref (concat new-xref " " (car art-group)
7853 ":" (cdr art-group)))
7854 ;; Now we have the new Xrefs header, so we insert
7855 ;; it and replace the new article.
7856 (nnheader-replace-header "Xref" new-xref)
7857 (gnus-request-replace-article
7858 (cdr art-group) to-newsgroup (current-buffer))
7862 (gnus-message 1 "Couldn't %s article %s: %s"
7863 (cadr (assq action names)) article
7864 (nnheader-get-report (car to-method))))
7865 ((eq art-group 'junk)
7866 (when (eq action 'move)
7867 (gnus-summary-mark-article article gnus-canceled-mark)
7868 (gnus-message 4 "Deleted article %s" article)))
7870 (let* ((pto-group (gnus-group-prefixed-name
7871 (car art-group) to-method))
7873 (gnus-gethash pto-group gnus-newsrc-hashtb))
7874 (info (nth 2 entry))
7875 (to-group (gnus-info-group info))
7877 ;; Update the group that has been moved to.
7879 (memq action '(move copy)))
7880 (unless (member to-group to-groups)
7881 (push to-group to-groups))
7883 (unless (memq article gnus-newsgroup-unreads)
7884 (push 'read to-marks)
7886 info (gnus-add-to-range (gnus-info-read info)
7887 (list (cdr art-group)))))
7889 ;; See whether the article is to be put in the cache.
7890 (let ((marks gnus-article-mark-lists)
7891 (to-article (cdr art-group)))
7893 ;; Enter the article into the cache in the new group,
7894 ;; if that is required.
7895 (when gnus-use-cache
7896 (gnus-cache-possibly-enter-article
7898 (memq article gnus-newsgroup-marked)
7899 (memq article gnus-newsgroup-dormant)
7900 (memq article gnus-newsgroup-unreads)))
7902 (when gnus-preserve-marks
7903 ;; Copy any marks over to the new group.
7904 (when (and (equal to-group gnus-newsgroup-name)
7905 (not (memq article gnus-newsgroup-unreads)))
7906 ;; Mark this article as read in this group.
7907 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
7908 (setcdr (gnus-active to-group) to-article)
7909 (setcdr gnus-newsgroup-active to-article))
7912 (when (memq article (symbol-value
7913 (intern (format "gnus-newsgroup-%s"
7915 (push (cdar marks) to-marks)
7916 ;; If the other group is the same as this group,
7917 ;; then we have to add the mark to the list.
7918 (when (equal to-group gnus-newsgroup-name)
7919 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
7922 (intern (format "gnus-newsgroup-%s"
7924 ;; Copy the marks to other group.
7925 (gnus-add-marked-articles
7926 to-group (cdar marks) (list to-article) info))
7927 (setq marks (cdr marks)))
7929 (gnus-request-set-mark to-group (list (list (list to-article)
7934 (concat "(gnus-group-set-info '"
7935 (gnus-prin1-to-string (gnus-get-info to-group))
7938 ;; Update the Xref header in this article to point to
7939 ;; the new crossposted article we have just created.
7940 (when (eq action 'crosspost)
7942 (set-buffer copy-buf)
7943 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7944 (nnheader-replace-header "Xref" new-xref)
7945 (gnus-request-replace-article
7946 article gnus-newsgroup-name (current-buffer)))))
7948 ;;;!!!Why is this necessary?
7949 (set-buffer gnus-summary-buffer)
7951 (gnus-summary-goto-subject article)
7952 (when (eq action 'move)
7953 (gnus-summary-mark-article article gnus-canceled-mark))))
7954 (gnus-summary-remove-process-mark article))
7955 ;; Re-activate all groups that have been moved to.
7958 (set-buffer gnus-group-buffer)
7959 (when (gnus-group-goto-group (car to-groups) t)
7960 (gnus-group-get-new-news-this-group 1 t))
7963 (gnus-kill-buffer copy-buf)
7964 (gnus-summary-position-point)
7965 (gnus-set-mode-line 'summary)))
7967 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
7968 "Move the current article to a different newsgroup.
7969 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7970 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7971 re-spool using this method."
7973 (gnus-summary-move-article n to-newsgroup select-method 'copy))
7975 (defun gnus-summary-crosspost-article (&optional n)
7976 "Crosspost the current article to some other group."
7978 (gnus-summary-move-article n nil nil 'crosspost))
7980 (defcustom gnus-summary-respool-default-method nil
7981 "Default method for respooling an article.
7982 If nil, use to the current newsgroup method."
7983 :type '(choice (gnus-select-method :value (nnml ""))
7985 :group 'gnus-summary-mail)
7987 (defun gnus-summary-respool-article (&optional n method)
7988 "Respool the current article.
7989 The article will be squeezed through the mail spooling process again,
7990 which means that it will be put in some mail newsgroup or other
7991 depending on `nnmail-split-methods'.
7992 If N is a positive number, respool the N next articles.
7993 If N is a negative number, respool the N previous articles.
7994 If N is nil and any articles have been marked with the process mark,
7995 respool those articles instead.
7997 Respooling can be done both from mail groups and \"real\" newsgroups.
7998 In the former case, the articles in question will be moved from the
7999 current group into whatever groups they are destined to. In the
8000 latter case, they will be copied into the relevant groups."
8002 (list current-prefix-arg
8003 (let* ((methods (gnus-methods-using 'respool))
8005 (symbol-name (or gnus-summary-respool-default-method
8006 (car (gnus-find-method-for-group
8007 gnus-newsgroup-name)))))
8009 (gnus-completing-read
8010 methname "What backend do you want to use when respooling?"
8011 methods nil t nil 'gnus-mail-method-history))
8014 ((zerop (length (setq ms (gnus-servers-using-backend
8016 (list (intern method) ""))
8020 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
8021 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
8024 (error "No method given for respooling"))
8025 (if (assoc (symbol-name
8026 (car (gnus-find-method-for-group gnus-newsgroup-name)))
8027 (gnus-methods-using 'respool))
8028 (gnus-summary-move-article n nil method)
8029 (gnus-summary-copy-article n nil method)))
8031 (defun gnus-summary-import-article (file &optional edit)
8032 "Import an arbitrary file into a mail newsgroup."
8033 (interactive "fImport file: \nP")
8034 (let ((group gnus-newsgroup-name)
8035 (now (current-time))
8036 atts lines group-art)
8037 (unless (gnus-check-backend-function 'request-accept-article group)
8038 (error "%s does not support article importing" group))
8039 (or (file-readable-p file)
8040 (not (file-regular-p file))
8041 (error "Can't read %s" file))
8043 (set-buffer (gnus-get-buffer-create " *import file*"))
8045 (nnheader-insert-file-contents file)
8046 (goto-char (point-min))
8047 (unless (nnheader-article-p)
8048 ;; This doesn't look like an article, so we fudge some headers.
8049 (setq atts (file-attributes file)
8050 lines (count-lines (point-min) (point-max)))
8051 (insert "From: " (read-string "From: ") "\n"
8052 "Subject: " (read-string "Subject: ") "\n"
8053 "Date: " (message-make-date (nth 5 atts)) "\n"
8054 "Message-ID: " (message-make-message-id) "\n"
8055 "Lines: " (int-to-string lines) "\n"
8056 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
8057 (setq group-art (gnus-request-accept-article group nil t))
8058 (kill-buffer (current-buffer)))
8059 (setq gnus-newsgroup-active (gnus-activate-group group))
8061 (gnus-summary-goto-article (cdr group-art) nil t)
8063 (gnus-summary-edit-article))))
8065 (defun gnus-summary-create-article ()
8066 "Create an article in a mail newsgroup."
8068 (let ((group gnus-newsgroup-name)
8069 (now (current-time))
8071 (unless (gnus-check-backend-function 'request-accept-article group)
8072 (error "%s does not support article importing" group))
8074 (set-buffer (gnus-get-buffer-create " *import file*"))
8076 (goto-char (point-min))
8077 ;; This doesn't look like an article, so we fudge some headers.
8078 (insert "From: " (read-string "From: ") "\n"
8079 "Subject: " (read-string "Subject: ") "\n"
8080 "Date: " (message-make-date now) "\n"
8081 "Message-ID: " (message-make-message-id) "\n")
8082 (setq group-art (gnus-request-accept-article group nil t))
8083 (kill-buffer (current-buffer)))
8084 (setq gnus-newsgroup-active (gnus-activate-group group))
8086 (gnus-summary-goto-article (cdr group-art) nil t)
8087 (gnus-summary-edit-article)))
8089 (defun gnus-summary-article-posted-p ()
8090 "Say whether the current (mail) article is available from news as well.
8091 This will be the case if the article has both been mailed and posted."
8093 (let ((id (mail-header-references (gnus-summary-article-header)))
8094 (gnus-override-method (car (gnus-refer-article-methods))))
8095 (if (gnus-request-head id "")
8096 (gnus-message 2 "The current message was found on %s"
8097 gnus-override-method)
8098 (gnus-message 2 "The current message couldn't be found on %s"
8099 gnus-override-method)
8102 (defun gnus-summary-expire-articles (&optional now)
8103 "Expire all articles that are marked as expirable in the current group."
8105 (when (gnus-check-backend-function
8106 'request-expire-articles gnus-newsgroup-name)
8107 ;; This backend supports expiry.
8108 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
8109 (expirable (if total
8111 ;; We need to update the info for
8112 ;; this group for `gnus-list-of-read-articles'
8113 ;; to give us the right answer.
8114 (gnus-run-hooks 'gnus-exit-group-hook)
8115 (gnus-summary-update-info)
8116 (gnus-list-of-read-articles gnus-newsgroup-name))
8117 (setq gnus-newsgroup-expirable
8118 (sort gnus-newsgroup-expirable '<))))
8119 (expiry-wait (if now 'immediate
8120 (gnus-group-find-parameter
8121 gnus-newsgroup-name 'expiry-wait)))
8122 (nnmail-expiry-target
8123 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
8124 nnmail-expiry-target))
8127 ;; There are expirable articles in this group, so we run them
8128 ;; through the expiry process.
8129 (gnus-message 6 "Expiring articles...")
8130 (unless (gnus-check-group gnus-newsgroup-name)
8131 (error "Can't open server for %s" gnus-newsgroup-name))
8132 ;; The list of articles that weren't expired is returned.
8135 (let ((nnmail-expiry-wait-function nil)
8136 (nnmail-expiry-wait expiry-wait))
8137 (setq es (gnus-request-expire-articles
8138 expirable gnus-newsgroup-name)))
8139 (setq es (gnus-request-expire-articles
8140 expirable gnus-newsgroup-name)))
8142 (setq gnus-newsgroup-expirable es))
8143 ;; We go through the old list of expirable, and mark all
8144 ;; really expired articles as nonexistent.
8145 (unless (eq es expirable) ;If nothing was expired, we don't mark.
8146 (let ((gnus-use-cache nil))
8148 (unless (memq (car expirable) es)
8149 (when (gnus-data-find (car expirable))
8150 (gnus-summary-mark-article
8151 (car expirable) gnus-canceled-mark)))
8152 (setq expirable (cdr expirable))))))
8153 (gnus-message 6 "Expiring articles...done")))))
8155 (defun gnus-summary-expire-articles-now ()
8156 "Expunge all expirable articles in the current group.
8157 This means that *all* articles that are marked as expirable will be
8158 deleted forever, right now."
8160 (or gnus-expert-user
8162 "Are you really, really, really sure you want to delete all these messages? ")
8164 (gnus-summary-expire-articles t))
8166 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
8167 (defun gnus-summary-delete-article (&optional n)
8168 "Delete the N next (mail) articles.
8169 This command actually deletes articles. This is not a marking
8170 command. The article will disappear forever from your life, never to
8172 If N is negative, delete backwards.
8173 If N is nil and articles have been marked with the process mark,
8174 delete these instead."
8176 (unless (gnus-check-backend-function 'request-expire-articles
8177 gnus-newsgroup-name)
8178 (error "The current newsgroup does not support article deletion"))
8179 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
8180 (error "Couldn't open server"))
8181 ;; Compute the list of articles to delete.
8182 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
8184 (if (and gnus-novice-user
8185 (not (gnus-yes-or-no-p
8186 (format "Do you really want to delete %s forever? "
8187 (if (> (length articles) 1)
8188 (format "these %s articles" (length articles))
8191 ;; Delete the articles.
8192 (setq not-deleted (gnus-request-expire-articles
8193 articles gnus-newsgroup-name 'force))
8195 (gnus-summary-remove-process-mark (car articles))
8196 ;; The backend might not have been able to delete the article
8198 (unless (memq (car articles) not-deleted)
8199 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
8200 (setq articles (cdr articles)))
8202 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
8203 (gnus-summary-position-point)
8204 (gnus-set-mode-line 'summary)
8207 (defun gnus-summary-edit-article (&optional arg)
8208 "Edit the current article.
8209 This will have permanent effect only in mail groups.
8210 If ARG is nil, edit the decoded articles.
8211 If ARG is 1, edit the raw articles.
8212 If ARG is 2, edit the raw articles even in read-only groups.
8213 If ARG is 3, edit the articles with the current handles.
8214 Otherwise, allow editing of articles even in read-only
8217 (let (force raw current-handles)
8220 ((eq arg 1) (setq raw t))
8221 ((eq arg 2) (setq raw t
8223 ((eq arg 3) (setq current-handles
8224 (and (gnus-buffer-live-p gnus-article-buffer)
8225 (with-current-buffer gnus-article-buffer
8227 gnus-article-mime-handles
8228 (setq gnus-article-mime-handles nil))))))
8230 (if (and raw (not force) (equal gnus-newsgroup-name "nndraft:drafts"))
8231 (error "Can't edit the raw article in group nndraft:drafts"))
8233 (set-buffer gnus-summary-buffer)
8234 (let ((mail-parse-charset gnus-newsgroup-charset)
8235 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
8236 (gnus-set-global-variables)
8237 (when (and (not force)
8238 (gnus-group-read-only-p))
8239 (error "The current newsgroup does not support article editing"))
8240 (gnus-summary-show-article t)
8241 (when (and (not raw) (gnus-buffer-live-p gnus-article-buffer))
8242 (with-current-buffer gnus-article-buffer
8243 (mm-enable-multibyte-mule4)))
8244 (if (equal gnus-newsgroup-name "nndraft:drafts")
8246 (gnus-article-edit-article
8249 (let ((mbl mml-buffer-list))
8250 (setq mml-buffer-list nil)
8251 (mime-to-mml ,'current-handles)
8252 (make-local-hook 'kill-buffer-hook)
8253 (let ((mbl1 mml-buffer-list))
8254 (setq mml-buffer-list mbl)
8255 (set (make-local-variable 'mml-buffer-list) mbl1))
8256 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))))
8257 `(lambda (no-highlight)
8258 (let ((mail-parse-charset ',gnus-newsgroup-charset)
8259 (message-options message-options)
8260 (message-options-set-recipient)
8261 (mail-parse-ignored-charsets
8262 ',gnus-newsgroup-ignored-charsets))
8263 ,(if (not raw) '(progn
8265 (mml-destroy-buffers)
8266 (remove-hook 'kill-buffer-hook
8267 'mml-destroy-buffers t)
8268 (kill-local-variable 'mml-buffer-list)))
8269 (gnus-summary-edit-article-done
8270 ,(or (mail-header-references gnus-current-headers) "")
8271 ,(gnus-group-read-only-p)
8272 ,gnus-summary-buffer no-highlight))))))))
8274 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
8276 (defun gnus-summary-edit-article-done (&optional references read-only buffer
8278 "Make edits to the current article permanent."
8281 ;; The buffer restriction contains the entire article if it exists.
8282 (when (article-goto-body)
8283 (let ((lines (count-lines (point) (point-max)))
8284 (length (- (point-max) (point)))
8285 (case-fold-search t)
8286 (body (copy-marker (point))))
8287 (goto-char (point-min))
8288 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
8289 (delete-region (match-beginning 1) (match-end 1))
8290 (insert (number-to-string length)))
8291 (goto-char (point-min))
8292 (when (re-search-forward
8293 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
8294 (delete-region (match-beginning 1) (match-end 1))
8295 (insert (number-to-string length)))
8296 (goto-char (point-min))
8297 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
8298 (delete-region (match-beginning 1) (match-end 1))
8299 (insert (number-to-string lines))))))
8300 ;; Replace the article.
8301 (let ((buf (current-buffer)))
8303 (insert-buffer-substring buf)
8305 (if (and (not read-only)
8306 (not (gnus-request-replace-article
8307 (cdr gnus-article-current) (car gnus-article-current)
8308 (current-buffer) t)))
8309 (error "Couldn't replace article")
8310 ;; Update the summary buffer.
8312 (equal (message-tokenize-header references " ")
8313 (message-tokenize-header
8314 (or (message-fetch-field "references") "") " ")))
8315 ;; We only have to update this line.
8318 (message-narrow-to-head)
8319 (let ((head (buffer-string))
8322 (insert (format "211 %d Article retrieved.\n"
8323 (cdr gnus-article-current)))
8326 (let ((nntp-server-buffer (current-buffer)))
8327 (setq header (car (gnus-get-newsgroup-headers
8329 (set-buffer gnus-summary-buffer)
8330 gnus-newsgroup-dependencies)
8333 (set-buffer gnus-summary-buffer)
8334 (gnus-data-set-header
8335 (gnus-data-find (cdr gnus-article-current))
8337 (gnus-summary-update-article-line
8338 (cdr gnus-article-current) header))))))
8340 (set-buffer (or buffer gnus-summary-buffer))
8341 (gnus-summary-update-article (cdr gnus-article-current)))
8342 ;; Prettify the article buffer again.
8343 (unless no-highlight
8345 (set-buffer gnus-article-buffer)
8346 ;;;!!! Fix this -- article should be rehighlighted.
8347 ;;;(gnus-run-hooks 'gnus-article-display-hook)
8348 (set-buffer gnus-original-article-buffer)
8349 (gnus-request-article
8350 (cdr gnus-article-current)
8351 (car gnus-article-current) (current-buffer))))
8352 ;; Prettify the summary buffer line.
8353 (when (gnus-visual-p 'summary-highlight 'highlight)
8354 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
8356 (defun gnus-summary-edit-wash (key)
8357 "Perform editing command KEY in the article buffer."
8361 (message "%s" (concat (this-command-keys) "- "))
8364 (gnus-summary-edit-article)
8365 (execute-kbd-macro (concat (this-command-keys) key))
8366 (gnus-article-edit-done))
8370 (defun gnus-summary-respool-query (&optional silent trace)
8371 "Query where the respool algorithm would put this article."
8373 (let (gnus-mark-article-hook)
8374 (gnus-summary-select-article)
8376 (set-buffer gnus-original-article-buffer)
8378 (message-narrow-to-head)
8379 (let ((groups (nnmail-article-group 'identity trace)))
8382 (message "This message would go to %s"
8383 (mapconcat 'car groups ", "))
8384 (message "This message would go to no groups"))
8387 (defun gnus-summary-respool-trace ()
8388 "Trace where the respool algorithm would put this article.
8389 Display a buffer showing all fancy splitting patterns which matched."
8391 (gnus-summary-respool-query nil t))
8393 ;; Summary marking commands.
8395 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
8396 "Mark articles which has the same subject as read, and then select the next.
8397 If UNMARK is positive, remove any kind of mark.
8398 If UNMARK is negative, tick articles."
8401 (setq unmark (prefix-numeric-value unmark)))
8403 (gnus-summary-mark-same-subject
8404 (gnus-summary-article-subject) unmark)))
8405 ;; Select next unread article. If auto-select-same mode, should
8406 ;; select the first unread article.
8407 (gnus-summary-next-article t (and gnus-auto-select-same
8408 (gnus-summary-article-subject)))
8409 (gnus-message 7 "%d article%s marked as %s"
8410 count (if (= count 1) " is" "s are")
8411 (if unmark "unread" "read"))))
8413 (defun gnus-summary-kill-same-subject (&optional unmark)
8414 "Mark articles which has the same subject as read.
8415 If UNMARK is positive, remove any kind of mark.
8416 If UNMARK is negative, tick articles."
8419 (setq unmark (prefix-numeric-value unmark)))
8421 (gnus-summary-mark-same-subject
8422 (gnus-summary-article-subject) unmark)))
8423 ;; If marked as read, go to next unread subject.
8425 ;; Go to next unread subject.
8426 (gnus-summary-next-subject 1 t))
8427 (gnus-message 7 "%d articles are marked as %s"
8428 count (if unmark "unread" "read"))))
8430 (defun gnus-summary-mark-same-subject (subject &optional unmark)
8431 "Mark articles with same SUBJECT as read, and return marked number.
8432 If optional argument UNMARK is positive, remove any kinds of marks.
8433 If optional argument UNMARK is negative, mark articles as unread instead."
8437 ((null unmark) ; Mark as read.
8440 (gnus-summary-mark-article-as-read gnus-killed-mark)
8441 (gnus-summary-show-thread) t)
8442 (gnus-summary-find-subject subject))
8443 (setq count (1+ count))))
8444 ((> unmark 0) ; Tick.
8447 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
8448 (gnus-summary-show-thread) t)
8449 (gnus-summary-find-subject subject))
8450 (setq count (1+ count))))
8451 (t ; Mark as unread.
8454 (gnus-summary-mark-article-as-unread gnus-unread-mark)
8455 (gnus-summary-show-thread) t)
8456 (gnus-summary-find-subject subject))
8457 (setq count (1+ count)))))
8458 (gnus-set-mode-line 'summary)
8459 ;; Return the number of marked articles.
8462 (defun gnus-summary-mark-as-processable (n &optional unmark)
8463 "Set the process mark on the next N articles.
8464 If N is negative, mark backward instead. If UNMARK is non-nil, remove
8465 the process mark instead. The difference between N and the actual
8466 number of articles marked is returned."
8468 (if (and (null n) (gnus-region-active-p))
8469 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
8470 (setq n (prefix-numeric-value n))
8471 (let ((backward (< n 0))
8476 (gnus-summary-remove-process-mark
8477 (gnus-summary-article-number))
8478 (gnus-summary-set-process-mark (gnus-summary-article-number)))
8479 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
8482 (gnus-message 7 "No more articles"))
8483 (gnus-summary-recenter)
8484 (gnus-summary-position-point)
8487 (defun gnus-summary-unmark-as-processable (n)
8488 "Remove the process mark from the next N articles.
8489 If N is negative, unmark backward instead. The difference between N and
8490 the actual number of articles unmarked is returned."
8492 (gnus-summary-mark-as-processable n t))
8494 (defun gnus-summary-unmark-all-processable ()
8495 "Remove the process mark from all articles."
8498 (while gnus-newsgroup-processable
8499 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
8500 (gnus-summary-position-point))
8502 (defun gnus-summary-add-mark (article type)
8503 "Mark ARTICLE with a mark of TYPE."
8504 (let ((vtype (car (assq type gnus-article-mark-lists)))
8507 (error "No such mark type: %s" type)
8508 (setq var (intern (format "gnus-newsgroup-%s" type)))
8509 (set var (cons article (symbol-value var)))
8510 (if (memq type '(processable cached replied forwarded saved))
8511 (gnus-summary-update-secondary-mark article)
8512 ;;; !!! This is bobus. We should find out what primary
8513 ;;; !!! mark we want to set.
8514 (gnus-summary-update-mark gnus-del-mark 'unread)))))
8516 (defun gnus-summary-mark-as-expirable (n)
8517 "Mark N articles forward as expirable.
8518 If N is negative, mark backward instead. The difference between N and
8519 the actual number of articles marked is returned."
8521 (gnus-summary-mark-forward n gnus-expirable-mark))
8523 (defun gnus-summary-mark-article-as-replied (article)
8524 "Mark ARTICLE as replied to and update the summary line.
8525 ARTICLE can also be a list of articles."
8526 (interactive (list (gnus-summary-article-number)))
8527 (let ((articles (if (listp article) article (list article))))
8528 (dolist (article articles)
8529 (push article gnus-newsgroup-replied)
8530 (let ((buffer-read-only nil))
8531 (when (gnus-summary-goto-subject article nil t)
8532 (gnus-summary-update-secondary-mark article))))))
8534 (defun gnus-summary-mark-article-as-forwarded (article)
8535 "Mark ARTICLE as forwarded and update the summary line.
8536 ARTICLE can also be a list of articles."
8537 (let ((articles (if (listp article) article (list article))))
8538 (dolist (article articles)
8539 (push article gnus-newsgroup-forwarded)
8540 (let ((buffer-read-only nil))
8541 (when (gnus-summary-goto-subject article nil t)
8542 (gnus-summary-update-secondary-mark article))))))
8544 (defun gnus-summary-set-bookmark (article)
8545 "Set a bookmark in current article."
8546 (interactive (list (gnus-summary-article-number)))
8547 (when (or (not (get-buffer gnus-article-buffer))
8548 (not gnus-current-article)
8549 (not gnus-article-current)
8550 (not (equal gnus-newsgroup-name (car gnus-article-current))))
8551 (error "No current article selected"))
8552 ;; Remove old bookmark, if one exists.
8553 (let ((old (assq article gnus-newsgroup-bookmarks)))
8555 (setq gnus-newsgroup-bookmarks
8556 (delq old gnus-newsgroup-bookmarks))))
8557 ;; Set the new bookmark, which is on the form
8558 ;; (article-number . line-number-in-body).
8562 (set-buffer gnus-article-buffer)
8566 (goto-char (point-min))
8567 (search-forward "\n\n" nil t)
8570 gnus-newsgroup-bookmarks)
8571 (gnus-message 6 "A bookmark has been added to the current article."))
8573 (defun gnus-summary-remove-bookmark (article)
8574 "Remove the bookmark from the current article."
8575 (interactive (list (gnus-summary-article-number)))
8576 ;; Remove old bookmark, if one exists.
8577 (let ((old (assq article gnus-newsgroup-bookmarks)))
8580 (setq gnus-newsgroup-bookmarks
8581 (delq old gnus-newsgroup-bookmarks))
8582 (gnus-message 6 "Removed bookmark."))
8583 (gnus-message 6 "No bookmark in current article."))))
8585 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8586 (defun gnus-summary-mark-as-dormant (n)
8587 "Mark N articles forward as dormant.
8588 If N is negative, mark backward instead. The difference between N and
8589 the actual number of articles marked is returned."
8591 (gnus-summary-mark-forward n gnus-dormant-mark))
8593 (defun gnus-summary-set-process-mark (article)
8594 "Set the process mark on ARTICLE and update the summary line."
8595 (setq gnus-newsgroup-processable
8597 (delq article gnus-newsgroup-processable)))
8598 (when (gnus-summary-goto-subject article)
8599 (gnus-summary-show-thread)
8600 (gnus-summary-goto-subject article)
8601 (gnus-summary-update-secondary-mark article)))
8603 (defun gnus-summary-remove-process-mark (article)
8604 "Remove the process mark from ARTICLE and update the summary line."
8605 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
8606 (when (gnus-summary-goto-subject article)
8607 (gnus-summary-show-thread)
8608 (gnus-summary-goto-subject article)
8609 (gnus-summary-update-secondary-mark article)))
8611 (defun gnus-summary-set-saved-mark (article)
8612 "Set the process mark on ARTICLE and update the summary line."
8613 (push article gnus-newsgroup-saved)
8614 (when (gnus-summary-goto-subject article)
8615 (gnus-summary-update-secondary-mark article)))
8617 (defun gnus-summary-mark-forward (n &optional mark no-expire)
8618 "Mark N articles as read forwards.
8619 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
8620 The difference between N and the actual number of articles marked is
8622 Iff NO-EXPIRE, auto-expiry will be inhibited."
8624 (gnus-summary-show-thread)
8625 (let ((backward (< n 0))
8626 (gnus-summary-goto-unread
8627 (and gnus-summary-goto-unread
8628 (not (eq gnus-summary-goto-unread 'never))
8629 (not (memq mark (list gnus-unread-mark
8630 gnus-ticked-mark gnus-dormant-mark)))))
8632 (mark (or mark gnus-del-mark)))
8634 (gnus-summary-mark-article nil mark no-expire)
8635 (zerop (gnus-summary-next-subject
8637 (and gnus-summary-goto-unread
8638 (not (eq gnus-summary-goto-unread 'never)))
8642 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
8643 (gnus-summary-recenter)
8644 (gnus-summary-position-point)
8645 (gnus-set-mode-line 'summary)
8648 (defun gnus-summary-mark-article-as-read (mark)
8649 "Mark the current article quickly as read with MARK."
8650 (let ((article (gnus-summary-article-number)))
8651 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8652 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8653 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8654 (push (cons article mark) gnus-newsgroup-reads)
8655 ;; Possibly remove from cache, if that is used.
8656 (when gnus-use-cache
8657 (gnus-cache-enter-remove-article article))
8658 ;; Allow the backend to change the mark.
8659 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8660 ;; Check for auto-expiry.
8661 (when (and gnus-newsgroup-auto-expire
8662 (memq mark gnus-auto-expirable-marks))
8663 (setq mark gnus-expirable-mark)
8664 ;; Let the backend know about the mark change.
8665 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8666 (push article gnus-newsgroup-expirable))
8667 ;; Set the mark in the buffer.
8668 (gnus-summary-update-mark mark 'unread)
8671 (defun gnus-summary-mark-article-as-unread (mark)
8672 "Mark the current article quickly as unread with MARK."
8673 (let* ((article (gnus-summary-article-number))
8674 (old-mark (gnus-summary-article-mark article)))
8675 ;; Allow the backend to change the mark.
8676 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8677 (if (eq mark old-mark)
8681 (gnus-error 1 "Can't mark negative article numbers")
8683 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8684 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8685 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
8686 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
8687 (cond ((= mark gnus-ticked-mark)
8688 (push article gnus-newsgroup-marked))
8689 ((= mark gnus-dormant-mark)
8690 (push article gnus-newsgroup-dormant))
8692 (push article gnus-newsgroup-unreads)))
8693 (gnus-pull article gnus-newsgroup-reads)
8695 ;; See whether the article is to be put in the cache.
8697 (vectorp (gnus-summary-article-header article))
8699 (gnus-cache-possibly-enter-article
8700 gnus-newsgroup-name article
8701 (= mark gnus-ticked-mark)
8702 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
8705 (gnus-summary-update-mark mark 'unread)
8708 (defun gnus-summary-mark-article (&optional article mark no-expire)
8709 "Mark ARTICLE with MARK. MARK can be any character.
8710 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
8711 `??' (dormant) and `?E' (expirable).
8712 If MARK is nil, then the default character `?r' is used.
8713 If ARTICLE is nil, then the article on the current line will be
8715 Iff NO-EXPIRE, auto-expiry will be inhibited."
8716 ;; The mark might be a string.
8717 (when (stringp mark)
8718 (setq mark (aref mark 0)))
8719 ;; If no mark is given, then we check auto-expiring.
8721 (setq mark gnus-del-mark))
8722 (when (and (not no-expire)
8723 gnus-newsgroup-auto-expire
8724 (memq mark gnus-auto-expirable-marks))
8725 (setq mark gnus-expirable-mark))
8726 (let ((article (or article (gnus-summary-article-number)))
8727 (old-mark (gnus-summary-article-mark article)))
8728 ;; Allow the backend to change the mark.
8729 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8730 (if (eq mark old-mark)
8733 (error "No article on current line"))
8734 (if (not (if (or (= mark gnus-unread-mark)
8735 (= mark gnus-ticked-mark)
8736 (= mark gnus-dormant-mark))
8737 (gnus-mark-article-as-unread article mark)
8738 (gnus-mark-article-as-read article mark)))
8740 ;; See whether the article is to be put in the cache.
8742 (not (= mark gnus-canceled-mark))
8743 (vectorp (gnus-summary-article-header article))
8745 (gnus-cache-possibly-enter-article
8746 gnus-newsgroup-name article
8747 (= mark gnus-ticked-mark)
8748 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
8750 (when (gnus-summary-goto-subject article nil t)
8751 (let ((buffer-read-only nil))
8752 (gnus-summary-show-thread)
8754 (gnus-summary-update-mark mark 'unread)
8757 (defun gnus-summary-update-secondary-mark (article)
8758 "Update the secondary (read, process, cache) mark."
8759 (gnus-summary-update-mark
8760 (cond ((memq article gnus-newsgroup-processable)
8762 ((memq article gnus-newsgroup-cached)
8764 ((memq article gnus-newsgroup-replied)
8766 ((memq article gnus-newsgroup-forwarded)
8767 gnus-forwarded-mark)
8768 ((memq article gnus-newsgroup-saved)
8772 (when (gnus-visual-p 'summary-highlight 'highlight)
8773 (gnus-run-hooks 'gnus-summary-update-hook))
8776 (defun gnus-summary-update-mark (mark type)
8777 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
8778 (buffer-read-only nil))
8779 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
8781 (when (looking-at "\r")
8783 (when (<= (+ forward (point)) (point-max))
8784 ;; Go to the right position on the line.
8785 (goto-char (+ forward (point)))
8786 ;; Replace the old mark with the new mark.
8787 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
8788 ;; Optionally update the marks by some user rule.
8789 (when (eq type 'unread)
8791 (gnus-data-find (gnus-summary-article-number)) mark)
8792 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
8794 (defun gnus-mark-article-as-read (article &optional mark)
8795 "Enter ARTICLE in the pertinent lists and remove it from others."
8796 ;; Make the article expirable.
8797 (let ((mark (or mark gnus-del-mark)))
8798 (if (= mark gnus-expirable-mark)
8799 (push article gnus-newsgroup-expirable)
8800 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
8801 ;; Remove from unread and marked lists.
8802 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8803 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8804 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8805 (push (cons article mark) gnus-newsgroup-reads)
8806 ;; Possibly remove from cache, if that is used.
8807 (when gnus-use-cache
8808 (gnus-cache-enter-remove-article article))
8811 (defun gnus-mark-article-as-unread (article &optional mark)
8812 "Enter ARTICLE in the pertinent lists and remove it from others."
8813 (let ((mark (or mark gnus-ticked-mark)))
8816 (gnus-error 1 "Can't mark negative article numbers")
8818 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
8819 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
8820 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
8821 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8823 ;; Unsuppress duplicates?
8824 (when gnus-suppress-duplicates
8825 (gnus-dup-unsuppress-article article))
8827 (cond ((= mark gnus-ticked-mark)
8828 (push article gnus-newsgroup-marked))
8829 ((= mark gnus-dormant-mark)
8830 (push article gnus-newsgroup-dormant))
8832 (push article gnus-newsgroup-unreads)))
8833 (gnus-pull article gnus-newsgroup-reads)
8836 (defalias 'gnus-summary-mark-as-unread-forward
8837 'gnus-summary-tick-article-forward)
8838 (make-obsolete 'gnus-summary-mark-as-unread-forward
8839 'gnus-summary-tick-article-forward)
8840 (defun gnus-summary-tick-article-forward (n)
8841 "Tick N articles forwards.
8842 If N is negative, tick backwards instead.
8843 The difference between N and the number of articles ticked is returned."
8845 (gnus-summary-mark-forward n gnus-ticked-mark))
8847 (defalias 'gnus-summary-mark-as-unread-backward
8848 'gnus-summary-tick-article-backward)
8849 (make-obsolete 'gnus-summary-mark-as-unread-backward
8850 'gnus-summary-tick-article-backward)
8851 (defun gnus-summary-tick-article-backward (n)
8852 "Tick N articles backwards.
8853 The difference between N and the number of articles ticked is returned."
8855 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
8857 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8858 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8859 (defun gnus-summary-tick-article (&optional article clear-mark)
8860 "Mark current article as unread.
8861 Optional 1st argument ARTICLE specifies article number to be marked as unread.
8862 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
8864 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
8867 (defun gnus-summary-mark-as-read-forward (n)
8868 "Mark N articles as read forwards.
8869 If N is negative, mark backwards instead.
8870 The difference between N and the actual number of articles marked is
8873 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
8875 (defun gnus-summary-mark-as-read-backward (n)
8876 "Mark the N articles as read backwards.
8877 The difference between N and the actual number of articles marked is
8880 (gnus-summary-mark-forward
8881 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
8883 (defun gnus-summary-mark-as-read (&optional article mark)
8884 "Mark current article as read.
8885 ARTICLE specifies the article to be marked as read.
8886 MARK specifies a string to be inserted at the beginning of the line."
8887 (gnus-summary-mark-article article mark))
8889 (defun gnus-summary-clear-mark-forward (n)
8890 "Clear marks from N articles forward.
8891 If N is negative, clear backward instead.
8892 The difference between N and the number of marks cleared is returned."
8894 (gnus-summary-mark-forward n gnus-unread-mark))
8896 (defun gnus-summary-clear-mark-backward (n)
8897 "Clear marks from N articles backward.
8898 The difference between N and the number of marks cleared is returned."
8900 (gnus-summary-mark-forward (- n) gnus-unread-mark))
8902 (defun gnus-summary-mark-unread-as-read ()
8903 "Intended to be used by `gnus-summary-mark-article-hook'."
8904 (when (memq gnus-current-article gnus-newsgroup-unreads)
8905 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
8907 (defun gnus-summary-mark-read-and-unread-as-read ()
8908 "Intended to be used by `gnus-summary-mark-article-hook'."
8909 (let ((mark (gnus-summary-article-mark)))
8910 (when (or (gnus-unread-mark-p mark)
8911 (gnus-read-mark-p mark))
8912 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
8914 (defun gnus-summary-mark-unread-as-ticked ()
8915 "Intended to be used by `gnus-summary-mark-article-hook'."
8916 (when (memq gnus-current-article gnus-newsgroup-unreads)
8917 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
8919 (defun gnus-summary-mark-region-as-read (point mark all)
8920 "Mark all unread articles between point and mark as read.
8921 If given a prefix, mark all articles between point and mark as read,
8922 even ticked and dormant ones."
8923 (interactive "r\nP")
8932 (memq (setq article (gnus-summary-article-number))
8933 gnus-newsgroup-unreads))
8934 (gnus-summary-mark-article article gnus-del-mark))
8936 (gnus-summary-find-next))))))
8938 (defun gnus-summary-mark-below (score mark)
8939 "Mark articles with score less than SCORE with MARK."
8940 (interactive "P\ncMark: ")
8941 (setq score (if score
8942 (prefix-numeric-value score)
8943 (or gnus-summary-default-score 0)))
8945 (set-buffer gnus-summary-buffer)
8946 (goto-char (point-min))
8949 (and (< (gnus-summary-article-score) score)
8950 (gnus-summary-mark-article nil mark))
8951 (gnus-summary-find-next)))))
8953 (defun gnus-summary-kill-below (&optional score)
8954 "Mark articles with score below SCORE as read."
8956 (gnus-summary-mark-below score gnus-killed-mark))
8958 (defun gnus-summary-clear-above (&optional score)
8959 "Clear all marks from articles with score above SCORE."
8961 (gnus-summary-mark-above score gnus-unread-mark))
8963 (defun gnus-summary-tick-above (&optional score)
8964 "Tick all articles with score above SCORE."
8966 (gnus-summary-mark-above score gnus-ticked-mark))
8968 (defun gnus-summary-mark-above (score mark)
8969 "Mark articles with score over SCORE with MARK."
8970 (interactive "P\ncMark: ")
8971 (setq score (if score
8972 (prefix-numeric-value score)
8973 (or gnus-summary-default-score 0)))
8975 (set-buffer gnus-summary-buffer)
8976 (goto-char (point-min))
8978 (when (> (gnus-summary-article-score) score)
8979 (gnus-summary-mark-article nil mark))
8981 (gnus-summary-find-next)))))
8983 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8984 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
8985 (defun gnus-summary-limit-include-expunged (&optional no-error)
8986 "Display all the hidden articles that were expunged for low scores."
8988 (let ((buffer-read-only nil))
8989 (let ((scored gnus-newsgroup-scored)
8992 (unless (gnus-summary-article-header (caar scored))
8993 (and (setq h (gnus-number-to-header (caar scored)))
8994 (< (cdar scored) gnus-summary-expunge-below)
8996 (setq scored (cdr scored)))
8998 (when (not no-error)
8999 (error "No expunged articles hidden"))
9000 (goto-char (point-min))
9001 (push gnus-newsgroup-limit gnus-newsgroup-limits)
9002 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
9003 (mapcar (lambda (x) (push (mail-header-number x)
9004 gnus-newsgroup-limit))
9006 (gnus-summary-prepare-unthreaded (nreverse headers))
9007 (goto-char (point-min))
9008 (gnus-summary-position-point)
9011 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
9012 "Mark all unread articles in this newsgroup as read.
9013 If prefix argument ALL is non-nil, ticked and dormant articles will
9014 also be marked as read.
9015 If QUIETLY is non-nil, no questions will be asked.
9016 If TO-HERE is non-nil, it should be a point in the buffer. All
9017 articles before (after, if REVERSE is set) this point will be marked as read.
9018 Note that this function will only catch up the unread article
9019 in the current summary buffer limitation.
9020 The number of articles marked as read is returned."
9025 (not gnus-interactive-catchup) ;Without confirmation?
9029 "Mark absolutely all articles as read? "
9030 "Mark all unread articles as read? ")))
9032 (not gnus-newsgroup-adaptive)
9033 (not gnus-newsgroup-auto-expire)
9034 (not gnus-suppress-duplicates)
9035 (or (not gnus-use-cache)
9036 (eq gnus-use-cache 'passive)))
9039 (setq gnus-newsgroup-marked nil
9040 gnus-newsgroup-dormant nil))
9041 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
9042 ;; We actually mark all articles as canceled, which we
9043 ;; have to do when using auto-expiry or adaptive scoring.
9044 (gnus-summary-show-all-threads)
9045 (if (and to-here reverse)
9049 (gnus-summary-mark-article-as-read gnus-catchup-mark)
9050 (gnus-summary-find-next (not all) nil nil t))))
9051 (when (gnus-summary-first-subject (not all) t)
9053 (if to-here (< (point) to-here) t)
9054 (gnus-summary-mark-article-as-read gnus-catchup-mark)
9055 (gnus-summary-find-next (not all) nil nil t)))))
9056 (gnus-set-mode-line 'summary))
9058 (gnus-summary-position-point)))
9060 (defun gnus-summary-catchup-to-here (&optional all)
9061 "Mark all unticked articles before the current one as read.
9062 If ALL is non-nil, also mark ticked and dormant articles as read."
9065 (gnus-save-hidden-threads
9066 (let ((beg (point)))
9067 ;; We check that there are unread articles.
9068 (when (or all (gnus-summary-find-prev))
9069 (gnus-summary-catchup all t beg)))))
9070 (gnus-summary-position-point))
9072 (defun gnus-summary-catchup-from-here (&optional all)
9073 "Mark all unticked articles after the current one as read.
9074 If ALL is non-nil, also mark ticked and dormant articles as read."
9077 (gnus-save-hidden-threads
9078 (let ((beg (point)))
9079 ;; We check that there are unread articles.
9080 (when (or all (gnus-summary-find-next))
9081 (gnus-summary-catchup all t beg nil t)))))
9083 (gnus-summary-position-point))
9084 (defun gnus-summary-catchup-all (&optional quietly)
9085 "Mark all articles in this newsgroup as read."
9087 (gnus-summary-catchup t quietly))
9089 (defun gnus-summary-catchup-and-exit (&optional all quietly)
9090 "Mark all unread articles in this group as read, then exit.
9091 If prefix argument ALL is non-nil, all articles are marked as read.
9092 If QUIETLY is non-nil, no questions will be asked."
9094 (when (gnus-summary-catchup all quietly nil 'fast)
9095 ;; Select next newsgroup or exit.
9096 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
9097 (eq gnus-auto-select-next 'quietly))
9098 (gnus-summary-next-group nil)
9099 (gnus-summary-exit))))
9101 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
9102 "Mark all articles in this newsgroup as read, and then exit."
9104 (gnus-summary-catchup-and-exit t quietly))
9106 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
9107 "Mark all articles in this group as read and select the next group.
9108 If given a prefix, mark all articles, unread as well as ticked, as
9112 (gnus-summary-catchup all))
9113 (gnus-summary-next-group))
9119 (defmacro gnus-with-article (article &rest forms)
9120 "Select ARTICLE and perform FORMS in the original article buffer.
9121 Then replace the article with the result."
9123 ;; We don't want the article to be marked as read.
9124 (let (gnus-mark-article-hook)
9125 (gnus-summary-select-article t t nil ,article))
9126 (set-buffer gnus-original-article-buffer)
9128 (if (not (gnus-check-backend-function
9129 'request-replace-article (car gnus-article-current)))
9130 (gnus-message 5 "Read-only group; not replacing")
9131 (unless (gnus-request-replace-article
9132 ,article (car gnus-article-current)
9134 (error "Couldn't replace article")))
9135 ;; The cache and backlog have to be flushed somewhat.
9136 (when gnus-keep-backlog
9137 (gnus-backlog-remove-article
9138 (car gnus-article-current) (cdr gnus-article-current)))
9139 (when gnus-use-cache
9140 (gnus-cache-update-article
9141 (car gnus-article-current) (cdr gnus-article-current)))))
9143 (put 'gnus-with-article 'lisp-indent-function 1)
9144 (put 'gnus-with-article 'edebug-form-spec '(form body))
9146 ;; Thread-based commands.
9148 (defun gnus-summary-articles-in-thread (&optional article)
9149 "Return a list of all articles in the current thread.
9150 If ARTICLE is non-nil, return all articles in the thread that starts
9152 (let* ((article (or article (gnus-summary-article-number)))
9153 (data (gnus-data-find-list article))
9154 (top-level (gnus-data-level (car data)))
9156 (cond ((null gnus-thread-operation-ignore-subject)
9157 (gnus-simplify-subject-re
9158 (mail-header-subject (gnus-data-header (car data)))))
9159 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
9160 (gnus-simplify-subject-fuzzy
9161 (mail-header-subject (gnus-data-header (car data)))))
9163 (end-point (save-excursion
9164 (if (gnus-summary-go-to-next-thread)
9165 (point) (point-max))))
9168 (< (gnus-data-pos (car data)) end-point))
9169 (when (or (not top-subject)
9170 (string= top-subject
9171 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
9172 (gnus-simplify-subject-fuzzy
9173 (mail-header-subject
9174 (gnus-data-header (car data))))
9175 (gnus-simplify-subject-re
9176 (mail-header-subject
9177 (gnus-data-header (car data)))))))
9178 (push (gnus-data-number (car data)) articles))
9179 (unless (and (setq data (cdr data))
9180 (> (gnus-data-level (car data)) top-level))
9182 ;; Return the list of articles.
9183 (nreverse articles)))
9185 (defun gnus-summary-rethread-current ()
9186 "Rethread the thread the current article is part of."
9188 (let* ((gnus-show-threads t)
9189 (article (gnus-summary-article-number))
9190 (id (mail-header-id (gnus-summary-article-header)))
9191 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
9193 (error "No article on the current line"))
9194 (gnus-rebuild-thread id)
9195 (gnus-summary-goto-subject article)))
9197 (defun gnus-summary-reparent-thread ()
9198 "Make the current article child of the marked (or previous) article.
9200 Note that the re-threading will only work if `gnus-thread-ignore-subject'
9201 is non-nil or the Subject: of both articles are the same."
9203 (unless (not (gnus-group-read-only-p))
9204 (error "The current newsgroup does not support article editing"))
9205 (unless (<= (length gnus-newsgroup-processable) 1)
9206 (error "No more than one article may be marked"))
9207 (save-window-excursion
9208 (let ((gnus-article-buffer " *reparent*")
9209 (current-article (gnus-summary-article-number))
9210 ;; First grab the marked article, otherwise one line up.
9211 (parent-article (if (not (null gnus-newsgroup-processable))
9212 (car gnus-newsgroup-processable)
9214 (if (eq (forward-line -1) 0)
9215 (gnus-summary-article-number)
9216 (error "Beginning of summary buffer"))))))
9217 (unless (not (eq current-article parent-article))
9218 (error "An article may not be self-referential"))
9219 (let ((message-id (mail-header-id
9220 (gnus-summary-article-header parent-article))))
9221 (unless (and message-id (not (equal message-id "")))
9222 (error "No message-id in desired parent"))
9223 (gnus-with-article current-article
9225 (goto-char (point-min))
9226 (message-narrow-to-head)
9227 (if (re-search-forward "^References: " nil t)
9229 (re-search-forward "^[^ \t]" nil t)
9232 (insert " " message-id))
9233 (insert "References: " message-id "\n"))))
9234 (set-buffer gnus-summary-buffer)
9235 (gnus-summary-unmark-all-processable)
9236 (gnus-summary-update-article current-article)
9237 (gnus-summary-rethread-current)
9238 (gnus-message 3 "Article %d is now the child of article %d"
9239 current-article parent-article)))))
9241 (defun gnus-summary-toggle-threads (&optional arg)
9242 "Toggle showing conversation threads.
9243 If ARG is positive number, turn showing conversation threads on."
9245 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
9246 (setq gnus-show-threads
9247 (if (null arg) (not gnus-show-threads)
9248 (> (prefix-numeric-value arg) 0)))
9249 (gnus-summary-prepare)
9250 (gnus-summary-goto-subject current)
9251 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
9252 (gnus-summary-position-point)))
9254 (defun gnus-summary-show-all-threads ()
9258 (let ((buffer-read-only nil))
9259 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
9260 (gnus-summary-position-point))
9262 (defun gnus-summary-show-thread ()
9263 "Show thread subtrees.
9264 Returns nil if no thread was there to be shown."
9266 (let ((buffer-read-only nil)
9268 ;; first goto end then to beg, to have point at beg after let
9269 (end (progn (end-of-line) (point)))
9270 (beg (progn (beginning-of-line) (point))))
9272 ;; Any hidden lines here?
9273 (search-forward "\r" end t)
9274 (subst-char-in-region beg end ?\^M ?\n t)
9276 (gnus-summary-position-point))))
9278 (defun gnus-summary-hide-all-threads ()
9279 "Hide all thread subtrees."
9282 (goto-char (point-min))
9283 (gnus-summary-hide-thread)
9284 (while (zerop (gnus-summary-next-thread 1 t))
9285 (gnus-summary-hide-thread)))
9286 (gnus-summary-position-point))
9288 (defun gnus-summary-hide-thread ()
9289 "Hide thread subtrees.
9290 Returns nil if no threads were there to be hidden."
9292 (let ((buffer-read-only nil)
9294 (article (gnus-summary-article-number)))
9296 ;; Go forward until either the buffer ends or the subthread
9298 (when (and (not (eobp))
9299 (or (zerop (gnus-summary-next-thread 1 t))
9300 (goto-char (point-max))))
9302 (if (and (> (point) start)
9303 (search-backward "\n" start t))
9305 (subst-char-in-region start (point) ?\n ?\^M)
9306 (gnus-summary-goto-subject article))
9310 (defun gnus-summary-go-to-next-thread (&optional previous)
9311 "Go to the same level (or less) next thread.
9312 If PREVIOUS is non-nil, go to previous thread instead.
9313 Return the article number moved to, or nil if moving was impossible."
9314 (let ((level (gnus-summary-thread-level))
9315 (way (if previous -1 1))
9318 (while (and (not (eobp))
9319 (< level (gnus-summary-thread-level)))
9327 (gnus-summary-article-number)
9330 (defun gnus-summary-next-thread (n &optional silent)
9331 "Go to the same level next N'th thread.
9332 If N is negative, search backward instead.
9333 Returns the difference between N and the number of skips actually
9336 If SILENT, don't output messages."
9338 (let ((backward (< n 0))
9341 (gnus-summary-go-to-next-thread backward))
9344 (gnus-summary-position-point))
9345 (when (and (not silent) (/= 0 n))
9346 (gnus-message 7 "No more threads"))
9349 (defun gnus-summary-prev-thread (n)
9350 "Go to the same level previous N'th thread.
9351 Returns the difference between N and the number of skips actually
9354 (gnus-summary-next-thread (- n)))
9356 (defun gnus-summary-go-down-thread ()
9357 "Go down one level in the current thread."
9358 (let ((children (gnus-summary-article-children)))
9360 (gnus-summary-goto-subject (car children)))))
9362 (defun gnus-summary-go-up-thread ()
9363 "Go up one level in the current thread."
9364 (let ((parent (gnus-summary-article-parent)))
9366 (gnus-summary-goto-subject parent))))
9368 (defun gnus-summary-down-thread (n)
9369 "Go down thread N steps.
9370 If N is negative, go up instead.
9371 Returns the difference between N and how many steps down that were
9377 (if up (gnus-summary-go-up-thread)
9378 (gnus-summary-go-down-thread)))
9380 (gnus-summary-position-point)
9382 (gnus-message 7 "Can't go further"))
9385 (defun gnus-summary-up-thread (n)
9386 "Go up thread N steps.
9387 If N is negative, go down instead.
9388 Returns the difference between N and how many steps down that were
9391 (gnus-summary-down-thread (- n)))
9393 (defun gnus-summary-top-thread ()
9394 "Go to the top of the thread."
9396 (while (gnus-summary-go-up-thread))
9397 (gnus-summary-article-number))
9399 (defun gnus-summary-kill-thread (&optional unmark)
9400 "Mark articles under current thread as read.
9401 If the prefix argument is positive, remove any kinds of marks.
9402 If the prefix argument is negative, tick articles instead."
9405 (setq unmark (prefix-numeric-value unmark)))
9406 (let ((articles (gnus-summary-articles-in-thread)))
9408 ;; Expand the thread.
9409 (gnus-summary-show-thread)
9410 ;; Mark all the articles.
9412 (gnus-summary-goto-subject (car articles))
9413 (cond ((null unmark)
9414 (gnus-summary-mark-article-as-read gnus-killed-mark))
9416 (gnus-summary-mark-article-as-unread gnus-unread-mark))
9418 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
9419 (setq articles (cdr articles))))
9420 ;; Hide killed subtrees.
9422 gnus-thread-hide-killed
9423 (gnus-summary-hide-thread))
9424 ;; If marked as read, go to next unread subject.
9426 ;; Go to next unread subject.
9427 (gnus-summary-next-subject 1 t)))
9428 (gnus-set-mode-line 'summary))
9430 ;; Summary sorting commands
9432 (defun gnus-summary-sort-by-number (&optional reverse)
9433 "Sort the summary buffer by article number.
9434 Argument REVERSE means reverse order."
9436 (gnus-summary-sort 'number reverse))
9438 (defun gnus-summary-sort-by-author (&optional reverse)
9439 "Sort the summary buffer by author name alphabetically.
9440 If `case-fold-search' is non-nil, case of letters is ignored.
9441 Argument REVERSE means reverse order."
9443 (gnus-summary-sort 'author reverse))
9445 (defun gnus-summary-sort-by-subject (&optional reverse)
9446 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
9447 If `case-fold-search' is non-nil, case of letters is ignored.
9448 Argument REVERSE means reverse order."
9450 (gnus-summary-sort 'subject reverse))
9452 (defun gnus-summary-sort-by-date (&optional reverse)
9453 "Sort the summary buffer by date.
9454 Argument REVERSE means reverse order."
9456 (gnus-summary-sort 'date reverse))
9458 (defun gnus-summary-sort-by-score (&optional reverse)
9459 "Sort the summary buffer by score.
9460 Argument REVERSE means reverse order."
9462 (gnus-summary-sort 'score reverse))
9464 (defun gnus-summary-sort-by-lines (&optional reverse)
9465 "Sort the summary buffer by the number of lines.
9466 Argument REVERSE means reverse order."
9468 (gnus-summary-sort 'lines reverse))
9470 (defun gnus-summary-sort-by-chars (&optional reverse)
9471 "Sort the summary buffer by article length.
9472 Argument REVERSE means reverse order."
9474 (gnus-summary-sort 'chars reverse))
9476 (defun gnus-summary-sort-by-original (&optional reverse)
9477 "Sort the summary buffer using the default sorting method.
9478 Argument REVERSE means reverse order."
9480 (let* ((buffer-read-only)
9481 (gnus-summary-prepare-hook nil))
9482 ;; We do the sorting by regenerating the threads.
9483 (gnus-summary-prepare)
9484 ;; Hide subthreads if needed.
9485 (when (and gnus-show-threads gnus-thread-hide-subtree)
9486 (gnus-summary-hide-all-threads))))
9488 (defun gnus-summary-sort (predicate reverse)
9489 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
9490 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
9491 (article (intern (format "gnus-article-sort-by-%s" predicate)))
9492 (gnus-thread-sort-functions
9497 (gnus-sort-gathered-threads-function
9498 gnus-thread-sort-functions)
9499 (gnus-article-sort-functions
9505 (gnus-summary-prepare-hook nil))
9506 ;; We do the sorting by regenerating the threads.
9507 (gnus-summary-prepare)
9508 ;; Hide subthreads if needed.
9509 (when (and gnus-show-threads gnus-thread-hide-subtree)
9510 (gnus-summary-hide-all-threads))))
9512 ;; Summary saving commands.
9514 (defun gnus-summary-save-article (&optional n not-saved)
9515 "Save the current article using the default saver function.
9516 If N is a positive number, save the N next articles.
9517 If N is a negative number, save the N previous articles.
9518 If N is nil and any articles have been marked with the process mark,
9519 save those articles instead.
9520 The variable `gnus-default-article-saver' specifies the saver function."
9522 (let* ((articles (gnus-summary-work-articles n))
9523 (save-buffer (save-excursion
9524 (nnheader-set-temp-buffer " *Gnus Save*")))
9525 (num (length articles))
9527 (dolist (article articles)
9528 (setq header (gnus-summary-article-header article))
9529 (if (not (vectorp header))
9530 ;; This is a pseudo-article.
9531 (if (assq 'name header)
9532 (gnus-copy-file (cdr (assq 'name header)))
9533 (gnus-message 1 "Article %d is unsaveable" article))
9534 ;; This is a real article.
9535 (save-window-excursion
9536 (gnus-summary-select-article t nil nil article))
9538 (set-buffer save-buffer)
9540 (insert-buffer-substring gnus-original-article-buffer))
9541 (setq file (gnus-article-save save-buffer file num))
9542 (gnus-summary-remove-process-mark article)
9544 (gnus-summary-set-saved-mark article))))
9545 (gnus-kill-buffer save-buffer)
9546 (gnus-summary-position-point)
9547 (gnus-set-mode-line 'summary)
9550 (defun gnus-summary-pipe-output (&optional arg)
9551 "Pipe the current article to a subprocess.
9552 If N is a positive number, pipe the N next articles.
9553 If N is a negative number, pipe the N previous articles.
9554 If N is nil and any articles have been marked with the process mark,
9555 pipe those articles instead."
9558 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
9559 (gnus-summary-save-article arg t))
9560 (let ((buffer (get-buffer "*Shell Command Output*")))
9562 (with-current-buffer buffer (> (point-max) (point-min))))
9563 (gnus-configure-windows 'pipe))))
9565 (defun gnus-summary-save-article-mail (&optional arg)
9566 "Append the current article to an mail file.
9567 If N is a positive number, save the N next articles.
9568 If N is a negative number, save the N previous articles.
9569 If N is nil and any articles have been marked with the process mark,
9570 save those articles instead."
9573 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
9574 (gnus-summary-save-article arg)))
9576 (defun gnus-summary-save-article-rmail (&optional arg)
9577 "Append the current article to an rmail file.
9578 If N is a positive number, save the N next articles.
9579 If N is a negative number, save the N previous articles.
9580 If N is nil and any articles have been marked with the process mark,
9581 save those articles instead."
9584 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
9585 (gnus-summary-save-article arg)))
9587 (defun gnus-summary-save-article-file (&optional arg)
9588 "Append the current article to a file.
9589 If N is a positive number, save the N next articles.
9590 If N is a negative number, save the N previous articles.
9591 If N is nil and any articles have been marked with the process mark,
9592 save those articles instead."
9595 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
9596 (gnus-summary-save-article arg)))
9598 (defun gnus-summary-write-article-file (&optional arg)
9599 "Write the current article to a file, deleting the previous file.
9600 If N is a positive number, save the N next articles.
9601 If N is a negative number, save the N previous articles.
9602 If N is nil and any articles have been marked with the process mark,
9603 save those articles instead."
9606 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
9607 (gnus-summary-save-article arg)))
9609 (defun gnus-summary-save-article-body-file (&optional arg)
9610 "Append the current article body to a file.
9611 If N is a positive number, save the N next articles.
9612 If N is a negative number, save the N previous articles.
9613 If N is nil and any articles have been marked with the process mark,
9614 save those articles instead."
9617 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
9618 (gnus-summary-save-article arg)))
9620 (defun gnus-summary-pipe-message (program)
9621 "Pipe the current article through PROGRAM."
9622 (interactive "sProgram: ")
9623 (gnus-summary-select-article)
9624 (let ((mail-header-separator ""))
9625 (gnus-eval-in-buffer-window gnus-article-buffer
9628 (let ((start (window-start))
9630 (message-pipe-buffer-body program)
9631 (set-window-start (get-buffer-window (current-buffer)) start))))))
9633 (defun gnus-get-split-value (methods)
9634 "Return a value based on the split METHODS."
9635 (let (split-name method result match)
9638 (set-buffer gnus-original-article-buffer)
9640 (nnheader-narrow-to-headers)
9641 (while (and methods (not split-name))
9642 (goto-char (point-min))
9643 (setq method (pop methods))
9644 (setq match (car method))
9647 ;; Regular expression.
9649 (re-search-forward match nil t)))
9650 ((gnus-functionp match)
9654 (setq result (funcall match gnus-newsgroup-name))))
9659 (setq result (eval match)))))
9660 (setq split-name (cdr method))
9661 (cond ((stringp result)
9662 (push (expand-file-name
9663 result gnus-article-save-directory)
9666 (setq split-name (append result split-name)))))))))
9667 (nreverse split-name)))
9669 (defun gnus-valid-move-group-p (group)
9672 (symbol-value group)
9673 (gnus-get-function (gnus-find-method-for-group
9674 (symbol-name group)) 'request-accept-article t)))
9676 (defun gnus-read-move-group-name (prompt default articles prefix)
9677 "Read a group name."
9678 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
9679 (minibuffer-confirm-incomplete nil) ; XEmacs
9683 (if (> (length articles) 1)
9684 (format "these %d articles" (length articles))
9689 (gnus-completing-read default prom
9691 'gnus-valid-move-group-p
9693 'gnus-group-history))
9694 ((= 1 (length split-name))
9695 (gnus-completing-read (car split-name) prom
9697 'gnus-valid-move-group-p
9699 'gnus-group-history))
9701 (gnus-completing-read nil prom
9702 (mapcar (lambda (el) (list el))
9703 (nreverse split-name))
9705 'gnus-group-history))))
9706 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
9708 (if (or (string= to-newsgroup "")
9709 (string= to-newsgroup prefix))
9710 (setq to-newsgroup default))
9711 (unless to-newsgroup
9712 (error "No group name entered"))
9713 (or (gnus-active to-newsgroup)
9714 (gnus-activate-group to-newsgroup nil nil to-method)
9715 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
9717 (or (and (gnus-request-create-group to-newsgroup to-method)
9718 (gnus-activate-group
9719 to-newsgroup nil nil to-method)
9720 (gnus-subscribe-group to-newsgroup))
9721 (error "Couldn't create group %s" to-newsgroup)))
9722 (error "No such group: %s" to-newsgroup)))
9725 (defun gnus-summary-save-parts (type dir n &optional reverse)
9726 "Save parts matching TYPE to DIR.
9727 If REVERSE, save parts that do not match TYPE."
9729 (list (read-string "Save parts of type: "
9730 (or (car gnus-summary-save-parts-type-history)
9731 gnus-summary-save-parts-default-mime)
9732 'gnus-summary-save-parts-type-history)
9733 (setq gnus-summary-save-parts-last-directory
9734 (read-file-name "Save to directory: "
9735 gnus-summary-save-parts-last-directory
9737 current-prefix-arg))
9738 (gnus-summary-iterate n
9739 (let ((gnus-display-mime-function nil)
9740 (gnus-inhibit-treatment t))
9741 (gnus-summary-select-article))
9743 (set-buffer gnus-article-buffer)
9744 (let ((handles (or gnus-article-mime-handles
9745 (mm-dissect-buffer) (mm-uu-dissect))))
9747 (gnus-summary-save-parts-1 type dir handles reverse)
9748 (unless gnus-article-mime-handles ;; Don't destroy this case.
9749 (mm-destroy-parts handles)))))))
9751 (defun gnus-summary-save-parts-1 (type dir handle reverse)
9752 (if (stringp (car handle))
9753 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
9756 (not (string-match type (mm-handle-media-type handle)))
9757 (string-match type (mm-handle-media-type handle)))
9758 (let ((file (expand-file-name
9759 (file-name-nondirectory
9761 (mail-content-type-get
9762 (mm-handle-disposition handle) 'filename)
9763 (concat gnus-newsgroup-name
9764 "." (number-to-string
9765 (cdr gnus-article-current)))))
9767 (unless (file-exists-p file)
9768 (mm-save-part-to-file handle file))))))
9770 ;; Summary extract commands
9772 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
9773 (let ((buffer-read-only nil)
9774 (article (gnus-summary-article-number))
9776 (unless (gnus-summary-goto-subject article)
9777 (error "No such article: %d" article))
9778 (gnus-summary-position-point)
9779 ;; If all commands are to be bunched up on one line, we collect
9781 (unless gnus-view-pseudos-separately
9782 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
9785 (setq action (cdr (assq 'action (car ps))))
9786 (setq files (list (cdr (assq 'name (car ps)))))
9787 (while (and ps (cdr ps)
9788 (string= (or action "1")
9789 (or (cdr (assq 'action (cadr ps))) "2")))
9790 (push (cdr (assq 'name (cadr ps))) files)
9791 (setcdr ps (cddr ps)))
9793 (when (not (string-match "%s" action))
9796 (when (assq 'execute (car ps))
9797 (setcdr (assq 'execute (car ps))
9798 (funcall (if (string-match "%s" action)
9807 (setq ps (cdr ps)))))
9808 (if (and gnus-view-pseudos (not not-view))
9810 (when (assq 'execute (car pslist))
9811 (gnus-execute-command (cdr (assq 'execute (car pslist)))
9812 (eq gnus-view-pseudos 'not-confirm)))
9813 (setq pslist (cdr pslist)))
9816 (setq after-article (or (cdr (assq 'article (car pslist)))
9817 (gnus-summary-article-number)))
9818 (gnus-summary-goto-subject after-article)
9821 (insert " " (file-name-nondirectory
9822 (cdr (assq 'name (car pslist))))
9823 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
9825 (forward-line -1) ; back to `b'
9826 (gnus-add-text-properties
9827 b (1- e) (list 'gnus-number gnus-reffed-article-number
9828 gnus-mouse-face-prop gnus-mouse-face))
9830 after-article gnus-reffed-article-number
9831 gnus-unread-mark b (car pslist) 0 (- e b))
9832 (push gnus-reffed-article-number gnus-newsgroup-unreads)
9833 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
9834 (setq pslist (cdr pslist)))))))
9836 (defun gnus-pseudos< (p1 p2)
9837 (let ((c1 (cdr (assq 'action p1)))
9838 (c2 (cdr (assq 'action p2))))
9839 (and c1 c2 (string< c1 c2))))
9841 (defun gnus-request-pseudo-article (props)
9842 (cond ((assq 'execute props)
9843 (gnus-execute-command (cdr (assq 'execute props)))))
9844 (let ((gnus-current-article (gnus-summary-article-number)))
9845 (gnus-run-hooks 'gnus-mark-article-hook)))
9847 (defun gnus-execute-command (command &optional automatic)
9849 (gnus-article-setup-buffer)
9850 (set-buffer gnus-article-buffer)
9851 (setq buffer-read-only nil)
9852 (let ((command (if automatic command
9853 (read-string "Command: " (cons command 0)))))
9855 (insert "$ " command "\n\n")
9856 (if gnus-view-pseudo-asynchronously
9857 (start-process "gnus-execute" (current-buffer) shell-file-name
9858 shell-command-switch command)
9859 (call-process shell-file-name nil t nil
9860 shell-command-switch command)))))
9862 ;; Summary kill commands.
9864 (defun gnus-summary-edit-global-kill (article)
9865 "Edit the \"global\" kill file."
9866 (interactive (list (gnus-summary-article-number)))
9867 (gnus-group-edit-global-kill article))
9869 (defun gnus-summary-edit-local-kill ()
9870 "Edit a local kill file applied to the current newsgroup."
9872 (setq gnus-current-headers (gnus-summary-article-header))
9873 (gnus-group-edit-local-kill
9874 (gnus-summary-article-number) gnus-newsgroup-name))
9878 (defun gnus-read-header (id &optional header)
9879 "Read the headers of article ID and enter them into the Gnus system."
9880 (let ((group gnus-newsgroup-name)
9881 (gnus-override-method
9883 gnus-override-method
9884 (and (gnus-news-group-p gnus-newsgroup-name)
9885 (car (gnus-refer-article-methods)))))
9887 ;; First we check to see whether the header in question is already
9890 ;; This is a Message-ID.
9891 (setq header (or header (gnus-id-to-header id)))
9892 ;; This is an article number.
9893 (setq header (or header (gnus-summary-article-header id))))
9895 (not (gnus-summary-article-sparse-p (mail-header-number header))))
9896 ;; We have found the header.
9898 ;; If this is a sparse article, we have to nix out its
9899 ;; previous entry in the thread hashtb.
9901 (gnus-summary-article-sparse-p (mail-header-number header)))
9902 (let* ((parent (gnus-parent-id (mail-header-references header)))
9903 (thread (and parent (gnus-id-to-thread parent))))
9905 (delq (assq header thread) thread))))
9906 ;; We have to really fetch the header to this article.
9908 (set-buffer nntp-server-buffer)
9909 (when (setq where (gnus-request-head id group))
9910 (nnheader-fold-continuation-lines)
9911 (goto-char (point-max))
9913 (goto-char (point-min))
9917 ((cdr where) (cdr where))
9918 (header (mail-header-number header))
9919 (t gnus-reffed-article-number))
9921 (insert " Article retrieved.\n"))
9923 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
9924 () ; Malformed head.
9925 (unless (gnus-summary-article-sparse-p (mail-header-number header))
9926 (when (and (stringp id)
9927 (not (string= (gnus-group-real-name group)
9929 ;; If we fetched by Message-ID and the article came
9930 ;; from a different group, we fudge some bogus article
9931 ;; numbers for this article.
9932 (mail-header-set-number header gnus-reffed-article-number))
9934 (set-buffer gnus-summary-buffer)
9935 (decf gnus-reffed-article-number)
9936 (gnus-remove-header (mail-header-number header))
9937 (push header gnus-newsgroup-headers)
9938 (setq gnus-current-headers header)
9939 (push (mail-header-number header) gnus-newsgroup-limit)))
9942 (defun gnus-remove-header (number)
9943 "Remove header NUMBER from `gnus-newsgroup-headers'."
9944 (if (and gnus-newsgroup-headers
9945 (= number (mail-header-number (car gnus-newsgroup-headers))))
9946 (pop gnus-newsgroup-headers)
9947 (let ((headers gnus-newsgroup-headers))
9948 (while (and (cdr headers)
9949 (not (= number (mail-header-number (cadr headers)))))
9952 (setcdr headers (cddr headers))))))
9955 ;;; summary highlights
9958 (defun gnus-highlight-selected-summary ()
9959 "Highlight selected article in summary buffer."
9960 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
9961 (when gnus-summary-selected-face
9963 (let* ((beg (progn (beginning-of-line) (point)))
9964 (end (progn (end-of-line) (point)))
9965 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
9966 (from (if (get-text-property beg gnus-mouse-face-prop)
9968 (or (next-single-property-change
9969 beg gnus-mouse-face-prop nil end)
9974 (or (next-single-property-change
9975 from gnus-mouse-face-prop nil end)
9977 ;; If no mouse-face prop on line we will have to = from = end,
9978 ;; so we highlight the entire line instead.
9979 (when (= (+ to 2) from)
9982 (if gnus-newsgroup-selected-overlay
9983 ;; Move old overlay.
9985 gnus-newsgroup-selected-overlay from to (current-buffer))
9986 ;; Create new overlay.
9988 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
9989 'face gnus-summary-selected-face))))))
9991 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
9992 (defun gnus-summary-highlight-line ()
9993 "Highlight current line according to `gnus-summary-highlight'."
9994 (let* ((list gnus-summary-highlight)
9996 (end (progn (end-of-line) (point)))
9997 ;; now find out where the line starts and leave point there.
9998 (beg (progn (beginning-of-line) (point)))
9999 (article (gnus-summary-article-number))
10000 (score (or (cdr (assq (or article gnus-current-article)
10001 gnus-newsgroup-scored))
10002 gnus-summary-default-score 0))
10003 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
10004 (inhibit-read-only t))
10005 ;; Eval the cars of the lists until we find a match.
10006 (let ((default gnus-summary-default-score)
10007 (default-high gnus-summary-default-high-score)
10008 (default-low gnus-summary-default-low-score))
10010 (not (eval (caar list))))
10011 (setq list (cdr list))))
10012 (let ((face (cdar list)))
10013 (unless (eq face (get-text-property beg 'face))
10014 (gnus-put-text-property-excluding-characters-with-faces
10016 (setq face (if (boundp face) (symbol-value face) face)))
10017 (when gnus-summary-highlight-line-function
10018 (funcall gnus-summary-highlight-line-function article face))))
10021 (defun gnus-update-read-articles (group unread &optional compute)
10022 "Update the list of read articles in GROUP."
10023 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
10024 (entry (gnus-gethash group gnus-newsrc-hashtb))
10025 (info (nth 2 entry))
10027 (unread (sort (copy-sequence unread) '<))
10029 (if (or (not info) (not active))
10030 ;; There is no info on this group if it was, in fact,
10031 ;; killed. Gnus stores no information on killed groups, so
10032 ;; there's nothing to be done.
10033 ;; One could store the information somewhere temporarily,
10034 ;; perhaps... Hmmm...
10036 ;; Remove any negative articles numbers.
10037 (while (and unread (< (car unread) 0))
10038 (setq unread (cdr unread)))
10039 ;; Remove any expired article numbers
10040 (while (and unread (< (car unread) (car active)))
10041 (setq unread (cdr unread)))
10042 ;; Compute the ranges of read articles by looking at the list of
10043 ;; unread articles.
10045 (when (/= (car unread) prev)
10046 (push (if (= prev (1- (car unread))) prev
10047 (cons prev (1- (car unread))))
10049 (setq prev (1+ (car unread)))
10050 (setq unread (cdr unread)))
10051 (when (<= prev (cdr active))
10052 (push (cons prev (cdr active)) read))
10053 (setq read (if (> (length read) 1) (nreverse read) read))
10058 ;; Propagate the read marks to the backend.
10059 (when (gnus-check-backend-function 'request-set-mark group)
10060 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
10061 (add (gnus-remove-from-range read (gnus-info-read info))))
10063 (unless (gnus-check-group group)
10064 (error "Can't open server for %s" group))
10065 (gnus-request-set-mark
10066 group (delq nil (list (if add (list add 'add '(read)))
10067 (if del (list del 'del '(read))))))
10069 `(gnus-request-set-mark
10072 (if del (list del 'add '(read)))
10073 (if add (list add 'del '(read))))))))))
10074 (set-buffer gnus-group-buffer)
10075 (gnus-undo-register
10077 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
10078 (gnus-info-set-read ',info ',(gnus-info-read info))
10079 (gnus-get-unread-articles-in-group ',info
10080 (gnus-active ,group))
10081 (gnus-group-update-group ,group t)
10083 ;; Enter this list into the group info.
10084 (gnus-info-set-read info read)
10085 ;; Set the number of unread articles in gnus-newsrc-hashtb.
10086 (gnus-get-unread-articles-in-group info (gnus-active group))
10089 (defun gnus-offer-save-summaries ()
10090 "Offer to save all active summary buffers."
10092 ;; Go through all buffers and find all summaries.
10093 (dolist (buffer (buffer-list))
10094 (when (and (setq buffer (buffer-name buffer))
10095 (string-match "Summary" buffer)
10097 (set-buffer buffer)
10098 ;; We check that this is, indeed, a summary buffer.
10099 (and (eq major-mode 'gnus-summary-mode)
10100 ;; Also make sure this isn't bogus.
10101 gnus-newsgroup-prepared
10102 ;; Also make sure that this isn't a
10103 ;; dead summary buffer.
10104 (not gnus-dead-summary-mode))))
10105 (push buffer buffers)))
10106 ;; Go through all these summary buffers and offer to save them.
10110 "Update summary buffer %s? "
10112 (switch-to-buffer buf)
10113 (gnus-summary-exit))
10116 (defun gnus-summary-setup-default-charset ()
10117 "Setup newsgroup default charset."
10118 (if (equal gnus-newsgroup-name "nndraft:drafts")
10119 (setq gnus-newsgroup-charset nil)
10120 (let* ((ignored-charsets
10121 (or gnus-newsgroup-ephemeral-ignored-charsets
10123 (and gnus-newsgroup-name
10124 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
10125 gnus-newsgroup-ignored-charsets))))
10126 (setq gnus-newsgroup-charset
10127 (or gnus-newsgroup-ephemeral-charset
10128 (and gnus-newsgroup-name
10129 (gnus-parameter-charset gnus-newsgroup-name))
10130 gnus-default-charset))
10131 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
10132 ignored-charsets))))
10138 (defun gnus-summary-display-buttonized (&optional show-all-parts)
10139 "Display the current article buffer fully MIME-buttonized.
10140 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
10141 treated as multipart/mixed."
10143 (require 'gnus-art)
10144 (let ((gnus-unbuttonized-mime-types nil)
10145 (gnus-mime-display-multipart-as-mixed show-all-parts))
10146 (gnus-summary-show-article)))
10148 (defun gnus-summary-repair-multipart (article)
10149 "Add a Content-Type header to a multipart article without one."
10150 (interactive (list (gnus-summary-article-number)))
10151 (gnus-with-article article
10152 (message-narrow-to-head)
10153 (message-remove-header "Mime-Version")
10154 (goto-char (point-max))
10155 (insert "Mime-Version: 1.0\n")
10157 (when (search-forward "\n--" nil t)
10158 (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
10159 (message-narrow-to-head)
10160 (message-remove-header "Content-Type")
10161 (goto-char (point-max))
10162 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
10165 (let (gnus-mark-article-hook)
10166 (gnus-summary-select-article t t nil article)))
10168 (defun gnus-summary-toggle-display-buttonized ()
10169 "Toggle the buttonizing of the article buffer."
10171 (require 'gnus-art)
10172 (if (setq gnus-inhibit-mime-unbuttonizing
10173 (not gnus-inhibit-mime-unbuttonizing))
10174 (let ((gnus-unbuttonized-mime-types nil))
10175 (gnus-summary-show-article))
10176 (gnus-summary-show-article)))
10179 ;;; Generic summary marking commands
10182 (defvar gnus-summary-marking-alist
10183 '((read gnus-del-mark "d")
10184 (unread gnus-unread-mark "u")
10185 (ticked gnus-ticked-mark "!")
10186 (dormant gnus-dormant-mark "?")
10187 (expirable gnus-expirable-mark "e"))
10188 "An alist of names/marks/keystrokes.")
10190 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
10191 (defvar gnus-summary-mark-map)
10193 (defun gnus-summary-make-all-marking-commands ()
10194 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
10195 (dolist (elem gnus-summary-marking-alist)
10196 (apply 'gnus-summary-make-marking-command elem)))
10198 (defun gnus-summary-make-marking-command (name mark keystroke)
10199 (let ((map (make-sparse-keymap)))
10200 (define-key gnus-summary-generic-mark-map keystroke map)
10201 (dolist (lway `((next "next" next nil "n")
10202 (next-unread "next unread" next t "N")
10203 (prev "previous" prev nil "p")
10204 (prev-unread "previous unread" prev t "P")
10205 (nomove "" nil nil ,keystroke)))
10206 (let ((func (gnus-summary-make-marking-command-1
10207 mark (car lway) lway name)))
10208 (setq func (eval func))
10209 (define-key map (nth 4 lway) func)))))
10211 (defun gnus-summary-make-marking-command-1 (mark way lway name)
10213 (format "gnus-summary-put-mark-as-%s%s"
10214 name (if (eq way 'nomove)
10216 (concat "-" (symbol-name way)))))
10219 "Mark the current article as %s%s.
10220 If N, the prefix, then repeat N times.
10221 If N is negative, move in reverse order.
10222 The difference between N and the actual number of articles marked is
10226 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
10228 (defun gnus-summary-generic-mark (n mark move unread)
10229 "Mark N articles with MARK."
10230 (unless (eq major-mode 'gnus-summary-mode)
10231 (error "This command can only be used in the summary buffer"))
10232 (gnus-summary-show-thread)
10235 ((eq move 'next) 1)
10236 ((eq move 'prev) -1)
10238 (if (zerop nummove)
10242 nummove (* -1 nummove))))
10243 (while (and (> n 0)
10244 (gnus-summary-mark-article nil mark)
10245 (zerop (gnus-summary-next-subject nummove unread t)))
10248 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
10249 (gnus-summary-recenter)
10250 (gnus-summary-position-point)
10251 (gnus-set-mode-line 'summary)
10254 (defun gnus-summary-insert-articles (articles)
10255 (when (setq articles
10256 (gnus-set-difference articles
10257 (mapcar (lambda (h) (mail-header-number h))
10258 gnus-newsgroup-headers)))
10259 (setq gnus-newsgroup-headers
10261 gnus-newsgroup-headers
10262 (gnus-fetch-headers articles)
10263 'gnus-article-sort-by-number))
10264 ;; Suppress duplicates?
10265 (when gnus-suppress-duplicates
10266 (gnus-dup-suppress-articles))
10268 ;; We might want to build some more threads first.
10269 (when (and gnus-fetch-old-headers
10270 (eq gnus-headers-retrieved-by 'nov))
10271 (if (eq gnus-fetch-old-headers 'invisible)
10272 (gnus-build-all-threads)
10273 (gnus-build-old-threads)))
10274 ;; Let the Gnus agent mark articles as read.
10276 (gnus-agent-get-undownloaded-list))
10277 ;; Remove list identifiers from subject
10278 (when gnus-list-identifiers
10279 (gnus-summary-remove-list-identifiers))
10280 ;; First and last article in this newsgroup.
10281 (when gnus-newsgroup-headers
10282 (setq gnus-newsgroup-begin
10283 (mail-header-number (car gnus-newsgroup-headers))
10285 (mail-header-number
10286 (gnus-last-element gnus-newsgroup-headers))))
10287 (when gnus-use-scoring
10288 (gnus-possibly-score-headers))))
10290 (defun gnus-summary-insert-old-articles (&optional all)
10291 "Insert all old articles in this group.
10292 If ALL is non-nil, already read articles become readable.
10293 If ALL is a number, fetch this number of articles."
10296 (let ((old (mapcar 'car gnus-newsgroup-data))
10297 (i (car gnus-newsgroup-active))
10299 (while (<= i (cdr gnus-newsgroup-active))
10300 (or (memq i old) (push i older))
10302 (setq len (length older))
10307 (setq older (subseq older 0 all))))
10310 (if (and (numberp gnus-large-newsgroup)
10311 (> len gnus-large-newsgroup))
10315 "How many articles from %s (default %d): "
10317 (gnus-group-decoded-name gnus-newsgroup-name) 35)
10319 (unless (string-match "^[ \t]*$" input)
10320 (setq all (string-to-number input))
10322 (setq older (subseq older 0 all))))))))
10324 (message "No old news.")
10325 (gnus-summary-insert-articles older)
10326 (gnus-summary-limit (gnus-union older old))))
10327 (gnus-summary-position-point)))
10329 (defun gnus-summary-insert-new-articles ()
10330 "Insert all new articles in this group."
10333 (let ((old (mapcar 'car gnus-newsgroup-data))
10334 (old-active gnus-newsgroup-active)
10335 (nnmail-fetched-sources (list t))
10337 (setq gnus-newsgroup-active
10338 (gnus-activate-group gnus-newsgroup-name 'scan))
10339 (setq i (1+ (cdr old-active)))
10340 (while (<= i (cdr gnus-newsgroup-active))
10344 (message "No gnus is bad news.")
10345 (setq new (nreverse new))
10346 (gnus-summary-insert-articles new)
10347 (setq gnus-newsgroup-unreads
10348 (append gnus-newsgroup-unreads new))
10349 (gnus-summary-limit (gnus-union old new))))
10350 (gnus-summary-position-point)))
10352 (gnus-summary-make-all-marking-commands)
10354 (gnus-ems-redefine)
10356 (provide 'gnus-sum)
10358 (run-hooks 'gnus-sum-load-hook)
10360 ;;; gnus-sum.el ends here