1 ;;; gnus-sum.el --- summary mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
29 (eval-when-compile (require 'cl))
40 ;; (require 'gnus-art)
42 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
43 (autoload 'gnus-cache-write-active "gnus-cache")
44 (autoload 'gnus-mailing-list-insinuate "gnus-ml" nil t)
45 (autoload 'turn-on-gnus-mailing-list-mode "gnus-ml" nil t)
46 (autoload 'mm-uu-dissect "mm-uu")
48 (defcustom gnus-kill-summary-on-exit t
49 "*If non-nil, kill the summary buffer when you exit from it.
50 If nil, the summary will become a \"*Dead Summary*\" buffer, and
51 it will be killed sometime later."
52 :group 'gnus-summary-exit
55 (defcustom gnus-fetch-old-headers nil
56 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
57 If an unread article in the group refers to an older, already read (or
58 just marked as read) article, the old article will not normally be
59 displayed in the Summary buffer. If this variable is non-nil, Gnus
60 will attempt to grab the headers to the old articles, and thereby
61 build complete threads. If it has the value `some', only enough
62 headers to connect otherwise loose threads will be displayed. This
63 variable can also be a number. In that case, no more than that number
64 of old headers will be fetched. If it has the value `invisible', all
65 old headers will be fetched, but none will be displayed.
67 The server has to support NOV for any of this to work."
69 :type '(choice (const :tag "off" nil)
72 (sexp :menu-tag "other" t)))
74 (defcustom gnus-refer-thread-limit 200
75 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
76 If t, fetch all the available old headers."
79 (sexp :menu-tag "other" t)))
81 (defcustom gnus-summary-make-false-root 'adopt
82 "*nil means that Gnus won't gather loose threads.
83 If the root of a thread has expired or been read in a previous
84 session, the information necessary to build a complete thread has been
85 lost. Instead of having many small sub-threads from this original thread
86 scattered all over the summary buffer, Gnus can gather them.
88 If non-nil, Gnus will try to gather all loose sub-threads from an
89 original thread into one large thread.
91 If this variable is non-nil, it should be one of `none', `adopt',
94 If this variable is `none', Gnus will not make a false root, but just
95 present the sub-threads after another.
96 If this variable is `dummy', Gnus will create a dummy root that will
97 have all the sub-threads as children.
98 If this variable is `adopt', Gnus will make one of the \"children\"
99 the parent and mark all the step-children as such.
100 If this variable is `empty', the \"children\" are printed with empty
101 subject fields. (Or rather, they will be printed with a string
102 given by the `gnus-summary-same-subject' variable.)"
104 :type '(choice (const :tag "off" nil)
110 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
111 "*A regexp to match subjects to be excluded from loose thread gathering.
112 As loose thread gathering is done on subjects only, that means that
113 there can be many false gatherings performed. By rooting out certain
114 common subjects, gathering might become saner."
118 (defcustom gnus-summary-gather-subject-limit nil
119 "*Maximum length of subject comparisons when gathering loose threads.
120 Use nil to compare full subjects. Setting this variable to a low
121 number will help gather threads that have been corrupted by
122 newsreaders chopping off subject lines, but it might also mean that
123 unrelated articles that have subject that happen to begin with the
124 same few characters will be incorrectly gathered.
126 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
129 :type '(choice (const :tag "off" nil)
131 (sexp :menu-tag "on" t)))
133 (defcustom gnus-simplify-subject-functions nil
134 "List of functions taking a string argument that simplify subjects.
135 The functions are applied recursively.
137 Useful functions to put in this list include: `gnus-simplify-subject-re',
138 `gnus-simplify-subject-fuzzy' and `gnus-simplify-whitespace'."
140 :type '(repeat function))
142 (defcustom gnus-simplify-ignored-prefixes nil
143 "*Regexp, matches for which are removed from subject lines when simplifying fuzzily."
145 :type '(choice (const :tag "off" nil)
148 (defcustom gnus-build-sparse-threads nil
149 "*If non-nil, fill in the gaps in threads.
150 If `some', only fill in the gaps that are needed to tie loose threads
151 together. If `more', fill in all leaf nodes that Gnus can find. If
152 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
154 :type '(choice (const :tag "off" nil)
157 (sexp :menu-tag "all" t)))
159 (defcustom gnus-summary-thread-gathering-function
160 'gnus-gather-threads-by-subject
161 "*Function used for gathering loose threads.
162 There are two pre-defined functions: `gnus-gather-threads-by-subject',
163 which only takes Subjects into consideration; and
164 `gnus-gather-threads-by-references', which compared the References
165 headers of the articles to find matches."
167 :type '(radio (function-item gnus-gather-threads-by-subject)
168 (function-item gnus-gather-threads-by-references)
169 (function :tag "other")))
171 (defcustom gnus-summary-same-subject ""
172 "*String indicating that the current article has the same subject as the previous.
173 This variable will only be used if the value of
174 `gnus-summary-make-false-root' is `empty'."
175 :group 'gnus-summary-format
178 (defcustom gnus-summary-goto-unread t
179 "*If t, many commands will go to the next unread article.
180 This applies to marking commands as well as other commands that
181 \"naturally\" select the next article, like, for instance, `SPC' at
182 the end of an article.
184 If nil, the marking commands do NOT go to the next unread article
185 (they go to the next article instead). If `never', commands that
186 usually go to the next unread article, will go to the next article,
187 whether it is read or not."
188 :group 'gnus-summary-marks
189 :link '(custom-manual "(gnus)Setting Marks")
190 :type '(choice (const :tag "off" nil)
192 (sexp :menu-tag "on" t)))
194 (defcustom gnus-summary-default-score 0
195 "*Default article score level.
196 All scores generated by the score files will be added to this score.
197 If this variable is nil, scoring will be disabled."
198 :group 'gnus-score-default
199 :type '(choice (const :tag "disable")
202 (defcustom gnus-summary-zcore-fuzz 0
203 "*Fuzziness factor for the zcore in the summary buffer.
204 Articles with scores closer than this to `gnus-summary-default-score'
206 :group 'gnus-summary-format
209 (defcustom gnus-simplify-subject-fuzzy-regexp nil
210 "*Strings to be removed when doing fuzzy matches.
211 This can either be a regular expression or list of regular expressions
212 that will be removed from subject strings if fuzzy subject
213 simplification is selected."
215 :type '(repeat regexp))
217 (defcustom gnus-show-threads t
218 "*If non-nil, display threads in summary mode."
222 (defcustom gnus-thread-hide-subtree nil
223 "*If non-nil, hide all threads initially.
224 If threads are hidden, you have to run the command
225 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
226 to expose hidden threads."
230 (defcustom gnus-thread-hide-killed t
231 "*If non-nil, hide killed threads automatically."
235 (defcustom gnus-thread-ignore-subject t
236 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
237 If nil, articles that have different subjects from their parents will
238 start separate threads."
242 (defcustom gnus-thread-operation-ignore-subject t
243 "*If non-nil, subjects will be ignored when doing thread commands.
244 This affects commands like `gnus-summary-kill-thread' and
245 `gnus-summary-lower-thread'.
247 If this variable is nil, articles in the same thread with different
248 subjects will not be included in the operation in question. If this
249 variable is `fuzzy', only articles that have subjects that are fuzzily
250 equal will be included."
252 :type '(choice (const :tag "off" nil)
256 (defcustom gnus-thread-indent-level 4
257 "*Number that says how much each sub-thread should be indented."
261 (defcustom gnus-auto-extend-newsgroup t
262 "*If non-nil, extend newsgroup forward and backward when requested."
263 :group 'gnus-summary-choose
266 (defcustom gnus-auto-select-first t
267 "*If nil, don't select the first unread article when entering a group.
268 If this variable is `best', select the highest-scored unread article
269 in the group. If t, select the first unread article.
271 This variable can also be a function to place point on a likely
272 subject line. Useful values include `gnus-summary-first-unread-subject',
273 `gnus-summary-first-unread-article' and
274 `gnus-summary-best-unread-article'.
276 If you want to prevent automatic selection of the first unread article
277 in some newsgroups, set the variable to nil in
278 `gnus-select-group-hook'."
279 :group 'gnus-group-select
280 :type '(choice (const :tag "none" nil)
282 (sexp :menu-tag "first" t)
283 (function-item gnus-summary-first-unread-subject)
284 (function-item gnus-summary-first-unread-article)
285 (function-item gnus-summary-best-unread-article)))
287 (defcustom gnus-auto-select-next t
288 "*If non-nil, offer to go to the next group from the end of the previous.
289 If the value is t and the next newsgroup is empty, Gnus will exit
290 summary mode and go back to group mode. If the value is neither nil
291 nor t, Gnus will select the following unread newsgroup. In
292 particular, if the value is the symbol `quietly', the next unread
293 newsgroup will be selected without any confirmation, and if it is
294 `almost-quietly', the next group will be selected without any
295 confirmation if you are located on the last article in the group.
296 Finally, if this variable is `slightly-quietly', the `Z n' command
297 will go to the next group without confirmation."
298 :group 'gnus-summary-maneuvering
299 :type '(choice (const :tag "off" nil)
301 (const almost-quietly)
302 (const slightly-quietly)
303 (sexp :menu-tag "on" t)))
305 (defcustom gnus-auto-select-same nil
306 "*If non-nil, select the next article with the same subject.
307 If there are no more articles with the same subject, go to
308 the first unread article."
309 :group 'gnus-summary-maneuvering
312 (defcustom gnus-summary-check-current nil
313 "*If non-nil, consider the current article when moving.
314 The \"unread\" movement commands will stay on the same line if the
315 current article is unread."
316 :group 'gnus-summary-maneuvering
319 (defcustom gnus-auto-center-summary t
320 "*If non-nil, always center the current summary buffer.
321 In particular, if `vertical' do only vertical recentering. If non-nil
322 and non-`vertical', do both horizontal and vertical recentering."
323 :group 'gnus-summary-maneuvering
324 :type '(choice (const :tag "none" nil)
326 (integer :tag "height")
327 (sexp :menu-tag "both" t)))
329 (defcustom gnus-show-all-headers nil
330 "*If non-nil, don't hide any headers."
331 :group 'gnus-article-hiding
332 :group 'gnus-article-headers
335 (defcustom gnus-summary-ignore-duplicates nil
336 "*If non-nil, ignore articles with identical Message-ID headers."
340 (defcustom gnus-single-article-buffer t
341 "*If non-nil, display all articles in the same buffer.
342 If nil, each group will get its own article buffer."
343 :group 'gnus-article-various
346 (defcustom gnus-break-pages t
347 "*If non-nil, do page breaking on articles.
348 The page delimiter is specified by the `gnus-page-delimiter'
350 :group 'gnus-article-various
353 (defcustom gnus-move-split-methods nil
354 "*Variable used to suggest where articles are to be moved to.
355 It uses the same syntax as the `gnus-split-methods' variable.
356 However, whereas `gnus-split-methods' specifies file names as targets,
357 this variable specifies group names."
358 :group 'gnus-summary-mail
359 :type '(repeat (choice (list :value (fun) function)
360 (cons :value ("" "") regexp (repeat string))
363 (defcustom gnus-unread-mark ? ;Whitespace
364 "*Mark used for unread articles."
365 :group 'gnus-summary-marks
368 (defcustom gnus-ticked-mark ?!
369 "*Mark used for ticked articles."
370 :group 'gnus-summary-marks
373 (defcustom gnus-dormant-mark ??
374 "*Mark used for dormant articles."
375 :group 'gnus-summary-marks
378 (defcustom gnus-del-mark ?r
379 "*Mark used for del'd articles."
380 :group 'gnus-summary-marks
383 (defcustom gnus-read-mark ?R
384 "*Mark used for read articles."
385 :group 'gnus-summary-marks
388 (defcustom gnus-expirable-mark ?E
389 "*Mark used for expirable articles."
390 :group 'gnus-summary-marks
393 (defcustom gnus-killed-mark ?K
394 "*Mark used for killed articles."
395 :group 'gnus-summary-marks
398 (defcustom gnus-souped-mark ?F
399 "*Mark used for souped articles."
400 :group 'gnus-summary-marks
403 (defcustom gnus-kill-file-mark ?X
404 "*Mark used for articles killed by kill files."
405 :group 'gnus-summary-marks
408 (defcustom gnus-low-score-mark ?Y
409 "*Mark used for articles with a low score."
410 :group 'gnus-summary-marks
413 (defcustom gnus-catchup-mark ?C
414 "*Mark used for articles that are caught up."
415 :group 'gnus-summary-marks
418 (defcustom gnus-replied-mark ?A
419 "*Mark used for articles that have been replied to."
420 :group 'gnus-summary-marks
423 (defcustom gnus-forwarded-mark ?O
424 "*Mark used for articles that have been forwarded."
425 :group 'gnus-summary-marks
428 (defcustom gnus-cached-mark ?*
429 "*Mark used for articles that are in the cache."
430 :group 'gnus-summary-marks
433 (defcustom gnus-saved-mark ?S
434 "*Mark used for articles that have been saved to."
435 :group 'gnus-summary-marks
438 (defcustom gnus-no-mark ? ;Whitespace
439 "*Mark used for articles that have no other secondary mark."
440 :group 'gnus-summary-marks
443 (defcustom gnus-ancient-mark ?O
444 "*Mark used for ancient articles."
445 :group 'gnus-summary-marks
448 (defcustom gnus-sparse-mark ?Q
449 "*Mark used for sparsely reffed articles."
450 :group 'gnus-summary-marks
453 (defcustom gnus-canceled-mark ?G
454 "*Mark used for canceled articles."
455 :group 'gnus-summary-marks
458 (defcustom gnus-duplicate-mark ?M
459 "*Mark used for duplicate articles."
460 :group 'gnus-summary-marks
463 (defcustom gnus-undownloaded-mark ?@
464 "*Mark used for articles that weren't downloaded."
465 :group 'gnus-summary-marks
468 (defcustom gnus-downloadable-mark ?%
469 "*Mark used for articles that are to be downloaded."
470 :group 'gnus-summary-marks
473 (defcustom gnus-unsendable-mark ?=
474 "*Mark used for articles that won't be sent."
475 :group 'gnus-summary-marks
478 (defcustom gnus-score-over-mark ?+
479 "*Score mark used for articles with high scores."
480 :group 'gnus-summary-marks
483 (defcustom gnus-score-below-mark ?-
484 "*Score mark used for articles with low scores."
485 :group 'gnus-summary-marks
488 (defcustom gnus-empty-thread-mark ? ;Whitespace
489 "*There is no thread under the article."
490 :group 'gnus-summary-marks
493 (defcustom gnus-not-empty-thread-mark ?=
494 "*There is a thread under the article."
495 :group 'gnus-summary-marks
498 (defcustom gnus-view-pseudo-asynchronously nil
499 "*If non-nil, Gnus will view pseudo-articles asynchronously."
500 :group 'gnus-extract-view
503 (defcustom gnus-auto-expirable-marks
504 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
505 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
506 gnus-souped-mark gnus-duplicate-mark)
507 "*The list of marks converted into expiration if a group is auto-expirable."
510 :type '(repeat character))
512 (defcustom gnus-inhibit-user-auto-expire t
513 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
518 (defcustom gnus-view-pseudos nil
519 "*If `automatic', pseudo-articles will be viewed automatically.
520 If `not-confirm', pseudos will be viewed automatically, and the user
521 will not be asked to confirm the command."
522 :group 'gnus-extract-view
523 :type '(choice (const :tag "off" nil)
525 (const not-confirm)))
527 (defcustom gnus-view-pseudos-separately t
528 "*If non-nil, one pseudo-article will be created for each file to be viewed.
529 If nil, all files that use the same viewing command will be given as a
530 list of parameters to that command."
531 :group 'gnus-extract-view
534 (defcustom gnus-insert-pseudo-articles t
535 "*If non-nil, insert pseudo-articles when decoding articles."
536 :group 'gnus-extract-view
539 (defcustom gnus-summary-dummy-line-format
541 "*The format specification for the dummy roots in the summary buffer.
542 It works along the same lines as a normal formatting string,
543 with some simple extensions.
546 :group 'gnus-threading
549 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
550 "*The format specification for the summary mode line.
551 It works along the same lines as a normal formatting string,
552 with some simple extensions:
555 %p Unprefixed group name
556 %A Current article number
557 %z Current article score
559 %U Number of unread articles in the group
560 %e Number of unselected articles in the group
561 %Z A string with unread/unselected article counts
562 %g Shortish group name
563 %S Subject of the current article
565 %s Current score file name
566 %d Number of dormant articles
567 %r Number of articles that have been marked as read in this session
568 %E Number of articles expunged by the score files"
569 :group 'gnus-summary-format
572 (defcustom gnus-list-identifiers nil
573 "Regexp that matches list identifiers to be removed from subject.
574 This can also be a list of regexps."
576 :group 'gnus-summary-format
577 :group 'gnus-article-hiding
578 :type '(choice (const :tag "none" nil)
580 (repeat :value (".*") regexp)))
582 (defcustom gnus-summary-mark-below 0
583 "*Mark all articles with a score below this variable as read.
584 This variable is local to each summary buffer and usually set by the
586 :group 'gnus-score-default
589 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
590 "*List of functions used for sorting articles in the summary buffer.
592 Each function takes two articles and returns non-nil if the first
593 article should be sorted before the other. If you use more than one
594 function, the primary sort function should be the last. You should
595 probably always include `gnus-article-sort-by-number' in the list of
596 sorting functions -- preferably first. Also note that sorting by date
597 is often much slower than sorting by number, and the sorting order is
598 very similar. (Sorting by date means sorting by the time the message
599 was sent, sorting by number means sorting by arrival time.)
601 Ready-made functions include `gnus-article-sort-by-number',
602 `gnus-article-sort-by-author', `gnus-article-sort-by-subject',
603 `gnus-article-sort-by-date' and `gnus-article-sort-by-score'.
605 When threading is turned on, the variable `gnus-thread-sort-functions'
606 controls how articles are sorted."
607 :group 'gnus-summary-sort
608 :type '(repeat (choice (function-item gnus-article-sort-by-number)
609 (function-item gnus-article-sort-by-author)
610 (function-item gnus-article-sort-by-subject)
611 (function-item gnus-article-sort-by-date)
612 (function-item gnus-article-sort-by-score)
613 (function :tag "other"))))
615 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
616 "*List of functions used for sorting threads in the summary buffer.
617 By default, threads are sorted by article number.
619 Each function takes two threads and returns non-nil if the first
620 thread should be sorted before the other. If you use more than one
621 function, the primary sort function should be the last. You should
622 probably always include `gnus-thread-sort-by-number' in the list of
623 sorting functions -- preferably first. Also note that sorting by date
624 is often much slower than sorting by number, and the sorting order is
625 very similar. (Sorting by date means sorting by the time the message
626 was sent, sorting by number means sorting by arrival time.)
628 Ready-made functions include `gnus-thread-sort-by-number',
629 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
630 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
631 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').
633 When threading is turned off, the variable
634 `gnus-article-sort-functions' controls how articles are sorted."
635 :group 'gnus-summary-sort
636 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
637 (function-item gnus-thread-sort-by-author)
638 (function-item gnus-thread-sort-by-subject)
639 (function-item gnus-thread-sort-by-date)
640 (function-item gnus-thread-sort-by-score)
641 (function-item gnus-thread-sort-by-total-score)
642 (function :tag "other"))))
644 (defcustom gnus-thread-score-function '+
645 "*Function used for calculating the total score of a thread.
647 The function is called with the scores of the article and each
648 subthread and should then return the score of the thread.
650 Some functions you can use are `+', `max', or `min'."
651 :group 'gnus-summary-sort
654 (defcustom gnus-summary-expunge-below nil
655 "All articles that have a score less than this variable will be expunged.
656 This variable is local to the summary buffers."
657 :group 'gnus-score-default
658 :type '(choice (const :tag "off" nil)
661 (defcustom gnus-thread-expunge-below nil
662 "All threads that have a total score less than this variable will be expunged.
663 See `gnus-thread-score-function' for en explanation of what a
666 This variable is local to the summary buffers."
667 :group 'gnus-threading
668 :group 'gnus-score-default
669 :type '(choice (const :tag "off" nil)
672 (defcustom gnus-summary-mode-hook nil
673 "*A hook for Gnus summary mode.
674 This hook is run before any variables are set in the summary buffer."
675 :options '(turn-on-gnus-mailing-list-mode)
676 :group 'gnus-summary-various
679 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
680 (when (featurep 'xemacs)
681 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
682 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
683 (add-hook 'gnus-summary-mode-hook
684 'gnus-xmas-switch-horizontal-scrollbar-off))
686 (defcustom gnus-summary-menu-hook nil
687 "*Hook run after the creation of the summary mode menu."
688 :group 'gnus-summary-visual
691 (defcustom gnus-summary-exit-hook nil
692 "*A hook called on exit from the summary buffer.
693 It will be called with point in the group buffer."
694 :group 'gnus-summary-exit
697 (defcustom gnus-summary-prepare-hook nil
698 "*A hook called after the summary buffer has been generated.
699 If you want to modify the summary buffer, you can use this hook."
700 :group 'gnus-summary-various
703 (defcustom gnus-summary-prepared-hook nil
704 "*A hook called as the last thing after the summary buffer has been generated."
705 :group 'gnus-summary-various
708 (defcustom gnus-summary-generate-hook nil
709 "*A hook run just before generating the summary buffer.
710 This hook is commonly used to customize threading variables and the
712 :group 'gnus-summary-various
715 (defcustom gnus-select-group-hook nil
716 "*A hook called when a newsgroup is selected.
718 If you'd like to simplify subjects like the
719 `gnus-summary-next-same-subject' command does, you can use the
722 (setq gnus-select-group-hook
725 (mapcar (lambda (header)
726 (mail-header-set-subject
728 (gnus-simplify-subject
729 (mail-header-subject header) 're-only)))
730 gnus-newsgroup-headers))))"
731 :group 'gnus-group-select
734 (defcustom gnus-select-article-hook nil
735 "*A hook called when an article is selected."
736 :group 'gnus-summary-choose
739 (defcustom gnus-visual-mark-article-hook
740 (list 'gnus-highlight-selected-summary)
741 "*Hook run after selecting an article in the summary buffer.
742 It is meant to be used for highlighting the article in some way. It
743 is not run if `gnus-visual' is nil."
744 :group 'gnus-summary-visual
747 (defcustom gnus-parse-headers-hook nil
748 "*A hook called before parsing the headers."
752 (defcustom gnus-exit-group-hook nil
753 "*A hook called when exiting summary mode.
754 This hook is not called from the non-updating exit commands like `Q'."
758 (defcustom gnus-summary-update-hook
759 (list 'gnus-summary-highlight-line)
760 "*A hook called when a summary line is changed.
761 The hook will not be called if `gnus-visual' is nil.
763 The default function `gnus-summary-highlight-line' will
764 highlight the line according to the `gnus-summary-highlight'
766 :group 'gnus-summary-visual
769 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
770 "*A hook called when an article is selected for the first time.
771 The hook is intended to mark an article as read (or unread)
772 automatically when it is selected."
773 :group 'gnus-summary-choose
776 (defcustom gnus-group-no-more-groups-hook nil
777 "*A hook run when returning to group mode having no more (unread) groups."
778 :group 'gnus-group-select
781 (defcustom gnus-ps-print-hook nil
782 "*A hook run before ps-printing something from Gnus."
786 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
787 "Face used for highlighting the current article in the summary buffer."
788 :group 'gnus-summary-visual
791 (defcustom gnus-summary-highlight
792 '(((= mark gnus-canceled-mark)
793 . gnus-summary-cancelled-face)
794 ((and (> score default)
795 (or (= mark gnus-dormant-mark)
796 (= mark gnus-ticked-mark)))
797 . gnus-summary-high-ticked-face)
798 ((and (< score default)
799 (or (= mark gnus-dormant-mark)
800 (= mark gnus-ticked-mark)))
801 . gnus-summary-low-ticked-face)
802 ((or (= mark gnus-dormant-mark)
803 (= mark gnus-ticked-mark))
804 . gnus-summary-normal-ticked-face)
805 ((and (> score default) (= mark gnus-ancient-mark))
806 . gnus-summary-high-ancient-face)
807 ((and (< score default) (= mark gnus-ancient-mark))
808 . gnus-summary-low-ancient-face)
809 ((= mark gnus-ancient-mark)
810 . gnus-summary-normal-ancient-face)
811 ((and (> score default) (= mark gnus-unread-mark))
812 . gnus-summary-high-unread-face)
813 ((and (< score default) (= mark gnus-unread-mark))
814 . gnus-summary-low-unread-face)
815 ((= mark gnus-unread-mark)
816 . gnus-summary-normal-unread-face)
817 ((and (> score default) (memq mark (list gnus-downloadable-mark
818 gnus-undownloaded-mark)))
819 . gnus-summary-high-unread-face)
820 ((and (< score default) (memq mark (list gnus-downloadable-mark
821 gnus-undownloaded-mark)))
822 . gnus-summary-low-unread-face)
823 ((memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
824 . gnus-summary-normal-unread-face)
826 . gnus-summary-high-read-face)
828 . gnus-summary-low-read-face)
830 . gnus-summary-normal-read-face))
831 "*Controls the highlighting of summary buffer lines.
833 A list of (FORM . FACE) pairs. When deciding how a a particular
834 summary line should be displayed, each form is evaluated. The content
835 of the face field after the first true form is used. You can change
836 how those summary lines are displayed, by editing the face field.
838 You can use the following variables in the FORM field.
840 score: The articles score
841 default: The default article score.
842 below: The score below which articles are automatically marked as read.
843 mark: The articles mark."
844 :group 'gnus-summary-visual
845 :type '(repeat (cons (sexp :tag "Form" nil)
848 (defcustom gnus-alter-header-function nil
849 "Function called to allow alteration of article header structures.
850 The function is called with one parameter, the article header vector,
851 which it may alter in any way.")
853 (defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string
854 "Variable that says which function should be used to decode a string with encoded words.")
856 (defcustom gnus-extra-headers nil
857 "*Extra headers to parse."
860 :type '(repeat symbol))
862 (defcustom gnus-ignored-from-addresses
863 (and user-mail-address (regexp-quote user-mail-address))
864 "*Regexp of From headers that may be suppressed in favor of To headers."
869 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
870 "List of charsets that should be ignored.
871 When these charsets are used in the \"charset\" parameter, the
872 default charset will be used instead."
874 :type '(repeat symbol)
875 :group 'gnus-charset)
877 (gnus-define-group-parameter
881 "Return the ignored charsets of GROUP."
882 :variable gnus-group-ignored-charsets-alist
884 '(("alt\\.chinese\\.text" iso-8859-1))
886 "Alist of regexps (to match group names) and charsets that should be ignored.
887 When these charsets are used in the \"charset\" parameter, the
888 default charset will be used instead."
889 :variable-group gnus-charset
890 :variable-type '(repeat (cons (regexp :tag "Group")
892 :parameter-type '(choice :tag "Ignored charsets"
895 :parameter-document "\
896 List of charsets that should be ignored.
898 When these charsets are used in the \"charset\" parameter, the
899 default charset will be used instead.")
901 (defcustom gnus-group-highlight-words-alist nil
902 "Alist of group regexps and highlight regexps.
903 This variable uses the same syntax as `gnus-emphasis-alist'."
905 :type '(repeat (cons (regexp :tag "Group")
906 (repeat (list (regexp :tag "Highlight regexp")
907 (number :tag "Group for entire word" 0)
908 (number :tag "Group for displayed part" 0)
910 gnus-emphasis-highlight-words)))))
911 :group 'gnus-summary-visual)
913 (defcustom gnus-summary-show-article-charset-alist
915 "Alist of number and charset.
916 The article will be shown with the charset corresponding to the
918 For example: ((1 . cn-gb-2312) (2 . big5))."
920 :type '(repeat (cons (number :tag "Argument" 1)
921 (symbol :tag "Charset")))
922 :group 'gnus-charset)
924 (defcustom gnus-preserve-marks t
925 "Whether marks are preserved when moving, copying and respooling messages."
928 :group 'gnus-summary-marks)
930 (defcustom gnus-alter-articles-to-read-function nil
931 "Function to be called to alter the list of articles to be selected."
932 :type '(choice (const nil) function)
933 :group 'gnus-summary)
935 (defcustom gnus-orphan-score nil
936 "*All orphans get this score added. Set in the score file."
937 :group 'gnus-score-default
938 :type '(choice (const nil)
941 (defcustom gnus-summary-save-parts-default-mime "image/.*"
942 "*A regexp to match MIME parts when saving multiple parts of a message
943 with gnus-summary-save-parts (X m). This regexp will be used by default
944 when prompting the user for which type of files to save."
949 (defcustom gnus-summary-save-parts-default-mime "image/.*"
950 "*A regexp to match MIME parts when saving multiple parts of a message
951 with gnus-summary-save-parts (X m). This regexp will be used by default
952 when prompting the user for which type of files to save."
957 ;;; Internal variables
959 (defvar gnus-article-mime-handles nil)
960 (defvar gnus-article-decoded-p nil)
961 (defvar gnus-article-charset nil)
962 (defvar gnus-article-ignored-charsets nil)
963 (defvar gnus-scores-exclude-files nil)
964 (defvar gnus-page-broken nil)
965 (defvar gnus-inhibit-mime-unbuttonizing nil)
967 (defvar gnus-original-article nil)
968 (defvar gnus-article-internal-prepare-hook nil)
969 (defvar gnus-newsgroup-process-stack nil)
971 (defvar gnus-thread-indent-array nil)
972 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
973 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
974 "Function called to sort the articles within a thread after it has been gathered together.")
976 (defvar gnus-summary-save-parts-type-history nil)
977 (defvar gnus-summary-save-parts-last-directory nil)
979 (defvar gnus-summary-save-parts-type-history nil)
980 (defvar gnus-summary-save-parts-last-directory nil)
982 ;; Avoid highlighting in kill files.
983 (defvar gnus-summary-inhibit-highlight nil)
984 (defvar gnus-newsgroup-selected-overlay nil)
985 (defvar gnus-inhibit-limiting nil)
986 (defvar gnus-newsgroup-adaptive-score-file nil)
987 (defvar gnus-current-score-file nil)
988 (defvar gnus-current-move-group nil)
989 (defvar gnus-current-copy-group nil)
990 (defvar gnus-current-crosspost-group nil)
992 (defvar gnus-newsgroup-dependencies nil)
993 (defvar gnus-newsgroup-adaptive nil)
994 (defvar gnus-summary-display-article-function nil)
995 (defvar gnus-summary-highlight-line-function nil
996 "Function called after highlighting a summary line.")
998 (defvar gnus-summary-line-format-alist
999 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1000 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1001 (?s gnus-tmp-subject-or-nil ?s)
1002 (?n gnus-tmp-name ?s)
1003 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1005 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1007 (?F gnus-tmp-from ?s)
1008 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1009 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1010 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1011 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1012 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1013 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1014 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1015 (?L gnus-tmp-lines ?s)
1016 (?I gnus-tmp-indentation ?s)
1017 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1018 (?R gnus-tmp-replied ?c)
1019 (?\[ gnus-tmp-opening-bracket ?c)
1020 (?\] gnus-tmp-closing-bracket ?c)
1021 (?\> (make-string gnus-tmp-level ? ) ?s)
1022 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1023 (?i gnus-tmp-score ?d)
1024 (?z gnus-tmp-score-char ?c)
1025 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1026 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1027 (?U gnus-tmp-unread ?c)
1028 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header) ?s)
1029 (?t (gnus-summary-number-of-articles-in-thread
1030 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1032 (?e (gnus-summary-number-of-articles-in-thread
1033 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1035 (?u gnus-tmp-user-defined ?s)
1036 (?P (gnus-pick-line-number) ?d))
1037 "An alist of format specifications that can appear in summary lines.
1038 These are paired with what variables they correspond with, along with
1039 the type of the variable (string, integer, character, etc).")
1041 (defvar gnus-summary-dummy-line-format-alist
1042 `((?S gnus-tmp-subject ?s)
1043 (?N gnus-tmp-number ?d)
1044 (?u gnus-tmp-user-defined ?s)))
1046 (defvar gnus-summary-mode-line-format-alist
1047 `((?G gnus-tmp-group-name ?s)
1048 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1049 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1050 (?A gnus-tmp-article-number ?d)
1051 (?Z gnus-tmp-unread-and-unselected ?s)
1052 (?V gnus-version ?s)
1053 (?U gnus-tmp-unread-and-unticked ?d)
1054 (?S gnus-tmp-subject ?s)
1055 (?e gnus-tmp-unselected ?d)
1056 (?u gnus-tmp-user-defined ?s)
1057 (?d (length gnus-newsgroup-dormant) ?d)
1058 (?t (length gnus-newsgroup-marked) ?d)
1059 (?r (length gnus-newsgroup-reads) ?d)
1060 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1061 (?E gnus-newsgroup-expunged-tally ?d)
1062 (?s (gnus-current-score-file-nondirectory) ?s)))
1064 (defvar gnus-last-search-regexp nil
1065 "Default regexp for article search command.")
1067 (defvar gnus-last-shell-command nil
1068 "Default shell command on article.")
1070 (defvar gnus-newsgroup-begin nil)
1071 (defvar gnus-newsgroup-end nil)
1072 (defvar gnus-newsgroup-last-rmail nil)
1073 (defvar gnus-newsgroup-last-mail nil)
1074 (defvar gnus-newsgroup-last-folder nil)
1075 (defvar gnus-newsgroup-last-file nil)
1076 (defvar gnus-newsgroup-auto-expire nil)
1077 (defvar gnus-newsgroup-active nil)
1079 (defvar gnus-newsgroup-data nil)
1080 (defvar gnus-newsgroup-data-reverse nil)
1081 (defvar gnus-newsgroup-limit nil)
1082 (defvar gnus-newsgroup-limits nil)
1084 (defvar gnus-newsgroup-unreads nil
1085 "List of unread articles in the current newsgroup.")
1087 (defvar gnus-newsgroup-unselected nil
1088 "List of unselected unread articles in the current newsgroup.")
1090 (defvar gnus-newsgroup-reads nil
1091 "Alist of read articles and article marks in the current newsgroup.")
1093 (defvar gnus-newsgroup-expunged-tally nil)
1095 (defvar gnus-newsgroup-marked nil
1096 "List of ticked articles in the current newsgroup (a subset of unread art).")
1098 (defvar gnus-newsgroup-killed nil
1099 "List of ranges of articles that have been through the scoring process.")
1101 (defvar gnus-newsgroup-cached nil
1102 "List of articles that come from the article cache.")
1104 (defvar gnus-newsgroup-saved nil
1105 "List of articles that have been saved.")
1107 (defvar gnus-newsgroup-kill-headers nil)
1109 (defvar gnus-newsgroup-replied nil
1110 "List of articles that have been replied to in the current newsgroup.")
1112 (defvar gnus-newsgroup-forwarded nil
1113 "List of articles that have been forwarded in the current newsgroup.")
1115 (defvar gnus-newsgroup-expirable nil
1116 "List of articles in the current newsgroup that can be expired.")
1118 (defvar gnus-newsgroup-processable nil
1119 "List of articles in the current newsgroup that can be processed.")
1121 (defvar gnus-newsgroup-downloadable nil
1122 "List of articles in the current newsgroup that can be processed.")
1124 (defvar gnus-newsgroup-undownloaded nil
1125 "List of articles in the current newsgroup that haven't been downloaded..")
1127 (defvar gnus-newsgroup-unsendable nil
1128 "List of articles in the current newsgroup that won't be sent.")
1130 (defvar gnus-newsgroup-bookmarks nil
1131 "List of articles in the current newsgroup that have bookmarks.")
1133 (defvar gnus-newsgroup-dormant nil
1134 "List of dormant articles in the current newsgroup.")
1136 (defvar gnus-newsgroup-scored nil
1137 "List of scored articles in the current newsgroup.")
1139 (defvar gnus-newsgroup-headers nil
1140 "List of article headers in the current newsgroup.")
1142 (defvar gnus-newsgroup-threads nil)
1144 (defvar gnus-newsgroup-prepared nil
1145 "Whether the current group has been prepared properly.")
1147 (defvar gnus-newsgroup-ancient nil
1148 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1150 (defvar gnus-newsgroup-sparse nil)
1152 (defvar gnus-current-article nil)
1153 (defvar gnus-article-current nil)
1154 (defvar gnus-current-headers nil)
1155 (defvar gnus-have-all-headers nil)
1156 (defvar gnus-last-article nil)
1157 (defvar gnus-newsgroup-history nil)
1158 (defvar gnus-newsgroup-charset nil)
1159 (defvar gnus-newsgroup-ephemeral-charset nil)
1160 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1162 (defvar gnus-article-before-search nil)
1164 (defconst gnus-summary-local-variables
1165 '(gnus-newsgroup-name
1166 gnus-newsgroup-begin gnus-newsgroup-end
1167 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1168 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1169 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1170 gnus-newsgroup-unselected gnus-newsgroup-marked
1171 gnus-newsgroup-reads gnus-newsgroup-saved
1172 gnus-newsgroup-replied gnus-newsgroup-forwarded
1173 gnus-newsgroup-expirable
1174 gnus-newsgroup-processable gnus-newsgroup-killed
1175 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1176 gnus-newsgroup-unsendable
1177 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1178 gnus-newsgroup-headers gnus-newsgroup-threads
1179 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1180 gnus-current-article gnus-current-headers gnus-have-all-headers
1181 gnus-last-article gnus-article-internal-prepare-hook
1182 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1183 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1184 gnus-thread-expunge-below
1185 gnus-score-alist gnus-current-score-file
1186 (gnus-summary-expunge-below . global)
1187 (gnus-summary-mark-below . global)
1188 (gnus-orphan-score . global)
1189 gnus-newsgroup-active gnus-scores-exclude-files
1190 gnus-newsgroup-history gnus-newsgroup-ancient
1191 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1192 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1193 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1194 (gnus-newsgroup-expunged-tally . 0)
1195 gnus-cache-removable-articles gnus-newsgroup-cached
1196 gnus-newsgroup-data gnus-newsgroup-data-reverse
1197 gnus-newsgroup-limit gnus-newsgroup-limits
1198 gnus-newsgroup-charset)
1199 "Variables that are buffer-local to the summary buffers.")
1201 (defvar gnus-newsgroup-variables nil
1202 "Variables that have separate values in the newsgroups.")
1204 ;; Byte-compiler warning.
1205 (eval-when-compile (defvar gnus-article-mode-map))
1209 (defvar gnus-decode-encoded-word-methods
1210 '(mail-decode-encoded-word-string)
1211 "List of methods used to decode encoded words.
1213 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item is
1214 FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1215 (REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
1216 whose names match REGEXP.
1219 ((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
1220 mail-decode-encoded-word-string
1221 (\"chinese\" . rfc1843-decode-string))")
1223 (defvar gnus-decode-encoded-word-methods-cache nil)
1225 (defun gnus-multi-decode-encoded-word-string (string)
1226 "Apply the functions from `gnus-encoded-word-methods' that match."
1227 (unless (and gnus-decode-encoded-word-methods-cache
1228 (eq gnus-newsgroup-name
1229 (car gnus-decode-encoded-word-methods-cache)))
1230 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
1233 (nconc gnus-decode-encoded-word-methods-cache (list x))
1234 (if (and gnus-newsgroup-name
1235 (string-match (car x) gnus-newsgroup-name))
1236 (nconc gnus-decode-encoded-word-methods-cache
1238 gnus-decode-encoded-word-methods))
1239 (let ((xlist gnus-decode-encoded-word-methods-cache))
1242 (setq string (funcall (pop xlist) string))))
1245 ;; Subject simplification.
1247 (defun gnus-simplify-whitespace (str)
1248 "Remove excessive whitespace from STR."
1251 (while (string-match "[ \t][ \t]+" mystr)
1252 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1254 (substring mystr (match-end 0)))))
1256 (when (string-match "^[ \t]+" mystr)
1257 (setq mystr (substring mystr (match-end 0))))
1259 (when (string-match "[ \t]+$" mystr)
1260 (setq mystr (substring mystr 0 (match-beginning 0))))
1263 (defsubst gnus-simplify-subject-re (subject)
1264 "Remove \"Re:\" from subject lines."
1265 (if (string-match message-subject-re-regexp subject)
1266 (substring subject (match-end 0))
1269 (defun gnus-simplify-subject (subject &optional re-only)
1270 "Remove `Re:' and words in parentheses.
1271 If RE-ONLY is non-nil, strip leading `Re:'s only."
1272 (let ((case-fold-search t)) ;Ignore case.
1273 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1274 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1275 (setq subject (substring subject (match-end 0))))
1276 ;; Remove uninteresting prefixes.
1277 (when (and (not re-only)
1278 gnus-simplify-ignored-prefixes
1279 (string-match gnus-simplify-ignored-prefixes subject))
1280 (setq subject (substring subject (match-end 0))))
1281 ;; Remove words in parentheses from end.
1283 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1284 (setq subject (substring subject 0 (match-beginning 0)))))
1285 ;; Return subject string.
1288 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1290 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1291 (goto-char (point-min))
1292 (while (re-search-forward regexp nil t)
1293 (replace-match (or newtext ""))))
1295 (defun gnus-simplify-buffer-fuzzy ()
1296 "Simplify string in the buffer fuzzily.
1297 The string in the accessible portion of the current buffer is simplified.
1298 It is assumed to be a single-line subject.
1299 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1300 matter is removed. Additional things can be deleted by setting
1301 `gnus-simplify-subject-fuzzy-regexp'."
1302 (let ((case-fold-search t)
1304 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1306 (while (not (eq modified-tick (buffer-modified-tick)))
1307 (setq modified-tick (buffer-modified-tick))
1309 ((listp gnus-simplify-subject-fuzzy-regexp)
1310 (mapcar 'gnus-simplify-buffer-fuzzy-step
1311 gnus-simplify-subject-fuzzy-regexp))
1312 (gnus-simplify-subject-fuzzy-regexp
1313 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1314 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1315 (gnus-simplify-buffer-fuzzy-step
1316 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1317 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1319 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1320 (gnus-simplify-buffer-fuzzy-step " +" " ")
1321 (gnus-simplify-buffer-fuzzy-step " $")
1322 (gnus-simplify-buffer-fuzzy-step "^ +")))
1324 (defun gnus-simplify-subject-fuzzy (subject)
1325 "Simplify a subject string fuzzily.
1326 See `gnus-simplify-buffer-fuzzy' for details."
1328 (gnus-set-work-buffer)
1329 (let ((case-fold-search t))
1330 ;; Remove uninteresting prefixes.
1331 (when (and gnus-simplify-ignored-prefixes
1332 (string-match gnus-simplify-ignored-prefixes subject))
1333 (setq subject (substring subject (match-end 0))))
1335 (inline (gnus-simplify-buffer-fuzzy))
1338 (defsubst gnus-simplify-subject-fully (subject)
1339 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1341 (gnus-simplify-subject-functions
1342 (gnus-map-function gnus-simplify-subject-functions subject))
1343 ((null gnus-summary-gather-subject-limit)
1344 (gnus-simplify-subject-re subject))
1345 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1346 (gnus-simplify-subject-fuzzy subject))
1347 ((numberp gnus-summary-gather-subject-limit)
1348 (gnus-limit-string (gnus-simplify-subject-re subject)
1349 gnus-summary-gather-subject-limit))
1353 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1354 "Check whether two subjects are equal.
1355 If optional argument simple-first is t, first argument is already
1358 ((null simple-first)
1359 (equal (gnus-simplify-subject-fully s1)
1360 (gnus-simplify-subject-fully s2)))
1363 (gnus-simplify-subject-fully s2)))))
1365 (defun gnus-summary-bubble-group ()
1366 "Increase the score of the current group.
1367 This is a handy function to add to `gnus-summary-exit-hook' to
1368 increase the score of each group you read."
1369 (gnus-group-add-score gnus-newsgroup-name))
1373 ;;; Gnus summary mode
1376 (put 'gnus-summary-mode 'mode-class 'special)
1378 (defvar gnus-article-commands-menu)
1381 ;; Non-orthogonal keys
1383 (gnus-define-keys gnus-summary-mode-map
1384 " " gnus-summary-next-page
1385 "\177" gnus-summary-prev-page
1386 [delete] gnus-summary-prev-page
1387 [backspace] gnus-summary-prev-page
1388 "\r" gnus-summary-scroll-up
1389 "\M-\r" gnus-summary-scroll-down
1390 "n" gnus-summary-next-unread-article
1391 "p" gnus-summary-prev-unread-article
1392 "N" gnus-summary-next-article
1393 "P" gnus-summary-prev-article
1394 "\M-\C-n" gnus-summary-next-same-subject
1395 "\M-\C-p" gnus-summary-prev-same-subject
1396 "\M-n" gnus-summary-next-unread-subject
1397 "\M-p" gnus-summary-prev-unread-subject
1398 "." gnus-summary-first-unread-article
1399 "," gnus-summary-best-unread-article
1400 "\M-s" gnus-summary-search-article-forward
1401 "\M-r" gnus-summary-search-article-backward
1402 "<" gnus-summary-beginning-of-article
1403 ">" gnus-summary-end-of-article
1404 "j" gnus-summary-goto-article
1405 "^" gnus-summary-refer-parent-article
1406 "\M-^" gnus-summary-refer-article
1407 "u" gnus-summary-tick-article-forward
1408 "!" gnus-summary-tick-article-forward
1409 "U" gnus-summary-tick-article-backward
1410 "d" gnus-summary-mark-as-read-forward
1411 "D" gnus-summary-mark-as-read-backward
1412 "E" gnus-summary-mark-as-expirable
1413 "\M-u" gnus-summary-clear-mark-forward
1414 "\M-U" gnus-summary-clear-mark-backward
1415 "k" gnus-summary-kill-same-subject-and-select
1416 "\C-k" gnus-summary-kill-same-subject
1417 "\M-\C-k" gnus-summary-kill-thread
1418 "\M-\C-l" gnus-summary-lower-thread
1419 "e" gnus-summary-edit-article
1420 "#" gnus-summary-mark-as-processable
1421 "\M-#" gnus-summary-unmark-as-processable
1422 "\M-\C-t" gnus-summary-toggle-threads
1423 "\M-\C-s" gnus-summary-show-thread
1424 "\M-\C-h" gnus-summary-hide-thread
1425 "\M-\C-f" gnus-summary-next-thread
1426 "\M-\C-b" gnus-summary-prev-thread
1427 [(meta down)] gnus-summary-next-thread
1428 [(meta up)] gnus-summary-prev-thread
1429 "\M-\C-u" gnus-summary-up-thread
1430 "\M-\C-d" gnus-summary-down-thread
1431 "&" gnus-summary-execute-command
1432 "c" gnus-summary-catchup-and-exit
1433 "\C-w" gnus-summary-mark-region-as-read
1434 "\C-t" gnus-summary-toggle-truncation
1435 "?" gnus-summary-mark-as-dormant
1436 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1437 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1438 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1439 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1440 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1441 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1442 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1443 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1444 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1445 "=" gnus-summary-expand-window
1446 "\C-x\C-s" gnus-summary-reselect-current-group
1447 "\M-g" gnus-summary-rescan-group
1448 "w" gnus-summary-stop-page-breaking
1449 "\C-c\C-r" gnus-summary-caesar-message
1450 "f" gnus-summary-followup
1451 "F" gnus-summary-followup-with-original
1452 "C" gnus-summary-cancel-article
1453 "r" gnus-summary-reply
1454 "R" gnus-summary-reply-with-original
1455 "\C-c\C-f" gnus-summary-mail-forward
1456 "o" gnus-summary-save-article
1457 "\C-o" gnus-summary-save-article-mail
1458 "|" gnus-summary-pipe-output
1459 "\M-k" gnus-summary-edit-local-kill
1460 "\M-K" gnus-summary-edit-global-kill
1462 "\C-c\C-d" gnus-summary-describe-group
1463 "q" gnus-summary-exit
1464 "Q" gnus-summary-exit-no-update
1465 "\C-c\C-i" gnus-info-find-node
1466 gnus-mouse-2 gnus-mouse-pick-article
1467 "m" gnus-summary-mail-other-window
1468 "a" gnus-summary-post-news
1469 "x" gnus-summary-limit-to-unread
1470 "s" gnus-summary-isearch-article
1471 "t" gnus-summary-toggle-header
1472 "g" gnus-summary-show-article
1473 "l" gnus-summary-goto-last-article
1474 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1475 "\C-d" gnus-summary-enter-digest-group
1476 "\M-\C-d" gnus-summary-read-document
1477 "\M-\C-e" gnus-summary-edit-parameters
1478 "\M-\C-a" gnus-summary-customize-parameters
1480 "*" gnus-cache-enter-article
1481 "\M-*" gnus-cache-remove-article
1482 "\M-&" gnus-summary-universal-argument
1483 "\C-l" gnus-recenter
1484 "I" gnus-summary-increase-score
1485 "L" gnus-summary-lower-score
1486 "\M-i" gnus-symbolic-argument
1487 "h" gnus-summary-select-article-buffer
1489 "b" gnus-article-view-part
1490 "\M-t" gnus-summary-toggle-display-buttonized
1492 "V" gnus-summary-score-map
1493 "X" gnus-uu-extract-map
1494 "S" gnus-summary-send-map)
1496 ;; Sort of orthogonal keymap
1497 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1498 "t" gnus-summary-tick-article-forward
1499 "!" gnus-summary-tick-article-forward
1500 "d" gnus-summary-mark-as-read-forward
1501 "r" gnus-summary-mark-as-read-forward
1502 "c" gnus-summary-clear-mark-forward
1503 " " gnus-summary-clear-mark-forward
1504 "e" gnus-summary-mark-as-expirable
1505 "x" gnus-summary-mark-as-expirable
1506 "?" gnus-summary-mark-as-dormant
1507 "b" gnus-summary-set-bookmark
1508 "B" gnus-summary-remove-bookmark
1509 "#" gnus-summary-mark-as-processable
1510 "\M-#" gnus-summary-unmark-as-processable
1511 "S" gnus-summary-limit-include-expunged
1512 "C" gnus-summary-catchup
1513 "H" gnus-summary-catchup-to-here
1514 "\C-c" gnus-summary-catchup-all
1515 "k" gnus-summary-kill-same-subject-and-select
1516 "K" gnus-summary-kill-same-subject
1517 "P" gnus-uu-mark-map)
1519 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1520 "c" gnus-summary-clear-above
1521 "u" gnus-summary-tick-above
1522 "m" gnus-summary-mark-above
1523 "k" gnus-summary-kill-below)
1525 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1526 "/" gnus-summary-limit-to-subject
1527 "n" gnus-summary-limit-to-articles
1528 "w" gnus-summary-pop-limit
1529 "s" gnus-summary-limit-to-subject
1530 "a" gnus-summary-limit-to-author
1531 "u" gnus-summary-limit-to-unread
1532 "m" gnus-summary-limit-to-marks
1533 "M" gnus-summary-limit-exclude-marks
1534 "v" gnus-summary-limit-to-score
1535 "*" gnus-summary-limit-include-cached
1536 "D" gnus-summary-limit-include-dormant
1537 "T" gnus-summary-limit-include-thread
1538 "d" gnus-summary-limit-exclude-dormant
1539 "t" gnus-summary-limit-to-age
1540 "x" gnus-summary-limit-to-extra
1541 "E" gnus-summary-limit-include-expunged
1542 "c" gnus-summary-limit-exclude-childless-dormant
1543 "C" gnus-summary-limit-mark-excluded-as-read
1544 "o" gnus-summary-insert-old-articles
1545 "N" gnus-summary-insert-new-articles)
1547 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1548 "n" gnus-summary-next-unread-article
1549 "p" gnus-summary-prev-unread-article
1550 "N" gnus-summary-next-article
1551 "P" gnus-summary-prev-article
1552 "\C-n" gnus-summary-next-same-subject
1553 "\C-p" gnus-summary-prev-same-subject
1554 "\M-n" gnus-summary-next-unread-subject
1555 "\M-p" gnus-summary-prev-unread-subject
1556 "f" gnus-summary-first-unread-article
1557 "b" gnus-summary-best-unread-article
1558 "j" gnus-summary-goto-article
1559 "g" gnus-summary-goto-subject
1560 "l" gnus-summary-goto-last-article
1561 "o" gnus-summary-pop-article)
1563 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1564 "k" gnus-summary-kill-thread
1565 "l" gnus-summary-lower-thread
1566 "i" gnus-summary-raise-thread
1567 "T" gnus-summary-toggle-threads
1568 "t" gnus-summary-rethread-current
1569 "^" gnus-summary-reparent-thread
1570 "s" gnus-summary-show-thread
1571 "S" gnus-summary-show-all-threads
1572 "h" gnus-summary-hide-thread
1573 "H" gnus-summary-hide-all-threads
1574 "n" gnus-summary-next-thread
1575 "p" gnus-summary-prev-thread
1576 "u" gnus-summary-up-thread
1577 "o" gnus-summary-top-thread
1578 "d" gnus-summary-down-thread
1579 "#" gnus-uu-mark-thread
1580 "\M-#" gnus-uu-unmark-thread)
1582 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1583 "g" gnus-summary-prepare
1584 "c" gnus-summary-insert-cached-articles)
1586 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1587 "c" gnus-summary-catchup-and-exit
1588 "C" gnus-summary-catchup-all-and-exit
1589 "E" gnus-summary-exit-no-update
1590 "Q" gnus-summary-exit
1591 "Z" gnus-summary-exit
1592 "n" gnus-summary-catchup-and-goto-next-group
1593 "R" gnus-summary-reselect-current-group
1594 "G" gnus-summary-rescan-group
1595 "N" gnus-summary-next-group
1596 "s" gnus-summary-save-newsrc
1597 "P" gnus-summary-prev-group)
1599 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1600 " " gnus-summary-next-page
1601 "n" gnus-summary-next-page
1602 "\177" gnus-summary-prev-page
1603 [delete] gnus-summary-prev-page
1604 "p" gnus-summary-prev-page
1605 "\r" gnus-summary-scroll-up
1606 "\M-\r" gnus-summary-scroll-down
1607 "<" gnus-summary-beginning-of-article
1608 ">" gnus-summary-end-of-article
1609 "b" gnus-summary-beginning-of-article
1610 "e" gnus-summary-end-of-article
1611 "^" gnus-summary-refer-parent-article
1612 "r" gnus-summary-refer-parent-article
1613 "D" gnus-summary-enter-digest-group
1614 "R" gnus-summary-refer-references
1615 "T" gnus-summary-refer-thread
1616 "g" gnus-summary-show-article
1617 "s" gnus-summary-isearch-article
1618 "P" gnus-summary-print-article
1619 "M" gnus-mailing-list-insinuate
1620 "t" gnus-article-babel)
1622 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1623 "b" gnus-article-add-buttons
1624 "B" gnus-article-add-buttons-to-head
1625 "o" gnus-article-treat-overstrike
1626 "e" gnus-article-emphasize
1627 "w" gnus-article-fill-cited-article
1628 "Q" gnus-article-fill-long-lines
1629 "C" gnus-article-capitalize-sentences
1630 "c" gnus-article-remove-cr
1631 "q" gnus-article-de-quoted-unreadable
1632 "6" gnus-article-de-base64-unreadable
1633 "Z" gnus-article-decode-HZ
1634 "h" gnus-article-wash-html
1635 "s" gnus-summary-force-verify-and-decrypt
1636 "f" gnus-article-display-x-face
1637 "l" gnus-summary-stop-page-breaking
1638 "r" gnus-summary-caesar-message
1639 "t" gnus-summary-toggle-header
1640 "v" gnus-summary-verbose-headers
1641 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
1642 "p" gnus-article-verify-x-pgp-sig
1643 "d" gnus-article-treat-dumbquotes)
1645 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1646 "a" gnus-article-hide
1647 "h" gnus-article-hide-headers
1648 "b" gnus-article-hide-boring-headers
1649 "s" gnus-article-hide-signature
1650 "c" gnus-article-hide-citation
1651 "C" gnus-article-hide-citation-in-followups
1652 "l" gnus-article-hide-list-identifiers
1653 "p" gnus-article-hide-pgp
1654 "B" gnus-article-strip-banner
1655 "P" gnus-article-hide-pem
1656 "\C-c" gnus-article-hide-citation-maybe)
1658 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1659 "a" gnus-article-highlight
1660 "h" gnus-article-highlight-headers
1661 "c" gnus-article-highlight-citation
1662 "s" gnus-article-highlight-signature)
1664 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
1665 "w" gnus-article-decode-mime-words
1666 "c" gnus-article-decode-charset
1667 "v" gnus-mime-view-all-parts
1668 "b" gnus-article-view-part)
1670 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1671 "z" gnus-article-date-ut
1672 "u" gnus-article-date-ut
1673 "l" gnus-article-date-local
1674 "p" gnus-article-date-english
1675 "e" gnus-article-date-lapsed
1676 "o" gnus-article-date-original
1677 "i" gnus-article-date-iso8601
1678 "s" gnus-article-date-user)
1680 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1681 "t" gnus-article-remove-trailing-blank-lines
1682 "l" gnus-article-strip-leading-blank-lines
1683 "m" gnus-article-strip-multiple-blank-lines
1684 "a" gnus-article-strip-blank-lines
1685 "A" gnus-article-strip-all-blank-lines
1686 "s" gnus-article-strip-leading-space
1687 "e" gnus-article-strip-trailing-space
1688 "w" gnus-article-remove-leading-whitespace)
1690 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1692 "f" gnus-summary-fetch-faq
1693 "d" gnus-summary-describe-group
1694 "h" gnus-summary-describe-briefly
1695 "i" gnus-info-find-node)
1697 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1698 "e" gnus-summary-expire-articles
1699 "\M-\C-e" gnus-summary-expire-articles-now
1700 "\177" gnus-summary-delete-article
1701 [delete] gnus-summary-delete-article
1702 [backspace] gnus-summary-delete-article
1703 "m" gnus-summary-move-article
1704 "r" gnus-summary-respool-article
1705 "w" gnus-summary-edit-article
1706 "c" gnus-summary-copy-article
1707 "B" gnus-summary-crosspost-article
1708 "q" gnus-summary-respool-query
1709 "t" gnus-summary-respool-trace
1710 "i" gnus-summary-import-article
1711 "I" gnus-summary-create-article
1712 "p" gnus-summary-article-posted-p)
1714 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1715 "o" gnus-summary-save-article
1716 "m" gnus-summary-save-article-mail
1717 "F" gnus-summary-write-article-file
1718 "r" gnus-summary-save-article-rmail
1719 "f" gnus-summary-save-article-file
1720 "b" gnus-summary-save-article-body-file
1721 "h" gnus-summary-save-article-folder
1722 "v" gnus-summary-save-article-vm
1723 "p" gnus-summary-pipe-output
1724 "s" gnus-soup-add-article)
1726 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
1727 "b" gnus-summary-display-buttonized
1728 "m" gnus-summary-repair-multipart
1729 "v" gnus-article-view-part
1730 "o" gnus-article-save-part
1731 "c" gnus-article-copy-part
1732 "C" gnus-article-view-part-as-charset
1733 "e" gnus-article-externalize-part
1734 "E" gnus-article-encrypt-body
1735 "i" gnus-article-inline-part
1736 "|" gnus-article-pipe-part))
1738 (defvar gnus-article-post-menu nil)
1740 (defun gnus-summary-make-menu-bar ()
1741 (gnus-turn-off-edit-menu 'summary)
1743 (unless (boundp 'gnus-summary-misc-menu)
1746 gnus-summary-kill-menu gnus-summary-mode-map ""
1751 ["Customize" gnus-score-customize t])
1752 (gnus-make-score-map 'increase)
1753 (gnus-make-score-map 'lower)
1755 ["Kill below" gnus-summary-kill-below t]
1756 ["Mark above" gnus-summary-mark-above t]
1757 ["Tick above" gnus-summary-tick-above t]
1758 ["Clear above" gnus-summary-clear-above t])
1759 ["Current score" gnus-summary-current-score t]
1760 ["Set score" gnus-summary-set-score t]
1761 ["Switch current score file..." gnus-score-change-score-file t]
1762 ["Set mark below..." gnus-score-set-mark-below t]
1763 ["Set expunge below..." gnus-score-set-expunge-below t]
1764 ["Edit current score file" gnus-score-edit-current-scores t]
1765 ["Edit score file" gnus-score-edit-file t]
1766 ["Trace score" gnus-score-find-trace t]
1767 ["Find words" gnus-score-find-favourite-words t]
1768 ["Rescore buffer" gnus-summary-rescore t]
1769 ["Increase score..." gnus-summary-increase-score t]
1770 ["Lower score..." gnus-summary-lower-score t]))))
1772 ;; Define both the Article menu in the summary buffer and the equivalent
1773 ;; Commands menu in the article buffer here for consistency.
1776 ["All" gnus-article-hide t]
1777 ["Headers" gnus-article-hide-headers t]
1778 ["Signature" gnus-article-hide-signature t]
1779 ["Citation" gnus-article-hide-citation t]
1780 ["List identifiers" gnus-article-hide-list-identifiers t]
1781 ["PGP" gnus-article-hide-pgp t]
1782 ["Banner" gnus-article-strip-banner t]
1783 ["Boring headers" gnus-article-hide-boring-headers t])
1785 ["All" gnus-article-highlight t]
1786 ["Headers" gnus-article-highlight-headers t]
1787 ["Signature" gnus-article-highlight-signature t]
1788 ["Citation" gnus-article-highlight-citation t])
1790 ["Words" gnus-article-decode-mime-words t]
1791 ["Charset" gnus-article-decode-charset t]
1792 ["QP" gnus-article-de-quoted-unreadable t]
1793 ["Base64" gnus-article-de-base64-unreadable t]
1794 ["View all" gnus-mime-view-all-parts t]
1795 ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t]
1796 ["Encrypt body" gnus-article-encrypt-body t])
1798 ["Local" gnus-article-date-local t]
1799 ["ISO8601" gnus-article-date-iso8601 t]
1800 ["UT" gnus-article-date-ut t]
1801 ["Original" gnus-article-date-original t]
1802 ["Lapsed" gnus-article-date-lapsed t]
1803 ["User-defined" gnus-article-date-user t])
1806 ["Leading" gnus-article-strip-leading-blank-lines t]
1807 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1808 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1809 ["All of the above" gnus-article-strip-blank-lines t]
1810 ["All" gnus-article-strip-all-blank-lines t]
1811 ["Leading space" gnus-article-strip-leading-space t]
1812 ["Trailing space" gnus-article-strip-trailing-space t]
1813 ["Leading space in headers"
1814 gnus-article-remove-leading-whitespace t])
1815 ["Overstrike" gnus-article-treat-overstrike t]
1816 ["Dumb quotes" gnus-article-treat-dumbquotes t]
1817 ["Emphasis" gnus-article-emphasize t]
1818 ["Word wrap" gnus-article-fill-cited-article t]
1819 ["Fill long lines" gnus-article-fill-long-lines t]
1820 ["Capitalize sentences" gnus-article-capitalize-sentences t]
1821 ["CR" gnus-article-remove-cr t]
1822 ["Show X-Face" gnus-article-display-x-face t]
1823 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
1824 ["Base64" gnus-article-de-base64-unreadable t]
1825 ["Rot 13" gnus-summary-caesar-message
1826 ,@(if (featurep 'xemacs) '(t)
1827 '(:help "\"Caesar rotate\" article by 13"))]
1828 ["Unix pipe" gnus-summary-pipe-message t]
1829 ["Add buttons" gnus-article-add-buttons t]
1830 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1831 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1832 ["Verbose header" gnus-summary-verbose-headers t]
1833 ["Toggle header" gnus-summary-toggle-header t]
1834 ["Html" gnus-article-wash-html t]
1835 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
1836 ["HZ" gnus-article-decode-HZ t])
1838 ["Save in default format" gnus-summary-save-article
1839 ,@(if (featurep 'xemacs) '(t)
1840 '(:help "Save article using default method"))]
1841 ["Save in file" gnus-summary-save-article-file
1842 ,@(if (featurep 'xemacs) '(t)
1843 '(:help "Save article in file"))]
1844 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1845 ["Save in MH folder" gnus-summary-save-article-folder t]
1846 ["Save in VM folder" gnus-summary-save-article-vm t]
1847 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1848 ["Save body in file" gnus-summary-save-article-body-file t]
1849 ["Pipe through a filter" gnus-summary-pipe-output t]
1850 ["Add to SOUP packet" gnus-soup-add-article t]
1851 ["Print" gnus-summary-print-article t])
1853 ["Respool article..." gnus-summary-respool-article t]
1854 ["Move article..." gnus-summary-move-article
1855 (gnus-check-backend-function
1856 'request-move-article gnus-newsgroup-name)]
1857 ["Copy article..." gnus-summary-copy-article t]
1858 ["Crosspost article..." gnus-summary-crosspost-article
1859 (gnus-check-backend-function
1860 'request-replace-article gnus-newsgroup-name)]
1861 ["Import file..." gnus-summary-import-article t]
1862 ["Create article..." gnus-summary-create-article t]
1863 ["Check if posted" gnus-summary-article-posted-p t]
1864 ["Edit article" gnus-summary-edit-article
1865 (not (gnus-group-read-only-p))]
1866 ["Delete article" gnus-summary-delete-article
1867 (gnus-check-backend-function
1868 'request-expire-articles gnus-newsgroup-name)]
1869 ["Query respool" gnus-summary-respool-query t]
1870 ["Trace respool" gnus-summary-respool-trace t]
1871 ["Delete expirable articles" gnus-summary-expire-articles-now
1872 (gnus-check-backend-function
1873 'request-expire-articles gnus-newsgroup-name)])
1875 ["Uudecode" gnus-uu-decode-uu
1876 ,@(if (featurep 'xemacs) '(t)
1877 '(:help "Decode uuencoded article(s)"))]
1878 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1879 ["Unshar" gnus-uu-decode-unshar t]
1880 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1881 ["Save" gnus-uu-decode-save t]
1882 ["Binhex" gnus-uu-decode-binhex t]
1883 ["Postscript" gnus-uu-decode-postscript t])
1885 ["Enter article" gnus-cache-enter-article t]
1886 ["Remove article" gnus-cache-remove-article t])
1887 ["Translate" gnus-article-babel t]
1888 ["Select article buffer" gnus-summary-select-article-buffer t]
1889 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1890 ["Isearch article..." gnus-summary-isearch-article t]
1891 ["Beginning of the article" gnus-summary-beginning-of-article t]
1892 ["End of the article" gnus-summary-end-of-article t]
1893 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1894 ["Fetch referenced articles" gnus-summary-refer-references t]
1895 ["Fetch current thread" gnus-summary-refer-thread t]
1896 ["Fetch article with id..." gnus-summary-refer-article t]
1897 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
1898 ["Redisplay" gnus-summary-show-article t])))
1900 gnus-summary-article-menu gnus-summary-mode-map ""
1901 (cons "Article" innards))
1903 (if (not (keymapp gnus-summary-article-menu))
1905 gnus-article-commands-menu gnus-article-mode-map ""
1906 (cons "Commands" innards))
1907 ;; in Emacs, don't share menu.
1908 (setq gnus-article-commands-menu
1909 (copy-keymap gnus-summary-article-menu))
1910 (define-key gnus-article-mode-map [menu-bar commands]
1911 (cons "Commands" gnus-article-commands-menu))))
1914 gnus-summary-thread-menu gnus-summary-mode-map ""
1916 ["Toggle threading" gnus-summary-toggle-threads t]
1917 ["Hide threads" gnus-summary-hide-all-threads t]
1918 ["Show threads" gnus-summary-show-all-threads t]
1919 ["Hide thread" gnus-summary-hide-thread t]
1920 ["Show thread" gnus-summary-show-thread t]
1921 ["Go to next thread" gnus-summary-next-thread t]
1922 ["Go to previous thread" gnus-summary-prev-thread t]
1923 ["Go down thread" gnus-summary-down-thread t]
1924 ["Go up thread" gnus-summary-up-thread t]
1925 ["Top of thread" gnus-summary-top-thread t]
1926 ["Mark thread as read" gnus-summary-kill-thread t]
1927 ["Lower thread score" gnus-summary-lower-thread t]
1928 ["Raise thread score" gnus-summary-raise-thread t]
1929 ["Rethread current" gnus-summary-rethread-current t]))
1932 gnus-summary-post-menu gnus-summary-mode-map ""
1934 ["Post an article" gnus-summary-post-news
1935 ,@(if (featurep 'xemacs) '(t)
1936 '(:help "Post an article"))]
1937 ["Followup" gnus-summary-followup
1938 ,@(if (featurep 'xemacs) '(t)
1939 '(:help "Post followup to this article"))]
1940 ["Followup and yank" gnus-summary-followup-with-original
1941 ,@(if (featurep 'xemacs) '(t)
1942 '(:help "Post followup to this article, quoting its contents"))]
1943 ["Supersede article" gnus-summary-supersede-article t]
1944 ["Cancel article" gnus-summary-cancel-article
1945 ,@(if (featurep 'xemacs) '(t)
1946 '(:help "Cancel an article you posted"))]
1947 ["Reply" gnus-summary-reply t]
1948 ["Reply and yank" gnus-summary-reply-with-original t]
1949 ["Wide reply" gnus-summary-wide-reply t]
1950 ["Wide reply and yank" gnus-summary-wide-reply-with-original
1951 ,@(if (featurep 'xemacs) '(t)
1952 '(:help "Mail a reply, quoting this article"))]
1953 ["Mail forward" gnus-summary-mail-forward t]
1954 ["Post forward" gnus-summary-post-forward t]
1955 ["Digest and mail" gnus-uu-digest-mail-forward t]
1956 ["Digest and post" gnus-uu-digest-post-forward t]
1957 ["Resend message" gnus-summary-resend-message t]
1958 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
1959 ["Send a mail" gnus-summary-mail-other-window t]
1960 ["Uuencode and post" gnus-uu-post-news
1961 ,@(if (featurep 'xemacs) '(t)
1962 '(:help "Post a uuencoded article"))]
1963 ["Followup via news" gnus-summary-followup-to-mail t]
1964 ["Followup via news and yank"
1965 gnus-summary-followup-to-mail-with-original t]
1967 ;;["Send" gnus-summary-send-draft t]
1968 ;;["Send bounced" gnus-resend-bounced-mail t])
1972 ((not (keymapp gnus-summary-post-menu))
1973 (setq gnus-article-post-menu gnus-summary-post-menu))
1974 ((not gnus-article-post-menu)
1975 ;; Don't share post menu.
1976 (setq gnus-article-post-menu
1977 (copy-keymap gnus-summary-post-menu))))
1978 (define-key gnus-article-mode-map [menu-bar post]
1979 (cons "Post" gnus-article-post-menu))
1982 gnus-summary-misc-menu gnus-summary-mode-map ""
1985 ["Mark as read" gnus-summary-mark-as-read-forward t]
1986 ["Mark same subject and select"
1987 gnus-summary-kill-same-subject-and-select t]
1988 ["Mark same subject" gnus-summary-kill-same-subject t]
1989 ["Catchup" gnus-summary-catchup
1990 ,@(if (featurep 'xemacs) '(t)
1991 '(:help "Mark unread articles in this group as read"))]
1992 ["Catchup all" gnus-summary-catchup-all t]
1993 ["Catchup to here" gnus-summary-catchup-to-here t]
1994 ["Catchup region" gnus-summary-mark-region-as-read t]
1995 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
1997 ["Tick" gnus-summary-tick-article-forward t]
1998 ["Mark as dormant" gnus-summary-mark-as-dormant t]
1999 ["Remove marks" gnus-summary-clear-mark-forward t]
2000 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2001 ["Set bookmark" gnus-summary-set-bookmark t]
2002 ["Remove bookmark" gnus-summary-remove-bookmark t])
2004 ["Marks..." gnus-summary-limit-to-marks t]
2005 ["Subject..." gnus-summary-limit-to-subject t]
2006 ["Author..." gnus-summary-limit-to-author t]
2007 ["Age..." gnus-summary-limit-to-age t]
2008 ["Extra..." gnus-summary-limit-to-extra t]
2009 ["Score" gnus-summary-limit-to-score t]
2010 ["Unread" gnus-summary-limit-to-unread t]
2011 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2012 ["Articles" gnus-summary-limit-to-articles t]
2013 ["Pop limit" gnus-summary-pop-limit t]
2014 ["Show dormant" gnus-summary-limit-include-dormant t]
2015 ["Hide childless dormant"
2016 gnus-summary-limit-exclude-childless-dormant t]
2017 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2018 ["Hide marked" gnus-summary-limit-exclude-marks t]
2019 ["Show expunged" gnus-summary-limit-include-expunged t])
2021 ["Set mark" gnus-summary-mark-as-processable t]
2022 ["Remove mark" gnus-summary-unmark-as-processable t]
2023 ["Remove all marks" gnus-summary-unmark-all-processable t]
2024 ["Mark above" gnus-uu-mark-over t]
2025 ["Mark series" gnus-uu-mark-series t]
2026 ["Mark region" gnus-uu-mark-region t]
2027 ["Unmark region" gnus-uu-unmark-region t]
2028 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2029 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2030 ["Mark all" gnus-uu-mark-all t]
2031 ["Mark buffer" gnus-uu-mark-buffer t]
2032 ["Mark sparse" gnus-uu-mark-sparse t]
2033 ["Mark thread" gnus-uu-mark-thread t]
2034 ["Unmark thread" gnus-uu-unmark-thread t]
2035 ("Process Mark Sets"
2036 ["Kill" gnus-summary-kill-process-mark t]
2037 ["Yank" gnus-summary-yank-process-mark
2038 gnus-newsgroup-process-stack]
2039 ["Save" gnus-summary-save-process-mark t]))
2041 ["Page forward" gnus-summary-next-page
2042 ,@(if (featurep 'xemacs) '(t)
2043 '(:help "Show next page of article"))]
2044 ["Page backward" gnus-summary-prev-page
2045 ,@(if (featurep 'xemacs) '(t)
2046 '(:help "Show previous page of article"))]
2047 ["Line forward" gnus-summary-scroll-up t])
2049 ["Next unread article" gnus-summary-next-unread-article t]
2050 ["Previous unread article" gnus-summary-prev-unread-article t]
2051 ["Next article" gnus-summary-next-article t]
2052 ["Previous article" gnus-summary-prev-article t]
2053 ["Next unread subject" gnus-summary-next-unread-subject t]
2054 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2055 ["Next article same subject" gnus-summary-next-same-subject t]
2056 ["Previous article same subject" gnus-summary-prev-same-subject t]
2057 ["First unread article" gnus-summary-first-unread-article t]
2058 ["Best unread article" gnus-summary-best-unread-article t]
2059 ["Go to subject number..." gnus-summary-goto-subject t]
2060 ["Go to article number..." gnus-summary-goto-article t]
2061 ["Go to the last article" gnus-summary-goto-last-article t]
2062 ["Pop article off history" gnus-summary-pop-article t])
2064 ["Sort by number" gnus-summary-sort-by-number t]
2065 ["Sort by author" gnus-summary-sort-by-author t]
2066 ["Sort by subject" gnus-summary-sort-by-subject t]
2067 ["Sort by date" gnus-summary-sort-by-date t]
2068 ["Sort by score" gnus-summary-sort-by-score t]
2069 ["Sort by lines" gnus-summary-sort-by-lines t]
2070 ["Sort by characters" gnus-summary-sort-by-chars t]
2071 ["Original sort" gnus-summary-sort-by-original t])
2073 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2074 ["Describe group" gnus-summary-describe-group t]
2075 ["Read manual" gnus-info-find-node t])
2077 ["Pick and read" gnus-pick-mode t]
2078 ["Binary" gnus-binary-mode t])
2080 ["Regenerate" gnus-summary-prepare t]
2081 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2082 ["Toggle threading" gnus-summary-toggle-threads t])
2083 ["See old articles" gnus-summary-insert-old-articles t]
2084 ["See new articles" gnus-summary-insert-new-articles t]
2085 ["Filter articles..." gnus-summary-execute-command t]
2086 ["Run command on subjects..." gnus-summary-universal-argument t]
2087 ["Search articles forward..." gnus-summary-search-article-forward t]
2088 ["Search articles backward..." gnus-summary-search-article-backward t]
2089 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2090 ["Expand window" gnus-summary-expand-window t]
2091 ["Expire expirable articles" gnus-summary-expire-articles
2092 (gnus-check-backend-function
2093 'request-expire-articles gnus-newsgroup-name)]
2094 ["Edit local kill file" gnus-summary-edit-local-kill t]
2095 ["Edit main kill file" gnus-summary-edit-global-kill t]
2096 ["Edit group parameters" gnus-summary-edit-parameters t]
2097 ["Customize group parameters" gnus-summary-customize-parameters t]
2098 ["Send a bug report" gnus-bug t]
2100 ["Catchup and exit" gnus-summary-catchup-and-exit
2101 ,@(if (featurep 'xemacs) '(t)
2102 '(:help "Mark unread articles in this group as read, then exit"))]
2103 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2104 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2105 ["Exit group" gnus-summary-exit
2106 ,@(if (featurep 'xemacs) '(t)
2107 '(:help "Exit current group, return to group selection mode"))]
2108 ["Exit group without updating" gnus-summary-exit-no-update t]
2109 ["Exit and goto next group" gnus-summary-next-group t]
2110 ["Exit and goto prev group" gnus-summary-prev-group t]
2111 ["Reselect group" gnus-summary-reselect-current-group t]
2112 ["Rescan group" gnus-summary-rescan-group t]
2113 ["Update dribble" gnus-summary-save-newsrc t])))
2115 (gnus-run-hooks 'gnus-summary-menu-hook)))
2117 (defvar gnus-summary-tool-bar-map nil)
2119 ;; Emacs 21 tool bar. Should be no-op otherwise.
2120 (defun gnus-summary-make-tool-bar ()
2121 (if (and (fboundp 'tool-bar-add-item-from-menu)
2122 (default-value 'tool-bar-mode)
2123 (not gnus-summary-tool-bar-map))
2124 (setq gnus-summary-tool-bar-map
2125 (let ((tool-bar-map (make-sparse-keymap))
2126 (load-path (mm-image-load-path)))
2127 (tool-bar-add-item-from-menu
2128 'gnus-summary-prev-unread "prev-ur" gnus-summary-mode-map)
2129 (tool-bar-add-item-from-menu
2130 'gnus-summary-next-unread "next-ur" gnus-summary-mode-map)
2131 (tool-bar-add-item-from-menu
2132 'gnus-summary-post-news "post" gnus-summary-mode-map)
2133 (tool-bar-add-item-from-menu
2134 'gnus-summary-followup-with-original "fuwo" gnus-summary-mode-map)
2135 (tool-bar-add-item-from-menu
2136 'gnus-summary-followup "followup" gnus-summary-mode-map)
2137 (tool-bar-add-item-from-menu
2138 'gnus-summary-reply-with-original "reply-wo" gnus-summary-mode-map)
2139 (tool-bar-add-item-from-menu
2140 'gnus-summary-reply "reply" gnus-summary-mode-map)
2141 (tool-bar-add-item-from-menu
2142 'gnus-summary-caesar-message "rot13" gnus-summary-mode-map)
2143 (tool-bar-add-item-from-menu
2144 'gnus-uu-decode-uu "uu-decode" gnus-summary-mode-map)
2145 (tool-bar-add-item-from-menu
2146 'gnus-summary-save-article-file "save-aif" gnus-summary-mode-map)
2147 (tool-bar-add-item-from-menu
2148 'gnus-summary-save-article "save-art" gnus-summary-mode-map)
2149 (tool-bar-add-item-from-menu
2150 'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2151 (tool-bar-add-item-from-menu
2152 'gnus-summary-catchup "catchup" gnus-summary-mode-map)
2153 (tool-bar-add-item-from-menu
2154 'gnus-summary-catchup-and-exit "cu-exit" gnus-summary-mode-map)
2155 (tool-bar-add-item-from-menu
2156 'gnus-summary-exit "exit-summ" gnus-summary-mode-map)
2158 (if gnus-summary-tool-bar-map
2159 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
2161 (defun gnus-score-set-default (var value)
2162 "A version of set that updates the GNU Emacs menu-bar."
2164 ;; It is the message that forces the active status to be updated.
2167 (defun gnus-make-score-map (type)
2168 "Make a summary score map of type TYPE."
2171 (let ((headers '(("author" "from" string)
2172 ("subject" "subject" string)
2173 ("article body" "body" string)
2174 ("article head" "head" string)
2175 ("xref" "xref" string)
2176 ("extra header" "extra" string)
2177 ("lines" "lines" number)
2178 ("followups to author" "followup" string)))
2179 (types '((number ("less than" <)
2182 (string ("substring" s)
2186 (perms '(("temporary" (current-time-string))
2194 (if (eq type 'lower)
2199 (setq header (car headers))
2205 (let ((ts (cdr (assoc (nth 2 header) types)))
2221 'gnus-summary-score-entry
2223 (if (or (string= (nth 1 header)
2225 (string= (nth 1 header)
2228 (list 'gnus-summary-header
2230 (list 'quote (nth 1 (car ts)))
2231 (list 'gnus-score-delta-default
2238 (list (nreverse outp))))
2241 (list (nreverse outt))))
2243 (setq headers (cdr headers)))
2244 (list (nreverse outh))))))))
2248 (defun gnus-summary-mode (&optional group)
2249 "Major mode for reading articles.
2251 All normal editing commands are switched off.
2252 \\<gnus-summary-mode-map>
2253 Each line in this buffer represents one article. To read an
2254 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2255 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2258 You can also post articles and send mail from this buffer. To
2259 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2260 of an article, type `\\[gnus-summary-reply]'.
2262 There are approx. one gazillion commands you can execute in this
2263 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2265 The following commands are available:
2267 \\{gnus-summary-mode-map}"
2269 (kill-all-local-variables)
2270 (when (gnus-visual-p 'summary-menu 'menu)
2271 (gnus-summary-make-menu-bar)
2272 (gnus-summary-make-tool-bar))
2273 (gnus-summary-make-local-variables)
2274 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2275 (gnus-summary-make-local-variables))
2276 (gnus-make-thread-indent-array)
2277 (gnus-simplify-mode-line)
2278 (setq major-mode 'gnus-summary-mode)
2279 (setq mode-name "Summary")
2280 (make-local-variable 'minor-mode-alist)
2281 (use-local-map gnus-summary-mode-map)
2282 (buffer-disable-undo)
2283 (setq buffer-read-only t) ;Disable modification
2284 (setq truncate-lines t)
2285 (setq selective-display t)
2286 (setq selective-display-ellipses t) ;Display `...'
2287 (gnus-summary-set-display-table)
2288 (gnus-set-default-directory)
2289 (setq gnus-newsgroup-name group)
2290 (make-local-variable 'gnus-summary-line-format)
2291 (make-local-variable 'gnus-summary-line-format-spec)
2292 (make-local-variable 'gnus-summary-dummy-line-format)
2293 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2294 (make-local-variable 'gnus-summary-mark-positions)
2295 (make-local-hook 'pre-command-hook)
2296 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2297 (gnus-run-hooks 'gnus-summary-mode-hook)
2298 (turn-on-gnus-mailing-list-mode)
2299 (mm-enable-multibyte-mule4)
2300 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2301 (gnus-update-summary-mark-positions))
2303 (defun gnus-summary-make-local-variables ()
2304 "Make all the local summary buffer variables."
2306 (dolist (local gnus-summary-local-variables)
2309 (if (eq (cdr local) 'global)
2310 ;; Copy the global value of the variable.
2311 (setq global (symbol-value (car local)))
2312 ;; Use the value from the list.
2313 (setq global (eval (cdr local))))
2314 (set (make-local-variable (car local)) global))
2315 ;; Simple nil-valued local variable.
2316 (set (make-local-variable local) nil)))))
2318 (defun gnus-summary-clear-local-variables ()
2319 (let ((locals gnus-summary-local-variables))
2321 (if (consp (car locals))
2322 (and (vectorp (caar locals))
2323 (set (caar locals) nil))
2324 (and (vectorp (car locals))
2325 (set (car locals) nil)))
2326 (setq locals (cdr locals)))))
2328 ;; Summary data functions.
2330 (defmacro gnus-data-number (data)
2333 (defmacro gnus-data-set-number (data number)
2334 `(setcar ,data ,number))
2336 (defmacro gnus-data-mark (data)
2339 (defmacro gnus-data-set-mark (data mark)
2340 `(setcar (nthcdr 1 ,data) ,mark))
2342 (defmacro gnus-data-pos (data)
2345 (defmacro gnus-data-set-pos (data pos)
2346 `(setcar (nthcdr 2 ,data) ,pos))
2348 (defmacro gnus-data-header (data)
2351 (defmacro gnus-data-set-header (data header)
2352 `(setf (nth 3 ,data) ,header))
2354 (defmacro gnus-data-level (data)
2357 (defmacro gnus-data-unread-p (data)
2358 `(= (nth 1 ,data) gnus-unread-mark))
2360 (defmacro gnus-data-read-p (data)
2361 `(/= (nth 1 ,data) gnus-unread-mark))
2363 (defmacro gnus-data-pseudo-p (data)
2364 `(consp (nth 3 ,data)))
2366 (defmacro gnus-data-find (number)
2367 `(assq ,number gnus-newsgroup-data))
2369 (defmacro gnus-data-find-list (number &optional data)
2370 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2371 (memq (assq ,number bdata)
2374 (defmacro gnus-data-make (number mark pos header level)
2375 `(list ,number ,mark ,pos ,header ,level))
2377 (defun gnus-data-enter (after-article number mark pos header level offset)
2378 (let ((data (gnus-data-find-list after-article)))
2380 (error "No such article: %d" after-article))
2381 (setcdr data (cons (gnus-data-make number mark pos header level)
2383 (setq gnus-newsgroup-data-reverse nil)
2384 (gnus-data-update-list (cddr data) offset)))
2386 (defun gnus-data-enter-list (after-article list &optional offset)
2388 (let ((data (and after-article (gnus-data-find-list after-article)))
2392 (let ((odata gnus-newsgroup-data))
2393 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2395 (gnus-data-update-list odata offset)))
2396 ;; Find the last element in the list to be spliced into the main
2399 (setq list (cdr list)))
2402 (setcdr list gnus-newsgroup-data)
2403 (setq gnus-newsgroup-data ilist)
2405 (gnus-data-update-list (cdr list) offset)))
2406 (setcdr list (cdr data))
2409 (gnus-data-update-list (cdr list) offset))))
2410 (setq gnus-newsgroup-data-reverse nil))))
2412 (defun gnus-data-remove (article &optional offset)
2413 (let ((data gnus-newsgroup-data))
2414 (if (= (gnus-data-number (car data)) article)
2416 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2417 gnus-newsgroup-data-reverse nil)
2419 (gnus-data-update-list gnus-newsgroup-data offset)))
2421 (when (= (gnus-data-number (cadr data)) article)
2422 (setcdr data (cddr data))
2424 (gnus-data-update-list (cdr data) offset))
2426 gnus-newsgroup-data-reverse nil))
2427 (setq data (cdr data))))))
2429 (defmacro gnus-data-list (backward)
2431 (or gnus-newsgroup-data-reverse
2432 (setq gnus-newsgroup-data-reverse
2433 (reverse gnus-newsgroup-data)))
2434 gnus-newsgroup-data))
2436 (defun gnus-data-update-list (data offset)
2437 "Add OFFSET to the POS of all data entries in DATA."
2438 (setq gnus-newsgroup-data-reverse nil)
2440 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2441 (setq data (cdr data))))
2443 (defun gnus-summary-article-pseudo-p (article)
2444 "Say whether this article is a pseudo article or not."
2445 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2447 (defmacro gnus-summary-article-sparse-p (article)
2448 "Say whether this article is a sparse article or not."
2449 `(memq ,article gnus-newsgroup-sparse))
2451 (defmacro gnus-summary-article-ancient-p (article)
2452 "Say whether this article is a sparse article or not."
2453 `(memq ,article gnus-newsgroup-ancient))
2455 (defun gnus-article-parent-p (number)
2456 "Say whether this article is a parent or not."
2457 (let ((data (gnus-data-find-list number)))
2458 (and (cdr data) ; There has to be an article after...
2459 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2460 (gnus-data-level (nth 1 data))))))
2462 (defun gnus-article-children (number)
2463 "Return a list of all children to NUMBER."
2464 (let* ((data (gnus-data-find-list number))
2465 (level (gnus-data-level (car data)))
2467 (setq data (cdr data))
2469 (= (gnus-data-level (car data)) (1+ level)))
2470 (push (gnus-data-number (car data)) children)
2471 (setq data (cdr data)))
2474 (defmacro gnus-summary-skip-intangible ()
2475 "If the current article is intangible, then jump to a different article."
2476 '(let ((to (get-text-property (point) 'gnus-intangible)))
2477 (and to (gnus-summary-goto-subject to))))
2479 (defmacro gnus-summary-article-intangible-p ()
2480 "Say whether this article is intangible or not."
2481 '(get-text-property (point) 'gnus-intangible))
2483 (defun gnus-article-read-p (article)
2484 "Say whether ARTICLE is read or not."
2485 (not (or (memq article gnus-newsgroup-marked)
2486 (memq article gnus-newsgroup-unreads)
2487 (memq article gnus-newsgroup-unselected)
2488 (memq article gnus-newsgroup-dormant))))
2490 ;; Some summary mode macros.
2492 (defmacro gnus-summary-article-number ()
2493 "The article number of the article on the current line.
2494 If there isn's an article number here, then we return the current
2497 (gnus-summary-skip-intangible)
2498 (or (get-text-property (point) 'gnus-number)
2499 (gnus-summary-last-subject))))
2501 (defmacro gnus-summary-article-header (&optional number)
2502 "Return the header of article NUMBER."
2503 `(gnus-data-header (gnus-data-find
2504 ,(or number '(gnus-summary-article-number)))))
2506 (defmacro gnus-summary-thread-level (&optional number)
2507 "Return the level of thread that starts with article NUMBER."
2508 `(if (and (eq gnus-summary-make-false-root 'dummy)
2509 (get-text-property (point) 'gnus-intangible))
2511 (gnus-data-level (gnus-data-find
2512 ,(or number '(gnus-summary-article-number))))))
2514 (defmacro gnus-summary-article-mark (&optional number)
2515 "Return the mark of article NUMBER."
2516 `(gnus-data-mark (gnus-data-find
2517 ,(or number '(gnus-summary-article-number)))))
2519 (defmacro gnus-summary-article-pos (&optional number)
2520 "Return the position of the line of article NUMBER."
2521 `(gnus-data-pos (gnus-data-find
2522 ,(or number '(gnus-summary-article-number)))))
2524 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2525 (defmacro gnus-summary-article-subject (&optional number)
2526 "Return current subject string or nil if nothing."
2529 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2530 '(gnus-data-header (assq (gnus-summary-article-number)
2531 gnus-newsgroup-data)))))
2534 (mail-header-subject headers))))
2536 (defmacro gnus-summary-article-score (&optional number)
2537 "Return current article score."
2538 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2539 gnus-newsgroup-scored))
2540 gnus-summary-default-score 0))
2542 (defun gnus-summary-article-children (&optional number)
2543 "Return a list of article numbers that are children of article NUMBER."
2544 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2545 (level (gnus-data-level (car data)))
2547 (while (and (setq data (cdr data))
2548 (> (setq l (gnus-data-level (car data))) level))
2549 (and (= (1+ level) l)
2550 (push (gnus-data-number (car data))
2552 (nreverse children)))
2554 (defun gnus-summary-article-parent (&optional number)
2555 "Return the article number of the parent of article NUMBER."
2556 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2557 (gnus-data-list t)))
2558 (level (gnus-data-level (car data))))
2560 () ; This is a root.
2561 ;; We search until we find an article with a level less than
2562 ;; this one. That function has to be the parent.
2563 (while (and (setq data (cdr data))
2564 (not (< (gnus-data-level (car data)) level))))
2565 (and data (gnus-data-number (car data))))))
2567 (defun gnus-unread-mark-p (mark)
2568 "Say whether MARK is the unread mark."
2569 (= mark gnus-unread-mark))
2571 (defun gnus-read-mark-p (mark)
2572 "Say whether MARK is one of the marks that mark as read.
2573 This is all marks except unread, ticked, dormant, and expirable."
2574 (not (or (= mark gnus-unread-mark)
2575 (= mark gnus-ticked-mark)
2576 (= mark gnus-dormant-mark)
2577 (= mark gnus-expirable-mark))))
2579 (defmacro gnus-article-mark (number)
2580 "Return the MARK of article NUMBER.
2581 This macro should only be used when computing the mark the \"first\"
2582 time; i.e., when generating the summary lines. After that,
2583 `gnus-summary-article-mark' should be used to examine the
2586 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2587 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2588 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2589 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2590 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2591 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2592 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2593 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2594 gnus-ancient-mark))))
2596 ;; Saving hidden threads.
2598 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2599 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2601 (defmacro gnus-save-hidden-threads (&rest forms)
2602 "Save hidden threads, eval FORMS, and restore the hidden threads."
2603 (let ((config (make-symbol "config")))
2604 `(let ((,config (gnus-hidden-threads-configuration)))
2608 (gnus-restore-hidden-threads-configuration ,config)))))
2610 (defun gnus-data-compute-positions ()
2611 "Compute the positions of all articles."
2612 (setq gnus-newsgroup-data-reverse nil)
2613 (let ((data gnus-newsgroup-data))
2615 (gnus-save-hidden-threads
2616 (gnus-summary-show-all-threads)
2617 (goto-char (point-min))
2619 (while (get-text-property (point) 'gnus-intangible)
2621 (gnus-data-set-pos (car data) (+ (point) 3))
2622 (setq data (cdr data))
2623 (forward-line 1))))))
2625 (defun gnus-hidden-threads-configuration ()
2626 "Return the current hidden threads configuration."
2629 (goto-char (point-min))
2630 (while (search-forward "\r" nil t)
2631 (push (1- (point)) config))
2634 (defun gnus-restore-hidden-threads-configuration (config)
2635 "Restore hidden threads configuration from CONFIG."
2637 (let (point buffer-read-only)
2638 (while (setq point (pop config))
2639 (when (and (< point (point-max))
2641 (eq (char-after) ?\n))
2642 (subst-char-in-region point (1+ point) ?\n ?\r))))))
2644 ;; Various summary mode internalish functions.
2646 (defun gnus-mouse-pick-article (e)
2649 (gnus-summary-next-page nil t))
2651 (defun gnus-summary-set-display-table ()
2652 "Change the display table.
2653 Odd characters have a tendency to mess
2654 up nicely formatted displays - we make all possible glyphs
2655 display only a single character."
2657 ;; We start from the standard display table, if any.
2658 (let ((table (or (copy-sequence standard-display-table)
2659 (make-display-table)))
2661 ;; Nix out all the control chars...
2662 (while (>= (setq i (1- i)) 0)
2663 (aset table i [??]))
2664 ;; ... but not newline and cr, of course. (cr is necessary for the
2665 ;; selective display).
2666 (aset table ?\n nil)
2667 (aset table ?\r nil)
2668 ;; We keep TAB as well.
2669 (aset table ?\t nil)
2670 ;; We nix out any glyphs over 126 that are not set already.
2672 (while (>= (setq i (1- i)) 127)
2673 ;; Only modify if the entry is nil.
2674 (unless (aref table i)
2675 (aset table i [??]))))
2676 (setq buffer-display-table table)))
2678 (defun gnus-summary-buffer-name (group)
2679 "Return the summary buffer name of GROUP."
2680 (concat "*Summary " group "*"))
2682 (defun gnus-summary-setup-buffer (group)
2683 "Initialize summary buffer."
2684 (let ((buffer (gnus-summary-buffer-name group)))
2685 (if (get-buffer buffer)
2688 (setq gnus-summary-buffer (current-buffer))
2689 (not gnus-newsgroup-prepared))
2690 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2691 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
2692 (gnus-summary-mode group)
2694 (gnus-carpal-setup-buffer 'summary))
2695 (unless gnus-single-article-buffer
2696 (make-local-variable 'gnus-article-buffer)
2697 (make-local-variable 'gnus-article-current)
2698 (make-local-variable 'gnus-original-article-buffer))
2699 (setq gnus-newsgroup-name group)
2700 ;; Set any local variables in the group parameters.
2701 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2704 (defun gnus-set-global-variables ()
2705 "Set the global equivalents of the buffer-local variables.
2706 They are set to the latest values they had. These reflect the summary
2707 buffer that was in action when the last article was fetched."
2708 (when (eq major-mode 'gnus-summary-mode)
2709 (setq gnus-summary-buffer (current-buffer))
2710 (let ((name gnus-newsgroup-name)
2711 (marked gnus-newsgroup-marked)
2712 (unread gnus-newsgroup-unreads)
2713 (headers gnus-current-headers)
2714 (data gnus-newsgroup-data)
2715 (summary gnus-summary-buffer)
2716 (article-buffer gnus-article-buffer)
2717 (original gnus-original-article-buffer)
2718 (gac gnus-article-current)
2719 (reffed gnus-reffed-article-number)
2720 (score-file gnus-current-score-file)
2721 (default-charset gnus-newsgroup-charset)
2723 (let ((locals gnus-newsgroup-variables))
2725 (if (consp (car locals))
2726 (push (eval (caar locals)) vlist)
2727 (push (eval (car locals)) vlist))
2728 (setq locals (cdr locals)))
2729 (setq vlist (nreverse vlist)))
2731 (set-buffer gnus-group-buffer)
2732 (setq gnus-newsgroup-name name
2733 gnus-newsgroup-marked marked
2734 gnus-newsgroup-unreads unread
2735 gnus-current-headers headers
2736 gnus-newsgroup-data data
2737 gnus-article-current gac
2738 gnus-summary-buffer summary
2739 gnus-article-buffer article-buffer
2740 gnus-original-article-buffer original
2741 gnus-reffed-article-number reffed
2742 gnus-current-score-file score-file
2743 gnus-newsgroup-charset default-charset)
2744 (let ((locals gnus-newsgroup-variables))
2746 (if (consp (car locals))
2747 (set (caar locals) (pop vlist))
2748 (set (car locals) (pop vlist)))
2749 (setq locals (cdr locals))))
2750 ;; The article buffer also has local variables.
2751 (when (gnus-buffer-live-p gnus-article-buffer)
2752 (set-buffer gnus-article-buffer)
2753 (setq gnus-summary-buffer summary))))))
2755 (defun gnus-summary-article-unread-p (article)
2756 "Say whether ARTICLE is unread or not."
2757 (memq article gnus-newsgroup-unreads))
2759 (defun gnus-summary-first-article-p (&optional article)
2760 "Return whether ARTICLE is the first article in the buffer."
2761 (if (not (setq article (or article (gnus-summary-article-number))))
2763 (eq article (caar gnus-newsgroup-data))))
2765 (defun gnus-summary-last-article-p (&optional article)
2766 "Return whether ARTICLE is the last article in the buffer."
2767 (if (not (setq article (or article (gnus-summary-article-number))))
2768 ;; All non-existent numbers are the last article. :-)
2770 (not (cdr (gnus-data-find-list article)))))
2772 (defun gnus-make-thread-indent-array ()
2774 (unless (and gnus-thread-indent-array
2775 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2776 (setq gnus-thread-indent-array (make-vector 201 "")
2777 gnus-thread-indent-array-level gnus-thread-indent-level)
2779 (aset gnus-thread-indent-array n
2780 (make-string (* n gnus-thread-indent-level) ? ))
2783 (defun gnus-update-summary-mark-positions ()
2784 "Compute where the summary marks are to go."
2786 (when (gnus-buffer-exists-p gnus-summary-buffer)
2787 (set-buffer gnus-summary-buffer))
2788 (let ((gnus-replied-mark 129)
2789 (gnus-score-below-mark 130)
2790 (gnus-score-over-mark 130)
2791 (gnus-download-mark 131)
2792 (spec gnus-summary-line-format-spec)
2795 (gnus-set-work-buffer)
2796 (let ((gnus-summary-line-format-spec spec)
2797 (gnus-newsgroup-downloadable '((0 . t))))
2798 (gnus-summary-insert-line
2799 [0 "" "" "" "" "" 0 0 "" nil] 0 nil 128 t nil "" nil 1)
2800 (goto-char (point-min))
2801 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2803 (goto-char (point-min))
2804 (push (cons 'replied (and (search-forward "\201" nil t)
2807 (goto-char (point-min))
2808 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2810 (goto-char (point-min))
2811 (push (cons 'download
2812 (and (search-forward "\203" nil t) (- (point) 2)))
2814 (setq gnus-summary-mark-positions pos))))
2816 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2817 "Insert a dummy root in the summary buffer."
2819 (gnus-add-text-properties
2820 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2821 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2823 (defun gnus-summary-from-or-to-or-newsgroups (header)
2824 (let ((to (cdr (assq 'To (mail-header-extra header))))
2825 (newsgroups (cdr (assq 'Newsgroups (mail-header-extra header))))
2826 (mail-parse-charset gnus-newsgroup-charset)
2827 (mail-parse-ignored-charsets
2828 (save-excursion (set-buffer gnus-summary-buffer)
2829 gnus-newsgroup-ignored-charsets)))
2832 gnus-ignored-from-addresses
2833 (string-match gnus-ignored-from-addresses
2834 (mail-header-from header)))
2836 (or (car (funcall gnus-extract-address-components
2838 gnus-decode-encoded-word-function to)))
2839 (funcall gnus-decode-encoded-word-function to))))
2841 gnus-ignored-from-addresses
2842 (string-match gnus-ignored-from-addresses
2843 (mail-header-from header)))
2844 (concat "=> " newsgroups))
2846 (or (car (funcall gnus-extract-address-components
2847 (mail-header-from header)))
2848 (mail-header-from header))))))
2850 (defun gnus-summary-insert-line (gnus-tmp-header
2851 gnus-tmp-level gnus-tmp-current
2852 gnus-tmp-unread gnus-tmp-replied
2853 gnus-tmp-expirable gnus-tmp-subject-or-nil
2854 &optional gnus-tmp-dummy gnus-tmp-score
2856 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2857 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2858 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2859 (gnus-tmp-score-char
2860 (if (or (null gnus-summary-default-score)
2861 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2862 gnus-summary-zcore-fuzz))
2864 (if (< gnus-tmp-score gnus-summary-default-score)
2865 gnus-score-below-mark gnus-score-over-mark)))
2867 (cond (gnus-tmp-process gnus-process-mark)
2868 ((memq gnus-tmp-current gnus-newsgroup-cached)
2870 (gnus-tmp-replied gnus-replied-mark)
2871 ((memq gnus-tmp-current gnus-newsgroup-saved)
2874 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2877 ((string-match "<[^>]+> *$" gnus-tmp-from)
2878 (let ((beg (match-beginning 0)))
2879 (or (and (string-match "^\".+\"" gnus-tmp-from)
2880 (substring gnus-tmp-from 1 (1- (match-end 0))))
2881 (substring gnus-tmp-from 0 beg))))
2882 ((string-match "(.+)" gnus-tmp-from)
2883 (substring gnus-tmp-from
2884 (1+ (match-beginning 0)) (1- (match-end 0))))
2886 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2887 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2888 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2889 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
2890 (buffer-read-only nil))
2891 (when (string= gnus-tmp-name "")
2892 (setq gnus-tmp-name gnus-tmp-from))
2893 (unless (numberp gnus-tmp-lines)
2894 (setq gnus-tmp-lines -1))
2895 (when (= gnus-tmp-lines -1)
2896 (setq gnus-tmp-lines "?"))
2897 (gnus-put-text-property
2899 (progn (eval gnus-summary-line-format-spec) (point))
2900 'gnus-number gnus-tmp-number)
2901 (when (gnus-visual-p 'summary-highlight 'highlight)
2903 (gnus-run-hooks 'gnus-summary-update-hook)
2906 (defun gnus-summary-update-line (&optional dont-update)
2907 "Update summary line after change."
2908 (when (and gnus-summary-default-score
2909 (not gnus-summary-inhibit-highlight))
2910 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
2911 (article (gnus-summary-article-number))
2912 (score (gnus-summary-article-score article)))
2914 (if (and gnus-summary-mark-below
2915 (< (gnus-summary-article-score)
2916 gnus-summary-mark-below))
2917 ;; This article has a low score, so we mark it as read.
2918 (when (memq article gnus-newsgroup-unreads)
2919 (gnus-summary-mark-article-as-read gnus-low-score-mark))
2920 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
2921 ;; This article was previously marked as read on account
2922 ;; of a low score, but now it has risen, so we mark it as
2924 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
2925 (gnus-summary-update-mark
2926 (if (or (null gnus-summary-default-score)
2927 (<= (abs (- score gnus-summary-default-score))
2928 gnus-summary-zcore-fuzz))
2930 (if (< score gnus-summary-default-score)
2931 gnus-score-below-mark gnus-score-over-mark))
2933 ;; Do visual highlighting.
2934 (when (gnus-visual-p 'summary-highlight 'highlight)
2935 (gnus-run-hooks 'gnus-summary-update-hook)))))
2937 (defvar gnus-tmp-new-adopts nil)
2939 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
2940 "Return the number of articles in THREAD.
2941 This may be 0 in some cases -- if none of the articles in
2942 the thread are to be displayed."
2944 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
2946 ((not (listp thread))
2948 ((and (consp thread) (cdr thread))
2951 'gnus-summary-number-of-articles-in-thread (cdr thread))))
2954 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
2957 (when (and level (zerop level) gnus-tmp-new-adopts)
2960 'gnus-summary-number-of-articles-in-thread
2961 gnus-tmp-new-adopts))))
2963 (if (> number 1) gnus-not-empty-thread-mark
2964 gnus-empty-thread-mark)
2967 (defun gnus-summary-set-local-parameters (group)
2968 "Go through the local params of GROUP and set all variable specs in that list."
2969 (let ((params (gnus-group-find-parameter group))
2972 (setq elem (car params)
2973 params (cdr params))
2974 (and (consp elem) ; Has to be a cons.
2975 (consp (cdr elem)) ; The cdr has to be a list.
2976 (symbolp (car elem)) ; Has to be a symbol in there.
2977 (not (memq (car elem) '(quit-config))) ; Ignore quit-config.
2978 (ignore-errors ; So we set it.
2979 (make-local-variable (car elem))
2980 (set (car elem) (eval (nth 1 elem))))))))
2982 (defun gnus-summary-read-group (group &optional show-all no-article
2983 kill-buffer no-display backward
2985 "Start reading news in newsgroup GROUP.
2986 If SHOW-ALL is non-nil, already read articles are also listed.
2987 If NO-ARTICLE is non-nil, no article is selected initially.
2988 If NO-DISPLAY, don't generate a summary buffer."
2992 (let ((gnus-auto-select-next nil))
2993 (or (gnus-summary-read-group-1
2994 group show-all no-article
2995 kill-buffer no-display
2998 select-articles nil)))))
2999 (eq gnus-auto-select-next 'quietly))
3000 (set-buffer gnus-group-buffer)
3001 ;; The entry function called above goes to the next
3002 ;; group automatically, so we go two groups back
3003 ;; if we are searching for the previous group.
3005 (gnus-group-prev-unread-group 2))
3006 (if (not (equal group (gnus-group-group-name)))
3007 (setq group (gnus-group-group-name))
3011 (defun gnus-summary-read-group-1 (group show-all no-article
3012 kill-buffer no-display
3013 &optional select-articles)
3014 ;; Killed foreign groups can't be entered.
3015 ;; (when (and (not (gnus-group-native-p group))
3016 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3017 ;; (error "Dead non-native groups can't be entered"))
3018 (gnus-message 5 "Retrieving newsgroup: %s..."
3019 (gnus-group-decoded-name group))
3020 (let* ((new-group (gnus-summary-setup-buffer group))
3021 (quit-config (gnus-group-quit-config group))
3022 (did-select (and new-group (gnus-select-newsgroup
3023 group show-all select-articles))))
3025 ;; This summary buffer exists already, so we just select it.
3027 (gnus-set-global-variables)
3029 (gnus-kill-or-deaden-summary kill-buffer))
3030 (gnus-configure-windows 'summary 'force)
3031 (gnus-set-mode-line 'summary)
3032 (gnus-summary-position-point)
3035 ;; We couldn't select this group.
3037 (when (and (eq major-mode 'gnus-summary-mode)
3038 (not (equal (current-buffer) kill-buffer)))
3039 (kill-buffer (current-buffer))
3040 (if (not quit-config)
3042 ;; Update the info -- marks might need to be removed,
3044 (gnus-summary-update-info)
3045 (set-buffer gnus-group-buffer)
3046 (gnus-group-jump-to-group group)
3047 (gnus-group-next-unread-group 1))
3048 (gnus-handle-ephemeral-exit quit-config)))
3049 (let ((grpinfo (gnus-get-info group)))
3050 (if (null (gnus-info-read grpinfo))
3051 (gnus-message 3 "Group %s contains no messages"
3052 (gnus-group-decoded-name group))
3053 (gnus-message 3 "Can't select group")))
3055 ;; The user did a `C-g' while prompting for number of articles,
3056 ;; so we exit this group.
3057 ((eq did-select 'quit)
3058 (and (eq major-mode 'gnus-summary-mode)
3059 (not (equal (current-buffer) kill-buffer))
3060 (kill-buffer (current-buffer)))
3062 (gnus-kill-or-deaden-summary kill-buffer))
3063 (if (not quit-config)
3065 (set-buffer gnus-group-buffer)
3066 (gnus-group-jump-to-group group)
3067 (gnus-group-next-unread-group 1)
3068 (gnus-configure-windows 'group 'force))
3069 (gnus-handle-ephemeral-exit quit-config))
3070 ;; Finally signal the quit.
3072 ;; The group was successfully selected.
3074 (gnus-set-global-variables)
3075 ;; Save the active value in effect when the group was entered.
3076 (setq gnus-newsgroup-active
3078 (gnus-active gnus-newsgroup-name)))
3079 ;; You can change the summary buffer in some way with this hook.
3080 (gnus-run-hooks 'gnus-select-group-hook)
3081 (gnus-update-format-specifications
3082 nil 'summary 'summary-mode 'summary-dummy)
3083 (gnus-update-summary-mark-positions)
3084 ;; Do score processing.
3085 (when gnus-use-scoring
3086 (gnus-possibly-score-headers))
3087 ;; Check whether to fill in the gaps in the threads.
3088 (when gnus-build-sparse-threads
3089 (gnus-build-sparse-threads))
3090 ;; Find the initial limit.
3091 (if gnus-show-threads
3093 (let ((gnus-newsgroup-dormant nil))
3094 (gnus-summary-initial-limit show-all))
3095 (gnus-summary-initial-limit show-all))
3096 ;; When untreaded, all articles are always shown.
3097 (setq gnus-newsgroup-limit
3099 (lambda (header) (mail-header-number header))
3100 gnus-newsgroup-headers)))
3101 ;; Generate the summary buffer.
3103 (gnus-summary-prepare))
3104 (when gnus-use-trees
3105 (gnus-tree-open group)
3106 (setq gnus-summary-highlight-line-function
3107 'gnus-tree-highlight-article))
3108 ;; If the summary buffer is empty, but there are some low-scored
3109 ;; articles or some excluded dormants, we include these in the
3111 (when (and (zerop (buffer-size))
3113 (cond (gnus-newsgroup-dormant
3114 (gnus-summary-limit-include-dormant))
3115 ((and gnus-newsgroup-scored show-all)
3116 (gnus-summary-limit-include-expunged t))))
3117 ;; Function `gnus-apply-kill-file' must be called in this hook.
3118 (gnus-run-hooks 'gnus-apply-kill-hook)
3119 (if (and (zerop (buffer-size))
3122 ;; This newsgroup is empty.
3123 (gnus-summary-catchup-and-exit nil t)
3124 (gnus-message 6 "No unread news")
3126 (gnus-kill-or-deaden-summary kill-buffer))
3127 ;; Return nil from this function.
3129 ;; Hide conversation thread subtrees. We cannot do this in
3130 ;; gnus-summary-prepare-hook since kill processing may not
3131 ;; work with hidden articles.
3132 (and gnus-show-threads
3133 gnus-thread-hide-subtree
3134 (gnus-summary-hide-all-threads))
3136 (gnus-kill-or-deaden-summary kill-buffer))
3137 ;; Show first unread article if requested.
3138 (if (and (not no-article)
3140 gnus-newsgroup-unreads
3141 gnus-auto-select-first)
3143 (gnus-configure-windows 'summary)
3145 ((eq gnus-auto-select-first 'best)
3146 (gnus-summary-best-unread-article))
3147 ((eq gnus-auto-select-first t)
3148 (gnus-summary-first-unread-article))
3149 ((gnus-functionp gnus-auto-select-first)
3150 (funcall gnus-auto-select-first))))
3151 ;; Don't select any articles, just move point to the first
3152 ;; article in the group.
3153 (goto-char (point-min))
3154 (gnus-summary-position-point)
3155 (gnus-configure-windows 'summary 'force)
3156 (gnus-set-mode-line 'summary))
3157 (when (get-buffer-window gnus-group-buffer t)
3158 ;; Gotta use windows, because recenter does weird stuff if
3159 ;; the current buffer ain't the displayed window.
3160 (let ((owin (selected-window)))
3161 (select-window (get-buffer-window gnus-group-buffer t))
3162 (when (gnus-group-goto-group group)
3164 (select-window owin)))
3165 ;; Mark this buffer as "prepared".
3166 (setq gnus-newsgroup-prepared t)
3167 (gnus-run-hooks 'gnus-summary-prepared-hook)
3170 (defun gnus-summary-prepare ()
3171 "Generate the summary buffer."
3173 (let ((buffer-read-only nil))
3175 (setq gnus-newsgroup-data nil
3176 gnus-newsgroup-data-reverse nil)
3177 (gnus-run-hooks 'gnus-summary-generate-hook)
3178 ;; Generate the buffer, either with threads or without.
3179 (when gnus-newsgroup-headers
3180 (gnus-summary-prepare-threads
3181 (if gnus-show-threads
3182 (gnus-sort-gathered-threads
3183 (funcall gnus-summary-thread-gathering-function
3185 (gnus-cut-threads (gnus-make-threads)))))
3186 ;; Unthreaded display.
3187 (gnus-sort-articles gnus-newsgroup-headers))))
3188 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3189 ;; Call hooks for modifying summary buffer.
3190 (goto-char (point-min))
3191 (gnus-run-hooks 'gnus-summary-prepare-hook)))
3193 (defsubst gnus-general-simplify-subject (subject)
3194 "Simply subject by the same rules as gnus-gather-threads-by-subject."
3197 ;; Truncate the subject.
3198 (gnus-simplify-subject-functions
3199 (gnus-map-function gnus-simplify-subject-functions subject))
3200 ((numberp gnus-summary-gather-subject-limit)
3201 (setq subject (gnus-simplify-subject-re subject))
3202 (if (> (length subject) gnus-summary-gather-subject-limit)
3203 (substring subject 0 gnus-summary-gather-subject-limit)
3205 ;; Fuzzily simplify it.
3206 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3207 (gnus-simplify-subject-fuzzy subject))
3208 ;; Just remove the leading "Re:".
3210 (gnus-simplify-subject-re subject))))
3212 (if (and gnus-summary-gather-exclude-subject
3213 (string-match gnus-summary-gather-exclude-subject subject))
3214 nil ; This article shouldn't be gathered
3217 (defun gnus-summary-simplify-subject-query ()
3218 "Query where the respool algorithm would put this article."
3220 (gnus-summary-select-article)
3221 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
3223 (defun gnus-gather-threads-by-subject (threads)
3224 "Gather threads by looking at Subject headers."
3225 (if (not gnus-summary-make-false-root)
3227 (let ((hashtb (gnus-make-hashtable 1024))
3230 subject hthread whole-subject)
3232 (setq subject (gnus-general-simplify-subject
3233 (setq whole-subject (mail-header-subject
3236 (if (setq hthread (gnus-gethash subject hashtb))
3238 ;; We enter a dummy root into the thread, if we
3239 ;; haven't done that already.
3240 (unless (stringp (caar hthread))
3241 (setcar hthread (list whole-subject (car hthread))))
3242 ;; We add this new gathered thread to this gathered
3244 (setcdr (car hthread)
3245 (nconc (cdar hthread) (list (car threads))))
3246 ;; Remove it from the list of threads.
3247 (setcdr prev (cdr threads))
3248 (setq threads prev))
3249 ;; Enter this thread into the hash table.
3250 (gnus-sethash subject threads hashtb)))
3252 (setq threads (cdr threads)))
3255 (defun gnus-gather-threads-by-references (threads)
3256 "Gather threads by looking at References headers."
3257 (let ((idhashtb (gnus-make-hashtable 1024))
3258 (thhashtb (gnus-make-hashtable 1024))
3261 ids references id gthread gid entered ref)
3263 (when (setq references (mail-header-references (caar threads)))
3264 (setq id (mail-header-id (caar threads))
3265 ids (gnus-split-references references)
3267 (while (setq ref (pop ids))
3268 (setq ids (delete ref ids))
3269 (if (not (setq gid (gnus-gethash ref idhashtb)))
3271 (gnus-sethash ref id idhashtb)
3272 (gnus-sethash id threads thhashtb))
3273 (setq gthread (gnus-gethash gid thhashtb))
3275 ;; We enter a dummy root into the thread, if we
3276 ;; haven't done that already.
3277 (unless (stringp (caar gthread))
3278 (setcar gthread (list (mail-header-subject (caar gthread))
3280 ;; We add this new gathered thread to this gathered
3282 (setcdr (car gthread)
3283 (nconc (cdar gthread) (list (car threads)))))
3284 ;; Add it into the thread hash table.
3285 (gnus-sethash id gthread thhashtb)
3287 ;; Remove it from the list of threads.
3288 (setcdr prev (cdr threads))
3289 (setq threads prev))))
3291 (setq threads (cdr threads)))
3294 (defun gnus-sort-gathered-threads (threads)
3295 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
3296 (let ((result threads))
3298 (when (stringp (caar threads))
3299 (setcdr (car threads)
3300 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3301 (setq threads (cdr threads)))
3304 (defun gnus-thread-loop-p (root thread)
3305 "Say whether ROOT is in THREAD."
3306 (let ((stack (list thread))
3309 (while (setq thread (pop stack))
3310 (setq th (cdr thread))
3312 (not (eq (caar th) root)))
3315 ;; We have found a loop.
3317 (setcdr thread (delq (car th) (cdr thread)))
3318 (if (boundp (setq ref-dep (intern "none"
3319 gnus-newsgroup-dependencies)))
3320 (setcdr (symbol-value ref-dep)
3321 (nconc (cdr (symbol-value ref-dep))
3323 (set ref-dep (list nil (car th))))
3326 ;; Push all the subthreads onto the stack.
3327 (push (cdr thread) stack)))
3330 (defun gnus-make-threads ()
3331 "Go through the dependency hashtb and find the roots. Return all threads."
3333 (while (catch 'infloop
3336 ;; Deal with self-referencing References loops.
3337 (when (and (car (symbol-value refs))
3344 (car (symbol-value refs)) thread))
3345 (cdr (symbol-value refs)))))))
3348 (unless (car (symbol-value refs))
3349 ;; These threads do not refer back to any other articles,
3350 ;; so they're roots.
3351 (setq threads (append (cdr (symbol-value refs)) threads))))
3352 gnus-newsgroup-dependencies)))
3355 ;; Build the thread tree.
3356 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3357 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3359 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3360 if it was already present.
3362 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3363 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3364 Message-IDs will be renamed be renamed to a unique Message-ID before
3367 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3368 (let* ((id (mail-header-id header))
3369 (id-dep (and id (intern id dependencies)))
3370 ref ref-dep ref-header)
3371 ;; Enter this `header' in the `dependencies' table.
3375 ;; The first two cases do the normal part: enter a new `header'
3376 ;; in the `dependencies' table.
3377 ((not (boundp id-dep))
3378 (set id-dep (list header)))
3379 ((null (car (symbol-value id-dep)))
3380 (setcar (symbol-value id-dep) header))
3382 ;; From here the `header' was already present in the
3383 ;; `dependencies' table.
3385 ;; Overrides an existing entry;
3386 ;; just set the header part of the entry.
3387 (setcar (symbol-value id-dep) header))
3389 ;; Renames the existing `header' to a unique Message-ID.
3390 ((not gnus-summary-ignore-duplicates)
3391 ;; An article with this Message-ID has already been seen.
3392 ;; We rename the Message-ID.
3393 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3395 (mail-header-set-id header id))
3397 ;; The last case ignores an existing entry, except it adds any
3398 ;; additional Xrefs (in case the two articles came from different
3400 ;; Also sets `header' to `nil' meaning that the `dependencies'
3401 ;; table was *not* modified.
3403 (mail-header-set-xref
3404 (car (symbol-value id-dep))
3405 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3407 (or (mail-header-xref header) "")))
3411 ;; First check if that we are not creating a References loop.
3412 (setq ref (gnus-parent-id (mail-header-references header)))
3414 (setq ref-dep (intern-soft ref dependencies))
3416 (setq ref-header (car (symbol-value ref-dep))))
3417 (if (string= id ref)
3418 ;; Yuk! This is a reference loop. Make the article be a
3421 (mail-header-set-references (car (symbol-value id-dep)) "none")
3423 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3424 (setq ref (gnus-parent-id (mail-header-references header)))
3425 (setq ref-dep (intern (or ref "none") dependencies))
3426 (if (boundp ref-dep)
3427 (setcdr (symbol-value ref-dep)
3428 (nconc (cdr (symbol-value ref-dep))
3429 (list (symbol-value id-dep))))
3430 (set ref-dep (list nil (symbol-value id-dep)))))
3433 (defun gnus-build-sparse-threads ()
3434 (let ((headers gnus-newsgroup-headers)
3435 (mail-parse-charset gnus-newsgroup-charset)
3436 (gnus-summary-ignore-duplicates t)
3437 header references generation relations
3438 subject child end new-child date)
3439 ;; First we create an alist of generations/relations, where
3440 ;; generations is how much we trust the relation, and the relation
3442 (gnus-message 7 "Making sparse threads...")
3444 (nnheader-set-temp-buffer " *gnus sparse threads*")
3445 (while (setq header (pop headers))
3446 (when (and (setq references (mail-header-references header))
3447 (not (string= references "")))
3449 (setq child (mail-header-id header)
3450 subject (mail-header-subject header)
3451 date (mail-header-date header)
3453 (while (search-backward ">" nil t)
3454 (setq end (1+ (point)))
3455 (when (search-backward "<" nil t)
3456 (setq new-child (buffer-substring (point) end))
3457 (push (list (incf generation)
3458 child (setq child new-child)
3462 (push (list (1+ generation) child nil subject) relations))
3464 (kill-buffer (current-buffer)))
3465 ;; Sort over trustworthiness.
3468 (when (gnus-dependencies-add-header
3469 (make-full-mail-header
3470 gnus-reffed-article-number
3471 (nth 3 relation) "" (or (nth 4 relation) "")
3473 (or (nth 2 relation) "") 0 0 "")
3474 gnus-newsgroup-dependencies nil)
3475 (push gnus-reffed-article-number gnus-newsgroup-limit)
3476 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3477 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3478 gnus-newsgroup-reads)
3479 (decf gnus-reffed-article-number)))
3480 (sort relations 'car-less-than-car))
3481 (gnus-message 7 "Making sparse threads...done")))
3483 (defun gnus-build-old-threads ()
3484 ;; Look at all the articles that refer back to old articles, and
3485 ;; fetch the headers for the articles that aren't there. This will
3486 ;; build complete threads - if the roots haven't been expired by the
3488 (let ((mail-parse-charset gnus-newsgroup-charset)
3492 (when (not (car (symbol-value refs)))
3493 (setq heads (cdr (symbol-value refs)))
3495 (if (memq (mail-header-number (caar heads))
3496 gnus-newsgroup-dormant)
3497 (setq heads (cdr heads))
3498 (setq id (symbol-name refs))
3499 (while (and (setq id (gnus-build-get-header id))
3500 (not (car (gnus-id-to-thread id)))))
3501 (setq heads nil)))))
3502 gnus-newsgroup-dependencies)))
3504 ;; This function has to be called with point after the article number
3505 ;; on the beginning of the line.
3506 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3507 (let ((eol (gnus-point-at-eol))
3508 (buffer (current-buffer))
3511 ;; overview: [num subject from date id refs chars lines misc]
3514 (narrow-to-region (point) eol)
3519 (make-full-mail-header
3521 (funcall gnus-decode-encoded-word-function
3522 (nnheader-nov-field)) ; subject
3523 (funcall gnus-decode-encoded-word-function
3524 (nnheader-nov-field)) ; from
3525 (nnheader-nov-field) ; date
3526 (nnheader-nov-read-message-id) ; id
3527 (nnheader-nov-field) ; refs
3528 (nnheader-nov-read-integer) ; chars
3529 (nnheader-nov-read-integer) ; lines
3531 (if (looking-at "Xref: ")
3532 (goto-char (match-end 0)))
3533 (nnheader-nov-field)) ; Xref
3534 (nnheader-nov-parse-extra)))) ; extra
3538 (when gnus-alter-header-function
3539 (funcall gnus-alter-header-function header))
3540 (gnus-dependencies-add-header header dependencies force-new)))
3542 (defun gnus-build-get-header (id)
3543 "Look through the buffer of NOV lines and find the header to ID.
3544 Enter this line into the dependencies hash table, and return
3545 the id of the parent article (if any)."
3546 (let ((deps gnus-newsgroup-dependencies)
3550 (set-buffer nntp-server-buffer)
3551 (let ((case-fold-search nil))
3552 (goto-char (point-min))
3553 (while (and (not found)
3554 (search-forward id nil t))
3556 (setq found (looking-at
3557 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3558 (regexp-quote id))))
3559 (or found (beginning-of-line 2)))
3563 (setq header (gnus-nov-parse-line
3564 (read (current-buffer)) deps))
3565 (gnus-parent-id (mail-header-references header))))))
3567 (let ((number (mail-header-number header)))
3568 (push number gnus-newsgroup-limit)
3569 (push header gnus-newsgroup-headers)
3570 (if (memq number gnus-newsgroup-unselected)
3572 (push number gnus-newsgroup-unreads)
3573 (setq gnus-newsgroup-unselected
3574 (delq number gnus-newsgroup-unselected)))
3575 (push number gnus-newsgroup-ancient)))))))
3577 (defun gnus-build-all-threads ()
3578 "Read all the headers."
3579 (let ((gnus-summary-ignore-duplicates t)
3580 (mail-parse-charset gnus-newsgroup-charset)
3581 (dependencies gnus-newsgroup-dependencies)
3584 (set-buffer nntp-server-buffer)
3585 (let ((case-fold-search nil))
3586 (goto-char (point-min))
3589 (setq article (read (current-buffer))
3590 header (gnus-nov-parse-line article dependencies)))
3593 (set-buffer gnus-summary-buffer)
3594 (push header gnus-newsgroup-headers)
3595 (if (memq (setq article (mail-header-number header))
3596 gnus-newsgroup-unselected)
3598 (push article gnus-newsgroup-unreads)
3599 (setq gnus-newsgroup-unselected
3600 (delq article gnus-newsgroup-unselected)))
3601 (push article gnus-newsgroup-ancient)))
3602 (forward-line 1)))))))
3604 (defun gnus-summary-update-article-line (article header)
3605 "Update the line for ARTICLE using HEADERS."
3606 (let* ((id (mail-header-id header))
3607 (thread (gnus-id-to-thread id)))
3609 (error "Article in no thread"))
3610 ;; Update the thread.
3611 (setcar thread header)
3612 (gnus-summary-goto-subject article)
3613 (let* ((datal (gnus-data-find-list article))
3615 (length (when (cdr datal)
3616 (- (gnus-data-pos data)
3617 (gnus-data-pos (cadr datal)))))
3618 (buffer-read-only nil)
3619 (level (gnus-summary-thread-level)))
3621 (gnus-summary-insert-line
3622 header level nil (gnus-article-mark article)
3623 (memq article gnus-newsgroup-replied)
3624 (memq article gnus-newsgroup-expirable)
3625 ;; Only insert the Subject string when it's different
3626 ;; from the previous Subject string.
3631 (mail-header-subject
3634 (gnus-data-find-list
3636 (gnus-data-list t)))))
3637 ;; Error on the side of excessive subjects.
3639 (mail-header-subject header)))
3641 (mail-header-subject header))
3642 nil (cdr (assq article gnus-newsgroup-scored))
3643 (memq article gnus-newsgroup-processable))
3645 (gnus-data-update-list
3646 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3648 (defun gnus-summary-update-article (article &optional iheader)
3649 "Update ARTICLE in the summary buffer."
3650 (set-buffer gnus-summary-buffer)
3651 (let* ((header (gnus-summary-article-header article))
3652 (id (mail-header-id header))
3653 (data (gnus-data-find article))
3654 (thread (gnus-id-to-thread id))
3655 (references (mail-header-references header))
3659 (when (and references
3660 (not (equal "" references)))
3663 (buffer-read-only nil)
3669 (delq thread parent)))
3670 (if (gnus-summary-insert-subject id header)
3671 ;; Set the (possibly) new article number in the data structure.
3672 (gnus-data-set-number data (gnus-id-to-article id))
3676 (defun gnus-rebuild-thread (id &optional line)
3677 "Rebuild the thread containing ID.
3678 If LINE, insert the rebuilt thread starting on line LINE."
3679 (let ((buffer-read-only nil)
3680 old-pos current thread data)
3681 (if (not gnus-show-threads)
3682 (setq thread (list (car (gnus-id-to-thread id))))
3683 ;; Get the thread this article is part of.
3684 (setq thread (gnus-remove-thread id)))
3685 (setq old-pos (gnus-point-at-bol))
3686 (setq current (save-excursion
3687 (and (zerop (forward-line -1))
3688 (gnus-summary-article-number))))
3689 ;; If this is a gathered thread, we have to go some re-gathering.
3690 (when (stringp (car thread))
3691 (let ((subject (car thread))
3693 (setq thread (cdr thread))
3695 (unless (memq (setq thr (gnus-id-to-thread
3697 (mail-header-id (caar thread)))))
3700 (setq thread (cdr thread)))
3701 ;; We now have all (unique) roots.
3702 (if (= (length roots) 1)
3703 ;; All the loose roots are now one solid root.
3704 (setq thread (car roots))
3705 (setq thread (cons subject (gnus-sort-threads roots))))))
3707 ;; We then insert this thread into the summary buffer.
3709 (goto-char (point-min))
3710 (forward-line (1- line)))
3711 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3712 (if gnus-show-threads
3713 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3714 (gnus-summary-prepare-unthreaded thread))
3715 (setq data (nreverse gnus-newsgroup-data))
3716 (setq threads gnus-newsgroup-threads))
3717 ;; We splice the new data into the data structure.
3718 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
3719 ;;!!! then we want to insert at the beginning of the buffer.
3720 ;;!!! That happens to be true with Gnus now, but that may
3721 ;;!!! change in the future. Perhaps.
3722 (gnus-data-enter-list
3723 (if line nil current) data (- (point) old-pos))
3724 (setq gnus-newsgroup-threads
3725 (nconc threads gnus-newsgroup-threads))
3726 (gnus-data-compute-positions))))
3728 (defun gnus-number-to-header (number)
3729 "Return the header for article NUMBER."
3730 (let ((headers gnus-newsgroup-headers))
3732 (not (= number (mail-header-number (car headers)))))
3737 (defun gnus-parent-headers (in-headers &optional generation)
3738 "Return the headers of the GENERATIONeth parent of HEADERS."
3740 (setq generation 1))
3742 (headers in-headers)
3745 (not (zerop generation))
3746 (setq references (mail-header-references headers)))
3747 (setq headers (if (and references
3748 (setq parent (gnus-parent-id references)))
3749 (car (gnus-id-to-thread parent))
3752 (and (not (eq headers in-headers))
3755 (defun gnus-id-to-thread (id)
3756 "Return the (sub-)thread where ID appears."
3757 (gnus-gethash id gnus-newsgroup-dependencies))
3759 (defun gnus-id-to-article (id)
3760 "Return the article number of ID."
3761 (let ((thread (gnus-id-to-thread id)))
3764 (mail-header-number (car thread)))))
3766 (defun gnus-id-to-header (id)
3767 "Return the article headers of ID."
3768 (car (gnus-id-to-thread id)))
3770 (defun gnus-article-displayed-root-p (article)
3771 "Say whether ARTICLE is a root(ish) article."
3772 (let ((level (gnus-summary-thread-level article))
3773 (refs (mail-header-references (gnus-summary-article-header article)))
3779 ((null (gnus-parent-id refs)) t)
3781 (null (setq particle (gnus-id-to-article
3782 (gnus-parent-id refs))))
3783 (null (gnus-summary-thread-level particle)))))))
3785 (defun gnus-root-id (id)
3786 "Return the id of the root of the thread where ID appears."
3788 (while (and id (setq prev (car (gnus-id-to-thread id))))
3790 id (gnus-parent-id (mail-header-references prev))))
3793 (defun gnus-articles-in-thread (thread)
3794 "Return the list of articles in THREAD."
3795 (cons (mail-header-number (car thread))
3796 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
3798 (defun gnus-remove-thread (id &optional dont-remove)
3799 "Remove the thread that has ID in it."
3800 (let (headers thread last-id)
3801 ;; First go up in this thread until we find the root.
3802 (setq last-id (gnus-root-id id)
3803 headers (message-flatten-list (gnus-id-to-thread last-id)))
3804 ;; We have now found the real root of this thread. It might have
3805 ;; been gathered into some loose thread, so we have to search
3806 ;; through the threads to find the thread we wanted.
3807 (let ((threads gnus-newsgroup-threads)
3810 (setq sub (car threads))
3811 (if (stringp (car sub))
3812 ;; This is a gathered thread, so we look at the roots
3813 ;; below it to find whether this article is in this
3816 (setq sub (cdr sub))
3818 (when (member (caar sub) headers)
3819 (setq thread (car threads)
3822 (setq sub (cdr sub))))
3823 ;; It's an ordinary thread, so we check it.
3824 (when (eq (car sub) (car headers))
3827 (setq threads (cdr threads)))
3828 ;; If this article is in no thread, then it's a root.
3831 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
3832 (setq thread (gnus-id-to-thread last-id)))
3835 thread ; We return this thread.
3837 (if (stringp (car thread))
3839 ;; If we use dummy roots, then we have to remove the
3840 ;; dummy root as well.
3841 (when (eq gnus-summary-make-false-root 'dummy)
3842 ;; We go to the dummy root by going to
3843 ;; the first sub-"thread", and then one line up.
3844 (gnus-summary-goto-article
3845 (mail-header-number (caadr thread)))
3848 (gnus-data-compute-positions))
3849 (setq thread (cdr thread))
3851 (gnus-remove-thread-1 (car thread))
3852 (setq thread (cdr thread))))
3853 (gnus-remove-thread-1 thread))))))))
3855 (defun gnus-remove-thread-1 (thread)
3856 "Remove the thread THREAD recursively."
3857 (let ((number (mail-header-number (pop thread)))
3859 (setq thread (reverse thread))
3861 (gnus-remove-thread-1 (pop thread)))
3862 (when (setq d (gnus-data-find number))
3863 (goto-char (gnus-data-pos d))
3864 (gnus-summary-show-thread)
3867 (- (gnus-point-at-bol)
3869 (1+ (gnus-point-at-eol))
3870 (gnus-delete-line)))))))
3872 (defun gnus-sort-threads-1 (threads func)
3873 (sort (mapcar (lambda (thread)
3876 (gnus-sort-threads-1 (cdr thread) func))))
3879 (defun gnus-sort-threads (threads)
3881 (if (not gnus-thread-sort-functions)
3883 (gnus-message 8 "Sorting threads...")
3885 (gnus-sort-threads-1
3887 (gnus-make-sort-function gnus-thread-sort-functions))
3888 (gnus-message 8 "Sorting threads...done"))))
3890 (defun gnus-sort-articles (articles)
3892 (when gnus-article-sort-functions
3893 (gnus-message 7 "Sorting articles...")
3895 (setq gnus-newsgroup-headers
3896 (sort articles (gnus-make-sort-function
3897 gnus-article-sort-functions)))
3898 (gnus-message 7 "Sorting articles...done"))))
3900 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3901 (defmacro gnus-thread-header (thread)
3902 "Return header of first article in THREAD.
3903 Note that THREAD must never, ever be anything else than a variable -
3904 using some other form will lead to serious barfage."
3905 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
3906 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
3907 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
3910 (defsubst gnus-article-sort-by-number (h1 h2)
3911 "Sort articles by article number."
3912 (< (mail-header-number h1)
3913 (mail-header-number h2)))
3915 (defun gnus-thread-sort-by-number (h1 h2)
3916 "Sort threads by root article number."
3917 (gnus-article-sort-by-number
3918 (gnus-thread-header h1) (gnus-thread-header h2)))
3920 (defsubst gnus-article-sort-by-lines (h1 h2)
3921 "Sort articles by article Lines header."
3922 (< (mail-header-lines h1)
3923 (mail-header-lines h2)))
3925 (defun gnus-thread-sort-by-lines (h1 h2)
3926 "Sort threads by root article Lines header."
3927 (gnus-article-sort-by-lines
3928 (gnus-thread-header h1) (gnus-thread-header h2)))
3930 (defsubst gnus-article-sort-by-chars (h1 h2)
3931 "Sort articles by octet length."
3932 (< (mail-header-chars h1)
3933 (mail-header-chars h2)))
3935 (defun gnus-thread-sort-by-chars (h1 h2)
3936 "Sort threads by root article octet length."
3937 (gnus-article-sort-by-chars
3938 (gnus-thread-header h1) (gnus-thread-header h2)))
3940 (defsubst gnus-article-sort-by-author (h1 h2)
3941 "Sort articles by root author."
3943 (let ((extract (funcall
3944 gnus-extract-address-components
3945 (mail-header-from h1))))
3946 (or (car extract) (cadr extract) ""))
3947 (let ((extract (funcall
3948 gnus-extract-address-components
3949 (mail-header-from h2))))
3950 (or (car extract) (cadr extract) ""))))
3952 (defun gnus-thread-sort-by-author (h1 h2)
3953 "Sort threads by root author."
3954 (gnus-article-sort-by-author
3955 (gnus-thread-header h1) (gnus-thread-header h2)))
3957 (defsubst gnus-article-sort-by-subject (h1 h2)
3958 "Sort articles by root subject."
3960 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
3961 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
3963 (defun gnus-thread-sort-by-subject (h1 h2)
3964 "Sort threads by root subject."
3965 (gnus-article-sort-by-subject
3966 (gnus-thread-header h1) (gnus-thread-header h2)))
3968 (defsubst gnus-article-sort-by-date (h1 h2)
3969 "Sort articles by root article date."
3971 (gnus-date-get-time (mail-header-date h1))
3972 (gnus-date-get-time (mail-header-date h2))))
3974 (defun gnus-thread-sort-by-date (h1 h2)
3975 "Sort threads by root article date."
3976 (gnus-article-sort-by-date
3977 (gnus-thread-header h1) (gnus-thread-header h2)))
3979 (defsubst gnus-article-sort-by-score (h1 h2)
3980 "Sort articles by root article score.
3981 Unscored articles will be counted as having a score of zero."
3982 (> (or (cdr (assq (mail-header-number h1)
3983 gnus-newsgroup-scored))
3984 gnus-summary-default-score 0)
3985 (or (cdr (assq (mail-header-number h2)
3986 gnus-newsgroup-scored))
3987 gnus-summary-default-score 0)))
3989 (defun gnus-thread-sort-by-score (h1 h2)
3990 "Sort threads by root article score."
3991 (gnus-article-sort-by-score
3992 (gnus-thread-header h1) (gnus-thread-header h2)))
3994 (defun gnus-thread-sort-by-total-score (h1 h2)
3995 "Sort threads by the sum of all scores in the thread.
3996 Unscored articles will be counted as having a score of zero."
3997 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
3999 (defun gnus-thread-total-score (thread)
4000 ;; This function find the total score of THREAD.
4001 (cond ((null thread)
4004 (if (stringp (car thread))
4005 (apply gnus-thread-score-function 0
4006 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4007 (gnus-thread-total-score-1 thread)))
4009 (gnus-thread-total-score-1 (list thread)))))
4011 (defun gnus-thread-total-score-1 (root)
4012 ;; This function find the total score of the thread below ROOT.
4013 (setq root (car root))
4014 (apply gnus-thread-score-function
4016 (mapcar 'gnus-thread-total-score
4017 (cdr (gnus-id-to-thread (mail-header-id root))))
4018 (when (> (mail-header-number root) 0)
4019 (list (or (cdr (assq (mail-header-number root)
4020 gnus-newsgroup-scored))
4021 gnus-summary-default-score 0))))
4022 (list gnus-summary-default-score)
4025 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
4026 (defvar gnus-tmp-prev-subject nil)
4027 (defvar gnus-tmp-false-parent nil)
4028 (defvar gnus-tmp-root-expunged nil)
4029 (defvar gnus-tmp-dummy-line nil)
4031 (eval-when-compile (defvar gnus-tmp-header))
4032 (defun gnus-extra-header (type &optional header)
4033 "Return the extra header of TYPE."
4034 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
4037 (defun gnus-summary-prepare-threads (threads)
4038 "Prepare summary buffer from THREADS and indentation LEVEL.
4039 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
4040 or a straight list of headers."
4041 (gnus-message 7 "Generating summary...")
4043 (setq gnus-newsgroup-threads threads)
4046 (let ((gnus-tmp-level 0)
4047 (default-score (or gnus-summary-default-score 0))
4048 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
4049 thread number subject stack state gnus-tmp-gathered beg-match
4050 new-roots gnus-tmp-new-adopts thread-end
4051 gnus-tmp-header gnus-tmp-unread
4052 gnus-tmp-replied gnus-tmp-subject-or-nil
4053 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
4054 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
4055 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
4057 (setq gnus-tmp-prev-subject nil)
4059 (if (vectorp (car threads))
4060 ;; If this is a straight (sic) list of headers, then a
4061 ;; threaded summary display isn't required, so we just create
4062 ;; an unthreaded one.
4063 (gnus-summary-prepare-unthreaded threads)
4065 ;; Do the threaded display.
4067 (while (or threads stack gnus-tmp-new-adopts new-roots)
4069 (if (and (= gnus-tmp-level 0)
4072 (not gnus-tmp-false-parent)
4073 (or gnus-tmp-new-adopts new-roots))
4074 (if gnus-tmp-new-adopts
4075 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
4076 thread (list (car gnus-tmp-new-adopts))
4077 gnus-tmp-header (caar thread)
4078 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
4080 (setq thread (list (car new-roots))
4081 gnus-tmp-header (caar thread)
4082 new-roots (cdr new-roots))))
4085 ;; If there are some threads, we do them before the
4086 ;; threads on the stack.
4087 (setq thread threads
4088 gnus-tmp-header (caar thread))
4089 ;; There were no current threads, so we pop something off
4091 (setq state (car stack)
4092 gnus-tmp-level (car state)
4095 gnus-tmp-header (caar thread))))
4097 (setq gnus-tmp-false-parent nil)
4098 (setq gnus-tmp-root-expunged nil)
4099 (setq thread-end nil)
4101 (if (stringp gnus-tmp-header)
4102 ;; The header is a dummy root.
4104 ((eq gnus-summary-make-false-root 'adopt)
4105 ;; We let the first article adopt the rest.
4106 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
4108 (setq gnus-tmp-gathered
4110 (lambda (h) (mail-header-number (car h)))
4113 (setq thread (cons (list (caar thread)
4116 (setq gnus-tmp-level -1
4117 gnus-tmp-false-parent t))
4118 ((eq gnus-summary-make-false-root 'empty)
4119 ;; We print adopted articles with empty subject fields.
4120 (setq gnus-tmp-gathered
4122 (lambda (h) (mail-header-number (car h)))
4125 (setq gnus-tmp-level -1))
4126 ((eq gnus-summary-make-false-root 'dummy)
4127 ;; We remember that we probably want to output a dummy
4129 (setq gnus-tmp-dummy-line gnus-tmp-header)
4130 (setq gnus-tmp-prev-subject gnus-tmp-header))
4132 ;; We do not make a root for the gathered
4133 ;; sub-threads at all.
4134 (setq gnus-tmp-level -1)))
4136 (setq number (mail-header-number gnus-tmp-header)
4137 subject (mail-header-subject gnus-tmp-header))
4140 ;; If the thread has changed subject, we might want to make
4141 ;; this subthread into a root.
4142 ((and (null gnus-thread-ignore-subject)
4143 (not (zerop gnus-tmp-level))
4144 gnus-tmp-prev-subject
4146 (gnus-subject-equal gnus-tmp-prev-subject subject))))
4147 (setq new-roots (nconc new-roots (list (car thread)))
4149 gnus-tmp-header nil))
4150 ;; If the article lies outside the current limit,
4151 ;; then we do not display it.
4152 ((not (memq number gnus-newsgroup-limit))
4153 (setq gnus-tmp-gathered
4155 (lambda (h) (mail-header-number (car h)))
4158 (setq gnus-tmp-new-adopts (if (cdar thread)
4159 (append gnus-tmp-new-adopts
4161 gnus-tmp-new-adopts)
4163 gnus-tmp-header nil)
4164 (when (zerop gnus-tmp-level)
4165 (setq gnus-tmp-root-expunged t)))
4166 ;; Perhaps this article is to be marked as read?
4167 ((and gnus-summary-mark-below
4168 (< (or (cdr (assq number gnus-newsgroup-scored))
4170 gnus-summary-mark-below)
4171 ;; Don't touch sparse articles.
4172 (not (gnus-summary-article-sparse-p number))
4173 (not (gnus-summary-article-ancient-p number)))
4174 (setq gnus-newsgroup-unreads
4175 (delq number gnus-newsgroup-unreads))
4176 (if gnus-newsgroup-auto-expire
4177 (push number gnus-newsgroup-expirable)
4178 (push (cons number gnus-low-score-mark)
4179 gnus-newsgroup-reads))))
4181 (when gnus-tmp-header
4182 ;; We may have an old dummy line to output before this
4184 (when (and gnus-tmp-dummy-line
4187 (mail-header-subject gnus-tmp-header)))
4188 (gnus-summary-insert-dummy-line
4189 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
4190 (setq gnus-tmp-dummy-line nil))
4192 ;; Compute the mark.
4193 (setq gnus-tmp-unread (gnus-article-mark number))
4195 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
4196 gnus-tmp-header gnus-tmp-level)
4197 gnus-newsgroup-data)
4199 ;; Actually insert the line.
4201 gnus-tmp-subject-or-nil
4203 ((and gnus-thread-ignore-subject
4204 gnus-tmp-prev-subject
4205 (not (inline (gnus-subject-equal
4206 gnus-tmp-prev-subject subject))))
4208 ((zerop gnus-tmp-level)
4209 (if (and (eq gnus-summary-make-false-root 'empty)
4210 (memq number gnus-tmp-gathered)
4211 gnus-tmp-prev-subject
4212 (inline (gnus-subject-equal
4213 gnus-tmp-prev-subject subject)))
4214 gnus-summary-same-subject
4216 (t gnus-summary-same-subject)))
4217 (if (and (eq gnus-summary-make-false-root 'adopt)
4218 (= gnus-tmp-level 1)
4219 (memq number gnus-tmp-gathered))
4220 (setq gnus-tmp-opening-bracket ?\<
4221 gnus-tmp-closing-bracket ?\>)
4222 (setq gnus-tmp-opening-bracket ?\[
4223 gnus-tmp-closing-bracket ?\]))
4225 gnus-tmp-indentation
4226 (aref gnus-thread-indent-array gnus-tmp-level)
4227 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4228 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4229 gnus-summary-default-score 0)
4231 (if (or (null gnus-summary-default-score)
4232 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
4233 gnus-summary-zcore-fuzz))
4235 (if (< gnus-tmp-score gnus-summary-default-score)
4236 gnus-score-below-mark gnus-score-over-mark))
4238 (cond ((memq number gnus-newsgroup-processable)
4240 ((memq number gnus-newsgroup-cached)
4242 ((memq number gnus-newsgroup-replied)
4244 ((memq number gnus-newsgroup-forwarded)
4245 gnus-forwarded-mark)
4246 ((memq number gnus-newsgroup-saved)
4249 gnus-tmp-from (mail-header-from gnus-tmp-header)
4252 ((string-match "<[^>]+> *$" gnus-tmp-from)
4253 (setq beg-match (match-beginning 0))
4254 (or (and (string-match "^\".+\"" gnus-tmp-from)
4255 (substring gnus-tmp-from 1 (1- (match-end 0))))
4256 (substring gnus-tmp-from 0 beg-match)))
4257 ((string-match "(.+)" gnus-tmp-from)
4258 (substring gnus-tmp-from
4259 (1+ (match-beginning 0)) (1- (match-end 0))))
4261 (when (string= gnus-tmp-name "")
4262 (setq gnus-tmp-name gnus-tmp-from))
4263 (unless (numberp gnus-tmp-lines)
4264 (setq gnus-tmp-lines -1))
4265 (when (= gnus-tmp-lines -1)
4266 (setq gnus-tmp-lines "?"))
4267 (gnus-put-text-property
4269 (progn (eval gnus-summary-line-format-spec) (point))
4270 'gnus-number number)
4273 (gnus-run-hooks 'gnus-summary-update-hook)
4276 (setq gnus-tmp-prev-subject subject)))
4278 (when (nth 1 thread)
4279 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
4280 (incf gnus-tmp-level)
4281 (setq threads (if thread-end nil (cdar thread)))
4283 (setq gnus-tmp-level 0)))))
4284 (gnus-message 7 "Generating summary...done"))
4286 (defun gnus-summary-prepare-unthreaded (headers)
4287 "Generate an unthreaded summary buffer based on HEADERS."
4288 (let (header number mark)
4293 ;; We may have to root out some bad articles...
4294 (when (memq (setq number (mail-header-number
4295 (setq header (pop headers))))
4296 gnus-newsgroup-limit)
4297 ;; Mark article as read when it has a low score.
4298 (when (and gnus-summary-mark-below
4299 (< (or (cdr (assq number gnus-newsgroup-scored))
4300 gnus-summary-default-score 0)
4301 gnus-summary-mark-below)
4302 (not (gnus-summary-article-ancient-p number)))
4303 (setq gnus-newsgroup-unreads
4304 (delq number gnus-newsgroup-unreads))
4305 (if gnus-newsgroup-auto-expire
4306 (push number gnus-newsgroup-expirable)
4307 (push (cons number gnus-low-score-mark)
4308 gnus-newsgroup-reads)))
4310 (setq mark (gnus-article-mark number))
4311 (push (gnus-data-make number mark (1+ (point)) header 0)
4312 gnus-newsgroup-data)
4313 (gnus-summary-insert-line
4315 mark (memq number gnus-newsgroup-replied)
4316 (memq number gnus-newsgroup-expirable)
4317 (mail-header-subject header) nil
4318 (cdr (assq number gnus-newsgroup-scored))
4319 (memq number gnus-newsgroup-processable))))))
4321 (defun gnus-summary-remove-list-identifiers ()
4322 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
4323 (let ((regexp (if (consp gnus-list-identifiers)
4324 (mapconcat 'identity gnus-list-identifiers " *\\|")
4325 gnus-list-identifiers))
4328 (dolist (header gnus-newsgroup-headers)
4329 (setq subject (mail-header-subject header)
4331 (while (string-match
4332 (concat "^\\(R[Ee]: +\\)*\\(" regexp " *\\)")
4335 (concat (substring subject 0 (match-beginning 2))
4336 (substring subject (match-end 0)))
4340 "^\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" subject))
4342 (concat (substring subject 0 (match-beginning 1))
4343 (substring subject (match-end 1)))))
4345 (mail-header-set-subject header subject))))))
4347 (defun gnus-fetch-headers (articles)
4348 "Fetch headers of ARTICLES."
4349 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
4350 (gnus-message 5 "Fetching headers for %s..." name)
4353 (setq gnus-headers-retrieved-by
4354 (gnus-retrieve-headers
4355 articles gnus-newsgroup-name
4356 ;; We might want to fetch old headers, but
4357 ;; not if there is only 1 article.
4359 (not (eq gnus-fetch-old-headers 'some))
4360 (not (numberp gnus-fetch-old-headers)))
4361 (> (length articles) 1))
4362 gnus-fetch-old-headers))))
4363 (gnus-get-newsgroup-headers-xover
4364 articles nil nil gnus-newsgroup-name t)
4365 (gnus-get-newsgroup-headers))
4366 (gnus-message 5 "Fetching headers for %s...done" name))))
4368 (defun gnus-select-newsgroup (group &optional read-all select-articles)
4369 "Select newsgroup GROUP.
4370 If READ-ALL is non-nil, all articles in the group are selected.
4371 If SELECT-ARTICLES, only select those articles from GROUP."
4372 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4373 ;;!!! Dirty hack; should be removed.
4374 (gnus-summary-ignore-duplicates
4375 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
4377 gnus-summary-ignore-duplicates))
4378 (info (nth 2 entry))
4379 articles fetched-articles cached)
4381 (unless (gnus-check-server
4382 (setq gnus-current-select-method
4383 (gnus-find-method-for-group group)))
4384 (error "Couldn't open server"))
4386 (or (and entry (not (eq (car entry) t))) ; Either it's active...
4387 (gnus-activate-group group) ; Or we can activate it...
4388 (progn ; Or we bug out.
4389 (when (equal major-mode 'gnus-summary-mode)
4390 (kill-buffer (current-buffer)))
4391 (error "Couldn't activate group %s: %s"
4392 group (gnus-status-message group))))
4394 (unless (gnus-request-group group t)
4395 (when (equal major-mode 'gnus-summary-mode)
4396 (kill-buffer (current-buffer)))
4397 (error "Couldn't request group %s: %s"
4398 group (gnus-status-message group)))
4400 (setq gnus-newsgroup-name group)
4401 (setq gnus-newsgroup-unselected nil)
4402 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
4403 (gnus-summary-setup-default-charset)
4405 ;; Adjust and set lists of article marks.
4407 (gnus-adjust-marked-articles info))
4409 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4410 (when (gnus-virtual-group-p group)
4411 (setq cached gnus-newsgroup-cached))
4413 (setq gnus-newsgroup-unreads
4414 (gnus-set-difference
4415 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
4416 gnus-newsgroup-dormant))
4418 (setq gnus-newsgroup-processable nil)
4420 (gnus-update-read-articles group gnus-newsgroup-unreads)
4422 (if (setq articles select-articles)
4423 (setq gnus-newsgroup-unselected
4424 (gnus-sorted-intersection
4425 gnus-newsgroup-unreads
4426 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4427 (setq articles (gnus-articles-to-read group read-all)))
4431 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
4433 ((eq articles 0) nil)
4435 ;; Init the dependencies hash table.
4436 (setq gnus-newsgroup-dependencies
4437 (gnus-make-hashtable (length articles)))
4438 (gnus-set-global-variables)
4439 ;; Retrieve the headers and read them in.
4440 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
4442 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4444 (setq gnus-newsgroup-cached cached))
4446 ;; Suppress duplicates?
4447 (when gnus-suppress-duplicates
4448 (gnus-dup-suppress-articles))
4450 ;; Set the initial limit.
4451 (setq gnus-newsgroup-limit (copy-sequence articles))
4452 ;; Remove canceled articles from the list of unread articles.
4453 (setq gnus-newsgroup-unreads
4454 (gnus-set-sorted-intersection
4455 gnus-newsgroup-unreads
4456 (setq fetched-articles
4457 (mapcar (lambda (headers) (mail-header-number headers))
4458 gnus-newsgroup-headers))))
4459 ;; Removed marked articles that do not exist.
4460 (gnus-update-missing-marks
4461 (gnus-sorted-complement fetched-articles articles))
4462 ;; We might want to build some more threads first.
4463 (when (and gnus-fetch-old-headers
4464 (eq gnus-headers-retrieved-by 'nov))
4465 (if (eq gnus-fetch-old-headers 'invisible)
4466 (gnus-build-all-threads)
4467 (gnus-build-old-threads)))
4468 ;; Let the Gnus agent mark articles as read.
4470 (gnus-agent-get-undownloaded-list))
4471 ;; Remove list identifiers from subject
4472 (when gnus-list-identifiers
4473 (gnus-summary-remove-list-identifiers))
4474 ;; Check whether auto-expire is to be done in this group.
4475 (setq gnus-newsgroup-auto-expire
4476 (gnus-group-auto-expirable-p group))
4477 ;; Set up the article buffer now, if necessary.
4478 (unless gnus-single-article-buffer
4479 (gnus-article-setup-buffer))
4480 ;; First and last article in this newsgroup.
4481 (when gnus-newsgroup-headers
4482 (setq gnus-newsgroup-begin
4483 (mail-header-number (car gnus-newsgroup-headers))
4486 (gnus-last-element gnus-newsgroup-headers))))
4487 ;; GROUP is successfully selected.
4488 (or gnus-newsgroup-headers t)))))
4490 (defun gnus-articles-to-read (group &optional read-all)
4491 "Find out what articles the user wants to read."
4493 ;; Select all articles if `read-all' is non-nil, or if there
4494 ;; are no unread articles.
4496 (and (zerop (length gnus-newsgroup-marked))
4497 (zerop (length gnus-newsgroup-unreads)))
4498 (eq (gnus-group-find-parameter group 'display)
4501 (gnus-uncompress-range (gnus-active group))
4502 (gnus-cache-articles-in-group group))
4503 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
4504 (copy-sequence gnus-newsgroup-unreads))
4506 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
4507 (scored (length scored-list))
4508 (number (length articles))
4509 (marked (+ (length gnus-newsgroup-marked)
4510 (length gnus-newsgroup-dormant)))
4518 ((and (or (<= scored marked) (= scored number))
4519 (numberp gnus-large-newsgroup)
4520 (> number gnus-large-newsgroup))
4524 "How many articles from %s (default %d): "
4525 (gnus-limit-string gnus-newsgroup-name 35)
4527 (if (string-match "^[ \t]*$" input) number input)))
4528 ((and (> scored marked) (< scored number)
4529 (> (- scored number) 20))
4532 (format "%s %s (%d scored, %d total): "
4533 "How many articles from"
4534 group scored number))))
4535 (if (string-match "^[ \t]*$" input)
4539 (message "Quit getting the articles to read")
4541 (setq select (if (stringp select) (string-to-number select) select))
4542 (if (or (null select) (zerop select))
4544 (if (and (not (zerop scored)) (<= (abs select) scored))
4546 (setq articles (sort scored-list '<))
4547 (setq number (length articles)))
4548 (setq articles (copy-sequence articles)))
4550 (when (< (abs select) number)
4552 ;; Select the N oldest articles.
4553 (setcdr (nthcdr (1- (abs select)) articles) nil)
4554 ;; Select the N most recent articles.
4555 (setq articles (nthcdr (- number select) articles))))
4556 (setq gnus-newsgroup-unselected
4557 (gnus-sorted-intersection
4558 gnus-newsgroup-unreads
4559 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4560 (when gnus-alter-articles-to-read-function
4561 (setq gnus-newsgroup-unreads
4563 (funcall gnus-alter-articles-to-read-function
4564 gnus-newsgroup-name gnus-newsgroup-unreads)
4568 (defun gnus-killed-articles (killed articles)
4571 (when (inline (gnus-member-of-range (car articles) killed))
4572 (push (car articles) out))
4573 (setq articles (cdr articles)))
4576 (defun gnus-uncompress-marks (marks)
4577 "Uncompress the mark ranges in MARKS."
4578 (let ((uncompressed '(score bookmark))
4581 (if (memq (caar marks) uncompressed)
4582 (push (car marks) out)
4583 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
4584 (setq marks (cdr marks)))
4587 (defun gnus-adjust-marked-articles (info)
4588 "Set all article lists and remove all marks that are no longer valid."
4589 (let* ((marked-lists (gnus-info-marks info))
4590 (active (gnus-active (gnus-info-group info)))
4593 (types gnus-article-mark-lists)
4594 (uncompressed '(score bookmark killed))
4595 marks var articles article mark)
4598 (setq marks (pop marked-lists))
4599 (set (setq var (intern (format "gnus-newsgroup-%s"
4600 (car (rassq (setq mark (car marks))
4602 (if (memq (car marks) uncompressed) (cdr marks)
4603 (gnus-uncompress-range (cdr marks))))
4605 (setq articles (symbol-value var))
4607 ;; All articles have to be subsets of the active articles.
4609 ;; Adjust "simple" lists.
4610 ((memq mark '(tick dormant expire reply save))
4612 (when (or (< (setq article (pop articles)) min) (> article max))
4613 (set var (delq article (symbol-value var))))))
4615 ((memq mark uncompressed)
4616 (when (not (listp (cdr (symbol-value var))))
4617 (set var (list (symbol-value var))))
4618 (when (not (listp (cdr articles)))
4619 (setq articles (list articles)))
4621 (when (or (not (consp (setq article (pop articles))))
4622 (< (car article) min)
4623 (> (car article) max))
4624 (set var (delq article (symbol-value var))))))))))
4626 (defun gnus-update-missing-marks (missing)
4627 "Go through the list of MISSING articles and remove them from the mark lists."
4629 (let ((types gnus-article-mark-lists)
4631 ;; Go through all types.
4633 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
4634 (when (symbol-value var)
4635 ;; This list has articles. So we delete all missing articles
4639 (set var (delq (pop m) (symbol-value var)))))))))
4641 (defun gnus-update-marks ()
4642 "Enter the various lists of marked articles into the newsgroup info list."
4643 (let ((types gnus-article-mark-lists)
4644 (info (gnus-get-info gnus-newsgroup-name))
4645 (uncompressed '(score bookmark killed))
4646 type list newmarked symbol delta-marks)
4648 ;; Add all marks lists to the list of marks lists.
4649 (while (setq type (pop types))
4650 (setq list (symbol-value
4652 (intern (format "gnus-newsgroup-%s"
4656 ;; Get rid of the entries of the articles that have the
4658 (when (and (eq (cdr type) 'score)
4662 (prev (cons nil list))
4665 (if (or (not (consp (car arts)))
4666 (= (cdar arts) gnus-summary-default-score))
4667 (setcdr prev (cdr arts))
4669 (setq arts (cdr arts)))
4670 (setq list (cdr all)))))
4672 (unless (memq (cdr type) uncompressed)
4673 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
4675 (when (gnus-check-backend-function
4676 'request-set-mark gnus-newsgroup-name)
4677 ;; propagate flags to server, with the following exceptions:
4678 ;; uncompressed:s are not proper flags (they are cons cells)
4679 ;; cache is a internal gnus flag
4680 ;; download are local to one gnus installation (well)
4681 ;; unsend are for nndraft groups only
4682 ;; xxx: generality of this? this suits nnimap anyway
4683 (unless (memq (cdr type) (append '(cache download unsend)
4685 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
4686 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
4687 (add (gnus-remove-from-range
4688 (gnus-copy-sequence list) old)))
4690 (push (list add 'add (list (cdr type))) delta-marks))
4692 (push (list del 'del (list (cdr type))) delta-marks)))))
4695 (push (cons (cdr type) list) newmarked)))
4698 (unless (gnus-check-group gnus-newsgroup-name)
4699 (error "Can't open server for %s" gnus-newsgroup-name))
4700 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
4702 ;; Enter these new marks into the info of the group.
4704 (setcar (nthcdr 3 info) newmarked)
4705 ;; Add the marks lists to the end of the info.
4707 (setcdr (nthcdr 2 info) (list newmarked))))
4709 ;; Cut off the end of the info if there's nothing else there.
4713 (when (nthcdr (decf i) info)
4714 (setcdr (nthcdr i info) nil)))))))
4716 (defun gnus-set-mode-line (where)
4717 "Set the mode line of the article or summary buffers.
4718 If WHERE is `summary', the summary mode line format will be used."
4719 ;; Is this mode line one we keep updated?
4720 (when (and (memq where gnus-updated-mode-lines)
4722 (intern (format "gnus-%s-mode-line-format-spec" where))))
4725 ;; We evaluate this in the summary buffer since these
4726 ;; variables are buffer-local to that buffer.
4727 (set-buffer gnus-summary-buffer)
4728 ;; We bind all these variables that are used in the `eval' form
4730 (let* ((mformat (symbol-value
4732 (format "gnus-%s-mode-line-format-spec" where))))
4733 (gnus-tmp-group-name (gnus-group-decoded-name
4734 gnus-newsgroup-name))
4735 (gnus-tmp-article-number (or gnus-current-article 0))
4736 (gnus-tmp-unread gnus-newsgroup-unreads)
4737 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
4738 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
4739 (gnus-tmp-unread-and-unselected
4740 (cond ((and (zerop gnus-tmp-unread-and-unticked)
4741 (zerop gnus-tmp-unselected))
4743 ((zerop gnus-tmp-unselected)
4744 (format "{%d more}" gnus-tmp-unread-and-unticked))
4745 (t (format "{%d(+%d) more}"
4746 gnus-tmp-unread-and-unticked
4747 gnus-tmp-unselected))))
4749 (if (and gnus-current-headers
4750 (vectorp gnus-current-headers))
4751 (gnus-mode-string-quote
4752 (mail-header-subject gnus-current-headers))
4754 bufname-length max-len
4755 gnus-tmp-header);; passed as argument to any user-format-funcs
4756 (setq mode-string (eval mformat))
4757 (setq bufname-length (if (string-match "%b" mode-string)
4760 (if (eq where 'summary)
4762 (get-buffer gnus-article-buffer))))
4765 (setq max-len (max 4 (if gnus-mode-non-string-length
4767 gnus-mode-non-string-length
4769 (length mode-string))))
4770 ;; We might have to chop a bit of the string off...
4771 (when (> (length mode-string) max-len)
4773 (concat (truncate-string-to-width mode-string (- max-len 3))
4775 ;; Pad the mode string a bit.
4776 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
4777 ;; Update the mode line.
4778 (setq mode-line-buffer-identification
4779 (gnus-mode-line-buffer-identification (list mode-string)))
4780 (set-buffer-modified-p t))))
4782 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
4783 "Go through the HEADERS list and add all Xrefs to a hash table.
4784 The resulting hash table is returned, or nil if no Xrefs were found."
4785 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
4786 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
4787 (xref-hashtb (gnus-make-hashtable))
4788 start group entry number xrefs header)
4790 (setq header (pop headers))
4791 (when (and (setq xrefs (mail-header-xref header))
4792 (not (memq (setq number (mail-header-number header))
4795 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
4796 (setq start (match-end 0))
4797 (setq group (if prefix
4798 (concat prefix (substring xrefs (match-beginning 1)
4800 (substring xrefs (match-beginning 1) (match-end 1))))
4802 (string-to-int (substring xrefs (match-beginning 2)
4804 (if (setq entry (gnus-gethash group xref-hashtb))
4805 (setcdr entry (cons number (cdr entry)))
4806 (gnus-sethash group (cons number nil) xref-hashtb)))))
4807 (and start xref-hashtb)))
4809 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
4810 "Look through all the headers and mark the Xrefs as read."
4811 (let ((virtual (gnus-virtual-group-p from-newsgroup))
4812 name entry info xref-hashtb idlist method nth4)
4814 (set-buffer gnus-group-buffer)
4815 (when (setq xref-hashtb
4816 (gnus-create-xref-hashtb from-newsgroup headers unreads))
4819 (unless (string= from-newsgroup (setq name (symbol-name group)))
4820 (setq idlist (symbol-value group))
4821 ;; Dead groups are not updated.
4823 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
4825 (when (stringp (setq nth4 (gnus-info-method info)))
4826 (setq nth4 (gnus-server-to-method nth4))))
4827 ;; Only do the xrefs if the group has the same
4828 ;; select method as the group we have just read.
4829 (or (gnus-methods-equal-p
4830 nth4 (gnus-find-method-for-group from-newsgroup))
4832 (equal nth4 (setq method (gnus-find-method-for-group
4834 (and (equal (car nth4) (car method))
4835 (equal (nth 1 nth4) (nth 1 method))))
4836 gnus-use-cross-reference
4837 (or (not (eq gnus-use-cross-reference t))
4839 ;; Only do cross-references on subscribed
4840 ;; groups, if that is what is wanted.
4841 (<= (gnus-info-level info) gnus-level-subscribed))
4842 (gnus-group-make-articles-read name idlist))))
4845 (defun gnus-compute-read-articles (group articles)
4846 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4847 (info (nth 2 entry))
4848 (active (gnus-active group))
4851 ;; First peel off all invalid article numbers.
4853 (let ((ids articles)
4855 (while (setq id (pop ids))
4856 (when (and first (> id (cdr active)))
4857 ;; We'll end up in this situation in one particular
4858 ;; obscure situation. If you re-scan a group and get
4859 ;; a new article that is cross-posted to a different
4860 ;; group that has not been re-scanned, you might get
4861 ;; crossposted article that has a higher number than
4862 ;; Gnus believes possible. So we re-activate this
4863 ;; group as well. This might mean doing the
4864 ;; crossposting thingy will *increase* the number
4865 ;; of articles in some groups. Tsk, tsk.
4866 (setq active (or (gnus-activate-group group) active)))
4867 (when (or (> id (cdr active))
4868 (< id (car active)))
4869 (setq articles (delq id articles))))))
4870 ;; If the read list is nil, we init it.
4872 (null (gnus-info-read info))
4874 (setq ninfo (cons 1 (1- (car active))))
4875 (setq ninfo (gnus-info-read info)))
4876 ;; Then we add the read articles to the range.
4878 ninfo (setq articles (sort articles '<))))))
4880 (defun gnus-group-make-articles-read (group articles)
4881 "Update the info of GROUP to say that ARTICLES are read."
4883 (entry (gnus-gethash group gnus-newsrc-hashtb))
4884 (info (nth 2 entry))
4885 (active (gnus-active group))
4888 (setq range (gnus-compute-read-articles group articles))
4890 (set-buffer gnus-group-buffer)
4893 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
4894 (gnus-info-set-read ',info ',(gnus-info-read info))
4895 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
4896 (gnus-group-update-group ,group t))))
4897 ;; Add the read articles to the range.
4898 (gnus-info-set-read info range)
4899 ;; Then we have to re-compute how many unread
4900 ;; articles there are in this group.
4904 (setq num (- (1+ (cdr active)) (car active))))
4905 ((not (listp (cdr range)))
4906 (setq num (- (cdr active) (- (1+ (cdr range))
4910 (if (numberp (car range))
4912 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
4913 (setq range (cdr range)))
4914 (setq num (- (cdr active) num))))
4915 ;; Update the number of unread articles.
4917 ;; Update the group buffer.
4918 (gnus-group-update-group group t)))))
4920 (defvar gnus-newsgroup-none-id 0)
4922 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
4923 (let ((cur nntp-server-buffer)
4926 (save-excursion (set-buffer gnus-summary-buffer)
4927 gnus-newsgroup-dependencies)))
4929 (mail-parse-charset gnus-newsgroup-charset)
4930 (mail-parse-ignored-charsets
4931 (save-excursion (condition-case nil
4932 (set-buffer gnus-summary-buffer)
4934 gnus-newsgroup-ignored-charsets)))
4936 (set-buffer nntp-server-buffer)
4937 ;; Translate all TAB characters into SPACE characters.
4938 (subst-char-in-region (point-min) (point-max) ?\t ? t)
4939 (subst-char-in-region (point-min) (point-max) ?\r ? t)
4940 (gnus-run-hooks 'gnus-parse-headers-hook)
4941 (let ((case-fold-search t)
4942 in-reply-to header p lines chars)
4943 (goto-char (point-min))
4944 ;; Search to the beginning of the next header. Error messages
4945 ;; do not begin with 2 or 3.
4946 (while (re-search-forward "^[23][0-9]+ " nil t)
4949 ;; This implementation of this function, with nine
4950 ;; search-forwards instead of the one re-search-forward and
4951 ;; a case (which basically was the old function) is actually
4952 ;; about twice as fast, even though it looks messier. You
4953 ;; can't have everything, I guess. Speed and elegance
4954 ;; doesn't always go hand in hand.
4963 (narrow-to-region (point)
4964 (or (and (search-forward "\n.\n" nil t)
4970 (if (search-forward "\nsubject: " nil t)
4971 (funcall gnus-decode-encoded-word-function
4972 (nnheader-header-value))
4977 (if (or (search-forward "\nfrom: " nil t)
4978 (search-forward "\nfrom:" nil t))
4979 (funcall gnus-decode-encoded-word-function
4980 (nnheader-header-value))
4985 (if (search-forward "\ndate: " nil t)
4986 (nnheader-header-value) ""))
4990 (setq id (if (re-search-forward
4991 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
4992 ;; We do it this way to make sure the Message-ID
4993 ;; is (somewhat) syntactically valid.
4994 (buffer-substring (match-beginning 1)
4996 ;; If there was no message-id, we just fake one
4997 ;; to make subsequent routines simpler.
4998 (nnheader-generate-fake-message-id))))
5002 (if (search-forward "\nreferences: " nil t)
5006 (nnheader-header-value)
5011 (search-backward ">" end t)
5014 (search-backward "<" end t)
5016 ;; Get the references from the in-reply-to header if there
5017 ;; were no references and the in-reply-to header looks
5019 (if (and (search-forward "\nin-reply-to: " nil t)
5020 (setq in-reply-to (nnheader-header-value))
5021 (string-match "<[^>]+>" in-reply-to))
5023 (setq ref (substring in-reply-to (match-beginning 0)
5025 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
5026 (setq ref2 (substring in-reply-to (match-beginning 0)
5028 (when (> (length ref2) (length ref))
5035 (if (search-forward "\nchars: " nil t)
5036 (if (numberp (setq chars (ignore-errors (read cur))))
5042 (if (search-forward "\nlines: " nil t)
5043 (if (numberp (setq lines (ignore-errors (read cur))))
5049 (and (search-forward "\nxref: " nil t)
5050 (nnheader-header-value)))
5052 (when gnus-extra-headers
5053 (let ((extra gnus-extra-headers)
5057 (when (search-forward
5058 (concat "\n" (symbol-name (car extra)) ": ") nil t)
5059 (push (cons (car extra) (nnheader-header-value))
5063 (when (equal id ref)
5066 (when gnus-alter-header-function
5067 (funcall gnus-alter-header-function header)
5068 (setq id (mail-header-id header)
5069 ref (gnus-parent-id (mail-header-references header))))
5072 (gnus-dependencies-add-header
5073 header dependencies force-new))
5074 (push header headers))
5075 (goto-char (point-max))
5077 (nreverse headers)))))
5079 ;; Goes through the xover lines and returns a list of vectors
5080 (defun gnus-get-newsgroup-headers-xover (sequence &optional
5081 force-new dependencies
5082 group also-fetch-heads)
5083 "Parse the news overview data in the server buffer.
5084 Return a list of headers that match SEQUENCE (see
5085 `nntp-retrieve-headers')."
5086 ;; Get the Xref when the users reads the articles since most/some
5087 ;; NNTP servers do not include Xrefs when using XOVER.
5088 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
5089 (let ((mail-parse-charset gnus-newsgroup-charset)
5090 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
5091 (cur nntp-server-buffer)
5092 (dependencies (or dependencies gnus-newsgroup-dependencies))
5093 number headers header)
5095 (set-buffer nntp-server-buffer)
5096 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5097 ;; Allow the user to mangle the headers before parsing them.
5098 (gnus-run-hooks 'gnus-parse-headers-hook)
5099 (goto-char (point-min))
5102 (while (and sequence (not (eobp)))
5103 (setq number (read cur))
5104 (while (and sequence
5105 (< (car sequence) number))
5106 (setq sequence (cdr sequence)))
5108 (eq number (car sequence))
5110 (setq sequence (cdr sequence))
5111 (setq header (inline
5112 (gnus-nov-parse-line
5113 number dependencies force-new))))
5114 (push header headers))
5117 (gnus-error 4 "Strange nov line (%d)"
5118 (count-lines (point-min) (point)))))
5120 ;; A common bug in inn is that if you have posted an article and
5121 ;; then retrieves the active file, it will answer correctly --
5122 ;; the new article is included. However, a NOV entry for the
5123 ;; article may not have been generated yet, so this may fail.
5124 ;; We work around this problem by retrieving the last few
5125 ;; headers using HEAD.
5126 (if (or (not also-fetch-heads)
5128 ;; We (probably) got all the headers.
5130 (let ((gnus-nov-is-evil t))
5133 (when (gnus-retrieve-headers sequence group)
5134 (gnus-get-newsgroup-headers))))))))
5136 (defun gnus-article-get-xrefs ()
5137 "Fill in the Xref value in `gnus-current-headers', if necessary.
5138 This is meant to be called in `gnus-article-internal-prepare-hook'."
5139 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
5140 gnus-current-headers)))
5141 (or (not gnus-use-cross-reference)
5143 (and (mail-header-xref headers)
5144 (not (string= (mail-header-xref headers) "")))
5145 (let ((case-fold-search t)
5148 (nnheader-narrow-to-headers)
5149 (goto-char (point-min))
5150 (when (or (and (not (eobp))
5151 (eq (downcase (char-after)) ?x)
5152 (looking-at "Xref:"))
5153 (search-forward "\nXref:" nil t))
5154 (goto-char (1+ (match-end 0)))
5155 (setq xref (buffer-substring (point)
5156 (progn (end-of-line) (point))))
5157 (mail-header-set-xref headers xref)))))))
5159 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
5160 "Find article ID and insert the summary line for that article.
5161 OLD-HEADER can either be a header or a line number to insert
5162 the subject line on."
5163 (let* ((line (and (numberp old-header) old-header))
5164 (old-header (and (vectorp old-header) old-header))
5165 (header (cond ((and old-header use-old-header)
5168 (gnus-number-to-header id))
5169 (gnus-number-to-header id))
5171 (gnus-read-header id))))
5172 (number (and (numberp id) id))
5175 ;; Rebuild the thread that this article is part of and go to the
5176 ;; article we have fetched.
5177 (when (and (not gnus-show-threads)
5180 (setq d (gnus-data-find (mail-header-number old-header))))
5181 (goto-char (gnus-data-pos d))
5184 (- (gnus-point-at-bol)
5186 (1+ (gnus-point-at-eol))
5187 (gnus-delete-line))))))
5189 (mail-header-set-number header (mail-header-number old-header)))
5190 (setq gnus-newsgroup-sparse
5191 (delq (setq number (mail-header-number header))
5192 gnus-newsgroup-sparse))
5193 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
5194 (push number gnus-newsgroup-limit)
5195 (gnus-rebuild-thread (mail-header-id header) line)
5196 (gnus-summary-goto-subject number nil t))
5197 (when (and (numberp number)
5199 ;; We have to update the boundaries even if we can't fetch the
5200 ;; article if ID is a number -- so that the next `P' or `N'
5201 ;; command will fetch the previous (or next) article even
5202 ;; if the one we tried to fetch this time has been canceled.
5203 (when (> number gnus-newsgroup-end)
5204 (setq gnus-newsgroup-end number))
5205 (when (< number gnus-newsgroup-begin)
5206 (setq gnus-newsgroup-begin number))
5207 (setq gnus-newsgroup-unselected
5208 (delq number gnus-newsgroup-unselected)))
5209 ;; Report back a success?
5210 (and header (mail-header-number header))))
5212 ;;; Process/prefix in the summary buffer
5214 (defun gnus-summary-work-articles (n)
5215 "Return a list of articles to be worked upon.
5216 The prefix argument, the list of process marked articles, and the
5217 current article will be taken into consideration."
5219 (set-buffer gnus-summary-buffer)
5222 ;; A numerical prefix has been given.
5223 (setq n (prefix-numeric-value n))
5224 (let ((backward (< n 0))
5225 (n (abs (prefix-numeric-value n)))
5230 (push (setq article (gnus-summary-article-number))
5233 (gnus-summary-find-prev nil article)
5234 (gnus-summary-find-next nil article)))
5236 (nreverse articles)))
5237 ((and (gnus-region-active-p) (mark))
5238 (message "region active")
5239 ;; Work on the region between point and mark.
5240 (let ((max (max (point) (mark)))
5243 (goto-char (min (min (point) (mark))))
5246 (push (setq article (gnus-summary-article-number)) articles)
5247 (gnus-summary-find-next nil article)
5249 (nreverse articles))))
5250 (gnus-newsgroup-processable
5251 ;; There are process-marked articles present.
5252 ;; Save current state.
5253 (gnus-summary-save-process-mark)
5255 (reverse gnus-newsgroup-processable))
5257 ;; Just return the current article.
5258 (list (gnus-summary-article-number))))))
5260 (defmacro gnus-summary-iterate (arg &rest forms)
5261 "Iterate over the process/prefixed articles and do FORMS.
5262 ARG is the interactive prefix given to the command. FORMS will be
5263 executed with point over the summary line of the articles."
5264 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
5265 `(let ((,articles (gnus-summary-work-articles ,arg)))
5267 (gnus-summary-goto-subject (car ,articles))
5271 (put 'gnus-summary-iterate 'lisp-indent-function 1)
5272 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
5274 (defun gnus-summary-save-process-mark ()
5275 "Push the current set of process marked articles on the stack."
5277 (push (copy-sequence gnus-newsgroup-processable)
5278 gnus-newsgroup-process-stack))
5280 (defun gnus-summary-kill-process-mark ()
5281 "Push the current set of process marked articles on the stack and unmark."
5283 (gnus-summary-save-process-mark)
5284 (gnus-summary-unmark-all-processable))
5286 (defun gnus-summary-yank-process-mark ()
5287 "Pop the last process mark state off the stack and restore it."
5289 (unless gnus-newsgroup-process-stack
5290 (error "Empty mark stack"))
5291 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
5293 (defun gnus-summary-process-mark-set (set)
5294 "Make SET into the current process marked articles."
5295 (gnus-summary-unmark-all-processable)
5297 (gnus-summary-set-process-mark (pop set))))
5299 ;;; Searching and stuff
5301 (defun gnus-summary-search-group (&optional backward use-level)
5302 "Search for next unread newsgroup.
5303 If optional argument BACKWARD is non-nil, search backward instead."
5305 (set-buffer gnus-group-buffer)
5306 (when (gnus-group-search-forward
5307 backward nil (if use-level (gnus-group-group-level) nil))
5308 (gnus-group-group-name))))
5310 (defun gnus-summary-best-group (&optional exclude-group)
5311 "Find the name of the best unread group.
5312 If EXCLUDE-GROUP, do not go to this group."
5314 (set-buffer gnus-group-buffer)
5316 (gnus-group-best-unread-group exclude-group))))
5318 (defun gnus-summary-find-next (&optional unread article backward undownloaded)
5319 (if backward (gnus-summary-find-prev)
5320 (let* ((dummy (gnus-summary-article-intangible-p))
5321 (article (or article (gnus-summary-article-number)))
5322 (arts (gnus-data-find-list article))
5324 (when (and (not dummy)
5325 (or (not gnus-summary-check-current)
5327 (not (gnus-data-unread-p (car arts)))))
5328 (setq arts (cdr arts)))
5333 (when (or (and undownloaded
5334 (eq gnus-undownloaded-mark
5335 (gnus-data-mark (car arts))))
5336 (gnus-data-unread-p (car arts)))
5337 (setq result (car arts)
5339 (setq arts (cdr arts)))
5342 (goto-char (gnus-data-pos result))
5343 (gnus-data-number result)))))
5345 (defun gnus-summary-find-prev (&optional unread article)
5346 (let* ((eobp (eobp))
5347 (article (or article (gnus-summary-article-number)))
5348 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
5350 (when (and (not eobp)
5351 (or (not gnus-summary-check-current)
5353 (not (gnus-data-unread-p (car arts)))))
5354 (setq arts (cdr arts)))
5359 (when (gnus-data-unread-p (car arts))
5360 (setq result (car arts)
5362 (setq arts (cdr arts)))
5365 (goto-char (gnus-data-pos result))
5366 (gnus-data-number result))))
5368 (defun gnus-summary-find-subject (subject &optional unread backward article)
5369 (let* ((simp-subject (gnus-simplify-subject-fully subject))
5370 (article (or article (gnus-summary-article-number)))
5371 (articles (gnus-data-list backward))
5372 (arts (gnus-data-find-list article articles))
5374 (when (or (not gnus-summary-check-current)
5376 (not (gnus-data-unread-p (car arts))))
5377 (setq arts (cdr arts)))
5379 (and (or (not unread)
5380 (gnus-data-unread-p (car arts)))
5381 (vectorp (gnus-data-header (car arts)))
5383 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
5384 (setq result (car arts)
5386 (setq arts (cdr arts)))
5388 (goto-char (gnus-data-pos result))
5389 (gnus-data-number result))))
5391 (defun gnus-summary-search-forward (&optional unread subject backward)
5392 "Search forward for an article.
5393 If UNREAD, look for unread articles. If SUBJECT, look for
5394 articles with that subject. If BACKWARD, search backward instead."
5395 (cond (subject (gnus-summary-find-subject subject unread backward))
5396 (backward (gnus-summary-find-prev unread))
5397 (t (gnus-summary-find-next unread))))
5399 (defun gnus-recenter (&optional n)
5400 "Center point in window and redisplay frame.
5401 Also do horizontal recentering."
5403 (when (and gnus-auto-center-summary
5404 (not (eq gnus-auto-center-summary 'vertical)))
5405 (gnus-horizontal-recenter))
5408 (defun gnus-summary-recenter ()
5409 "Center point in the summary window.
5410 If `gnus-auto-center-summary' is nil, or the article buffer isn't
5411 displayed, no centering will be performed."
5412 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
5413 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
5415 (let* ((top (cond ((< (window-height) 4) 0)
5416 ((< (window-height) 7) 1)
5417 (t (if (numberp gnus-auto-center-summary)
5418 gnus-auto-center-summary
5420 (height (1- (window-height)))
5421 (bottom (save-excursion (goto-char (point-max))
5422 (forward-line (- height))
5424 (window (get-buffer-window (current-buffer))))
5425 ;; The user has to want it.
5426 (when gnus-auto-center-summary
5427 (when (get-buffer-window gnus-article-buffer)
5428 ;; Only do recentering when the article buffer is displayed,
5429 ;; Set the window start to either `bottom', which is the biggest
5430 ;; possible valid number, or the second line from the top,
5431 ;; whichever is the least.
5432 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
5433 (if (> bottom top-pos)
5434 ;; Keep the second line from the top visible
5435 (set-window-start window top-pos t)
5436 ;; Try to keep the bottom line visible; if it's partially
5437 ;; obscured, either scroll one more line to make it fully
5438 ;; visible, or revert to using TOP-POS.
5440 (goto-char (point-max))
5442 (let ((last-line-start (point)))
5444 (set-window-start window (point) t)
5445 (when (not (pos-visible-in-window-p last-line-start window))
5447 (set-window-start window (min (point) top-pos) t)))))))
5448 ;; Do horizontal recentering while we're at it.
5449 (when (and (get-buffer-window (current-buffer) t)
5450 (not (eq gnus-auto-center-summary 'vertical)))
5451 (let ((selected (selected-window)))
5452 (select-window (get-buffer-window (current-buffer) t))
5453 (gnus-summary-position-point)
5454 (gnus-horizontal-recenter)
5455 (select-window selected))))))
5457 (defun gnus-summary-jump-to-group (newsgroup)
5458 "Move point to NEWSGROUP in group mode buffer."
5459 ;; Keep update point of group mode buffer if visible.
5460 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
5461 (save-window-excursion
5462 ;; Take care of tree window mode.
5463 (when (get-buffer-window gnus-group-buffer)
5464 (pop-to-buffer gnus-group-buffer))
5465 (gnus-group-jump-to-group newsgroup))
5467 ;; Take care of tree window mode.
5468 (if (get-buffer-window gnus-group-buffer)
5469 (pop-to-buffer gnus-group-buffer)
5470 (set-buffer gnus-group-buffer))
5471 (gnus-group-jump-to-group newsgroup))))
5473 ;; This function returns a list of article numbers based on the
5474 ;; difference between the ranges of read articles in this group and
5475 ;; the range of active articles.
5476 (defun gnus-list-of-unread-articles (group)
5477 (let* ((read (gnus-info-read (gnus-get-info group)))
5478 (active (or (gnus-active group) (gnus-activate-group group)))
5481 ;; If none are read, then all are unread.
5483 (setq first (car active))
5484 ;; If the range of read articles is a single range, then the
5485 ;; first unread article is the article after the last read
5486 ;; article. Sounds logical, doesn't it?
5487 (if (and (not (listp (cdr read)))
5488 (or (< (car read) (car active))
5489 (progn (setq read (list read))
5491 (setq first (max (car active) (1+ (cdr read))))
5492 ;; `read' is a list of ranges.
5493 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
5496 (setq first (car active)))
5499 (while (< first nlast)
5501 (setq first (1+ first))))
5502 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
5503 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
5504 (setq read (cdr read)))))
5505 ;; And add the last unread articles.
5506 (while (<= first last)
5508 (setq first (1+ first)))
5509 ;; Return the list of unread articles.
5510 (delq 0 (nreverse unread))))
5512 (defun gnus-list-of-read-articles (group)
5513 "Return a list of unread, unticked and non-dormant articles."
5514 (let* ((info (gnus-get-info group))
5515 (marked (gnus-info-marks info))
5516 (active (gnus-active group)))
5518 (gnus-set-difference
5519 (gnus-sorted-complement
5520 (gnus-uncompress-range active)
5521 (gnus-list-of-unread-articles group))
5523 (gnus-uncompress-range (cdr (assq 'dormant marked)))
5524 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
5526 ;; Various summary commands
5528 (defun gnus-summary-select-article-buffer ()
5529 "Reconfigure windows to show article buffer."
5531 (if (not (gnus-buffer-live-p gnus-article-buffer))
5532 (error "There is no article buffer for this summary buffer")
5533 (gnus-configure-windows 'article)
5534 (select-window (get-buffer-window gnus-article-buffer))))
5536 (defun gnus-summary-universal-argument (arg)
5537 "Perform any operation on all articles that are process/prefixed."
5539 (let ((articles (gnus-summary-work-articles arg))
5546 (substitute-command-keys
5547 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
5549 (gnus-error 1 "Undefined key")
5552 (gnus-summary-goto-subject (setq article (pop articles)))
5553 (let (gnus-newsgroup-processable)
5554 (command-execute func))
5555 (gnus-summary-remove-process-mark article)))))
5556 (gnus-summary-position-point))
5558 (defun gnus-summary-toggle-truncation (&optional arg)
5559 "Toggle truncation of summary lines.
5560 With arg, turn line truncation on iff arg is positive."
5562 (setq truncate-lines
5563 (if (null arg) (not truncate-lines)
5564 (> (prefix-numeric-value arg) 0)))
5567 (defun gnus-summary-reselect-current-group (&optional all rescan)
5568 "Exit and then reselect the current newsgroup.
5569 The prefix argument ALL means to select all articles."
5571 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
5572 (error "Ephemeral groups can't be reselected"))
5573 (let ((current-subject (gnus-summary-article-number))
5574 (group gnus-newsgroup-name))
5575 (setq gnus-newsgroup-begin nil)
5577 ;; We have to adjust the point of group mode buffer because
5578 ;; point was moved to the next unread newsgroup by exiting.
5579 (gnus-summary-jump-to-group group)
5582 (gnus-group-get-new-news-this-group 1)))
5583 (gnus-group-read-group all t)
5584 (gnus-summary-goto-subject current-subject nil t)))
5586 (defun gnus-summary-rescan-group (&optional all)
5587 "Exit the newsgroup, ask for new articles, and select the newsgroup."
5589 (gnus-summary-reselect-current-group all t))
5591 (defun gnus-summary-update-info (&optional non-destructive)
5593 (let ((group gnus-newsgroup-name))
5595 (when gnus-newsgroup-kill-headers
5596 (setq gnus-newsgroup-killed
5597 (gnus-compress-sequence
5599 (gnus-set-sorted-intersection
5600 (gnus-uncompress-range gnus-newsgroup-killed)
5601 (setq gnus-newsgroup-unselected
5602 (sort gnus-newsgroup-unselected '<)))
5603 (setq gnus-newsgroup-unreads
5604 (sort gnus-newsgroup-unreads '<)))
5606 (unless (listp (cdr gnus-newsgroup-killed))
5607 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
5608 (let ((headers gnus-newsgroup-headers))
5609 ;; Set the new ranges of read articles.
5611 (set-buffer gnus-group-buffer)
5612 (gnus-undo-force-boundary))
5613 (gnus-update-read-articles
5614 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
5615 ;; Set the current article marks.
5616 (let ((gnus-newsgroup-scored
5617 (if (and (not gnus-save-score)
5618 (not non-destructive))
5620 gnus-newsgroup-scored)))
5622 (gnus-update-marks)))
5623 ;; Do the cross-ref thing.
5624 (when gnus-use-cross-reference
5625 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
5626 ;; Do not switch windows but change the buffer to work.
5627 (set-buffer gnus-group-buffer)
5628 (unless (gnus-ephemeral-group-p group)
5629 (gnus-group-update-group group)))))))
5631 (defun gnus-summary-save-newsrc (&optional force)
5632 "Save the current number of read/marked articles in the dribble buffer.
5633 The dribble buffer will then be saved.
5634 If FORCE (the prefix), also save the .newsrc file(s)."
5636 (gnus-summary-update-info t)
5638 (gnus-save-newsrc-file)
5639 (gnus-dribble-save)))
5641 (defun gnus-summary-exit (&optional temporary)
5642 "Exit reading current newsgroup, and then return to group selection mode.
5643 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
5645 (gnus-set-global-variables)
5646 (when (gnus-buffer-live-p gnus-article-buffer)
5648 (set-buffer gnus-article-buffer)
5649 (mm-destroy-parts gnus-article-mime-handles)
5650 ;; Set it to nil for safety reason.
5651 (setq gnus-article-mime-handle-alist nil)
5652 (setq gnus-article-mime-handles nil)))
5653 (gnus-kill-save-kill-buffer)
5654 (gnus-async-halt-prefetch)
5655 (let* ((group gnus-newsgroup-name)
5656 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
5659 (buf (current-buffer)))
5661 ;; Do adaptive scoring, and possibly save score files.
5662 (when gnus-newsgroup-adaptive
5663 (gnus-score-adaptive))
5664 (when gnus-use-scoring
5666 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
5667 ;; If we have several article buffers, we kill them at exit.
5668 (unless gnus-single-article-buffer
5669 (gnus-kill-buffer gnus-original-article-buffer)
5670 (setq gnus-article-current nil))
5671 (when gnus-use-cache
5672 (gnus-cache-possibly-remove-articles)
5673 (gnus-cache-save-buffers))
5674 (gnus-async-prefetch-remove-group group)
5675 (when gnus-suppress-duplicates
5676 (gnus-dup-enter-articles))
5677 (when gnus-use-trees
5678 (gnus-tree-close group))
5679 (when gnus-use-cache
5680 (gnus-cache-write-active))
5681 ;; Remove entries for this group.
5682 (nnmail-purge-split-history (gnus-group-real-name group))
5683 ;; Make all changes in this group permanent.
5685 (gnus-run-hooks 'gnus-exit-group-hook)
5686 (gnus-summary-update-info))
5687 (gnus-close-group group)
5688 ;; Make sure where we were, and go to next newsgroup.
5689 (set-buffer gnus-group-buffer)
5691 (gnus-group-jump-to-group group))
5692 (gnus-run-hooks 'gnus-summary-exit-hook)
5693 (unless (or quit-config
5694 ;; If this group has disappeared from the summary
5695 ;; buffer, don't skip forwards.
5696 (not (string= group (gnus-group-group-name))))
5697 (gnus-group-next-unread-group 1))
5698 (setq group-point (point))
5701 ;; If we have several article buffers, we kill them at exit.
5702 (unless gnus-single-article-buffer
5703 (gnus-kill-buffer gnus-article-buffer)
5704 (gnus-kill-buffer gnus-original-article-buffer)
5705 (setq gnus-article-current nil))
5707 (if (not gnus-kill-summary-on-exit)
5708 (gnus-deaden-summary)
5709 ;; We set all buffer-local variables to nil. It is unclear why
5710 ;; this is needed, but if we don't, buffer-local variables are
5711 ;; not garbage-collected, it seems. This would the lead to en
5712 ;; ever-growing Emacs.
5713 (gnus-summary-clear-local-variables)
5714 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
5715 (gnus-summary-clear-local-variables))
5716 (when (get-buffer gnus-article-buffer)
5717 (bury-buffer gnus-article-buffer))
5718 ;; We clear the global counterparts of the buffer-local
5719 ;; variables as well, just to be on the safe side.
5720 (set-buffer gnus-group-buffer)
5721 (gnus-summary-clear-local-variables)
5722 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
5723 (gnus-summary-clear-local-variables))
5724 ;; Return to group mode buffer.
5725 (when (eq mode 'gnus-summary-mode)
5726 (gnus-kill-buffer buf)))
5727 (setq gnus-current-select-method gnus-select-method)
5728 (pop-to-buffer gnus-group-buffer)
5729 (if (not quit-config)
5731 (goto-char group-point)
5732 (gnus-configure-windows 'group 'force))
5733 (gnus-handle-ephemeral-exit quit-config))
5734 ;; Clear the current group name.
5736 (setq gnus-newsgroup-name nil)))))
5738 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
5739 (defun gnus-summary-exit-no-update (&optional no-questions)
5740 "Quit reading current newsgroup without updating read article info."
5742 (let* ((group gnus-newsgroup-name)
5743 (quit-config (gnus-group-quit-config group)))
5744 (when (or no-questions
5746 (gnus-y-or-n-p "Discard changes to this group and exit? "))
5747 (gnus-async-halt-prefetch)
5749 (delq 'gnus-summary-expire-articles
5750 (copy-sequence gnus-summary-prepare-exit-hook)))
5751 (when (gnus-buffer-live-p gnus-article-buffer)
5753 (set-buffer gnus-article-buffer)
5754 (mm-destroy-parts gnus-article-mime-handles)
5755 ;; Set it to nil for safety reason.
5756 (setq gnus-article-mime-handle-alist nil)
5757 (setq gnus-article-mime-handles nil)))
5758 ;; If we have several article buffers, we kill them at exit.
5759 (unless gnus-single-article-buffer
5760 (gnus-kill-buffer gnus-article-buffer)
5761 (gnus-kill-buffer gnus-original-article-buffer)
5762 (setq gnus-article-current nil))
5763 (if (not gnus-kill-summary-on-exit)
5764 (gnus-deaden-summary)
5765 (gnus-close-group group)
5766 (gnus-summary-clear-local-variables)
5767 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
5768 (gnus-summary-clear-local-variables))
5769 (set-buffer gnus-group-buffer)
5770 (gnus-summary-clear-local-variables)
5771 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
5772 (gnus-summary-clear-local-variables))
5773 (when (get-buffer gnus-summary-buffer)
5774 (kill-buffer gnus-summary-buffer)))
5775 (unless gnus-single-article-buffer
5776 (setq gnus-article-current nil))
5777 (when gnus-use-trees
5778 (gnus-tree-close group))
5779 (gnus-async-prefetch-remove-group group)
5780 (when (get-buffer gnus-article-buffer)
5781 (bury-buffer gnus-article-buffer))
5782 ;; Return to the group buffer.
5783 (gnus-configure-windows 'group 'force)
5784 ;; Clear the current group name.
5785 (setq gnus-newsgroup-name nil)
5786 (when (equal (gnus-group-group-name) group)
5787 (gnus-group-next-unread-group 1))
5789 (gnus-handle-ephemeral-exit quit-config)))))
5791 (defun gnus-handle-ephemeral-exit (quit-config)
5792 "Handle movement when leaving an ephemeral group.
5793 The state which existed when entering the ephemeral is reset."
5794 (if (not (buffer-name (car quit-config)))
5795 (gnus-configure-windows 'group 'force)
5796 (set-buffer (car quit-config))
5797 (cond ((eq major-mode 'gnus-summary-mode)
5798 (gnus-set-global-variables))
5799 ((eq major-mode 'gnus-article-mode)
5801 ;; The `gnus-summary-buffer' variable may point
5802 ;; to the old summary buffer when using a single
5804 (unless (gnus-buffer-live-p gnus-summary-buffer)
5805 (set-buffer gnus-group-buffer))
5806 (set-buffer gnus-summary-buffer)
5807 (gnus-set-global-variables))))
5808 (if (or (eq (cdr quit-config) 'article)
5809 (eq (cdr quit-config) 'pick))
5811 ;; The current article may be from the ephemeral group
5812 ;; thus it is best that we reload this article
5813 (gnus-summary-show-article)
5814 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
5815 (gnus-configure-windows 'pick 'force)
5816 (gnus-configure-windows (cdr quit-config) 'force)))
5817 (gnus-configure-windows (cdr quit-config) 'force))
5818 (when (eq major-mode 'gnus-summary-mode)
5819 (gnus-summary-next-subject 1 nil t)
5820 (gnus-summary-recenter)
5821 (gnus-summary-position-point))))
5825 (defvar gnus-dead-summary-mode-map nil)
5827 (unless gnus-dead-summary-mode-map
5828 (setq gnus-dead-summary-mode-map (make-keymap))
5829 (suppress-keymap gnus-dead-summary-mode-map)
5830 (substitute-key-definition
5831 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
5832 (let ((keys '("\C-d" "\r" "\177" [delete])))
5834 (define-key gnus-dead-summary-mode-map
5835 (pop keys) 'gnus-summary-wake-up-the-dead))))
5837 (defvar gnus-dead-summary-mode nil
5838 "Minor mode for Gnus summary buffers.")
5840 (defun gnus-dead-summary-mode (&optional arg)
5841 "Minor mode for Gnus summary buffers."
5843 (when (eq major-mode 'gnus-summary-mode)
5844 (make-local-variable 'gnus-dead-summary-mode)
5845 (setq gnus-dead-summary-mode
5846 (if (null arg) (not gnus-dead-summary-mode)
5847 (> (prefix-numeric-value arg) 0)))
5848 (when gnus-dead-summary-mode
5849 (gnus-add-minor-mode
5850 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
5852 (defun gnus-deaden-summary ()
5853 "Make the current summary buffer into a dead summary buffer."
5854 ;; Kill any previous dead summary buffer.
5855 (when (and gnus-dead-summary
5856 (buffer-name gnus-dead-summary))
5858 (set-buffer gnus-dead-summary)
5859 (when gnus-dead-summary-mode
5860 (kill-buffer (current-buffer)))))
5861 ;; Make this the current dead summary.
5862 (setq gnus-dead-summary (current-buffer))
5863 (gnus-dead-summary-mode 1)
5864 (let ((name (buffer-name)))
5865 (when (string-match "Summary" name)
5867 (concat (substring name 0 (match-beginning 0)) "Dead "
5868 (substring name (match-beginning 0)))
5872 (defun gnus-kill-or-deaden-summary (buffer)
5873 "Kill or deaden the summary BUFFER."
5875 (when (and (buffer-name buffer)
5876 (not gnus-single-article-buffer))
5879 (gnus-kill-buffer gnus-article-buffer)
5880 (gnus-kill-buffer gnus-original-article-buffer)))
5881 (cond (gnus-kill-summary-on-exit
5882 (when (and gnus-use-trees
5883 (gnus-buffer-exists-p buffer))
5886 (gnus-tree-close gnus-newsgroup-name)))
5887 (gnus-kill-buffer buffer))
5888 ((gnus-buffer-exists-p buffer)
5891 (gnus-deaden-summary))))))
5893 (defun gnus-summary-wake-up-the-dead (&rest args)
5894 "Wake up the dead summary buffer."
5896 (gnus-dead-summary-mode -1)
5897 (let ((name (buffer-name)))
5898 (when (string-match "Dead " name)
5900 (concat (substring name 0 (match-beginning 0))
5901 (substring name (match-end 0)))
5903 (gnus-message 3 "This dead summary is now alive again"))
5905 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
5906 (defun gnus-summary-fetch-faq (&optional faq-dir)
5907 "Fetch the FAQ for the current group.
5908 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
5912 (when current-prefix-arg
5914 "Faq dir: " (and (listp gnus-group-faq-directory)
5915 (mapcar (lambda (file) (list file))
5916 gnus-group-faq-directory))))))
5917 (let (gnus-faq-buffer)
5918 (when (setq gnus-faq-buffer
5919 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
5920 (gnus-configure-windows 'summary-faq))))
5922 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
5923 (defun gnus-summary-describe-group (&optional force)
5924 "Describe the current newsgroup."
5926 (gnus-group-describe-group force gnus-newsgroup-name))
5928 (defun gnus-summary-describe-briefly ()
5929 "Describe summary mode commands briefly."
5931 (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")))
5933 ;; Walking around group mode buffer from summary mode.
5935 (defun gnus-summary-next-group (&optional no-article target-group backward)
5936 "Exit current newsgroup and then select next unread newsgroup.
5937 If prefix argument NO-ARTICLE is non-nil, no article is selected
5938 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
5939 previous group instead."
5941 ;; Stop pre-fetching.
5942 (gnus-async-halt-prefetch)
5943 (let ((current-group gnus-newsgroup-name)
5944 (current-buffer (current-buffer))
5946 ;; First we semi-exit this group to update Xrefs and all variables.
5947 ;; We can't do a real exit, because the window conf must remain
5948 ;; the same in case the user is prompted for info, and we don't
5949 ;; want the window conf to change before that...
5950 (gnus-summary-exit t)
5951 (while (not entered)
5952 ;; Then we find what group we are supposed to enter.
5953 (set-buffer gnus-group-buffer)
5954 (gnus-group-jump-to-group current-group)
5957 (if (eq gnus-keep-same-level 'best)
5958 (gnus-summary-best-group gnus-newsgroup-name)
5959 (gnus-summary-search-group backward gnus-keep-same-level))))
5960 (if (not target-group)
5961 ;; There are no further groups, so we return to the group
5964 (gnus-message 5 "Returning to the group buffer")
5966 (when (gnus-buffer-live-p current-buffer)
5967 (set-buffer current-buffer)
5968 (gnus-summary-exit))
5969 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
5970 ;; We try to enter the target group.
5971 (gnus-group-jump-to-group target-group)
5972 (let ((unreads (gnus-group-group-unread)))
5973 (if (and (or (eq t unreads)
5974 (and unreads (not (zerop unreads))))
5975 (gnus-summary-read-group
5976 target-group nil no-article
5977 (and (buffer-name current-buffer) current-buffer)
5980 (setq current-group target-group
5981 target-group nil)))))))
5983 (defun gnus-summary-prev-group (&optional no-article)
5984 "Exit current newsgroup and then select previous unread newsgroup.
5985 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
5987 (gnus-summary-next-group no-article nil t))
5989 ;; Walking around summary lines.
5991 (defun gnus-summary-first-subject (&optional unread undownloaded)
5992 "Go to the first unread subject.
5993 If UNREAD is non-nil, go to the first unread article.
5994 Returns the article selected or nil if there are no unread articles."
5999 ((null gnus-newsgroup-data)
6000 (gnus-message 3 "No articles in the group")
6002 ;; Pick the first article.
6004 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
6005 (gnus-data-number (car gnus-newsgroup-data)))
6006 ;; No unread articles.
6007 ((null gnus-newsgroup-unreads)
6008 (gnus-message 3 "No more unread articles")
6010 ;; Find the first unread article.
6012 (let ((data gnus-newsgroup-data))
6014 (and (not (and undownloaded
6015 (eq gnus-undownloaded-mark
6016 (gnus-data-mark (car data)))))
6017 (not (gnus-data-unread-p (car data)))))
6018 (setq data (cdr data)))
6020 (goto-char (gnus-data-pos (car data)))
6021 (gnus-data-number (car data))))))
6022 (gnus-summary-position-point)))
6024 (defun gnus-summary-next-subject (n &optional unread dont-display)
6025 "Go to next N'th summary line.
6026 If N is negative, go to the previous N'th subject line.
6027 If UNREAD is non-nil, only unread articles are selected.
6028 The difference between N and the actual number of steps taken is
6031 (let ((backward (< n 0))
6035 (gnus-summary-find-prev unread)
6036 (gnus-summary-find-next unread)))
6037 (unless (zerop (setq n (1- n)))
6038 (gnus-summary-show-thread)))
6040 (gnus-message 7 "No more%s articles"
6041 (if unread " unread" "")))
6042 (unless dont-display
6043 (gnus-summary-recenter)
6044 (gnus-summary-position-point))
6047 (defun gnus-summary-next-unread-subject (n)
6048 "Go to next N'th unread summary line."
6050 (gnus-summary-next-subject n t))
6052 (defun gnus-summary-prev-subject (n &optional unread)
6053 "Go to previous N'th summary line.
6054 If optional argument UNREAD is non-nil, only unread article is selected."
6056 (gnus-summary-next-subject (- n) unread))
6058 (defun gnus-summary-prev-unread-subject (n)
6059 "Go to previous N'th unread summary line."
6061 (gnus-summary-next-subject (- n) t))
6063 (defun gnus-summary-goto-subject (article &optional force silent)
6064 "Go the subject line of ARTICLE.
6065 If FORCE, also allow jumping to articles not currently shown."
6066 (interactive "nArticle number: ")
6068 (data (gnus-data-find article)))
6069 ;; We read in the article if we have to.
6072 (gnus-summary-insert-subject
6074 (if (or (numberp force) (vectorp force)) force)
6076 (setq data (gnus-data-find article)))
6081 (gnus-message 3 "Can't find article %d" article))
6083 (goto-char (gnus-data-pos data))
6084 (gnus-summary-position-point)
6087 ;; Walking around summary lines with displaying articles.
6089 (defun gnus-summary-expand-window (&optional arg)
6090 "Make the summary buffer take up the entire Emacs frame.
6091 Given a prefix, will force an `article' buffer configuration."
6094 (gnus-configure-windows 'article 'force)
6095 (gnus-configure-windows 'summary 'force)))
6097 (defun gnus-summary-display-article (article &optional all-header)
6098 "Display ARTICLE in article buffer."
6099 (when (gnus-buffer-live-p gnus-article-buffer)
6100 (with-current-buffer gnus-article-buffer
6101 (mm-enable-multibyte-mule4)))
6102 (gnus-set-global-variables)
6103 (when (gnus-buffer-live-p gnus-article-buffer)
6104 (with-current-buffer gnus-article-buffer
6105 (setq gnus-article-charset gnus-newsgroup-charset)
6106 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
6107 (mm-enable-multibyte-mule4)))
6111 (if gnus-summary-display-article-function
6112 (funcall gnus-summary-display-article-function article all-header)
6113 (gnus-article-prepare article all-header))
6114 (gnus-run-hooks 'gnus-select-article-hook)
6115 (when (and gnus-current-article
6116 (not (zerop gnus-current-article)))
6117 (gnus-summary-goto-subject gnus-current-article))
6118 (gnus-summary-recenter)
6119 (when (and gnus-use-trees gnus-show-threads)
6120 (gnus-possibly-generate-tree article)
6121 (gnus-highlight-selected-tree article))
6122 ;; Successfully display article.
6123 (gnus-article-set-window-start
6124 (cdr (assq article gnus-newsgroup-bookmarks))))))
6126 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
6127 "Select the current article.
6128 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
6129 non-nil, the article will be re-fetched even if it already present in
6130 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
6132 ;; Make sure we are in the summary buffer to work around bbdb bug.
6133 (unless (eq major-mode 'gnus-summary-mode)
6134 (set-buffer gnus-summary-buffer))
6135 (let ((article (or article (gnus-summary-article-number)))
6136 (all-headers (not (not all-headers))) ;Must be T or NIL.
6137 gnus-summary-display-article-function)
6139 (gnus-summary-article-pseudo-p article)
6140 (error "This is a pseudo-article"))
6142 (set-buffer gnus-summary-buffer)
6143 (if (or (and gnus-single-article-buffer
6144 (or (null gnus-current-article)
6145 (null gnus-article-current)
6146 (null (get-buffer gnus-article-buffer))
6147 (not (eq article (cdr gnus-article-current)))
6148 (not (equal (car gnus-article-current)
6149 gnus-newsgroup-name))))
6150 (and (not gnus-single-article-buffer)
6151 (or (null gnus-current-article)
6152 (not (eq gnus-current-article article))))
6154 ;; The requested article is different from the current article.
6156 (gnus-summary-display-article article all-headers)
6157 (when (gnus-buffer-live-p gnus-article-buffer)
6158 (with-current-buffer gnus-article-buffer
6159 (if (not gnus-article-decoded-p) ;; a local variable
6160 (mm-disable-multibyte-mule4))))
6161 (when (or all-headers gnus-show-all-headers)
6162 (gnus-article-show-all-headers))
6163 (gnus-article-set-window-start
6164 (cdr (assq article gnus-newsgroup-bookmarks)))
6166 (when (or all-headers gnus-show-all-headers)
6167 (gnus-article-show-all-headers))
6170 (defun gnus-summary-force-verify-and-decrypt ()
6172 (let ((mm-verify-option 'known)
6173 (mm-decrypt-option 'known))
6174 (gnus-summary-select-article nil 'force)))
6176 (defun gnus-summary-set-current-mark (&optional current-mark)
6177 "Obsolete function."
6180 (defun gnus-summary-next-article (&optional unread subject backward push)
6181 "Select the next article.
6182 If UNREAD, only unread articles are selected.
6183 If SUBJECT, only articles with SUBJECT are selected.
6184 If BACKWARD, the previous article is selected instead of the next."
6187 ;; Is there such an article?
6188 ((and (gnus-summary-search-forward unread subject backward)
6189 (or (gnus-summary-display-article (gnus-summary-article-number))
6190 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
6191 (gnus-summary-position-point))
6192 ;; If not, we try the first unread, if that is wanted.
6194 gnus-auto-select-same
6195 (gnus-summary-first-unread-article))
6196 (gnus-summary-position-point)
6197 (gnus-message 6 "Wrapped"))
6198 ;; Try to get next/previous article not displayed in this group.
6199 ((and gnus-auto-extend-newsgroup
6200 (not unread) (not subject))
6201 (gnus-summary-goto-article
6202 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
6203 nil (count-lines (point-min) (point))))
6204 ;; Go to next/previous group.
6206 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
6207 (gnus-summary-jump-to-group gnus-newsgroup-name))
6208 (let ((cmd last-command-char)
6211 (set-buffer gnus-group-buffer)
6214 (if (eq gnus-keep-same-level 'best)
6215 (gnus-summary-best-group gnus-newsgroup-name)
6216 (gnus-summary-search-group backward gnus-keep-same-level))))
6217 ;; For some reason, the group window gets selected. We change
6219 (select-window (get-buffer-window (current-buffer)))
6220 ;; Select next unread newsgroup automagically.
6222 ((or (not gnus-auto-select-next)
6224 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
6225 ((or (eq gnus-auto-select-next 'quietly)
6226 (and (eq gnus-auto-select-next 'slightly-quietly)
6228 (and (eq gnus-auto-select-next 'almost-quietly)
6229 (gnus-summary-last-article-p)))
6231 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
6233 (gnus-message 7 "No more%s articles (%s)..."
6234 (if unread " unread" "")
6235 (if group (concat "selecting " group)
6237 (gnus-summary-next-group nil group backward)))
6239 (when (gnus-key-press-event-p last-input-event)
6240 (gnus-summary-walk-group-buffer
6241 gnus-newsgroup-name cmd unread backward point))))))))
6243 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
6244 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
6245 (?\C-p (gnus-group-prev-unread-group 1))))
6246 (cursor-in-echo-area t)
6247 keve key group ended)
6249 (set-buffer gnus-group-buffer)
6252 (if (eq gnus-keep-same-level 'best)
6253 (gnus-summary-best-group gnus-newsgroup-name)
6254 (gnus-summary-search-group backward gnus-keep-same-level))))
6257 5 "No more%s articles%s" (if unread " unread" "")
6259 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
6260 (format " (Type %s for %s [%s])"
6261 (single-key-description cmd) group
6262 (car (gnus-gethash group gnus-newsrc-hashtb)))
6263 (format " (Type %s to exit %s)"
6264 (single-key-description cmd)
6265 gnus-newsgroup-name)))
6266 ;; Confirm auto selection.
6267 (setq key (car (setq keve (gnus-read-event-char))))
6270 ((assq key keystrokes)
6271 (let ((obuf (current-buffer)))
6272 (switch-to-buffer gnus-group-buffer)
6274 (gnus-group-jump-to-group group))
6275 (eval (cadr (assq key keystrokes)))
6276 (setq group (gnus-group-group-name))
6277 (switch-to-buffer obuf))
6281 (gnus-ephemeral-group-p gnus-newsgroup-name))
6283 (gnus-summary-next-group nil group backward)))
6285 (push (cdr keve) unread-command-events))))))
6287 (defun gnus-summary-next-unread-article ()
6288 "Select unread article after current one."
6290 (gnus-summary-next-article
6291 (or (not (eq gnus-summary-goto-unread 'never))
6292 (gnus-summary-last-article-p (gnus-summary-article-number)))
6293 (and gnus-auto-select-same
6294 (gnus-summary-article-subject))))
6296 (defun gnus-summary-prev-article (&optional unread subject)
6297 "Select the article after the current one.
6298 If UNREAD is non-nil, only unread articles are selected."
6300 (gnus-summary-next-article unread subject t))
6302 (defun gnus-summary-prev-unread-article ()
6303 "Select unread article before current one."
6305 (gnus-summary-prev-article
6306 (or (not (eq gnus-summary-goto-unread 'never))
6307 (gnus-summary-first-article-p (gnus-summary-article-number)))
6308 (and gnus-auto-select-same
6309 (gnus-summary-article-subject))))
6311 (defun gnus-summary-next-page (&optional lines circular)
6312 "Show next page of the selected article.
6313 If at the end of the current article, select the next article.
6314 LINES says how many lines should be scrolled up.
6316 If CIRCULAR is non-nil, go to the start of the article instead of
6317 selecting the next article when reaching the end of the current
6320 (setq gnus-summary-buffer (current-buffer))
6321 (gnus-set-global-variables)
6322 (let ((article (gnus-summary-article-number))
6323 (article-window (get-buffer-window gnus-article-buffer t))
6325 ;; If the buffer is empty, we have no article.
6327 (error "No article to select"))
6328 (gnus-configure-windows 'article)
6329 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
6330 (if (and (eq gnus-summary-goto-unread 'never)
6331 (not (gnus-summary-last-article-p article)))
6332 (gnus-summary-next-article)
6333 (gnus-summary-next-unread-article))
6334 (if (or (null gnus-current-article)
6335 (null gnus-article-current)
6336 (/= article (cdr gnus-article-current))
6337 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6338 ;; Selected subject is different from current article's.
6339 (gnus-summary-display-article article)
6340 (when article-window
6341 (gnus-eval-in-buffer-window gnus-article-buffer
6342 (setq endp (gnus-article-next-page lines)))
6345 (gnus-summary-beginning-of-article))
6347 (gnus-message 3 "End of message"))
6349 (if (and (eq gnus-summary-goto-unread 'never)
6350 (not (gnus-summary-last-article-p article)))
6351 (gnus-summary-next-article)
6352 (gnus-summary-next-unread-article))))))))
6353 (gnus-summary-recenter)
6354 (gnus-summary-position-point)))
6356 (defun gnus-summary-prev-page (&optional lines move)
6357 "Show previous page of selected article.
6358 Argument LINES specifies lines to be scrolled down.
6359 If MOVE, move to the previous unread article if point is at
6360 the beginning of the buffer."
6362 (let ((article (gnus-summary-article-number))
6363 (article-window (get-buffer-window gnus-article-buffer t))
6365 (gnus-configure-windows 'article)
6366 (if (or (null gnus-current-article)
6367 (null gnus-article-current)
6368 (/= article (cdr gnus-article-current))
6369 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6370 ;; Selected subject is different from current article's.
6371 (gnus-summary-display-article article)
6372 (gnus-summary-recenter)
6373 (when article-window
6374 (gnus-eval-in-buffer-window gnus-article-buffer
6375 (setq endp (gnus-article-prev-page lines)))
6376 (when (and move endp)
6378 (gnus-message 3 "Beginning of message"))
6380 (if (and (eq gnus-summary-goto-unread 'never)
6381 (not (gnus-summary-first-article-p article)))
6382 (gnus-summary-prev-article)
6383 (gnus-summary-prev-unread-article))))))))
6384 (gnus-summary-position-point))
6386 (defun gnus-summary-prev-page-or-article (&optional lines)
6387 "Show previous page of selected article.
6388 Argument LINES specifies lines to be scrolled down.
6389 If at the beginning of the article, go to the next article."
6391 (gnus-summary-prev-page lines t))
6393 (defun gnus-summary-scroll-up (lines)
6394 "Scroll up (or down) one line current article.
6395 Argument LINES specifies lines to be scrolled up (or down if negative)."
6397 (gnus-configure-windows 'article)
6398 (gnus-summary-show-thread)
6399 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
6400 (gnus-eval-in-buffer-window gnus-article-buffer
6402 (when (gnus-article-next-page lines)
6403 (gnus-message 3 "End of message")))
6405 (gnus-article-prev-page (- lines))))))
6406 (gnus-summary-recenter)
6407 (gnus-summary-position-point))
6409 (defun gnus-summary-scroll-down (lines)
6410 "Scroll down (or up) one line current article.
6411 Argument LINES specifies lines to be scrolled down (or up if negative)."
6413 (gnus-summary-scroll-up (- lines)))
6415 (defun gnus-summary-next-same-subject ()
6416 "Select next article which has the same subject as current one."
6418 (gnus-summary-next-article nil (gnus-summary-article-subject)))
6420 (defun gnus-summary-prev-same-subject ()
6421 "Select previous article which has the same subject as current one."
6423 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
6425 (defun gnus-summary-next-unread-same-subject ()
6426 "Select next unread article which has the same subject as current one."
6428 (gnus-summary-next-article t (gnus-summary-article-subject)))
6430 (defun gnus-summary-prev-unread-same-subject ()
6431 "Select previous unread article which has the same subject as current one."
6433 (gnus-summary-prev-article t (gnus-summary-article-subject)))
6435 (defun gnus-summary-first-unread-article ()
6436 "Select the first unread article.
6437 Return nil if there are no unread articles."
6440 (when (gnus-summary-first-subject t)
6441 (gnus-summary-show-thread)
6442 (gnus-summary-first-subject t)
6443 (gnus-summary-display-article (gnus-summary-article-number)))
6444 (gnus-summary-position-point)))
6446 (defun gnus-summary-first-unread-subject ()
6447 "Place the point on the subject line of the first unread article.
6448 Return nil if there are no unread articles."
6451 (when (gnus-summary-first-subject t)
6452 (gnus-summary-show-thread)
6453 (gnus-summary-first-subject t))
6454 (gnus-summary-position-point)))
6456 (defun gnus-summary-first-article ()
6457 "Select the first article.
6458 Return nil if there are no articles."
6461 (when (gnus-summary-first-subject)
6462 (gnus-summary-show-thread)
6463 (gnus-summary-first-subject)
6464 (gnus-summary-display-article (gnus-summary-article-number)))
6465 (gnus-summary-position-point)))
6467 (defun gnus-summary-best-unread-article ()
6468 "Select the unread article with the highest score."
6470 (let ((best -1000000)
6471 (data gnus-newsgroup-data)
6474 (and (gnus-data-unread-p (car data))
6476 (gnus-summary-article-score (gnus-data-number (car data))))
6479 article (gnus-data-number (car data))))
6480 (setq data (cdr data)))
6483 (gnus-summary-goto-article article)
6484 (error "No unread articles"))
6485 (gnus-summary-position-point))))
6487 (defun gnus-summary-last-subject ()
6488 "Go to the last displayed subject line in the group."
6489 (let ((article (gnus-data-number (car (gnus-data-list t)))))
6491 (gnus-summary-goto-subject article))))
6493 (defun gnus-summary-goto-article (article &optional all-headers force)
6494 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
6495 If ALL-HEADERS is non-nil, no header lines are hidden.
6496 If FORCE, go to the article even if it isn't displayed. If FORCE
6497 is a number, it is the line the article is to be displayed on."
6501 "Article number or Message-ID: "
6502 (mapcar (lambda (number) (list (int-to-string number)))
6503 gnus-newsgroup-limit))
6507 (if (and (stringp article)
6508 (string-match "@" article))
6509 (gnus-summary-refer-article article)
6510 (when (stringp article)
6511 (setq article (string-to-number article)))
6512 (if (gnus-summary-goto-subject article force)
6513 (gnus-summary-display-article article all-headers)
6514 (gnus-message 4 "Couldn't go to article %s" article) nil))
6515 (gnus-summary-position-point)))
6517 (defun gnus-summary-goto-last-article ()
6518 "Go to the previously read article."
6521 (when gnus-last-article
6522 (gnus-summary-goto-article gnus-last-article nil t))
6523 (gnus-summary-position-point)))
6525 (defun gnus-summary-pop-article (number)
6526 "Pop one article off the history and go to the previous.
6527 NUMBER articles will be popped off."
6530 (setq gnus-newsgroup-history
6531 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
6533 (gnus-summary-goto-article (car to) nil t)
6534 (error "Article history empty")))
6535 (gnus-summary-position-point))
6537 ;; Summary commands and functions for limiting the summary buffer.
6539 (defun gnus-summary-limit-to-articles (n)
6540 "Limit the summary buffer to the next N articles.
6541 If not given a prefix, use the process marked articles instead."
6544 (let ((articles (gnus-summary-work-articles n)))
6545 (setq gnus-newsgroup-processable nil)
6546 (gnus-summary-limit articles))
6547 (gnus-summary-position-point)))
6549 (defun gnus-summary-pop-limit (&optional total)
6550 "Restore the previous limit.
6551 If given a prefix, remove all limits."
6554 (setq gnus-newsgroup-limits
6555 (list (mapcar (lambda (h) (mail-header-number h))
6556 gnus-newsgroup-headers))))
6557 (unless gnus-newsgroup-limits
6558 (error "No limit to pop"))
6560 (gnus-summary-limit nil 'pop)
6561 (gnus-summary-position-point)))
6563 (defun gnus-summary-limit-to-subject (subject &optional header)
6564 "Limit the summary buffer to articles that have subjects that match a regexp."
6565 (interactive "sLimit to subject (regexp): ")
6567 (setq header "subject"))
6568 (when (not (equal "" subject))
6570 (let ((articles (gnus-summary-find-matching
6571 (or header "subject") subject 'all)))
6573 (error "Found no matches for \"%s\"" subject))
6574 (gnus-summary-limit articles))
6575 (gnus-summary-position-point))))
6577 (defun gnus-summary-limit-to-author (from)
6578 "Limit the summary buffer to articles that have authors that match a regexp."
6579 (interactive "sLimit to author (regexp): ")
6580 (gnus-summary-limit-to-subject from "from"))
6582 (defun gnus-summary-limit-to-age (age &optional younger-p)
6583 "Limit the summary buffer to articles that are older than (or equal) AGE days.
6584 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
6585 articles that are younger than AGE days."
6587 (let ((younger current-prefix-arg)
6590 (while (not days-got)
6591 (setq days (if younger
6592 (read-string "Limit to articles within (in days): ")
6593 (read-string "Limit to articles older than (in days): ")))
6594 (when (> (length days) 0)
6595 (setq days (read days)))
6598 (message "Please enter a number.")
6600 (list days younger)))
6602 (let ((data gnus-newsgroup-data)
6603 (cutoff (days-to-time age))
6604 articles d date is-younger)
6605 (while (setq d (pop data))
6606 (when (and (vectorp (gnus-data-header d))
6607 (setq date (mail-header-date (gnus-data-header d))))
6608 (setq is-younger (time-less-p
6609 (time-since (condition-case ()
6616 (push (gnus-data-number d) articles))))
6617 (gnus-summary-limit (nreverse articles)))
6618 (gnus-summary-position-point)))
6620 (defun gnus-summary-limit-to-extra (header regexp)
6621 "Limit the summary buffer to articles that match an 'extra' header."
6625 (gnus-completing-read
6626 (symbol-name (car gnus-extra-headers))
6627 "Limit extra header:"
6629 (cons (symbol-name x) x))
6634 (read-string (format "Limit to header %s (regexp): " header)))))
6635 (when (not (equal "" regexp))
6637 (let ((articles (gnus-summary-find-matching
6638 (cons 'extra header) regexp 'all)))
6640 (error "Found no matches for \"%s\"" regexp))
6641 (gnus-summary-limit articles))
6642 (gnus-summary-position-point))))
6644 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6646 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6648 (defun gnus-summary-limit-to-unread (&optional all)
6649 "Limit the summary buffer to articles that are not marked as read.
6650 If ALL is non-nil, limit strictly to unread articles."
6653 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
6654 (gnus-summary-limit-to-marks
6655 ;; Concat all the marks that say that an article is read and have
6657 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
6658 gnus-killed-mark gnus-kill-file-mark
6659 gnus-low-score-mark gnus-expirable-mark
6660 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
6661 gnus-duplicate-mark gnus-souped-mark)
6664 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
6665 (make-obsolete 'gnus-summary-delete-marked-with
6666 'gnus-summary-limit-exlude-marks)
6668 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
6669 "Exclude articles that are marked with MARKS (e.g. \"DK\").
6670 If REVERSE, limit the summary buffer to articles that are marked
6671 with MARKS. MARKS can either be a string of marks or a list of marks.
6672 Returns how many articles were removed."
6673 (interactive "sMarks: ")
6674 (gnus-summary-limit-to-marks marks t))
6676 (defun gnus-summary-limit-to-marks (marks &optional reverse)
6677 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
6678 If REVERSE (the prefix), limit the summary buffer to articles that are
6679 not marked with MARKS. MARKS can either be a string of marks or a
6681 Returns how many articles were removed."
6682 (interactive "sMarks: \nP")
6684 (let ((data gnus-newsgroup-data)
6685 (marks (if (listp marks) marks
6686 (append marks nil))) ; Transform to list.
6689 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
6690 (memq (gnus-data-mark (car data)) marks))
6691 (push (gnus-data-number (car data)) articles))
6692 (setq data (cdr data)))
6693 (gnus-summary-limit articles))
6694 (gnus-summary-position-point)))
6696 (defun gnus-summary-limit-to-score (&optional score)
6697 "Limit to articles with score at or above SCORE."
6699 (setq score (if score
6700 (prefix-numeric-value score)
6701 (or gnus-summary-default-score 0)))
6702 (let ((data gnus-newsgroup-data)
6705 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
6707 (push (gnus-data-number (car data)) articles))
6708 (setq data (cdr data)))
6710 (gnus-summary-limit articles)
6711 (gnus-summary-position-point))))
6713 (defun gnus-summary-limit-include-thread (id)
6714 "Display all the hidden articles that in the current thread."
6715 (interactive (list (mail-header-id (gnus-summary-article-header))))
6716 (let ((articles (gnus-articles-in-thread
6717 (gnus-id-to-thread (gnus-root-id id)))))
6719 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
6720 (gnus-summary-position-point))))
6722 (defun gnus-summary-limit-include-dormant ()
6723 "Display all the hidden articles that are marked as dormant.
6724 Note that this command only works on a subset of the articles currently
6725 fetched for this group."
6727 (unless gnus-newsgroup-dormant
6728 (error "There are no dormant articles in this group"))
6730 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
6731 (gnus-summary-position-point)))
6733 (defun gnus-summary-limit-exclude-dormant ()
6734 "Hide all dormant articles."
6737 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
6738 (gnus-summary-position-point)))
6740 (defun gnus-summary-limit-exclude-childless-dormant ()
6741 "Hide all dormant articles that have no children."
6743 (let ((data (gnus-data-list t))
6744 articles d children)
6745 ;; Find all articles that are either not dormant or have
6747 (while (setq d (pop data))
6748 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
6750 (gnus-article-children (gnus-data-number d)))
6753 (when (memq (car children) articles)
6758 (push (gnus-data-number d) articles)))
6761 (gnus-summary-limit articles)
6762 (gnus-summary-position-point))))
6764 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
6765 "Mark all unread excluded articles as read.
6766 If ALL, mark even excluded ticked and dormants as read."
6768 (let ((articles (gnus-sorted-complement
6770 (mapcar (lambda (h) (mail-header-number h))
6771 gnus-newsgroup-headers)
6773 (sort gnus-newsgroup-limit '<)))
6775 (setq gnus-newsgroup-unreads
6776 (gnus-intersection gnus-newsgroup-unreads gnus-newsgroup-limit))
6778 (setq gnus-newsgroup-dormant nil
6779 gnus-newsgroup-marked nil
6780 gnus-newsgroup-reads
6782 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
6783 gnus-newsgroup-reads))
6784 (while (setq article (pop articles))
6785 (unless (or (memq article gnus-newsgroup-dormant)
6786 (memq article gnus-newsgroup-marked))
6787 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
6789 (defun gnus-summary-limit (articles &optional pop)
6791 ;; We pop the previous limit off the stack and use that.
6792 (setq articles (car gnus-newsgroup-limits)
6793 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
6794 ;; We use the new limit, so we push the old limit on the stack.
6795 (push gnus-newsgroup-limit gnus-newsgroup-limits))
6797 (setq gnus-newsgroup-limit articles)
6798 (let ((total (length gnus-newsgroup-data))
6799 (data (gnus-data-find-list (gnus-summary-article-number)))
6800 (gnus-summary-mark-below nil) ; Inhibit this.
6802 ;; This will do all the work of generating the new summary buffer
6803 ;; according to the new limit.
6804 (gnus-summary-prepare)
6805 ;; Hide any threads, possibly.
6806 (and gnus-show-threads
6807 gnus-thread-hide-subtree
6808 (gnus-summary-hide-all-threads))
6809 ;; Try to return to the article you were at, or one in the
6812 ;; We try to find some article after the current one.
6814 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
6817 (setq data (cdr data))))
6819 ;; If there is no data, that means that we were after the last
6820 ;; article. The same goes when we can't find any articles
6821 ;; after the current one.
6822 (goto-char (point-max))
6823 (gnus-summary-find-prev))
6824 (gnus-set-mode-line 'summary)
6825 ;; We return how many articles were removed from the summary
6826 ;; buffer as a result of the new limit.
6827 (- total (length gnus-newsgroup-data))))
6829 (defsubst gnus-invisible-cut-children (threads)
6832 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
6837 (defsubst gnus-cut-thread (thread)
6838 "Go forwards in the thread until we find an article that we want to display."
6839 (when (or (eq gnus-fetch-old-headers 'some)
6840 (eq gnus-fetch-old-headers 'invisible)
6841 (numberp gnus-fetch-old-headers)
6842 (eq gnus-build-sparse-threads 'some)
6843 (eq gnus-build-sparse-threads 'more))
6844 ;; Deal with old-fetched headers and sparse threads.
6848 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
6849 (gnus-summary-article-ancient-p
6850 (mail-header-number (car thread))))
6851 (if (or (<= (length (cdr thread)) 1)
6852 (eq gnus-fetch-old-headers 'invisible))
6853 (setq gnus-newsgroup-limit
6854 (delq (mail-header-number (car thread))
6855 gnus-newsgroup-limit)
6856 thread (cadr thread))
6857 (when (gnus-invisible-cut-children (cdr thread))
6858 (let ((th (cdr thread)))
6860 (if (memq (mail-header-number (caar th))
6861 gnus-newsgroup-limit)
6862 (setq thread (car th)
6864 (setq th (cdr th))))))))))
6867 (defun gnus-cut-threads (threads)
6868 "Cut off all uninteresting articles from the beginning of threads."
6869 (when (or (eq gnus-fetch-old-headers 'some)
6870 (eq gnus-fetch-old-headers 'invisible)
6871 (numberp gnus-fetch-old-headers)
6872 (eq gnus-build-sparse-threads 'some)
6873 (eq gnus-build-sparse-threads 'more))
6876 (setcar th (gnus-cut-thread (car th)))
6877 (setq th (cdr th)))))
6878 ;; Remove nixed out threads.
6881 (defun gnus-summary-initial-limit (&optional show-if-empty)
6882 "Figure out what the initial limit is supposed to be on group entry.
6883 This entails weeding out unwanted dormants, low-scored articles,
6884 fetch-old-headers verbiage, and so on."
6885 ;; Most groups have nothing to remove.
6886 (if (or gnus-inhibit-limiting
6887 (and (null gnus-newsgroup-dormant)
6888 (not (eq gnus-fetch-old-headers 'some))
6889 (not (numberp gnus-fetch-old-headers))
6890 (not (eq gnus-fetch-old-headers 'invisible))
6891 (null gnus-summary-expunge-below)
6892 (not (eq gnus-build-sparse-threads 'some))
6893 (not (eq gnus-build-sparse-threads 'more))
6894 (null gnus-thread-expunge-below)
6895 (not gnus-use-nocem)))
6897 (push gnus-newsgroup-limit gnus-newsgroup-limits)
6898 (setq gnus-newsgroup-limit nil)
6901 (unless (car (symbol-value node))
6902 ;; These threads have no parents -- they are roots.
6903 (let ((nodes (cdr (symbol-value node)))
6906 (if (and gnus-thread-expunge-below
6907 (< (gnus-thread-total-score (car nodes))
6908 gnus-thread-expunge-below))
6909 (gnus-expunge-thread (pop nodes))
6910 (setq thread (pop nodes))
6911 (gnus-summary-limit-children thread))))))
6912 gnus-newsgroup-dependencies)
6913 ;; If this limitation resulted in an empty group, we might
6914 ;; pop the previous limit and use it instead.
6915 (when (and (not gnus-newsgroup-limit)
6917 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
6918 gnus-newsgroup-limit))
6920 (defun gnus-summary-limit-children (thread)
6921 "Return 1 if this subthread is visible and 0 if it is not."
6922 ;; First we get the number of visible children to this thread. This
6923 ;; is done by recursing down the thread using this function, so this
6924 ;; will really go down to a leaf article first, before slowly
6925 ;; working its way up towards the root.
6929 (apply '+ (mapcar 'gnus-summary-limit-children
6932 (number (mail-header-number (car thread)))
6935 (not (memq number gnus-newsgroup-marked))
6937 ;; If this article is dormant and has absolutely no visible
6938 ;; children, then this article isn't visible.
6939 (and (memq number gnus-newsgroup-dormant)
6941 ;; If this is "fetch-old-headered" and there is no
6942 ;; visible children, then we don't want this article.
6943 (and (or (eq gnus-fetch-old-headers 'some)
6944 (numberp gnus-fetch-old-headers))
6945 (gnus-summary-article-ancient-p number)
6947 ;; If this is "fetch-old-headered" and `invisible', then
6948 ;; we don't want this article.
6949 (and (eq gnus-fetch-old-headers 'invisible)
6950 (gnus-summary-article-ancient-p number))
6951 ;; If this is a sparsely inserted article with no children,
6952 ;; we don't want it.
6953 (and (eq gnus-build-sparse-threads 'some)
6954 (gnus-summary-article-sparse-p number)
6956 ;; If we use expunging, and this article is really
6957 ;; low-scored, then we don't want this article.
6958 (when (and gnus-summary-expunge-below
6960 (or (cdr (assq number gnus-newsgroup-scored))
6961 gnus-summary-default-score))
6962 gnus-summary-expunge-below))
6963 ;; We increase the expunge-tally here, but that has
6964 ;; nothing to do with the limits, really.
6965 (incf gnus-newsgroup-expunged-tally)
6966 ;; We also mark as read here, if that's wanted.
6967 (when (and gnus-summary-mark-below
6968 (< score gnus-summary-mark-below))
6969 (setq gnus-newsgroup-unreads
6970 (delq number gnus-newsgroup-unreads))
6971 (if gnus-newsgroup-auto-expire
6972 (push number gnus-newsgroup-expirable)
6973 (push (cons number gnus-low-score-mark)
6974 gnus-newsgroup-reads)))
6976 ;; Check NoCeM things.
6977 (if (and gnus-use-nocem
6978 (gnus-nocem-unwanted-article-p
6979 (mail-header-id (car thread))))
6981 (setq gnus-newsgroup-unreads
6982 (delq number gnus-newsgroup-unreads))
6984 ;; Nope, invisible article.
6986 ;; Ok, this article is to be visible, so we add it to the limit
6988 (push number gnus-newsgroup-limit)
6991 (defun gnus-expunge-thread (thread)
6992 "Mark all articles in THREAD as read."
6993 (let* ((number (mail-header-number (car thread))))
6994 (incf gnus-newsgroup-expunged-tally)
6995 ;; We also mark as read here, if that's wanted.
6996 (setq gnus-newsgroup-unreads
6997 (delq number gnus-newsgroup-unreads))
6998 (if gnus-newsgroup-auto-expire
6999 (push number gnus-newsgroup-expirable)
7000 (push (cons number gnus-low-score-mark)
7001 gnus-newsgroup-reads)))
7002 ;; Go recursively through all subthreads.
7003 (mapcar 'gnus-expunge-thread (cdr thread)))
7005 ;; Summary article oriented commands
7007 (defun gnus-summary-refer-parent-article (n)
7008 "Refer parent article N times.
7009 If N is negative, go to ancestor -N instead.
7010 The difference between N and the number of articles fetched is returned."
7014 (when (not (natnump n))
7019 (setq header (gnus-summary-article-header))
7020 (if (and (eq (mail-header-number header)
7021 (cdr gnus-article-current))
7022 (equal gnus-newsgroup-name
7023 (car gnus-article-current)))
7024 ;; If we try to find the parent of the currently
7025 ;; displayed article, then we take a look at the actual
7026 ;; References header, since this is slightly more
7027 ;; reliable than the References field we got from the
7030 (set-buffer gnus-original-article-buffer)
7031 (nnheader-narrow-to-headers)
7032 (unless (setq ref (message-fetch-field "references"))
7033 (setq ref (message-fetch-field "in-reply-to")))
7036 ;; It's not the current article, so we take a bet on
7037 ;; the value we got from the server.
7038 (mail-header-references header)))
7040 (not (equal ref "")))
7041 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
7042 (gnus-message 1 "Couldn't find parent"))
7043 (gnus-message 1 "No references in article %d"
7044 (gnus-summary-article-number))
7047 (gnus-summary-position-point)
7050 (defun gnus-summary-refer-references ()
7051 "Fetch all articles mentioned in the References header.
7052 Return the number of articles fetched."
7054 (let ((ref (mail-header-references (gnus-summary-article-header)))
7055 (current (gnus-summary-article-number))
7059 (error "No References in the current article")
7060 ;; For each Message-ID in the References header...
7061 (while (string-match "<[^>]*>" ref)
7063 ;; ... fetch that article.
7064 (gnus-summary-refer-article
7065 (prog1 (match-string 0 ref)
7066 (setq ref (substring ref (match-end 0))))))
7067 (gnus-summary-goto-subject current)
7068 (gnus-summary-position-point)
7071 (defun gnus-summary-refer-thread (&optional limit)
7072 "Fetch all articles in the current thread.
7073 If LIMIT (the numerical prefix), fetch that many old headers instead
7074 of what's specified by the `gnus-refer-thread-limit' variable."
7076 (let ((id (mail-header-id (gnus-summary-article-header)))
7077 (limit (if limit (prefix-numeric-value limit)
7078 gnus-refer-thread-limit)))
7079 ;; We want to fetch LIMIT *old* headers, but we also have to
7080 ;; re-fetch all the headers in the current buffer, because many of
7081 ;; them may be undisplayed. So we adjust LIMIT.
7082 (when (numberp limit)
7083 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
7084 (unless (eq gnus-fetch-old-headers 'invisible)
7085 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
7086 ;; Retrieve the headers and read them in.
7087 (if (eq (gnus-retrieve-headers
7088 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
7090 (gnus-build-all-threads)
7091 (error "Can't fetch thread from backends that don't support NOV"))
7092 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
7093 (gnus-summary-limit-include-thread id)))
7095 (defun gnus-summary-refer-article (message-id)
7096 "Fetch an article specified by MESSAGE-ID."
7097 (interactive "sMessage-ID: ")
7098 (when (and (stringp message-id)
7099 (not (zerop (length message-id))))
7100 ;; Construct the correct Message-ID if necessary.
7101 ;; Suggested by tale@pawl.rpi.edu.
7102 (unless (string-match "^<" message-id)
7103 (setq message-id (concat "<" message-id)))
7104 (unless (string-match ">$" message-id)
7105 (setq message-id (concat message-id ">")))
7106 (let* ((header (gnus-id-to-header message-id))
7108 (gnus-summary-article-sparse-p
7109 (mail-header-number header))
7110 (memq (mail-header-number header)
7111 gnus-newsgroup-limit)))
7114 ;; If the article is present in the buffer we just go to it.
7116 (or (not (gnus-summary-article-sparse-p
7117 (mail-header-number header)))
7120 (gnus-summary-goto-article
7121 (mail-header-number header) nil t)
7123 (gnus-summary-update-article (mail-header-number header)))))
7125 ;; We fetch the article.
7127 (dolist (gnus-override-method (gnus-refer-article-methods))
7128 (gnus-check-server gnus-override-method)
7129 ;; Fetch the header, and display the article.
7130 (when (setq number (gnus-summary-insert-subject message-id))
7131 (gnus-summary-select-article nil nil nil number)
7133 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
7135 (defun gnus-refer-article-methods ()
7136 "Return a list of referrable methods."
7138 ;; No method, so we default to current and native.
7139 ((null gnus-refer-article-method)
7140 (list gnus-current-select-method gnus-select-method))
7142 ((eq 'current gnus-refer-article-method)
7143 (list gnus-current-select-method))
7144 ;; List of select methods.
7145 ((not (and (symbolp (car gnus-refer-article-method))
7146 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
7148 (dolist (method gnus-refer-article-method)
7149 (push (if (eq 'current method)
7150 gnus-current-select-method
7154 ;; One single select method.
7156 (list gnus-refer-article-method))))
7158 (defun gnus-summary-edit-parameters ()
7159 "Edit the group parameters of the current group."
7161 (gnus-group-edit-group gnus-newsgroup-name 'params))
7163 (defun gnus-summary-customize-parameters ()
7164 "Customize the group parameters of the current group."
7166 (gnus-group-customize gnus-newsgroup-name))
7168 (defun gnus-summary-enter-digest-group (&optional force)
7169 "Enter an nndoc group based on the current article.
7170 If FORCE, force a digest interpretation. If not, try
7171 to guess what the document format is."
7173 (let ((conf gnus-current-window-configuration))
7175 (gnus-summary-select-article))
7176 (setq gnus-current-window-configuration conf)
7177 (let* ((name (format "%s-%d"
7178 (gnus-group-prefixed-name
7179 gnus-newsgroup-name (list 'nndoc ""))
7181 (set-buffer gnus-summary-buffer)
7182 gnus-current-article)))
7183 (ogroup gnus-newsgroup-name)
7184 (params (append (gnus-info-params (gnus-get-info ogroup))
7185 (list (cons 'to-group ogroup))
7186 (list (cons 'save-article-group ogroup))))
7187 (case-fold-search t)
7188 (buf (current-buffer))
7191 (set-buffer gnus-original-article-buffer)
7192 ;; Have the digest group inherit the main mail address of
7193 ;; the parent article.
7194 (when (setq to-address (or (message-fetch-field "reply-to")
7195 (message-fetch-field "from")))
7196 (setq params (append
7197 (list (cons 'to-address
7198 (funcall gnus-decode-encoded-word-function
7200 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
7201 (insert-buffer-substring gnus-original-article-buffer)
7202 ;; Remove lines that may lead nndoc to misinterpret the
7205 (goto-char (point-min))
7206 (or (search-forward "\n\n" nil t) (point)))
7207 (goto-char (point-min))
7208 (delete-matching-lines "^Path:\\|^From ")
7211 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
7212 (gnus-newsgroup-ephemeral-ignored-charsets
7213 gnus-newsgroup-ignored-charsets))
7214 (gnus-group-read-ephemeral-group
7215 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
7217 ,(if force 'mbox 'guess))) t))
7218 ;; Make all postings to this group go to the parent group.
7219 (nconc (gnus-info-params (gnus-get-info name))
7221 ;; Couldn't select this doc group.
7222 (switch-to-buffer buf)
7223 (gnus-set-global-variables)
7224 (gnus-configure-windows 'summary)
7225 (gnus-message 3 "Article couldn't be entered?"))
7226 (kill-buffer dig)))))
7228 (defun gnus-summary-read-document (n)
7229 "Open a new group based on the current article(s).
7230 This will allow you to read digests and other similar
7231 documents as newsgroups.
7232 Obeys the standard process/prefix convention."
7234 (let* ((articles (gnus-summary-work-articles n))
7235 (ogroup gnus-newsgroup-name)
7236 (params (append (gnus-info-params (gnus-get-info ogroup))
7237 (list (cons 'to-group ogroup))))
7238 article group egroup groups vgroup)
7239 (while (setq article (pop articles))
7240 (setq group (format "%s-%d" gnus-newsgroup-name article))
7241 (gnus-summary-remove-process-mark article)
7242 (when (gnus-summary-display-article article)
7245 (insert-buffer-substring gnus-original-article-buffer)
7246 ;; Remove some headers that may lead nndoc to make
7248 (message-narrow-to-head)
7249 (goto-char (point-min))
7250 (delete-matching-lines "^\\(Path\\):\\|^From ")
7253 (gnus-group-read-ephemeral-group
7254 group `(nndoc ,group (nndoc-address ,(current-buffer))
7255 (nndoc-article-type guess))
7258 ;; Make all postings to this group go to the parent group.
7259 (nconc (gnus-info-params (gnus-get-info egroup))
7261 (push egroup groups))
7262 ;; Couldn't select this doc group.
7263 (gnus-error 3 "Article couldn't be entered"))))))
7264 ;; Now we have selected all the documents.
7267 (error "None of the articles could be interpreted as documents"))
7268 ((gnus-group-read-ephemeral-group
7269 (setq vgroup (format
7270 "nnvirtual:%s-%s" gnus-newsgroup-name
7271 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
7272 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
7274 (cons (current-buffer) 'summary)))
7276 (error "Couldn't select virtual nndoc group")))))
7278 (defun gnus-summary-isearch-article (&optional regexp-p)
7279 "Do incremental search forward on the current article.
7280 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
7282 (gnus-summary-select-article)
7283 (gnus-configure-windows 'article)
7284 (gnus-eval-in-buffer-window gnus-article-buffer
7287 (isearch-forward regexp-p))))
7289 (defun gnus-summary-search-article-forward (regexp &optional backward)
7290 "Search for an article containing REGEXP forward.
7291 If BACKWARD, search backward instead."
7294 (format "Search article %s (regexp%s): "
7295 (if current-prefix-arg "backward" "forward")
7296 (if gnus-last-search-regexp
7297 (concat ", default " gnus-last-search-regexp)
7299 current-prefix-arg))
7300 (if (string-equal regexp "")
7301 (setq regexp (or gnus-last-search-regexp ""))
7302 (setq gnus-last-search-regexp regexp)
7303 (setq gnus-article-before-search gnus-current-article))
7304 ;; Intentionally set gnus-last-article.
7305 (setq gnus-last-article gnus-article-before-search)
7306 (let ((gnus-last-article gnus-last-article))
7307 (if (gnus-summary-search-article regexp backward)
7308 (gnus-summary-show-thread)
7309 (error "Search failed: \"%s\"" regexp))))
7311 (defun gnus-summary-search-article-backward (regexp)
7312 "Search for an article containing REGEXP backward."
7315 (format "Search article backward (regexp%s): "
7316 (if gnus-last-search-regexp
7317 (concat ", default " gnus-last-search-regexp)
7319 (gnus-summary-search-article-forward regexp 'backward))
7321 (defun gnus-summary-search-article (regexp &optional backward)
7322 "Search for an article containing REGEXP.
7323 Optional argument BACKWARD means do search for backward.
7324 `gnus-select-article-hook' is not called during the search."
7325 ;; We have to require this here to make sure that the following
7326 ;; dynamic binding isn't shadowed by autoloading.
7327 (require 'gnus-async)
7329 (let ((gnus-select-article-hook nil) ;Disable hook.
7330 (gnus-article-prepare-hook nil)
7331 (gnus-mark-article-hook nil) ;Inhibit marking as read.
7332 (gnus-use-article-prefetch nil)
7333 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
7334 (gnus-use-trees nil) ;Inhibit updating tree buffer.
7335 (sum (current-buffer))
7336 (gnus-display-mime-function nil)
7339 (gnus-save-hidden-threads
7340 (gnus-summary-select-article)
7341 (set-buffer gnus-article-buffer)
7342 (goto-char (window-point (get-buffer-window (current-buffer))))
7346 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
7348 (re-search-backward regexp nil t)
7349 (re-search-forward regexp nil t))
7350 ;; We found the regexp.
7355 (get-buffer-window (current-buffer))
7359 (get-buffer-window (current-buffer))
7362 (setq point (point)))
7363 ;; We didn't find it, so we go to the next article.
7366 (while (eq found 'not)
7367 (if (not (if backward (gnus-summary-find-prev)
7368 (gnus-summary-find-next)))
7369 ;; No more articles.
7371 ;; Select the next article and adjust point.
7372 (unless (gnus-summary-article-sparse-p
7373 (gnus-summary-article-number))
7375 (gnus-summary-select-article)
7376 (set-buffer gnus-article-buffer)
7378 (goto-char (if backward (point-max) (point-min))))))))
7379 (gnus-message 7 ""))
7380 ;; Return whether we found the regexp.
7381 (when (eq found 'found)
7383 (gnus-summary-show-thread)
7384 (gnus-summary-goto-subject gnus-current-article)
7385 (gnus-summary-position-point)
7388 (defun gnus-summary-find-matching (header regexp &optional backward unread
7390 "Return a list of all articles that match REGEXP on HEADER.
7391 The search stars on the current article and goes forwards unless
7392 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
7393 If UNREAD is non-nil, only unread articles will
7394 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
7395 in the comparisons."
7396 (let ((data (if (eq backward 'all) gnus-newsgroup-data
7397 (gnus-data-find-list
7398 (gnus-summary-article-number) (gnus-data-list backward))))
7399 (case-fold-search (not not-case-fold))
7402 (if (eq (car header) 'extra)
7405 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
7407 (error "%s is an invalid header" header))
7408 (unless (fboundp (intern (concat "mail-header-" header)))
7409 (error "%s is not a valid header" header))
7410 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
7413 (and (or (not unread) ; We want all articles...
7414 (gnus-data-unread-p d)) ; Or just unreads.
7415 (vectorp (gnus-data-header d)) ; It's not a pseudo.
7416 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
7417 (push (gnus-data-number d) articles)) ; Success!
7418 (setq data (cdr data)))
7419 (nreverse articles)))
7421 (defun gnus-summary-execute-command (header regexp command &optional backward)
7422 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
7423 If HEADER is an empty string (or nil), the match is done on the entire
7424 article. If BACKWARD (the prefix) is non-nil, search backward instead."
7426 (list (let ((completion-ignore-case t))
7429 (mapcar (lambda (string) (list string))
7430 '("Number" "Subject" "From" "Lines" "Date"
7431 "Message-ID" "Xref" "References" "Body"))
7432 nil 'require-match))
7433 (read-string "Regexp: ")
7434 (read-key-sequence "Command: ")
7435 current-prefix-arg))
7436 (when (equal header "Body")
7438 ;; Hidden thread subtrees must be searched as well.
7439 (gnus-summary-show-all-threads)
7440 ;; We don't want to change current point nor window configuration.
7442 (save-window-excursion
7443 (gnus-message 6 "Executing %s..." (key-description command))
7444 ;; We'd like to execute COMMAND interactively so as to give arguments.
7445 (gnus-execute header regexp
7446 `(call-interactively ',(key-binding command))
7448 (gnus-message 6 "Executing %s...done" (key-description command)))))
7450 (defun gnus-summary-beginning-of-article ()
7451 "Scroll the article back to the beginning."
7453 (gnus-summary-select-article)
7454 (gnus-configure-windows 'article)
7455 (gnus-eval-in-buffer-window gnus-article-buffer
7457 (goto-char (point-min))
7458 (when gnus-page-broken
7459 (gnus-narrow-to-page))))
7461 (defun gnus-summary-end-of-article ()
7462 "Scroll to the end of the article."
7464 (gnus-summary-select-article)
7465 (gnus-configure-windows 'article)
7466 (gnus-eval-in-buffer-window gnus-article-buffer
7468 (goto-char (point-max))
7470 (when gnus-page-broken
7471 (gnus-narrow-to-page))))
7473 (defun gnus-summary-print-article (&optional filename n)
7474 "Generate and print a PostScript image of the N next (mail) articles.
7476 If N is negative, print the N previous articles. If N is nil and articles
7477 have been marked with the process mark, print these instead.
7479 If the optional first argument FILENAME is nil, send the image to the
7480 printer. If FILENAME is a string, save the PostScript image in a file with
7481 that name. If FILENAME is a number, prompt the user for the name of the file
7483 (interactive (list (ps-print-preprint current-prefix-arg)))
7484 (dolist (article (gnus-summary-work-articles n))
7485 (gnus-summary-select-article nil nil 'pseudo article)
7486 (gnus-eval-in-buffer-window gnus-article-buffer
7487 (let ((buffer (generate-new-buffer " *print*")))
7490 (copy-to-buffer buffer (point-min) (point-max))
7492 (gnus-article-delete-invisible-text)
7493 (when (gnus-visual-p 'article-highlight 'highlight)
7494 ;; Copy-to-buffer doesn't copy overlay. So redo
7496 (let ((gnus-article-buffer buffer))
7497 (gnus-article-highlight-citation t)
7498 (gnus-article-highlight-signature)))
7499 (let ((ps-left-header
7502 (mail-header-subject gnus-current-headers) ")")
7504 (mail-header-from gnus-current-headers) ")")))
7507 "/pagenumberstring load"
7509 (mail-header-date gnus-current-headers) ")"))))
7510 (gnus-run-hooks 'gnus-ps-print-hook)
7513 (ps-spool-buffer-with-faces)
7514 (ps-spool-buffer)))))
7515 (kill-buffer buffer))))
7516 (gnus-summary-remove-process-mark article))
7517 (ps-despool filename))
7519 (defun gnus-summary-show-article (&optional arg)
7520 "Force re-fetching of the current article.
7521 If ARG (the prefix) is a number, show the article with the charset
7522 defined in `gnus-summary-show-article-charset-alist', or the charset
7524 If ARG (the prefix) is non-nil and not a number, show the raw article
7525 without any article massaging functions being run."
7529 (let ((gnus-newsgroup-charset
7530 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
7531 (read-coding-system "Charset: ")))
7532 (gnus-newsgroup-ignored-charsets 'gnus-all))
7533 (gnus-summary-select-article nil 'force)
7534 (let ((deps gnus-newsgroup-dependencies)
7537 (set-buffer gnus-original-article-buffer)
7539 (message-narrow-to-head)
7540 (setq head (buffer-string)))
7542 (insert (format "211 %d Article retrieved.\n"
7543 (cdr gnus-article-current)))
7546 (let ((nntp-server-buffer (current-buffer)))
7547 (setq header (car (gnus-get-newsgroup-headers deps t))))))
7548 (gnus-data-set-header
7549 (gnus-data-find (cdr gnus-article-current))
7551 (gnus-summary-update-article-line
7552 (cdr gnus-article-current) header))))
7554 ;; Select the article the normal way.
7555 (gnus-summary-select-article nil 'force))
7557 ;; We have to require this here to make sure that the following
7558 ;; dynamic binding isn't shadowed by autoloading.
7559 (require 'gnus-async)
7561 ;; Bind the article treatment functions to nil.
7562 (let ((gnus-have-all-headers t)
7563 gnus-article-prepare-hook
7564 gnus-article-decode-hook
7565 gnus-display-mime-function
7567 ;; Destroy any MIME parts.
7568 (when (gnus-buffer-live-p gnus-article-buffer)
7570 (set-buffer gnus-article-buffer)
7571 (mm-destroy-parts gnus-article-mime-handles)
7572 ;; Set it to nil for safety reason.
7573 (setq gnus-article-mime-handle-alist nil)
7574 (setq gnus-article-mime-handles nil)))
7575 (gnus-summary-select-article nil 'force))))
7576 (gnus-summary-goto-subject gnus-current-article)
7577 (gnus-summary-position-point))
7579 (defun gnus-summary-verbose-headers (&optional arg)
7580 "Toggle permanent full header display.
7581 If ARG is a positive number, turn header display on.
7582 If ARG is a negative number, turn header display off."
7584 (setq gnus-show-all-headers
7585 (cond ((or (not (numberp arg))
7587 (not gnus-show-all-headers))
7590 (gnus-summary-show-article))
7592 (defun gnus-summary-toggle-header (&optional arg)
7593 "Show the headers if they are hidden, or hide them if they are shown.
7594 If ARG is a positive number, show the entire header.
7595 If ARG is a negative number, hide the unwanted header lines."
7598 (set-buffer gnus-article-buffer)
7600 (let* ((buffer-read-only nil)
7601 (inhibit-point-motion-hooks t)
7607 (article-narrow-to-head)
7608 (gnus-article-hidden-text-p 'headers))))
7609 (goto-char (point-min))
7610 (when (search-forward "\n\n" nil t)
7611 (delete-region (point-min) (1- (point))))
7612 (goto-char (point-min))
7614 (set-buffer gnus-original-article-buffer)
7615 (goto-char (point-min))
7616 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
7617 (insert-buffer-substring gnus-original-article-buffer 1 e)
7619 (narrow-to-region (point-min) (point))
7620 (article-decode-encoded-words)
7622 (let ((gnus-treat-hide-headers nil)
7623 (gnus-treat-hide-boring-headers nil))
7624 (setq gnus-article-wash-types
7625 (delq 'headers gnus-article-wash-types))
7626 (gnus-treat-article 'head))
7627 (gnus-treat-article 'head)))
7628 (gnus-set-mode-line 'article)))))
7630 (defun gnus-summary-show-all-headers ()
7631 "Make all header lines visible."
7633 (gnus-summary-toggle-header 1))
7635 (defun gnus-summary-caesar-message (&optional arg)
7636 "Caesar rotate the current article by 13.
7637 The numerical prefix specifies how many places to rotate each letter
7640 (gnus-summary-select-article)
7641 (let ((mail-header-separator ""))
7642 (gnus-eval-in-buffer-window gnus-article-buffer
7645 (let ((start (window-start))
7647 (message-caesar-buffer-body arg)
7648 (set-window-start (get-buffer-window (current-buffer)) start))))))
7650 (defun gnus-summary-stop-page-breaking ()
7651 "Stop page breaking in the current article."
7653 (gnus-summary-select-article)
7654 (gnus-eval-in-buffer-window gnus-article-buffer
7656 (when (gnus-visual-p 'page-marker)
7657 (let ((buffer-read-only nil))
7658 (gnus-remove-text-with-property 'gnus-prev)
7659 (gnus-remove-text-with-property 'gnus-next))
7660 (setq gnus-page-broken nil))))
7662 (defun gnus-summary-move-article (&optional n to-newsgroup
7663 select-method action)
7664 "Move the current article to a different newsgroup.
7665 If N is a positive number, move the N next articles.
7666 If N is a negative number, move the N previous articles.
7667 If N is nil and any articles have been marked with the process mark,
7668 move those articles instead.
7669 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7670 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7671 re-spool using this method.
7673 For this function to work, both the current newsgroup and the
7674 newsgroup that you want to move to have to support the `request-move'
7675 and `request-accept' functions.
7677 ACTION can be either `move' (the default), `crosspost' or `copy'."
7680 (setq action 'move))
7681 ;; Disable marking as read.
7682 (let (gnus-mark-article-hook)
7683 (save-window-excursion
7684 (gnus-summary-select-article)))
7685 ;; Check whether the source group supports the required functions.
7686 (cond ((and (eq action 'move)
7687 (not (gnus-check-backend-function
7688 'request-move-article gnus-newsgroup-name)))
7689 (error "The current group does not support article moving"))
7690 ((and (eq action 'crosspost)
7691 (not (gnus-check-backend-function
7692 'request-replace-article gnus-newsgroup-name)))
7693 (error "The current group does not support article editing")))
7694 (let ((articles (gnus-summary-work-articles n))
7695 (prefix (if (gnus-check-backend-function
7696 'request-move-article gnus-newsgroup-name)
7697 (gnus-group-real-prefix gnus-newsgroup-name)
7699 (names '((move "Move" "Moving")
7700 (copy "Copy" "Copying")
7701 (crosspost "Crosspost" "Crossposting")))
7702 (copy-buf (save-excursion
7703 (nnheader-set-temp-buffer " *copy article*")))
7704 art-group to-method new-xref article to-groups)
7705 (unless (assq action names)
7706 (error "Unknown action %s" action))
7707 ;; Read the newsgroup name.
7708 (when (and (not to-newsgroup)
7709 (not select-method))
7711 (gnus-read-move-group-name
7712 (cadr (assq action names))
7713 (symbol-value (intern (format "gnus-current-%s-group" action)))
7715 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
7716 (setq to-method (or select-method
7717 (gnus-server-to-method
7718 (gnus-group-method to-newsgroup))))
7719 ;; Check the method we are to move this article to...
7720 (unless (gnus-check-backend-function
7721 'request-accept-article (car to-method))
7722 (error "%s does not support article copying" (car to-method)))
7723 (unless (gnus-check-server to-method)
7724 (error "Can't open server %s" (car to-method)))
7725 (gnus-message 6 "%s to %s: %s..."
7726 (caddr (assq action names))
7727 (or (car select-method) to-newsgroup) articles)
7729 (setq article (pop articles))
7733 ;; Move the article.
7735 ;; Remove this article from future suppression.
7736 (gnus-dup-unsuppress-article article)
7737 (gnus-request-move-article
7738 article ; Article to move
7739 gnus-newsgroup-name ; From newsgroup
7740 (nth 1 (gnus-find-method-for-group
7741 gnus-newsgroup-name)) ; Server
7742 (list 'gnus-request-accept-article
7743 to-newsgroup (list 'quote select-method)
7744 (not articles) t) ; Accept form
7745 (not articles))) ; Only save nov last time
7746 ;; Copy the article.
7749 (set-buffer copy-buf)
7750 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
7751 (gnus-request-accept-article
7752 to-newsgroup select-method (not articles) t))))
7753 ;; Crosspost the article.
7754 ((eq action 'crosspost)
7755 (let ((xref (message-tokenize-header
7756 (mail-header-xref (gnus-summary-article-header article))
7758 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
7761 (setq xref (list (system-name))))
7764 (mapconcat 'identity
7765 (delete "Xref:" (delete new-xref xref))
7769 (set-buffer copy-buf)
7770 ;; First put the article in the destination group.
7771 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7772 (when (consp (setq art-group
7773 (gnus-request-accept-article
7774 to-newsgroup select-method (not articles))))
7775 (setq new-xref (concat new-xref " " (car art-group)
7776 ":" (cdr art-group)))
7777 ;; Now we have the new Xrefs header, so we insert
7778 ;; it and replace the new article.
7779 (nnheader-replace-header "Xref" new-xref)
7780 (gnus-request-replace-article
7781 (cdr art-group) to-newsgroup (current-buffer))
7785 (gnus-message 1 "Couldn't %s article %s: %s"
7786 (cadr (assq action names)) article
7787 (nnheader-get-report (car to-method))))
7788 ((eq art-group 'junk)
7789 (when (eq action 'move)
7790 (gnus-summary-mark-article article gnus-canceled-mark)
7791 (gnus-message 4 "Deleted article %s" article)))
7793 (let* ((pto-group (gnus-group-prefixed-name
7794 (car art-group) to-method))
7796 (gnus-gethash pto-group gnus-newsrc-hashtb))
7797 (info (nth 2 entry))
7798 (to-group (gnus-info-group info))
7800 ;; Update the group that has been moved to.
7802 (memq action '(move copy)))
7803 (unless (member to-group to-groups)
7804 (push to-group to-groups))
7806 (unless (memq article gnus-newsgroup-unreads)
7807 (push 'read to-marks)
7809 info (gnus-add-to-range (gnus-info-read info)
7810 (list (cdr art-group)))))
7812 ;; See whether the article is to be put in the cache.
7813 (let ((marks gnus-article-mark-lists)
7814 (to-article (cdr art-group)))
7816 ;; Enter the article into the cache in the new group,
7817 ;; if that is required.
7818 (when gnus-use-cache
7819 (gnus-cache-possibly-enter-article
7821 (memq article gnus-newsgroup-marked)
7822 (memq article gnus-newsgroup-dormant)
7823 (memq article gnus-newsgroup-unreads)))
7825 (when gnus-preserve-marks
7826 ;; Copy any marks over to the new group.
7827 (when (and (equal to-group gnus-newsgroup-name)
7828 (not (memq article gnus-newsgroup-unreads)))
7829 ;; Mark this article as read in this group.
7830 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
7831 (setcdr (gnus-active to-group) to-article)
7832 (setcdr gnus-newsgroup-active to-article))
7835 (when (memq article (symbol-value
7836 (intern (format "gnus-newsgroup-%s"
7838 (push (cdar marks) to-marks)
7839 ;; If the other group is the same as this group,
7840 ;; then we have to add the mark to the list.
7841 (when (equal to-group gnus-newsgroup-name)
7842 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
7845 (intern (format "gnus-newsgroup-%s"
7847 ;; Copy the marks to other group.
7848 (gnus-add-marked-articles
7849 to-group (cdar marks) (list to-article) info))
7850 (setq marks (cdr marks)))
7852 (gnus-request-set-mark to-group (list (list (list to-article)
7857 (concat "(gnus-group-set-info '"
7858 (gnus-prin1-to-string (gnus-get-info to-group))
7861 ;; Update the Xref header in this article to point to
7862 ;; the new crossposted article we have just created.
7863 (when (eq action 'crosspost)
7865 (set-buffer copy-buf)
7866 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7867 (nnheader-replace-header "Xref" new-xref)
7868 (gnus-request-replace-article
7869 article gnus-newsgroup-name (current-buffer)))))
7871 ;;;!!!Why is this necessary?
7872 (set-buffer gnus-summary-buffer)
7874 (gnus-summary-goto-subject article)
7875 (when (eq action 'move)
7876 (gnus-summary-mark-article article gnus-canceled-mark))))
7877 (gnus-summary-remove-process-mark article))
7878 ;; Re-activate all groups that have been moved to.
7881 (set-buffer gnus-group-buffer)
7882 (when (gnus-group-goto-group (car to-groups) t)
7883 (gnus-group-get-new-news-this-group 1 t))
7886 (gnus-kill-buffer copy-buf)
7887 (gnus-summary-position-point)
7888 (gnus-set-mode-line 'summary)))
7890 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
7891 "Move the current article to a different newsgroup.
7892 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7893 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7894 re-spool using this method."
7896 (gnus-summary-move-article n to-newsgroup select-method 'copy))
7898 (defun gnus-summary-crosspost-article (&optional n)
7899 "Crosspost the current article to some other group."
7901 (gnus-summary-move-article n nil nil 'crosspost))
7903 (defcustom gnus-summary-respool-default-method nil
7904 "Default method for respooling an article.
7905 If nil, use to the current newsgroup method."
7906 :type '(choice (gnus-select-method :value (nnml ""))
7908 :group 'gnus-summary-mail)
7910 (defun gnus-summary-respool-article (&optional n method)
7911 "Respool the current article.
7912 The article will be squeezed through the mail spooling process again,
7913 which means that it will be put in some mail newsgroup or other
7914 depending on `nnmail-split-methods'.
7915 If N is a positive number, respool the N next articles.
7916 If N is a negative number, respool the N previous articles.
7917 If N is nil and any articles have been marked with the process mark,
7918 respool those articles instead.
7920 Respooling can be done both from mail groups and \"real\" newsgroups.
7921 In the former case, the articles in question will be moved from the
7922 current group into whatever groups they are destined to. In the
7923 latter case, they will be copied into the relevant groups."
7925 (list current-prefix-arg
7926 (let* ((methods (gnus-methods-using 'respool))
7928 (symbol-name (or gnus-summary-respool-default-method
7929 (car (gnus-find-method-for-group
7930 gnus-newsgroup-name)))))
7932 (gnus-completing-read
7933 methname "What backend do you want to use when respooling?"
7934 methods nil t nil 'gnus-mail-method-history))
7937 ((zerop (length (setq ms (gnus-servers-using-backend
7939 (list (intern method) ""))
7943 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
7944 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
7947 (error "No method given for respooling"))
7948 (if (assoc (symbol-name
7949 (car (gnus-find-method-for-group gnus-newsgroup-name)))
7950 (gnus-methods-using 'respool))
7951 (gnus-summary-move-article n nil method)
7952 (gnus-summary-copy-article n nil method)))
7954 (defun gnus-summary-import-article (file &optional edit)
7955 "Import an arbitrary file into a mail newsgroup."
7956 (interactive "fImport file: \nP")
7957 (let ((group gnus-newsgroup-name)
7958 (now (current-time))
7959 atts lines group-art)
7960 (unless (gnus-check-backend-function 'request-accept-article group)
7961 (error "%s does not support article importing" group))
7962 (or (file-readable-p file)
7963 (not (file-regular-p file))
7964 (error "Can't read %s" file))
7966 (set-buffer (gnus-get-buffer-create " *import file*"))
7968 (nnheader-insert-file-contents file)
7969 (goto-char (point-min))
7970 (unless (nnheader-article-p)
7971 ;; This doesn't look like an article, so we fudge some headers.
7972 (setq atts (file-attributes file)
7973 lines (count-lines (point-min) (point-max)))
7974 (insert "From: " (read-string "From: ") "\n"
7975 "Subject: " (read-string "Subject: ") "\n"
7976 "Date: " (message-make-date (nth 5 atts)) "\n"
7977 "Message-ID: " (message-make-message-id) "\n"
7978 "Lines: " (int-to-string lines) "\n"
7979 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
7980 (setq group-art (gnus-request-accept-article group nil t))
7981 (kill-buffer (current-buffer)))
7982 (setq gnus-newsgroup-active (gnus-activate-group group))
7984 (gnus-summary-goto-article (cdr group-art) nil t)
7986 (gnus-summary-edit-article))))
7988 (defun gnus-summary-create-article ()
7989 "Create an article in a mail newsgroup."
7991 (let ((group gnus-newsgroup-name)
7992 (now (current-time))
7994 (unless (gnus-check-backend-function 'request-accept-article group)
7995 (error "%s does not support article importing" group))
7997 (set-buffer (gnus-get-buffer-create " *import file*"))
7999 (goto-char (point-min))
8000 ;; This doesn't look like an article, so we fudge some headers.
8001 (insert "From: " (read-string "From: ") "\n"
8002 "Subject: " (read-string "Subject: ") "\n"
8003 "Date: " (message-make-date now) "\n"
8004 "Message-ID: " (message-make-message-id) "\n")
8005 (setq group-art (gnus-request-accept-article group nil t))
8006 (kill-buffer (current-buffer)))
8007 (setq gnus-newsgroup-active (gnus-activate-group group))
8009 (gnus-summary-goto-article (cdr group-art) nil t)
8010 (gnus-summary-edit-article)))
8012 (defun gnus-summary-article-posted-p ()
8013 "Say whether the current (mail) article is available from news as well.
8014 This will be the case if the article has both been mailed and posted."
8016 (let ((id (mail-header-references (gnus-summary-article-header)))
8017 (gnus-override-method (car (gnus-refer-article-methods))))
8018 (if (gnus-request-head id "")
8019 (gnus-message 2 "The current message was found on %s"
8020 gnus-override-method)
8021 (gnus-message 2 "The current message couldn't be found on %s"
8022 gnus-override-method)
8025 (defun gnus-summary-expire-articles (&optional now)
8026 "Expire all articles that are marked as expirable in the current group."
8028 (when (gnus-check-backend-function
8029 'request-expire-articles gnus-newsgroup-name)
8030 ;; This backend supports expiry.
8031 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
8032 (expirable (if total
8034 ;; We need to update the info for
8035 ;; this group for `gnus-list-of-read-articles'
8036 ;; to give us the right answer.
8037 (gnus-run-hooks 'gnus-exit-group-hook)
8038 (gnus-summary-update-info)
8039 (gnus-list-of-read-articles gnus-newsgroup-name))
8040 (setq gnus-newsgroup-expirable
8041 (sort gnus-newsgroup-expirable '<))))
8042 (expiry-wait (if now 'immediate
8043 (gnus-group-find-parameter
8044 gnus-newsgroup-name 'expiry-wait)))
8045 (nnmail-expiry-target
8046 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
8047 nnmail-expiry-target))
8050 ;; There are expirable articles in this group, so we run them
8051 ;; through the expiry process.
8052 (gnus-message 6 "Expiring articles...")
8053 (unless (gnus-check-group gnus-newsgroup-name)
8054 (error "Can't open server for %s" gnus-newsgroup-name))
8055 ;; The list of articles that weren't expired is returned.
8058 (let ((nnmail-expiry-wait-function nil)
8059 (nnmail-expiry-wait expiry-wait))
8060 (setq es (gnus-request-expire-articles
8061 expirable gnus-newsgroup-name)))
8062 (setq es (gnus-request-expire-articles
8063 expirable gnus-newsgroup-name)))
8065 (setq gnus-newsgroup-expirable es))
8066 ;; We go through the old list of expirable, and mark all
8067 ;; really expired articles as nonexistent.
8068 (unless (eq es expirable) ;If nothing was expired, we don't mark.
8069 (let ((gnus-use-cache nil))
8071 (unless (memq (car expirable) es)
8072 (when (gnus-data-find (car expirable))
8073 (gnus-summary-mark-article
8074 (car expirable) gnus-canceled-mark)))
8075 (setq expirable (cdr expirable))))))
8076 (gnus-message 6 "Expiring articles...done")))))
8078 (defun gnus-summary-expire-articles-now ()
8079 "Expunge all expirable articles in the current group.
8080 This means that *all* articles that are marked as expirable will be
8081 deleted forever, right now."
8083 (or gnus-expert-user
8085 "Are you really, really, really sure you want to delete all these messages? ")
8087 (gnus-summary-expire-articles t))
8089 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
8090 (defun gnus-summary-delete-article (&optional n)
8091 "Delete the N next (mail) articles.
8092 This command actually deletes articles. This is not a marking
8093 command. The article will disappear forever from your life, never to
8095 If N is negative, delete backwards.
8096 If N is nil and articles have been marked with the process mark,
8097 delete these instead."
8099 (unless (gnus-check-backend-function 'request-expire-articles
8100 gnus-newsgroup-name)
8101 (error "The current newsgroup does not support article deletion"))
8102 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
8103 (error "Couldn't open server"))
8104 ;; Compute the list of articles to delete.
8105 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
8107 (if (and gnus-novice-user
8108 (not (gnus-yes-or-no-p
8109 (format "Do you really want to delete %s forever? "
8110 (if (> (length articles) 1)
8111 (format "these %s articles" (length articles))
8114 ;; Delete the articles.
8115 (setq not-deleted (gnus-request-expire-articles
8116 articles gnus-newsgroup-name 'force))
8118 (gnus-summary-remove-process-mark (car articles))
8119 ;; The backend might not have been able to delete the article
8121 (unless (memq (car articles) not-deleted)
8122 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
8123 (setq articles (cdr articles)))
8125 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
8126 (gnus-summary-position-point)
8127 (gnus-set-mode-line 'summary)
8130 (defun gnus-summary-edit-article (&optional arg)
8131 "Edit the current article.
8132 This will have permanent effect only in mail groups.
8133 If ARG is nil, edit the decoded articles.
8134 If ARG is 1, edit the raw articles.
8135 If ARG is 2, edit the raw articles even in read-only groups.
8136 If ARG is 3, edit the articles with the current handles.
8137 Otherwise, allow editing of articles even in read-only
8140 (let (force raw current-handles)
8143 ((eq arg 1) (setq raw t))
8144 ((eq arg 2) (setq raw t
8146 ((eq arg 3) (setq current-handles
8147 (and (gnus-buffer-live-p gnus-article-buffer)
8148 (with-current-buffer gnus-article-buffer
8150 gnus-article-mime-handles
8151 (setq gnus-article-mime-handles nil))))))
8153 (if (and raw (not force) (equal gnus-newsgroup-name "nndraft:drafts"))
8154 (error "Can't edit the raw article in group nndraft:drafts."))
8156 (set-buffer gnus-summary-buffer)
8157 (let ((mail-parse-charset gnus-newsgroup-charset)
8158 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
8159 (gnus-set-global-variables)
8160 (when (and (not force)
8161 (gnus-group-read-only-p))
8162 (error "The current newsgroup does not support article editing"))
8163 (gnus-summary-show-article t)
8164 (when (and (not raw) (gnus-buffer-live-p gnus-article-buffer))
8165 (with-current-buffer gnus-article-buffer
8166 (mm-enable-multibyte-mule4)))
8167 (if (equal gnus-newsgroup-name "nndraft:drafts")
8169 (gnus-article-edit-article
8172 (let ((mbl mml-buffer-list))
8173 (setq mml-buffer-list nil)
8174 (mime-to-mml ,'current-handles)
8175 (make-local-hook 'kill-buffer-hook)
8176 (let ((mbl1 mml-buffer-list))
8177 (setq mml-buffer-list mbl)
8178 (set (make-local-variable 'mml-buffer-list) mbl1))
8179 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))))
8180 `(lambda (no-highlight)
8181 (let ((mail-parse-charset ',gnus-newsgroup-charset)
8182 (message-options message-options)
8183 (message-options-set-recipient)
8184 (mail-parse-ignored-charsets
8185 ',gnus-newsgroup-ignored-charsets))
8186 ,(if (not raw) '(progn
8188 (mml-destroy-buffers)
8189 (remove-hook 'kill-buffer-hook
8190 'mml-destroy-buffers t)
8191 (kill-local-variable 'mml-buffer-list)))
8192 (gnus-summary-edit-article-done
8193 ,(or (mail-header-references gnus-current-headers) "")
8194 ,(gnus-group-read-only-p)
8195 ,gnus-summary-buffer no-highlight))))))))
8197 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
8199 (defun gnus-summary-edit-article-done (&optional references read-only buffer
8201 "Make edits to the current article permanent."
8204 ;; The buffer restriction contains the entire article if it exists.
8205 (when (article-goto-body)
8206 (let ((lines (count-lines (point) (point-max)))
8207 (length (- (point-max) (point)))
8208 (case-fold-search t)
8209 (body (copy-marker (point))))
8210 (goto-char (point-min))
8211 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
8212 (delete-region (match-beginning 1) (match-end 1))
8213 (insert (number-to-string length)))
8214 (goto-char (point-min))
8215 (when (re-search-forward
8216 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
8217 (delete-region (match-beginning 1) (match-end 1))
8218 (insert (number-to-string length)))
8219 (goto-char (point-min))
8220 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
8221 (delete-region (match-beginning 1) (match-end 1))
8222 (insert (number-to-string lines))))))
8223 ;; Replace the article.
8224 (let ((buf (current-buffer)))
8226 (insert-buffer-substring buf)
8228 (if (and (not read-only)
8229 (not (gnus-request-replace-article
8230 (cdr gnus-article-current) (car gnus-article-current)
8231 (current-buffer) t)))
8232 (error "Couldn't replace article")
8233 ;; Update the summary buffer.
8235 (equal (message-tokenize-header references " ")
8236 (message-tokenize-header
8237 (or (message-fetch-field "references") "") " ")))
8238 ;; We only have to update this line.
8241 (message-narrow-to-head)
8242 (let ((head (buffer-string))
8245 (insert (format "211 %d Article retrieved.\n"
8246 (cdr gnus-article-current)))
8249 (let ((nntp-server-buffer (current-buffer)))
8250 (setq header (car (gnus-get-newsgroup-headers
8252 (set-buffer gnus-summary-buffer)
8253 gnus-newsgroup-dependencies)
8256 (set-buffer gnus-summary-buffer)
8257 (gnus-data-set-header
8258 (gnus-data-find (cdr gnus-article-current))
8260 (gnus-summary-update-article-line
8261 (cdr gnus-article-current) header))))))
8263 (set-buffer (or buffer gnus-summary-buffer))
8264 (gnus-summary-update-article (cdr gnus-article-current)))
8265 ;; Prettify the article buffer again.
8266 (unless no-highlight
8268 (set-buffer gnus-article-buffer)
8269 ;;;!!! Fix this -- article should be rehighlighted.
8270 ;;;(gnus-run-hooks 'gnus-article-display-hook)
8271 (set-buffer gnus-original-article-buffer)
8272 (gnus-request-article
8273 (cdr gnus-article-current)
8274 (car gnus-article-current) (current-buffer))))
8275 ;; Prettify the summary buffer line.
8276 (when (gnus-visual-p 'summary-highlight 'highlight)
8277 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
8279 (defun gnus-summary-edit-wash (key)
8280 "Perform editing command KEY in the article buffer."
8284 (message "%s" (concat (this-command-keys) "- "))
8287 (gnus-summary-edit-article)
8288 (execute-kbd-macro (concat (this-command-keys) key))
8289 (gnus-article-edit-done))
8293 (defun gnus-summary-respool-query (&optional silent trace)
8294 "Query where the respool algorithm would put this article."
8296 (let (gnus-mark-article-hook)
8297 (gnus-summary-select-article)
8299 (set-buffer gnus-original-article-buffer)
8301 (message-narrow-to-head)
8302 (let ((groups (nnmail-article-group 'identity trace)))
8305 (message "This message would go to %s"
8306 (mapconcat 'car groups ", "))
8307 (message "This message would go to no groups"))
8310 (defun gnus-summary-respool-trace ()
8311 "Trace where the respool algorithm would put this article.
8312 Display a buffer showing all fancy splitting patterns which matched."
8314 (gnus-summary-respool-query nil t))
8316 ;; Summary marking commands.
8318 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
8319 "Mark articles which has the same subject as read, and then select the next.
8320 If UNMARK is positive, remove any kind of mark.
8321 If UNMARK is negative, tick articles."
8324 (setq unmark (prefix-numeric-value unmark)))
8326 (gnus-summary-mark-same-subject
8327 (gnus-summary-article-subject) unmark)))
8328 ;; Select next unread article. If auto-select-same mode, should
8329 ;; select the first unread article.
8330 (gnus-summary-next-article t (and gnus-auto-select-same
8331 (gnus-summary-article-subject)))
8332 (gnus-message 7 "%d article%s marked as %s"
8333 count (if (= count 1) " is" "s are")
8334 (if unmark "unread" "read"))))
8336 (defun gnus-summary-kill-same-subject (&optional unmark)
8337 "Mark articles which has the same subject as read.
8338 If UNMARK is positive, remove any kind of mark.
8339 If UNMARK is negative, tick articles."
8342 (setq unmark (prefix-numeric-value unmark)))
8344 (gnus-summary-mark-same-subject
8345 (gnus-summary-article-subject) unmark)))
8346 ;; If marked as read, go to next unread subject.
8348 ;; Go to next unread subject.
8349 (gnus-summary-next-subject 1 t))
8350 (gnus-message 7 "%d articles are marked as %s"
8351 count (if unmark "unread" "read"))))
8353 (defun gnus-summary-mark-same-subject (subject &optional unmark)
8354 "Mark articles with same SUBJECT as read, and return marked number.
8355 If optional argument UNMARK is positive, remove any kinds of marks.
8356 If optional argument UNMARK is negative, mark articles as unread instead."
8360 ((null unmark) ; Mark as read.
8363 (gnus-summary-mark-article-as-read gnus-killed-mark)
8364 (gnus-summary-show-thread) t)
8365 (gnus-summary-find-subject subject))
8366 (setq count (1+ count))))
8367 ((> unmark 0) ; Tick.
8370 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
8371 (gnus-summary-show-thread) t)
8372 (gnus-summary-find-subject subject))
8373 (setq count (1+ count))))
8374 (t ; Mark as unread.
8377 (gnus-summary-mark-article-as-unread gnus-unread-mark)
8378 (gnus-summary-show-thread) t)
8379 (gnus-summary-find-subject subject))
8380 (setq count (1+ count)))))
8381 (gnus-set-mode-line 'summary)
8382 ;; Return the number of marked articles.
8385 (defun gnus-summary-mark-as-processable (n &optional unmark)
8386 "Set the process mark on the next N articles.
8387 If N is negative, mark backward instead. If UNMARK is non-nil, remove
8388 the process mark instead. The difference between N and the actual
8389 number of articles marked is returned."
8391 (if (and (null n) (gnus-region-active-p))
8392 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
8393 (setq n (prefix-numeric-value n))
8394 (let ((backward (< n 0))
8399 (gnus-summary-remove-process-mark
8400 (gnus-summary-article-number))
8401 (gnus-summary-set-process-mark (gnus-summary-article-number)))
8402 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
8405 (gnus-message 7 "No more articles"))
8406 (gnus-summary-recenter)
8407 (gnus-summary-position-point)
8410 (defun gnus-summary-unmark-as-processable (n)
8411 "Remove the process mark from the next N articles.
8412 If N is negative, unmark backward instead. The difference between N and
8413 the actual number of articles unmarked is returned."
8415 (gnus-summary-mark-as-processable n t))
8417 (defun gnus-summary-unmark-all-processable ()
8418 "Remove the process mark from all articles."
8421 (while gnus-newsgroup-processable
8422 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
8423 (gnus-summary-position-point))
8425 (defun gnus-summary-add-mark (article type)
8426 "Mark ARTICLE with a mark of TYPE."
8427 (let ((vtype (car (assq type gnus-article-mark-lists)))
8430 (error "No such mark type: %s" type)
8431 (setq var (intern (format "gnus-newsgroup-%s" type)))
8432 (set var (cons article (symbol-value var)))
8433 (if (memq type '(processable cached replied forwarded saved))
8434 (gnus-summary-update-secondary-mark article)
8435 ;;; !!! This is bobus. We should find out what primary
8436 ;;; !!! mark we want to set.
8437 (gnus-summary-update-mark gnus-del-mark 'unread)))))
8439 (defun gnus-summary-mark-as-expirable (n)
8440 "Mark N articles forward as expirable.
8441 If N is negative, mark backward instead. The difference between N and
8442 the actual number of articles marked is returned."
8444 (gnus-summary-mark-forward n gnus-expirable-mark))
8446 (defun gnus-summary-mark-article-as-replied (article)
8447 "Mark ARTICLE as replied to and update the summary line.
8448 ARTICLE can also be a list of articles."
8449 (interactive (list (gnus-summary-article-number)))
8450 (let ((articles (if (listp article) article (list article))))
8451 (dolist (article articles)
8452 (push article gnus-newsgroup-replied)
8453 (let ((buffer-read-only nil))
8454 (when (gnus-summary-goto-subject article nil t)
8455 (gnus-summary-update-secondary-mark article))))))
8457 (defun gnus-summary-mark-article-as-forwarded (article)
8458 "Mark ARTICLE as forwarded and update the summary line.
8459 ARTICLE can also be a list of articles."
8460 (let ((articles (if (listp article) article (list article))))
8461 (dolist (article articles)
8462 (push article gnus-newsgroup-forwarded)
8463 (let ((buffer-read-only nil))
8464 (when (gnus-summary-goto-subject article nil t)
8465 (gnus-summary-update-secondary-mark article))))))
8467 (defun gnus-summary-set-bookmark (article)
8468 "Set a bookmark in current article."
8469 (interactive (list (gnus-summary-article-number)))
8470 (when (or (not (get-buffer gnus-article-buffer))
8471 (not gnus-current-article)
8472 (not gnus-article-current)
8473 (not (equal gnus-newsgroup-name (car gnus-article-current))))
8474 (error "No current article selected"))
8475 ;; Remove old bookmark, if one exists.
8476 (let ((old (assq article gnus-newsgroup-bookmarks)))
8478 (setq gnus-newsgroup-bookmarks
8479 (delq old gnus-newsgroup-bookmarks))))
8480 ;; Set the new bookmark, which is on the form
8481 ;; (article-number . line-number-in-body).
8485 (set-buffer gnus-article-buffer)
8489 (goto-char (point-min))
8490 (search-forward "\n\n" nil t)
8493 gnus-newsgroup-bookmarks)
8494 (gnus-message 6 "A bookmark has been added to the current article."))
8496 (defun gnus-summary-remove-bookmark (article)
8497 "Remove the bookmark from the current article."
8498 (interactive (list (gnus-summary-article-number)))
8499 ;; Remove old bookmark, if one exists.
8500 (let ((old (assq article gnus-newsgroup-bookmarks)))
8503 (setq gnus-newsgroup-bookmarks
8504 (delq old gnus-newsgroup-bookmarks))
8505 (gnus-message 6 "Removed bookmark."))
8506 (gnus-message 6 "No bookmark in current article."))))
8508 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8509 (defun gnus-summary-mark-as-dormant (n)
8510 "Mark N articles forward as dormant.
8511 If N is negative, mark backward instead. The difference between N and
8512 the actual number of articles marked is returned."
8514 (gnus-summary-mark-forward n gnus-dormant-mark))
8516 (defun gnus-summary-set-process-mark (article)
8517 "Set the process mark on ARTICLE and update the summary line."
8518 (setq gnus-newsgroup-processable
8520 (delq article gnus-newsgroup-processable)))
8521 (when (gnus-summary-goto-subject article)
8522 (gnus-summary-show-thread)
8523 (gnus-summary-goto-subject article)
8524 (gnus-summary-update-secondary-mark article)))
8526 (defun gnus-summary-remove-process-mark (article)
8527 "Remove the process mark from ARTICLE and update the summary line."
8528 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
8529 (when (gnus-summary-goto-subject article)
8530 (gnus-summary-show-thread)
8531 (gnus-summary-goto-subject article)
8532 (gnus-summary-update-secondary-mark article)))
8534 (defun gnus-summary-set-saved-mark (article)
8535 "Set the process mark on ARTICLE and update the summary line."
8536 (push article gnus-newsgroup-saved)
8537 (when (gnus-summary-goto-subject article)
8538 (gnus-summary-update-secondary-mark article)))
8540 (defun gnus-summary-mark-forward (n &optional mark no-expire)
8541 "Mark N articles as read forwards.
8542 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
8543 The difference between N and the actual number of articles marked is
8545 Iff NO-EXPIRE, auto-expiry will be inhibited."
8547 (gnus-summary-show-thread)
8548 (let ((backward (< n 0))
8549 (gnus-summary-goto-unread
8550 (and gnus-summary-goto-unread
8551 (not (eq gnus-summary-goto-unread 'never))
8552 (not (memq mark (list gnus-unread-mark
8553 gnus-ticked-mark gnus-dormant-mark)))))
8555 (mark (or mark gnus-del-mark)))
8557 (gnus-summary-mark-article nil mark no-expire)
8558 (zerop (gnus-summary-next-subject
8560 (and gnus-summary-goto-unread
8561 (not (eq gnus-summary-goto-unread 'never)))
8565 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
8566 (gnus-summary-recenter)
8567 (gnus-summary-position-point)
8568 (gnus-set-mode-line 'summary)
8571 (defun gnus-summary-mark-article-as-read (mark)
8572 "Mark the current article quickly as read with MARK."
8573 (let ((article (gnus-summary-article-number)))
8574 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8575 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8576 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8577 (push (cons article mark) gnus-newsgroup-reads)
8578 ;; Possibly remove from cache, if that is used.
8579 (when gnus-use-cache
8580 (gnus-cache-enter-remove-article article))
8581 ;; Allow the backend to change the mark.
8582 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8583 ;; Check for auto-expiry.
8584 (when (and gnus-newsgroup-auto-expire
8585 (memq mark gnus-auto-expirable-marks))
8586 (setq mark gnus-expirable-mark)
8587 ;; Let the backend know about the mark change.
8588 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8589 (push article gnus-newsgroup-expirable))
8590 ;; Set the mark in the buffer.
8591 (gnus-summary-update-mark mark 'unread)
8594 (defun gnus-summary-mark-article-as-unread (mark)
8595 "Mark the current article quickly as unread with MARK."
8596 (let* ((article (gnus-summary-article-number))
8597 (old-mark (gnus-summary-article-mark article)))
8598 ;; Allow the backend to change the mark.
8599 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8600 (if (eq mark old-mark)
8604 (gnus-error 1 "Can't mark negative article numbers")
8606 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8607 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8608 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
8609 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
8610 (cond ((= mark gnus-ticked-mark)
8611 (push article gnus-newsgroup-marked))
8612 ((= mark gnus-dormant-mark)
8613 (push article gnus-newsgroup-dormant))
8615 (push article gnus-newsgroup-unreads)))
8616 (gnus-pull article gnus-newsgroup-reads)
8618 ;; See whether the article is to be put in the cache.
8620 (vectorp (gnus-summary-article-header article))
8622 (gnus-cache-possibly-enter-article
8623 gnus-newsgroup-name article
8624 (= mark gnus-ticked-mark)
8625 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
8628 (gnus-summary-update-mark mark 'unread)
8631 (defun gnus-summary-mark-article (&optional article mark no-expire)
8632 "Mark ARTICLE with MARK. MARK can be any character.
8633 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
8634 `??' (dormant) and `?E' (expirable).
8635 If MARK is nil, then the default character `?r' is used.
8636 If ARTICLE is nil, then the article on the current line will be
8638 Iff NO-EXPIRE, auto-expiry will be inhibited."
8639 ;; The mark might be a string.
8640 (when (stringp mark)
8641 (setq mark (aref mark 0)))
8642 ;; If no mark is given, then we check auto-expiring.
8644 (setq mark gnus-del-mark))
8645 (when (and (not no-expire)
8646 gnus-newsgroup-auto-expire
8647 (memq mark gnus-auto-expirable-marks))
8648 (setq mark gnus-expirable-mark))
8649 (let ((article (or article (gnus-summary-article-number)))
8650 (old-mark (gnus-summary-article-mark article)))
8651 ;; Allow the backend to change the mark.
8652 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8653 (if (eq mark old-mark)
8656 (error "No article on current line"))
8657 (if (not (if (or (= mark gnus-unread-mark)
8658 (= mark gnus-ticked-mark)
8659 (= mark gnus-dormant-mark))
8660 (gnus-mark-article-as-unread article mark)
8661 (gnus-mark-article-as-read article mark)))
8663 ;; See whether the article is to be put in the cache.
8665 (not (= mark gnus-canceled-mark))
8666 (vectorp (gnus-summary-article-header article))
8668 (gnus-cache-possibly-enter-article
8669 gnus-newsgroup-name article
8670 (= mark gnus-ticked-mark)
8671 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
8673 (when (gnus-summary-goto-subject article nil t)
8674 (let ((buffer-read-only nil))
8675 (gnus-summary-show-thread)
8677 (gnus-summary-update-mark mark 'unread)
8680 (defun gnus-summary-update-secondary-mark (article)
8681 "Update the secondary (read, process, cache) mark."
8682 (gnus-summary-update-mark
8683 (cond ((memq article gnus-newsgroup-processable)
8685 ((memq article gnus-newsgroup-cached)
8687 ((memq article gnus-newsgroup-replied)
8689 ((memq article gnus-newsgroup-forwarded)
8690 gnus-forwarded-mark)
8691 ((memq article gnus-newsgroup-saved)
8695 (when (gnus-visual-p 'summary-highlight 'highlight)
8696 (gnus-run-hooks 'gnus-summary-update-hook))
8699 (defun gnus-summary-update-mark (mark type)
8700 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
8701 (buffer-read-only nil))
8702 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
8704 (when (looking-at "\r")
8706 (when (<= (+ forward (point)) (point-max))
8707 ;; Go to the right position on the line.
8708 (goto-char (+ forward (point)))
8709 ;; Replace the old mark with the new mark.
8710 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
8711 ;; Optionally update the marks by some user rule.
8712 (when (eq type 'unread)
8714 (gnus-data-find (gnus-summary-article-number)) mark)
8715 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
8717 (defun gnus-mark-article-as-read (article &optional mark)
8718 "Enter ARTICLE in the pertinent lists and remove it from others."
8719 ;; Make the article expirable.
8720 (let ((mark (or mark gnus-del-mark)))
8721 (if (= mark gnus-expirable-mark)
8722 (push article gnus-newsgroup-expirable)
8723 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
8724 ;; Remove from unread and marked lists.
8725 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8726 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8727 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8728 (push (cons article mark) gnus-newsgroup-reads)
8729 ;; Possibly remove from cache, if that is used.
8730 (when gnus-use-cache
8731 (gnus-cache-enter-remove-article article))
8734 (defun gnus-mark-article-as-unread (article &optional mark)
8735 "Enter ARTICLE in the pertinent lists and remove it from others."
8736 (let ((mark (or mark gnus-ticked-mark)))
8739 (gnus-error 1 "Can't mark negative article numbers")
8741 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
8742 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
8743 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
8744 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8746 ;; Unsuppress duplicates?
8747 (when gnus-suppress-duplicates
8748 (gnus-dup-unsuppress-article article))
8750 (cond ((= mark gnus-ticked-mark)
8751 (push article gnus-newsgroup-marked))
8752 ((= mark gnus-dormant-mark)
8753 (push article gnus-newsgroup-dormant))
8755 (push article gnus-newsgroup-unreads)))
8756 (gnus-pull article gnus-newsgroup-reads)
8759 (defalias 'gnus-summary-mark-as-unread-forward
8760 'gnus-summary-tick-article-forward)
8761 (make-obsolete 'gnus-summary-mark-as-unread-forward
8762 'gnus-summary-tick-article-forward)
8763 (defun gnus-summary-tick-article-forward (n)
8764 "Tick N articles forwards.
8765 If N is negative, tick backwards instead.
8766 The difference between N and the number of articles ticked is returned."
8768 (gnus-summary-mark-forward n gnus-ticked-mark))
8770 (defalias 'gnus-summary-mark-as-unread-backward
8771 'gnus-summary-tick-article-backward)
8772 (make-obsolete 'gnus-summary-mark-as-unread-backward
8773 'gnus-summary-tick-article-backward)
8774 (defun gnus-summary-tick-article-backward (n)
8775 "Tick N articles backwards.
8776 The difference between N and the number of articles ticked is returned."
8778 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
8780 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8781 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8782 (defun gnus-summary-tick-article (&optional article clear-mark)
8783 "Mark current article as unread.
8784 Optional 1st argument ARTICLE specifies article number to be marked as unread.
8785 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
8787 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
8790 (defun gnus-summary-mark-as-read-forward (n)
8791 "Mark N articles as read forwards.
8792 If N is negative, mark backwards instead.
8793 The difference between N and the actual number of articles marked is
8796 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
8798 (defun gnus-summary-mark-as-read-backward (n)
8799 "Mark the N articles as read backwards.
8800 The difference between N and the actual number of articles marked is
8803 (gnus-summary-mark-forward
8804 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
8806 (defun gnus-summary-mark-as-read (&optional article mark)
8807 "Mark current article as read.
8808 ARTICLE specifies the article to be marked as read.
8809 MARK specifies a string to be inserted at the beginning of the line."
8810 (gnus-summary-mark-article article mark))
8812 (defun gnus-summary-clear-mark-forward (n)
8813 "Clear marks from N articles forward.
8814 If N is negative, clear backward instead.
8815 The difference between N and the number of marks cleared is returned."
8817 (gnus-summary-mark-forward n gnus-unread-mark))
8819 (defun gnus-summary-clear-mark-backward (n)
8820 "Clear marks from N articles backward.
8821 The difference between N and the number of marks cleared is returned."
8823 (gnus-summary-mark-forward (- n) gnus-unread-mark))
8825 (defun gnus-summary-mark-unread-as-read ()
8826 "Intended to be used by `gnus-summary-mark-article-hook'."
8827 (when (memq gnus-current-article gnus-newsgroup-unreads)
8828 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
8830 (defun gnus-summary-mark-read-and-unread-as-read ()
8831 "Intended to be used by `gnus-summary-mark-article-hook'."
8832 (let ((mark (gnus-summary-article-mark)))
8833 (when (or (gnus-unread-mark-p mark)
8834 (gnus-read-mark-p mark))
8835 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
8837 (defun gnus-summary-mark-unread-as-ticked ()
8838 "Intended to be used by `gnus-summary-mark-article-hook'."
8839 (when (memq gnus-current-article gnus-newsgroup-unreads)
8840 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
8842 (defun gnus-summary-mark-region-as-read (point mark all)
8843 "Mark all unread articles between point and mark as read.
8844 If given a prefix, mark all articles between point and mark as read,
8845 even ticked and dormant ones."
8846 (interactive "r\nP")
8855 (memq (setq article (gnus-summary-article-number))
8856 gnus-newsgroup-unreads))
8857 (gnus-summary-mark-article article gnus-del-mark))
8859 (gnus-summary-find-next))))))
8861 (defun gnus-summary-mark-below (score mark)
8862 "Mark articles with score less than SCORE with MARK."
8863 (interactive "P\ncMark: ")
8864 (setq score (if score
8865 (prefix-numeric-value score)
8866 (or gnus-summary-default-score 0)))
8868 (set-buffer gnus-summary-buffer)
8869 (goto-char (point-min))
8872 (and (< (gnus-summary-article-score) score)
8873 (gnus-summary-mark-article nil mark))
8874 (gnus-summary-find-next)))))
8876 (defun gnus-summary-kill-below (&optional score)
8877 "Mark articles with score below SCORE as read."
8879 (gnus-summary-mark-below score gnus-killed-mark))
8881 (defun gnus-summary-clear-above (&optional score)
8882 "Clear all marks from articles with score above SCORE."
8884 (gnus-summary-mark-above score gnus-unread-mark))
8886 (defun gnus-summary-tick-above (&optional score)
8887 "Tick all articles with score above SCORE."
8889 (gnus-summary-mark-above score gnus-ticked-mark))
8891 (defun gnus-summary-mark-above (score mark)
8892 "Mark articles with score over SCORE with MARK."
8893 (interactive "P\ncMark: ")
8894 (setq score (if score
8895 (prefix-numeric-value score)
8896 (or gnus-summary-default-score 0)))
8898 (set-buffer gnus-summary-buffer)
8899 (goto-char (point-min))
8901 (when (> (gnus-summary-article-score) score)
8902 (gnus-summary-mark-article nil mark))
8904 (gnus-summary-find-next)))))
8906 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8907 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
8908 (defun gnus-summary-limit-include-expunged (&optional no-error)
8909 "Display all the hidden articles that were expunged for low scores."
8911 (let ((buffer-read-only nil))
8912 (let ((scored gnus-newsgroup-scored)
8915 (unless (gnus-summary-article-header (caar scored))
8916 (and (setq h (gnus-number-to-header (caar scored)))
8917 (< (cdar scored) gnus-summary-expunge-below)
8919 (setq scored (cdr scored)))
8921 (when (not no-error)
8922 (error "No expunged articles hidden"))
8923 (goto-char (point-min))
8924 (push gnus-newsgroup-limit gnus-newsgroup-limits)
8925 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
8926 (mapcar (lambda (x) (push (mail-header-number x)
8927 gnus-newsgroup-limit))
8929 (gnus-summary-prepare-unthreaded (nreverse headers))
8930 (goto-char (point-min))
8931 (gnus-summary-position-point)
8934 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
8935 "Mark all unread articles in this newsgroup as read.
8936 If prefix argument ALL is non-nil, ticked and dormant articles will
8937 also be marked as read.
8938 If QUIETLY is non-nil, no questions will be asked.
8939 If TO-HERE is non-nil, it should be a point in the buffer. All
8940 articles before this point will be marked as read.
8941 Note that this function will only catch up the unread article
8942 in the current summary buffer limitation.
8943 The number of articles marked as read is returned."
8948 (not gnus-interactive-catchup) ;Without confirmation?
8952 "Mark absolutely all articles as read? "
8953 "Mark all unread articles as read? ")))
8955 (not gnus-newsgroup-adaptive)
8956 (not gnus-newsgroup-auto-expire)
8957 (not gnus-suppress-duplicates)
8958 (or (not gnus-use-cache)
8959 (eq gnus-use-cache 'passive)))
8962 (setq gnus-newsgroup-marked nil
8963 gnus-newsgroup-dormant nil))
8964 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
8965 ;; We actually mark all articles as canceled, which we
8966 ;; have to do when using auto-expiry or adaptive scoring.
8967 (gnus-summary-show-all-threads)
8968 (when (gnus-summary-first-subject (not all) t)
8970 (if to-here (< (point) to-here) t)
8971 (gnus-summary-mark-article-as-read gnus-catchup-mark)
8972 (gnus-summary-find-next (not all) nil nil t))))
8973 (gnus-set-mode-line 'summary))
8975 (gnus-summary-position-point)))
8977 (defun gnus-summary-catchup-to-here (&optional all)
8978 "Mark all unticked articles before the current one as read.
8979 If ALL is non-nil, also mark ticked and dormant articles as read."
8982 (gnus-save-hidden-threads
8983 (let ((beg (point)))
8984 ;; We check that there are unread articles.
8985 (when (or all (gnus-summary-find-prev))
8986 (gnus-summary-catchup all t beg)))))
8987 (gnus-summary-position-point))
8989 (defun gnus-summary-catchup-all (&optional quietly)
8990 "Mark all articles in this newsgroup as read."
8992 (gnus-summary-catchup t quietly))
8994 (defun gnus-summary-catchup-and-exit (&optional all quietly)
8995 "Mark all unread articles in this group as read, then exit.
8996 If prefix argument ALL is non-nil, all articles are marked as read.
8997 If QUIETLY is non-nil, no questions will be asked."
8999 (when (gnus-summary-catchup all quietly nil 'fast)
9000 ;; Select next newsgroup or exit.
9001 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
9002 (eq gnus-auto-select-next 'quietly))
9003 (gnus-summary-next-group nil)
9004 (gnus-summary-exit))))
9006 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
9007 "Mark all articles in this newsgroup as read, and then exit."
9009 (gnus-summary-catchup-and-exit t quietly))
9011 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
9012 "Mark all articles in this group as read and select the next group.
9013 If given a prefix, mark all articles, unread as well as ticked, as
9017 (gnus-summary-catchup all))
9018 (gnus-summary-next-group))
9024 (defmacro gnus-with-article (article &rest forms)
9025 "Select ARTICLE and perform FORMS in the original article buffer.
9026 Then replace the article with the result."
9028 ;; We don't want the article to be marked as read.
9029 (let (gnus-mark-article-hook)
9030 (gnus-summary-select-article t t nil ,article))
9031 (set-buffer gnus-original-article-buffer)
9033 (if (not (gnus-check-backend-function
9034 'request-replace-article (car gnus-article-current)))
9035 (gnus-message 5 "Read-only group; not replacing")
9036 (unless (gnus-request-replace-article
9037 ,article (car gnus-article-current)
9039 (error "Couldn't replace article")))
9040 ;; The cache and backlog have to be flushed somewhat.
9041 (when gnus-keep-backlog
9042 (gnus-backlog-remove-article
9043 (car gnus-article-current) (cdr gnus-article-current)))
9044 (when gnus-use-cache
9045 (gnus-cache-update-article
9046 (car gnus-article-current) (cdr gnus-article-current)))))
9048 (put 'gnus-with-article 'lisp-indent-function 1)
9049 (put 'gnus-with-article 'edebug-form-spec '(form body))
9051 ;; Thread-based commands.
9053 (defun gnus-summary-articles-in-thread (&optional article)
9054 "Return a list of all articles in the current thread.
9055 If ARTICLE is non-nil, return all articles in the thread that starts
9057 (let* ((article (or article (gnus-summary-article-number)))
9058 (data (gnus-data-find-list article))
9059 (top-level (gnus-data-level (car data)))
9061 (cond ((null gnus-thread-operation-ignore-subject)
9062 (gnus-simplify-subject-re
9063 (mail-header-subject (gnus-data-header (car data)))))
9064 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
9065 (gnus-simplify-subject-fuzzy
9066 (mail-header-subject (gnus-data-header (car data)))))
9068 (end-point (save-excursion
9069 (if (gnus-summary-go-to-next-thread)
9070 (point) (point-max))))
9073 (< (gnus-data-pos (car data)) end-point))
9074 (when (or (not top-subject)
9075 (string= top-subject
9076 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
9077 (gnus-simplify-subject-fuzzy
9078 (mail-header-subject
9079 (gnus-data-header (car data))))
9080 (gnus-simplify-subject-re
9081 (mail-header-subject
9082 (gnus-data-header (car data)))))))
9083 (push (gnus-data-number (car data)) articles))
9084 (unless (and (setq data (cdr data))
9085 (> (gnus-data-level (car data)) top-level))
9087 ;; Return the list of articles.
9088 (nreverse articles)))
9090 (defun gnus-summary-rethread-current ()
9091 "Rethread the thread the current article is part of."
9093 (let* ((gnus-show-threads t)
9094 (article (gnus-summary-article-number))
9095 (id (mail-header-id (gnus-summary-article-header)))
9096 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
9098 (error "No article on the current line"))
9099 (gnus-rebuild-thread id)
9100 (gnus-summary-goto-subject article)))
9102 (defun gnus-summary-reparent-thread ()
9103 "Make the current article child of the marked (or previous) article.
9105 Note that the re-threading will only work if `gnus-thread-ignore-subject'
9106 is non-nil or the Subject: of both articles are the same."
9108 (unless (not (gnus-group-read-only-p))
9109 (error "The current newsgroup does not support article editing"))
9110 (unless (<= (length gnus-newsgroup-processable) 1)
9111 (error "No more than one article may be marked"))
9112 (save-window-excursion
9113 (let ((gnus-article-buffer " *reparent*")
9114 (current-article (gnus-summary-article-number))
9115 ;; First grab the marked article, otherwise one line up.
9116 (parent-article (if (not (null gnus-newsgroup-processable))
9117 (car gnus-newsgroup-processable)
9119 (if (eq (forward-line -1) 0)
9120 (gnus-summary-article-number)
9121 (error "Beginning of summary buffer"))))))
9122 (unless (not (eq current-article parent-article))
9123 (error "An article may not be self-referential"))
9124 (let ((message-id (mail-header-id
9125 (gnus-summary-article-header parent-article))))
9126 (unless (and message-id (not (equal message-id "")))
9127 (error "No message-id in desired parent"))
9128 (gnus-with-article current-article
9130 (goto-char (point-min))
9131 (message-narrow-to-head)
9132 (if (re-search-forward "^References: " nil t)
9134 (re-search-forward "^[^ \t]" nil t)
9137 (insert " " message-id))
9138 (insert "References: " message-id "\n"))))
9139 (set-buffer gnus-summary-buffer)
9140 (gnus-summary-unmark-all-processable)
9141 (gnus-summary-update-article current-article)
9142 (gnus-summary-rethread-current)
9143 (gnus-message 3 "Article %d is now the child of article %d"
9144 current-article parent-article)))))
9146 (defun gnus-summary-toggle-threads (&optional arg)
9147 "Toggle showing conversation threads.
9148 If ARG is positive number, turn showing conversation threads on."
9150 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
9151 (setq gnus-show-threads
9152 (if (null arg) (not gnus-show-threads)
9153 (> (prefix-numeric-value arg) 0)))
9154 (gnus-summary-prepare)
9155 (gnus-summary-goto-subject current)
9156 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
9157 (gnus-summary-position-point)))
9159 (defun gnus-summary-show-all-threads ()
9163 (let ((buffer-read-only nil))
9164 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
9165 (gnus-summary-position-point))
9167 (defun gnus-summary-show-thread ()
9168 "Show thread subtrees.
9169 Returns nil if no thread was there to be shown."
9171 (let ((buffer-read-only nil)
9173 ;; first goto end then to beg, to have point at beg after let
9174 (end (progn (end-of-line) (point)))
9175 (beg (progn (beginning-of-line) (point))))
9177 ;; Any hidden lines here?
9178 (search-forward "\r" end t)
9179 (subst-char-in-region beg end ?\^M ?\n t)
9181 (gnus-summary-position-point))))
9183 (defun gnus-summary-hide-all-threads ()
9184 "Hide all thread subtrees."
9187 (goto-char (point-min))
9188 (gnus-summary-hide-thread)
9189 (while (zerop (gnus-summary-next-thread 1 t))
9190 (gnus-summary-hide-thread)))
9191 (gnus-summary-position-point))
9193 (defun gnus-summary-hide-thread ()
9194 "Hide thread subtrees.
9195 Returns nil if no threads were there to be hidden."
9197 (let ((buffer-read-only nil)
9199 (article (gnus-summary-article-number)))
9201 ;; Go forward until either the buffer ends or the subthread
9203 (when (and (not (eobp))
9204 (or (zerop (gnus-summary-next-thread 1 t))
9205 (goto-char (point-max))))
9207 (if (and (> (point) start)
9208 (search-backward "\n" start t))
9210 (subst-char-in-region start (point) ?\n ?\^M)
9211 (gnus-summary-goto-subject article))
9215 (defun gnus-summary-go-to-next-thread (&optional previous)
9216 "Go to the same level (or less) next thread.
9217 If PREVIOUS is non-nil, go to previous thread instead.
9218 Return the article number moved to, or nil if moving was impossible."
9219 (let ((level (gnus-summary-thread-level))
9220 (way (if previous -1 1))
9223 (while (and (not (eobp))
9224 (< level (gnus-summary-thread-level)))
9232 (gnus-summary-article-number)
9235 (defun gnus-summary-next-thread (n &optional silent)
9236 "Go to the same level next N'th thread.
9237 If N is negative, search backward instead.
9238 Returns the difference between N and the number of skips actually
9241 If SILENT, don't output messages."
9243 (let ((backward (< n 0))
9246 (gnus-summary-go-to-next-thread backward))
9249 (gnus-summary-position-point))
9250 (when (and (not silent) (/= 0 n))
9251 (gnus-message 7 "No more threads"))
9254 (defun gnus-summary-prev-thread (n)
9255 "Go to the same level previous N'th thread.
9256 Returns the difference between N and the number of skips actually
9259 (gnus-summary-next-thread (- n)))
9261 (defun gnus-summary-go-down-thread ()
9262 "Go down one level in the current thread."
9263 (let ((children (gnus-summary-article-children)))
9265 (gnus-summary-goto-subject (car children)))))
9267 (defun gnus-summary-go-up-thread ()
9268 "Go up one level in the current thread."
9269 (let ((parent (gnus-summary-article-parent)))
9271 (gnus-summary-goto-subject parent))))
9273 (defun gnus-summary-down-thread (n)
9274 "Go down thread N steps.
9275 If N is negative, go up instead.
9276 Returns the difference between N and how many steps down that were
9282 (if up (gnus-summary-go-up-thread)
9283 (gnus-summary-go-down-thread)))
9285 (gnus-summary-position-point)
9287 (gnus-message 7 "Can't go further"))
9290 (defun gnus-summary-up-thread (n)
9291 "Go up thread N steps.
9292 If N is negative, go down instead.
9293 Returns the difference between N and how many steps down that were
9296 (gnus-summary-down-thread (- n)))
9298 (defun gnus-summary-top-thread ()
9299 "Go to the top of the thread."
9301 (while (gnus-summary-go-up-thread))
9302 (gnus-summary-article-number))
9304 (defun gnus-summary-kill-thread (&optional unmark)
9305 "Mark articles under current thread as read.
9306 If the prefix argument is positive, remove any kinds of marks.
9307 If the prefix argument is negative, tick articles instead."
9310 (setq unmark (prefix-numeric-value unmark)))
9311 (let ((articles (gnus-summary-articles-in-thread)))
9313 ;; Expand the thread.
9314 (gnus-summary-show-thread)
9315 ;; Mark all the articles.
9317 (gnus-summary-goto-subject (car articles))
9318 (cond ((null unmark)
9319 (gnus-summary-mark-article-as-read gnus-killed-mark))
9321 (gnus-summary-mark-article-as-unread gnus-unread-mark))
9323 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
9324 (setq articles (cdr articles))))
9325 ;; Hide killed subtrees.
9327 gnus-thread-hide-killed
9328 (gnus-summary-hide-thread))
9329 ;; If marked as read, go to next unread subject.
9331 ;; Go to next unread subject.
9332 (gnus-summary-next-subject 1 t)))
9333 (gnus-set-mode-line 'summary))
9335 ;; Summary sorting commands
9337 (defun gnus-summary-sort-by-number (&optional reverse)
9338 "Sort the summary buffer by article number.
9339 Argument REVERSE means reverse order."
9341 (gnus-summary-sort 'number reverse))
9343 (defun gnus-summary-sort-by-author (&optional reverse)
9344 "Sort the summary buffer by author name alphabetically.
9345 If `case-fold-search' is non-nil, case of letters is ignored.
9346 Argument REVERSE means reverse order."
9348 (gnus-summary-sort 'author reverse))
9350 (defun gnus-summary-sort-by-subject (&optional reverse)
9351 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
9352 If `case-fold-search' is non-nil, case of letters is ignored.
9353 Argument REVERSE means reverse order."
9355 (gnus-summary-sort 'subject reverse))
9357 (defun gnus-summary-sort-by-date (&optional reverse)
9358 "Sort the summary buffer by date.
9359 Argument REVERSE means reverse order."
9361 (gnus-summary-sort 'date reverse))
9363 (defun gnus-summary-sort-by-score (&optional reverse)
9364 "Sort the summary buffer by score.
9365 Argument REVERSE means reverse order."
9367 (gnus-summary-sort 'score reverse))
9369 (defun gnus-summary-sort-by-lines (&optional reverse)
9370 "Sort the summary buffer by the number of lines.
9371 Argument REVERSE means reverse order."
9373 (gnus-summary-sort 'lines reverse))
9375 (defun gnus-summary-sort-by-chars (&optional reverse)
9376 "Sort the summary buffer by article length.
9377 Argument REVERSE means reverse order."
9379 (gnus-summary-sort 'chars reverse))
9381 (defun gnus-summary-sort-by-original (&optional reverse)
9382 "Sort the summary buffer using the default sorting method.
9383 Argument REVERSE means reverse order."
9385 (let* ((buffer-read-only)
9386 (gnus-summary-prepare-hook nil))
9387 ;; We do the sorting by regenerating the threads.
9388 (gnus-summary-prepare)
9389 ;; Hide subthreads if needed.
9390 (when (and gnus-show-threads gnus-thread-hide-subtree)
9391 (gnus-summary-hide-all-threads))))
9393 (defun gnus-summary-sort (predicate reverse)
9394 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
9395 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
9396 (article (intern (format "gnus-article-sort-by-%s" predicate)))
9397 (gnus-thread-sort-functions
9402 (gnus-sort-gathered-threads-function
9403 gnus-thread-sort-functions)
9404 (gnus-article-sort-functions
9410 (gnus-summary-prepare-hook nil))
9411 ;; We do the sorting by regenerating the threads.
9412 (gnus-summary-prepare)
9413 ;; Hide subthreads if needed.
9414 (when (and gnus-show-threads gnus-thread-hide-subtree)
9415 (gnus-summary-hide-all-threads))))
9417 ;; Summary saving commands.
9419 (defun gnus-summary-save-article (&optional n not-saved)
9420 "Save the current article using the default saver function.
9421 If N is a positive number, save the N next articles.
9422 If N is a negative number, save the N previous articles.
9423 If N is nil and any articles have been marked with the process mark,
9424 save those articles instead.
9425 The variable `gnus-default-article-saver' specifies the saver function."
9427 (let* ((articles (gnus-summary-work-articles n))
9428 (save-buffer (save-excursion
9429 (nnheader-set-temp-buffer " *Gnus Save*")))
9430 (num (length articles))
9432 (dolist (article articles)
9433 (setq header (gnus-summary-article-header article))
9434 (if (not (vectorp header))
9435 ;; This is a pseudo-article.
9436 (if (assq 'name header)
9437 (gnus-copy-file (cdr (assq 'name header)))
9438 (gnus-message 1 "Article %d is unsaveable" article))
9439 ;; This is a real article.
9440 (save-window-excursion
9441 (gnus-summary-select-article t nil nil article))
9443 (set-buffer save-buffer)
9445 (insert-buffer-substring gnus-original-article-buffer))
9446 (setq file (gnus-article-save save-buffer file num))
9447 (gnus-summary-remove-process-mark article)
9449 (gnus-summary-set-saved-mark article))))
9450 (gnus-kill-buffer save-buffer)
9451 (gnus-summary-position-point)
9452 (gnus-set-mode-line 'summary)
9455 (defun gnus-summary-pipe-output (&optional arg)
9456 "Pipe the current article to a subprocess.
9457 If N is a positive number, pipe the N next articles.
9458 If N is a negative number, pipe the N previous articles.
9459 If N is nil and any articles have been marked with the process mark,
9460 pipe those articles instead."
9463 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
9464 (gnus-summary-save-article arg t))
9465 (gnus-configure-windows 'pipe))
9467 (defun gnus-summary-save-article-mail (&optional arg)
9468 "Append the current article to an mail file.
9469 If N is a positive number, save the N next articles.
9470 If N is a negative number, save the N previous articles.
9471 If N is nil and any articles have been marked with the process mark,
9472 save those articles instead."
9475 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
9476 (gnus-summary-save-article arg)))
9478 (defun gnus-summary-save-article-rmail (&optional arg)
9479 "Append the current article to an rmail file.
9480 If N is a positive number, save the N next articles.
9481 If N is a negative number, save the N previous articles.
9482 If N is nil and any articles have been marked with the process mark,
9483 save those articles instead."
9486 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
9487 (gnus-summary-save-article arg)))
9489 (defun gnus-summary-save-article-file (&optional arg)
9490 "Append the current article to a file.
9491 If N is a positive number, save the N next articles.
9492 If N is a negative number, save the N previous articles.
9493 If N is nil and any articles have been marked with the process mark,
9494 save those articles instead."
9497 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
9498 (gnus-summary-save-article arg)))
9500 (defun gnus-summary-write-article-file (&optional arg)
9501 "Write the current article to a file, deleting the previous file.
9502 If N is a positive number, save the N next articles.
9503 If N is a negative number, save the N previous articles.
9504 If N is nil and any articles have been marked with the process mark,
9505 save those articles instead."
9508 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
9509 (gnus-summary-save-article arg)))
9511 (defun gnus-summary-save-article-body-file (&optional arg)
9512 "Append the current article body to a file.
9513 If N is a positive number, save the N next articles.
9514 If N is a negative number, save the N previous articles.
9515 If N is nil and any articles have been marked with the process mark,
9516 save those articles instead."
9519 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
9520 (gnus-summary-save-article arg)))
9522 (defun gnus-summary-pipe-message (program)
9523 "Pipe the current article through PROGRAM."
9524 (interactive "sProgram: ")
9525 (gnus-summary-select-article)
9526 (let ((mail-header-separator ""))
9527 (gnus-eval-in-buffer-window gnus-article-buffer
9530 (let ((start (window-start))
9532 (message-pipe-buffer-body program)
9533 (set-window-start (get-buffer-window (current-buffer)) start))))))
9535 (defun gnus-get-split-value (methods)
9536 "Return a value based on the split METHODS."
9537 (let (split-name method result match)
9540 (set-buffer gnus-original-article-buffer)
9542 (nnheader-narrow-to-headers)
9543 (while (and methods (not split-name))
9544 (goto-char (point-min))
9545 (setq method (pop methods))
9546 (setq match (car method))
9549 ;; Regular expression.
9551 (re-search-forward match nil t)))
9552 ((gnus-functionp match)
9556 (setq result (funcall match gnus-newsgroup-name))))
9561 (setq result (eval match)))))
9562 (setq split-name (cdr method))
9563 (cond ((stringp result)
9564 (push (expand-file-name
9565 result gnus-article-save-directory)
9568 (setq split-name (append result split-name)))))))))
9569 (nreverse split-name)))
9571 (defun gnus-valid-move-group-p (group)
9574 (symbol-value group)
9575 (gnus-get-function (gnus-find-method-for-group
9576 (symbol-name group)) 'request-accept-article t)))
9578 (defun gnus-read-move-group-name (prompt default articles prefix)
9579 "Read a group name."
9580 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
9581 (minibuffer-confirm-incomplete nil) ; XEmacs
9585 (if (> (length articles) 1)
9586 (format "these %d articles" (length articles))
9591 (gnus-completing-read default prom
9593 'gnus-valid-move-group-p
9595 'gnus-group-history))
9596 ((= 1 (length split-name))
9597 (gnus-completing-read (car split-name) prom
9599 'gnus-valid-move-group-p
9601 'gnus-group-history))
9603 (gnus-completing-read nil prom
9604 (mapcar (lambda (el) (list el))
9605 (nreverse split-name))
9607 'gnus-group-history))))
9608 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
9610 (if (or (string= to-newsgroup "")
9611 (string= to-newsgroup prefix))
9612 (setq to-newsgroup default))
9613 (unless to-newsgroup
9614 (error "No group name entered"))
9615 (or (gnus-active to-newsgroup)
9616 (gnus-activate-group to-newsgroup nil nil to-method)
9617 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
9619 (or (and (gnus-request-create-group to-newsgroup to-method)
9620 (gnus-activate-group
9621 to-newsgroup nil nil to-method)
9622 (gnus-subscribe-group to-newsgroup))
9623 (error "Couldn't create group %s" to-newsgroup)))
9624 (error "No such group: %s" to-newsgroup)))
9627 (defun gnus-summary-save-parts (type dir n &optional reverse)
9628 "Save parts matching TYPE to DIR.
9629 If REVERSE, save parts that do not match TYPE."
9631 (list (read-string "Save parts of type: "
9632 (or (car gnus-summary-save-parts-type-history)
9633 gnus-summary-save-parts-default-mime)
9634 'gnus-summary-save-parts-type-history)
9635 (setq gnus-summary-save-parts-last-directory
9636 (read-file-name "Save to directory: "
9637 gnus-summary-save-parts-last-directory
9639 current-prefix-arg))
9640 (gnus-summary-iterate n
9641 (let ((gnus-display-mime-function nil)
9642 (gnus-inhibit-treatment t))
9643 (gnus-summary-select-article))
9645 (set-buffer gnus-article-buffer)
9646 (let ((handles (or gnus-article-mime-handles
9647 (mm-dissect-buffer) (mm-uu-dissect))))
9649 (gnus-summary-save-parts-1 type dir handles reverse)
9650 (unless gnus-article-mime-handles ;; Don't destroy this case.
9651 (mm-destroy-parts handles)))))))
9653 (defun gnus-summary-save-parts-1 (type dir handle reverse)
9654 (if (stringp (car handle))
9655 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
9658 (not (string-match type (mm-handle-media-type handle)))
9659 (string-match type (mm-handle-media-type handle)))
9660 (let ((file (expand-file-name
9661 (file-name-nondirectory
9663 (mail-content-type-get
9664 (mm-handle-disposition handle) 'filename)
9665 (concat gnus-newsgroup-name
9666 "." (number-to-string
9667 (cdr gnus-article-current)))))
9669 (unless (file-exists-p file)
9670 (mm-save-part-to-file handle file))))))
9672 ;; Summary extract commands
9674 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
9675 (let ((buffer-read-only nil)
9676 (article (gnus-summary-article-number))
9678 (unless (gnus-summary-goto-subject article)
9679 (error "No such article: %d" article))
9680 (gnus-summary-position-point)
9681 ;; If all commands are to be bunched up on one line, we collect
9683 (unless gnus-view-pseudos-separately
9684 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
9687 (setq action (cdr (assq 'action (car ps))))
9688 (setq files (list (cdr (assq 'name (car ps)))))
9689 (while (and ps (cdr ps)
9690 (string= (or action "1")
9691 (or (cdr (assq 'action (cadr ps))) "2")))
9692 (push (cdr (assq 'name (cadr ps))) files)
9693 (setcdr ps (cddr ps)))
9695 (when (not (string-match "%s" action))
9698 (when (assq 'execute (car ps))
9699 (setcdr (assq 'execute (car ps))
9700 (funcall (if (string-match "%s" action)
9709 (setq ps (cdr ps)))))
9710 (if (and gnus-view-pseudos (not not-view))
9712 (when (assq 'execute (car pslist))
9713 (gnus-execute-command (cdr (assq 'execute (car pslist)))
9714 (eq gnus-view-pseudos 'not-confirm)))
9715 (setq pslist (cdr pslist)))
9718 (setq after-article (or (cdr (assq 'article (car pslist)))
9719 (gnus-summary-article-number)))
9720 (gnus-summary-goto-subject after-article)
9723 (insert " " (file-name-nondirectory
9724 (cdr (assq 'name (car pslist))))
9725 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
9727 (forward-line -1) ; back to `b'
9728 (gnus-add-text-properties
9729 b (1- e) (list 'gnus-number gnus-reffed-article-number
9730 gnus-mouse-face-prop gnus-mouse-face))
9732 after-article gnus-reffed-article-number
9733 gnus-unread-mark b (car pslist) 0 (- e b))
9734 (push gnus-reffed-article-number gnus-newsgroup-unreads)
9735 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
9736 (setq pslist (cdr pslist)))))))
9738 (defun gnus-pseudos< (p1 p2)
9739 (let ((c1 (cdr (assq 'action p1)))
9740 (c2 (cdr (assq 'action p2))))
9741 (and c1 c2 (string< c1 c2))))
9743 (defun gnus-request-pseudo-article (props)
9744 (cond ((assq 'execute props)
9745 (gnus-execute-command (cdr (assq 'execute props)))))
9746 (let ((gnus-current-article (gnus-summary-article-number)))
9747 (gnus-run-hooks 'gnus-mark-article-hook)))
9749 (defun gnus-execute-command (command &optional automatic)
9751 (gnus-article-setup-buffer)
9752 (set-buffer gnus-article-buffer)
9753 (setq buffer-read-only nil)
9754 (let ((command (if automatic command
9755 (read-string "Command: " (cons command 0)))))
9757 (insert "$ " command "\n\n")
9758 (if gnus-view-pseudo-asynchronously
9759 (start-process "gnus-execute" (current-buffer) shell-file-name
9760 shell-command-switch command)
9761 (call-process shell-file-name nil t nil
9762 shell-command-switch command)))))
9764 ;; Summary kill commands.
9766 (defun gnus-summary-edit-global-kill (article)
9767 "Edit the \"global\" kill file."
9768 (interactive (list (gnus-summary-article-number)))
9769 (gnus-group-edit-global-kill article))
9771 (defun gnus-summary-edit-local-kill ()
9772 "Edit a local kill file applied to the current newsgroup."
9774 (setq gnus-current-headers (gnus-summary-article-header))
9775 (gnus-group-edit-local-kill
9776 (gnus-summary-article-number) gnus-newsgroup-name))
9780 (defun gnus-read-header (id &optional header)
9781 "Read the headers of article ID and enter them into the Gnus system."
9782 (let ((group gnus-newsgroup-name)
9783 (gnus-override-method
9785 gnus-override-method
9786 (and (gnus-news-group-p gnus-newsgroup-name)
9787 (car (gnus-refer-article-methods)))))
9789 ;; First we check to see whether the header in question is already
9792 ;; This is a Message-ID.
9793 (setq header (or header (gnus-id-to-header id)))
9794 ;; This is an article number.
9795 (setq header (or header (gnus-summary-article-header id))))
9797 (not (gnus-summary-article-sparse-p (mail-header-number header))))
9798 ;; We have found the header.
9800 ;; If this is a sparse article, we have to nix out its
9801 ;; previous entry in the thread hashtb.
9803 (gnus-summary-article-sparse-p (mail-header-number header)))
9804 (let* ((parent (gnus-parent-id (mail-header-references header)))
9805 (thread (and parent (gnus-id-to-thread parent))))
9807 (delq (assq header thread) thread))))
9808 ;; We have to really fetch the header to this article.
9810 (set-buffer nntp-server-buffer)
9811 (when (setq where (gnus-request-head id group))
9812 (nnheader-fold-continuation-lines)
9813 (goto-char (point-max))
9815 (goto-char (point-min))
9819 ((cdr where) (cdr where))
9820 (header (mail-header-number header))
9821 (t gnus-reffed-article-number))
9823 (insert " Article retrieved.\n"))
9825 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
9826 () ; Malformed head.
9827 (unless (gnus-summary-article-sparse-p (mail-header-number header))
9828 (when (and (stringp id)
9829 (not (string= (gnus-group-real-name group)
9831 ;; If we fetched by Message-ID and the article came
9832 ;; from a different group, we fudge some bogus article
9833 ;; numbers for this article.
9834 (mail-header-set-number header gnus-reffed-article-number))
9836 (set-buffer gnus-summary-buffer)
9837 (decf gnus-reffed-article-number)
9838 (gnus-remove-header (mail-header-number header))
9839 (push header gnus-newsgroup-headers)
9840 (setq gnus-current-headers header)
9841 (push (mail-header-number header) gnus-newsgroup-limit)))
9844 (defun gnus-remove-header (number)
9845 "Remove header NUMBER from `gnus-newsgroup-headers'."
9846 (if (and gnus-newsgroup-headers
9847 (= number (mail-header-number (car gnus-newsgroup-headers))))
9848 (pop gnus-newsgroup-headers)
9849 (let ((headers gnus-newsgroup-headers))
9850 (while (and (cdr headers)
9851 (not (= number (mail-header-number (cadr headers)))))
9854 (setcdr headers (cddr headers))))))
9857 ;;; summary highlights
9860 (defun gnus-highlight-selected-summary ()
9861 "Highlight selected article in summary buffer."
9862 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
9863 (when gnus-summary-selected-face
9865 (let* ((beg (progn (beginning-of-line) (point)))
9866 (end (progn (end-of-line) (point)))
9867 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
9868 (from (if (get-text-property beg gnus-mouse-face-prop)
9870 (or (next-single-property-change
9871 beg gnus-mouse-face-prop nil end)
9876 (or (next-single-property-change
9877 from gnus-mouse-face-prop nil end)
9879 ;; If no mouse-face prop on line we will have to = from = end,
9880 ;; so we highlight the entire line instead.
9881 (when (= (+ to 2) from)
9884 (if gnus-newsgroup-selected-overlay
9885 ;; Move old overlay.
9887 gnus-newsgroup-selected-overlay from to (current-buffer))
9888 ;; Create new overlay.
9890 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
9891 'face gnus-summary-selected-face))))))
9893 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
9894 (defun gnus-summary-highlight-line ()
9895 "Highlight current line according to `gnus-summary-highlight'."
9896 (let* ((list gnus-summary-highlight)
9898 (end (progn (end-of-line) (point)))
9899 ;; now find out where the line starts and leave point there.
9900 (beg (progn (beginning-of-line) (point)))
9901 (article (gnus-summary-article-number))
9902 (score (or (cdr (assq (or article gnus-current-article)
9903 gnus-newsgroup-scored))
9904 gnus-summary-default-score 0))
9905 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
9906 (inhibit-read-only t))
9907 ;; Eval the cars of the lists until we find a match.
9908 (let ((default gnus-summary-default-score))
9910 (not (eval (caar list))))
9911 (setq list (cdr list))))
9912 (let ((face (cdar list)))
9913 (unless (eq face (get-text-property beg 'face))
9914 (gnus-put-text-property-excluding-characters-with-faces
9916 (setq face (if (boundp face) (symbol-value face) face)))
9917 (when gnus-summary-highlight-line-function
9918 (funcall gnus-summary-highlight-line-function article face))))
9921 (defun gnus-update-read-articles (group unread &optional compute)
9922 "Update the list of read articles in GROUP."
9923 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
9924 (entry (gnus-gethash group gnus-newsrc-hashtb))
9925 (info (nth 2 entry))
9927 (unread (sort (copy-sequence unread) '<))
9929 (if (or (not info) (not active))
9930 ;; There is no info on this group if it was, in fact,
9931 ;; killed. Gnus stores no information on killed groups, so
9932 ;; there's nothing to be done.
9933 ;; One could store the information somewhere temporarily,
9934 ;; perhaps... Hmmm...
9936 ;; Remove any negative articles numbers.
9937 (while (and unread (< (car unread) 0))
9938 (setq unread (cdr unread)))
9939 ;; Remove any expired article numbers
9940 (while (and unread (< (car unread) (car active)))
9941 (setq unread (cdr unread)))
9942 ;; Compute the ranges of read articles by looking at the list of
9945 (when (/= (car unread) prev)
9946 (push (if (= prev (1- (car unread))) prev
9947 (cons prev (1- (car unread))))
9949 (setq prev (1+ (car unread)))
9950 (setq unread (cdr unread)))
9951 (when (<= prev (cdr active))
9952 (push (cons prev (cdr active)) read))
9953 (setq read (if (> (length read) 1) (nreverse read) read))
9958 ;; Propagate the read marks to the backend.
9959 (when (gnus-check-backend-function 'request-set-mark group)
9960 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
9961 (add (gnus-remove-from-range read (gnus-info-read info))))
9963 (unless (gnus-check-group group)
9964 (error "Can't open server for %s" group))
9965 (gnus-request-set-mark
9966 group (delq nil (list (if add (list add 'add '(read)))
9967 (if del (list del 'del '(read))))))
9969 `(gnus-request-set-mark
9972 (if del (list del 'add '(read)))
9973 (if add (list add 'del '(read))))))))))
9974 (set-buffer gnus-group-buffer)
9977 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
9978 (gnus-info-set-read ',info ',(gnus-info-read info))
9979 (gnus-get-unread-articles-in-group ',info
9980 (gnus-active ,group))
9981 (gnus-group-update-group ,group t)
9983 ;; Enter this list into the group info.
9984 (gnus-info-set-read info read)
9985 ;; Set the number of unread articles in gnus-newsrc-hashtb.
9986 (gnus-get-unread-articles-in-group info (gnus-active group))
9989 (defun gnus-offer-save-summaries ()
9990 "Offer to save all active summary buffers."
9992 (let ((buflist (buffer-list))
9994 ;; Go through all buffers and find all summaries.
9996 (and (setq bufname (buffer-name (car buflist)))
9997 (string-match "Summary" bufname)
9999 (set-buffer bufname)
10000 ;; We check that this is, indeed, a summary buffer.
10001 (and (eq major-mode 'gnus-summary-mode)
10002 ;; Also make sure this isn't bogus.
10003 gnus-newsgroup-prepared
10004 ;; Also make sure that this isn't a dead summary buffer.
10005 (not gnus-dead-summary-mode)))
10006 (push bufname buffers))
10007 (setq buflist (cdr buflist)))
10008 ;; Go through all these summary buffers and offer to save them.
10011 "Update summary buffer %s? "
10013 (switch-to-buffer buf)
10014 (gnus-summary-exit))
10017 (defun gnus-summary-setup-default-charset ()
10018 "Setup newsgroup default charset."
10019 (if (equal gnus-newsgroup-name "nndraft:drafts")
10020 (setq gnus-newsgroup-charset nil)
10021 (let* ((ignored-charsets
10022 (or gnus-newsgroup-ephemeral-ignored-charsets
10024 (and gnus-newsgroup-name
10025 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
10026 gnus-newsgroup-ignored-charsets))))
10027 (setq gnus-newsgroup-charset
10028 (or gnus-newsgroup-ephemeral-charset
10029 (and gnus-newsgroup-name
10030 (gnus-parameter-charset gnus-newsgroup-name))
10031 gnus-default-charset))
10032 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
10033 ignored-charsets))))
10039 (defun gnus-summary-display-buttonized (&optional show-all-parts)
10040 "Display the current article buffer fully MIME-buttonized.
10041 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
10042 treated as multipart/mixed."
10044 (require 'gnus-art)
10045 (let ((gnus-unbuttonized-mime-types nil)
10046 (gnus-mime-display-multipart-as-mixed show-all-parts))
10047 (gnus-summary-show-article)))
10049 (defun gnus-summary-repair-multipart (article)
10050 "Add a Content-Type header to a multipart article without one."
10051 (interactive (list (gnus-summary-article-number)))
10052 (gnus-with-article article
10053 (message-narrow-to-head)
10054 (message-remove-header "Mime-Version")
10055 (goto-char (point-max))
10056 (insert "Mime-Version: 1.0\n")
10058 (when (search-forward "\n--" nil t)
10059 (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
10060 (message-narrow-to-head)
10061 (message-remove-header "Content-Type")
10062 (goto-char (point-max))
10063 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
10066 (let (gnus-mark-article-hook)
10067 (gnus-summary-select-article t t nil article)))
10069 (defun gnus-summary-toggle-display-buttonized ()
10070 "Toggle the buttonizing of the article buffer."
10072 (require 'gnus-art)
10073 (if (setq gnus-inhibit-mime-unbuttonizing
10074 (not gnus-inhibit-mime-unbuttonizing))
10075 (let ((gnus-unbuttonized-mime-types nil))
10076 (gnus-summary-show-article))
10077 (gnus-summary-show-article)))
10080 ;;; Generic summary marking commands
10083 (defvar gnus-summary-marking-alist
10084 '((read gnus-del-mark "d")
10085 (unread gnus-unread-mark "u")
10086 (ticked gnus-ticked-mark "!")
10087 (dormant gnus-dormant-mark "?")
10088 (expirable gnus-expirable-mark "e"))
10089 "An alist of names/marks/keystrokes.")
10091 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
10092 (defvar gnus-summary-mark-map)
10094 (defun gnus-summary-make-all-marking-commands ()
10095 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
10096 (dolist (elem gnus-summary-marking-alist)
10097 (apply 'gnus-summary-make-marking-command elem)))
10099 (defun gnus-summary-make-marking-command (name mark keystroke)
10100 (let ((map (make-sparse-keymap)))
10101 (define-key gnus-summary-generic-mark-map keystroke map)
10102 (dolist (lway `((next "next" next nil "n")
10103 (next-unread "next unread" next t "N")
10104 (prev "previous" prev nil "p")
10105 (prev-unread "previous unread" prev t "P")
10106 (nomove "" nil nil ,keystroke)))
10107 (let ((func (gnus-summary-make-marking-command-1
10108 mark (car lway) lway name)))
10109 (setq func (eval func))
10110 (define-key map (nth 4 lway) func)))))
10112 (defun gnus-summary-make-marking-command-1 (mark way lway name)
10114 (format "gnus-summary-put-mark-as-%s%s"
10115 name (if (eq way 'nomove)
10117 (concat "-" (symbol-name way)))))
10120 "Mark the current article as %s%s.
10121 If N, the prefix, then repeat N times.
10122 If N is negative, move in reverse order.
10123 The difference between N and the actual number of articles marked is
10127 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
10129 (defun gnus-summary-generic-mark (n mark move unread)
10130 "Mark N articles with MARK."
10131 (unless (eq major-mode 'gnus-summary-mode)
10132 (error "This command can only be used in the summary buffer"))
10133 (gnus-summary-show-thread)
10136 ((eq move 'next) 1)
10137 ((eq move 'prev) -1)
10139 (if (zerop nummove)
10143 nummove (* -1 nummove))))
10144 (while (and (> n 0)
10145 (gnus-summary-mark-article nil mark)
10146 (zerop (gnus-summary-next-subject nummove unread t)))
10149 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
10150 (gnus-summary-recenter)
10151 (gnus-summary-position-point)
10152 (gnus-set-mode-line 'summary)
10155 (defun gnus-summary-insert-articles (articles)
10156 (when (setq articles
10157 (gnus-set-difference articles
10158 (mapcar (lambda (h) (mail-header-number h))
10159 gnus-newsgroup-headers)))
10160 (setq gnus-newsgroup-headers
10162 gnus-newsgroup-headers
10163 (gnus-fetch-headers articles)
10164 'gnus-article-sort-by-number))
10165 ;; Suppress duplicates?
10166 (when gnus-suppress-duplicates
10167 (gnus-dup-suppress-articles))
10169 ;; We might want to build some more threads first.
10170 (when (and gnus-fetch-old-headers
10171 (eq gnus-headers-retrieved-by 'nov))
10172 (if (eq gnus-fetch-old-headers 'invisible)
10173 (gnus-build-all-threads)
10174 (gnus-build-old-threads)))
10175 ;; Let the Gnus agent mark articles as read.
10177 (gnus-agent-get-undownloaded-list))
10178 ;; Remove list identifiers from subject
10179 (when gnus-list-identifiers
10180 (gnus-summary-remove-list-identifiers))
10181 ;; First and last article in this newsgroup.
10182 (when gnus-newsgroup-headers
10183 (setq gnus-newsgroup-begin
10184 (mail-header-number (car gnus-newsgroup-headers))
10186 (mail-header-number
10187 (gnus-last-element gnus-newsgroup-headers))))
10188 (when gnus-use-scoring
10189 (gnus-possibly-score-headers))))
10191 (defun gnus-summary-insert-old-articles (&optional all)
10192 "Insert all old articles in this group.
10193 If ALL is non-nil, already read articles become readable.
10194 If ALL is a number, fetch this number of articles."
10197 (let ((old (mapcar 'car gnus-newsgroup-data))
10198 (i (car gnus-newsgroup-active))
10200 (while (<= i (cdr gnus-newsgroup-active))
10201 (or (memq i old) (push i older))
10203 (setq len (length older))
10208 (setq older (subseq older 0 all))))
10211 (if (and (numberp gnus-large-newsgroup)
10212 (> len gnus-large-newsgroup))
10216 "How many articles from %s (default %d): "
10218 (gnus-group-decoded-name gnus-newsgroup-name) 35)
10220 (unless (string-match "^[ \t]*$" input)
10221 (setq all (string-to-number input))
10223 (setq older (subseq older 0 all))))))))
10225 (message "No old news.")
10226 (gnus-summary-insert-articles older)
10227 (gnus-summary-limit (gnus-union older old))))
10228 (gnus-summary-position-point)))
10230 (defun gnus-summary-insert-new-articles ()
10231 "Insert all new articles in this group."
10234 (let ((old (mapcar 'car gnus-newsgroup-data))
10235 (old-active gnus-newsgroup-active)
10236 (nnmail-fetched-sources (list t))
10238 (setq gnus-newsgroup-active
10239 (gnus-activate-group gnus-newsgroup-name 'scan))
10240 (setq i (1+ (cdr old-active)))
10241 (while (<= i (cdr gnus-newsgroup-active))
10245 (message "No gnus is bad news.")
10246 (gnus-summary-insert-articles new)
10247 (setq gnus-newsgroup-unreads
10248 (append gnus-newsgroup-unreads new))
10249 (gnus-summary-limit (gnus-union old new))))
10250 (gnus-summary-position-point)))
10252 (gnus-summary-make-all-marking-commands)
10254 (gnus-ems-redefine)
10256 (provide 'gnus-sum)
10258 (run-hooks 'gnus-sum-load-hook)
10260 ;;; gnus-sum.el ends here