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 killed articles."
400 :group 'gnus-summary-marks
403 (defcustom gnus-kill-file-mark ?X
404 "*Mark used for articles killed by kill files."
405 :group 'gnus-summary-marks
408 (defcustom gnus-low-score-mark ?Y
409 "*Mark used for articles with a low score."
410 :group 'gnus-summary-marks
413 (defcustom gnus-catchup-mark ?C
414 "*Mark used for articles that are caught up."
415 :group 'gnus-summary-marks
418 (defcustom gnus-replied-mark ?A
419 "*Mark used for articles that have been replied to."
420 :group 'gnus-summary-marks
423 (defcustom gnus-cached-mark ?*
424 "*Mark used for articles that are in the cache."
425 :group 'gnus-summary-marks
428 (defcustom gnus-saved-mark ?S
429 "*Mark used for articles that have been saved to."
430 :group 'gnus-summary-marks
433 (defcustom gnus-no-mark ? ;Whitespace
434 "*Mark used for articles that have no other secondary mark."
435 :group 'gnus-summary-marks
438 (defcustom gnus-ancient-mark ?O
439 "*Mark used for ancient articles."
440 :group 'gnus-summary-marks
443 (defcustom gnus-sparse-mark ?Q
444 "*Mark used for sparsely reffed articles."
445 :group 'gnus-summary-marks
448 (defcustom gnus-canceled-mark ?G
449 "*Mark used for canceled articles."
450 :group 'gnus-summary-marks
453 (defcustom gnus-duplicate-mark ?M
454 "*Mark used for duplicate articles."
455 :group 'gnus-summary-marks
458 (defcustom gnus-undownloaded-mark ?@
459 "*Mark used for articles that weren't downloaded."
460 :group 'gnus-summary-marks
463 (defcustom gnus-downloadable-mark ?%
464 "*Mark used for articles that are to be downloaded."
465 :group 'gnus-summary-marks
468 (defcustom gnus-unsendable-mark ?=
469 "*Mark used for articles that won't be sent."
470 :group 'gnus-summary-marks
473 (defcustom gnus-score-over-mark ?+
474 "*Score mark used for articles with high scores."
475 :group 'gnus-summary-marks
478 (defcustom gnus-score-below-mark ?-
479 "*Score mark used for articles with low scores."
480 :group 'gnus-summary-marks
483 (defcustom gnus-empty-thread-mark ? ;Whitespace
484 "*There is no thread under the article."
485 :group 'gnus-summary-marks
488 (defcustom gnus-not-empty-thread-mark ?=
489 "*There is a thread under the article."
490 :group 'gnus-summary-marks
493 (defcustom gnus-view-pseudo-asynchronously nil
494 "*If non-nil, Gnus will view pseudo-articles asynchronously."
495 :group 'gnus-extract-view
498 (defcustom gnus-auto-expirable-marks
499 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
500 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
501 gnus-souped-mark gnus-duplicate-mark)
502 "*The list of marks converted into expiration if a group is auto-expirable."
505 :type '(repeat character))
507 (defcustom gnus-inhibit-user-auto-expire t
508 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
513 (defcustom gnus-view-pseudos nil
514 "*If `automatic', pseudo-articles will be viewed automatically.
515 If `not-confirm', pseudos will be viewed automatically, and the user
516 will not be asked to confirm the command."
517 :group 'gnus-extract-view
518 :type '(choice (const :tag "off" nil)
520 (const not-confirm)))
522 (defcustom gnus-view-pseudos-separately t
523 "*If non-nil, one pseudo-article will be created for each file to be viewed.
524 If nil, all files that use the same viewing command will be given as a
525 list of parameters to that command."
526 :group 'gnus-extract-view
529 (defcustom gnus-insert-pseudo-articles t
530 "*If non-nil, insert pseudo-articles when decoding articles."
531 :group 'gnus-extract-view
534 (defcustom gnus-summary-dummy-line-format
536 "*The format specification for the dummy roots in the summary buffer.
537 It works along the same lines as a normal formatting string,
538 with some simple extensions.
541 :group 'gnus-threading
544 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
545 "*The format specification for the summary mode line.
546 It works along the same lines as a normal formatting string,
547 with some simple extensions:
550 %p Unprefixed group name
551 %A Current article number
552 %z Current article score
554 %U Number of unread articles in the group
555 %e Number of unselected articles in the group
556 %Z A string with unread/unselected article counts
557 %g Shortish group name
558 %S Subject of the current article
560 %s Current score file name
561 %d Number of dormant articles
562 %r Number of articles that have been marked as read in this session
563 %E Number of articles expunged by the score files"
564 :group 'gnus-summary-format
567 (defcustom gnus-list-identifiers nil
568 "Regexp that matches list identifiers to be removed from subject.
569 This can also be a list of regexps."
571 :group 'gnus-summary-format
572 :group 'gnus-article-hiding
573 :type '(choice (const :tag "none" nil)
575 (repeat :value (".*") regexp)))
577 (defcustom gnus-summary-mark-below 0
578 "*Mark all articles with a score below this variable as read.
579 This variable is local to each summary buffer and usually set by the
581 :group 'gnus-score-default
584 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
585 "*List of functions used for sorting articles in the summary buffer.
586 This variable is only used when not using a threaded display."
587 :group 'gnus-summary-sort
588 :type '(repeat (choice (function-item gnus-article-sort-by-number)
589 (function-item gnus-article-sort-by-author)
590 (function-item gnus-article-sort-by-subject)
591 (function-item gnus-article-sort-by-date)
592 (function-item gnus-article-sort-by-score)
593 (function :tag "other"))))
595 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
596 "*List of functions used for sorting threads in the summary buffer.
597 By default, threads are sorted by article number.
599 Each function takes two threads and return non-nil if the first thread
600 should be sorted before the other. If you use more than one function,
601 the primary sort function should be the last. You should probably
602 always include `gnus-thread-sort-by-number' in the list of sorting
603 functions -- preferably first.
605 Ready-made functions include `gnus-thread-sort-by-number',
606 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
607 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
608 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function')."
609 :group 'gnus-summary-sort
610 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
611 (function-item gnus-thread-sort-by-author)
612 (function-item gnus-thread-sort-by-subject)
613 (function-item gnus-thread-sort-by-date)
614 (function-item gnus-thread-sort-by-score)
615 (function-item gnus-thread-sort-by-total-score)
616 (function :tag "other"))))
618 (defcustom gnus-thread-score-function '+
619 "*Function used for calculating the total score of a thread.
621 The function is called with the scores of the article and each
622 subthread and should then return the score of the thread.
624 Some functions you can use are `+', `max', or `min'."
625 :group 'gnus-summary-sort
628 (defcustom gnus-summary-expunge-below nil
629 "All articles that have a score less than this variable will be expunged.
630 This variable is local to the summary buffers."
631 :group 'gnus-score-default
632 :type '(choice (const :tag "off" nil)
635 (defcustom gnus-thread-expunge-below nil
636 "All threads that have a total score less than this variable will be expunged.
637 See `gnus-thread-score-function' for en explanation of what a
640 This variable is local to the summary buffers."
641 :group 'gnus-threading
642 :group 'gnus-score-default
643 :type '(choice (const :tag "off" nil)
646 (defcustom gnus-summary-mode-hook nil
647 "*A hook for Gnus summary mode.
648 This hook is run before any variables are set in the summary buffer."
649 :options '(turn-on-gnus-mailing-list-mode)
650 :group 'gnus-summary-various
653 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
654 (when (featurep 'xemacs)
655 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
656 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
657 (add-hook 'gnus-summary-mode-hook
658 'gnus-xmas-switch-horizontal-scrollbar-off))
660 (defcustom gnus-summary-menu-hook nil
661 "*Hook run after the creation of the summary mode menu."
662 :group 'gnus-summary-visual
665 (defcustom gnus-summary-exit-hook nil
666 "*A hook called on exit from the summary buffer.
667 It will be called with point in the group buffer."
668 :group 'gnus-summary-exit
671 (defcustom gnus-summary-prepare-hook nil
672 "*A hook called after the summary buffer has been generated.
673 If you want to modify the summary buffer, you can use this hook."
674 :group 'gnus-summary-various
677 (defcustom gnus-summary-prepared-hook nil
678 "*A hook called as the last thing after the summary buffer has been generated."
679 :group 'gnus-summary-various
682 (defcustom gnus-summary-generate-hook nil
683 "*A hook run just before generating the summary buffer.
684 This hook is commonly used to customize threading variables and the
686 :group 'gnus-summary-various
689 (defcustom gnus-select-group-hook nil
690 "*A hook called when a newsgroup is selected.
692 If you'd like to simplify subjects like the
693 `gnus-summary-next-same-subject' command does, you can use the
696 (setq gnus-select-group-hook
699 (mapcar (lambda (header)
700 (mail-header-set-subject
702 (gnus-simplify-subject
703 (mail-header-subject header) 're-only)))
704 gnus-newsgroup-headers))))"
705 :group 'gnus-group-select
708 (defcustom gnus-select-article-hook nil
709 "*A hook called when an article is selected."
710 :group 'gnus-summary-choose
713 (defcustom gnus-visual-mark-article-hook
714 (list 'gnus-highlight-selected-summary)
715 "*Hook run after selecting an article in the summary buffer.
716 It is meant to be used for highlighting the article in some way. It
717 is not run if `gnus-visual' is nil."
718 :group 'gnus-summary-visual
721 (defcustom gnus-parse-headers-hook nil
722 "*A hook called before parsing the headers."
726 (defcustom gnus-exit-group-hook nil
727 "*A hook called when exiting summary mode.
728 This hook is not called from the non-updating exit commands like `Q'."
732 (defcustom gnus-summary-update-hook
733 (list 'gnus-summary-highlight-line)
734 "*A hook called when a summary line is changed.
735 The hook will not be called if `gnus-visual' is nil.
737 The default function `gnus-summary-highlight-line' will
738 highlight the line according to the `gnus-summary-highlight'
740 :group 'gnus-summary-visual
743 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
744 "*A hook called when an article is selected for the first time.
745 The hook is intended to mark an article as read (or unread)
746 automatically when it is selected."
747 :group 'gnus-summary-choose
750 (defcustom gnus-group-no-more-groups-hook nil
751 "*A hook run when returning to group mode having no more (unread) groups."
752 :group 'gnus-group-select
755 (defcustom gnus-ps-print-hook nil
756 "*A hook run before ps-printing something from Gnus."
760 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
761 "Face used for highlighting the current article in the summary buffer."
762 :group 'gnus-summary-visual
765 (defcustom gnus-summary-highlight
766 '(((= mark gnus-canceled-mark)
767 . gnus-summary-cancelled-face)
768 ((and (> score default)
769 (or (= mark gnus-dormant-mark)
770 (= mark gnus-ticked-mark)))
771 . gnus-summary-high-ticked-face)
772 ((and (< score default)
773 (or (= mark gnus-dormant-mark)
774 (= mark gnus-ticked-mark)))
775 . gnus-summary-low-ticked-face)
776 ((or (= mark gnus-dormant-mark)
777 (= mark gnus-ticked-mark))
778 . gnus-summary-normal-ticked-face)
779 ((and (> score default) (= mark gnus-ancient-mark))
780 . gnus-summary-high-ancient-face)
781 ((and (< score default) (= mark gnus-ancient-mark))
782 . gnus-summary-low-ancient-face)
783 ((= mark gnus-ancient-mark)
784 . gnus-summary-normal-ancient-face)
785 ((and (> score default) (= mark gnus-unread-mark))
786 . gnus-summary-high-unread-face)
787 ((and (< score default) (= mark gnus-unread-mark))
788 . gnus-summary-low-unread-face)
789 ((= mark gnus-unread-mark)
790 . gnus-summary-normal-unread-face)
791 ((and (> score default) (memq mark (list gnus-downloadable-mark
792 gnus-undownloaded-mark)))
793 . gnus-summary-high-unread-face)
794 ((and (< score default) (memq mark (list gnus-downloadable-mark
795 gnus-undownloaded-mark)))
796 . gnus-summary-low-unread-face)
797 ((memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
798 . gnus-summary-normal-unread-face)
800 . gnus-summary-high-read-face)
802 . gnus-summary-low-read-face)
804 . gnus-summary-normal-read-face))
805 "*Controls the highlighting of summary buffer lines.
807 A list of (FORM . FACE) pairs. When deciding how a a particular
808 summary line should be displayed, each form is evaluated. The content
809 of the face field after the first true form is used. You can change
810 how those summary lines are displayed, by editing the face field.
812 You can use the following variables in the FORM field.
814 score: The articles score
815 default: The default article score.
816 below: The score below which articles are automatically marked as read.
817 mark: The articles mark."
818 :group 'gnus-summary-visual
819 :type '(repeat (cons (sexp :tag "Form" nil)
822 (defcustom gnus-alter-header-function nil
823 "Function called to allow alteration of article header structures.
824 The function is called with one parameter, the article header vector,
825 which it may alter in any way.")
827 (defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string
828 "Variable that says which function should be used to decode a string with encoded words.")
830 (defcustom gnus-extra-headers nil
831 "*Extra headers to parse."
834 :type '(repeat symbol))
836 (defcustom gnus-ignored-from-addresses
837 (and user-mail-address (regexp-quote user-mail-address))
838 "*Regexp of From headers that may be suppressed in favor of To headers."
843 (defcustom gnus-group-charset-alist
844 '(("^hk\\>\\|^tw\\>\\|\\<big5\\>" cn-big5)
845 ("^cn\\>\\|\\<chinese\\>" cn-gb-2312)
846 ("^fj\\>\\|^japan\\>" iso-2022-jp-2)
847 ("^tnn\\>\\|^pin\\>\\|^sci.lang.japan" iso-2022-7bit)
848 ("^relcom\\>" koi8-r)
850 ("^\\(cz\\|hun\\|pl\\|sk\\|hr\\)\\>" iso-8859-2)
851 ("^israel\\>" iso-8859-1)
853 ("^alt.chinese.text.big5\\>" chinese-big5)
854 ("^soc.culture.vietnamese\\>" vietnamese-viqr)
855 ("^\\(comp\\|rec\\|alt\\|sci\\|soc\\|news\\|gnu\\|bofh\\)\\>" iso-8859-1)
857 "Alist of regexps (to match group names) and default charsets to be used when reading."
858 :type '(repeat (list (regexp :tag "Group")
859 (symbol :tag "Charset")))
860 :group 'gnus-charset)
862 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
863 "List of charsets that should be ignored.
864 When these charsets are used in the \"charset\" parameter, the
865 default charset will be used instead."
867 :type '(repeat symbol)
868 :group 'gnus-charset)
870 (defcustom gnus-group-ignored-charsets-alist
871 '(("alt\\.chinese\\.text" iso-8859-1))
872 "Alist of regexps (to match group names) and charsets that should be ignored.
873 When these charsets are used in the \"charset\" parameter, the
874 default charset will be used instead."
875 :type '(repeat (cons (regexp :tag "Group")
877 :group 'gnus-charset)
879 (defcustom gnus-group-highlight-words-alist nil
880 "Alist of group regexps and highlight regexps.
881 This variable uses the same syntax as `gnus-emphasis-alist'."
883 :type '(repeat (cons (regexp :tag "Group")
884 (repeat (list (regexp :tag "Highlight regexp")
885 (number :tag "Group for entire word" 0)
886 (number :tag "Group for displayed part" 0)
888 gnus-emphasis-highlight-words)))))
889 :group 'gnus-summary-visual)
891 (defcustom gnus-summary-show-article-charset-alist
893 "Alist of number and charset.
894 The article will be shown with the charset corresponding to the
896 For example: ((1 . cn-gb-2312) (2 . big5))."
898 :type '(repeat (cons (number :tag "Argument" 1)
899 (symbol :tag "Charset")))
900 :group 'gnus-charset)
902 (defcustom gnus-preserve-marks t
903 "Whether marks are preserved when moving, copying and respooling messages."
906 :group 'gnus-summary-marks)
908 (defcustom gnus-alter-articles-to-read-function nil
909 "Function to be called to alter the list of articles to be selected."
911 :group 'gnus-summary)
913 (defcustom gnus-orphan-score nil
914 "*All orphans get this score added. Set in the score file."
915 :group 'gnus-score-default
916 :type '(choice (const nil)
919 (defcustom gnus-summary-save-parts-default-mime "image/.*"
920 "*A regexp to match MIME parts when saving multiple parts of a message
921 with gnus-summary-save-parts (X m). This regexp will be used by default
922 when prompting the user for which type of files to save."
927 (defcustom gnus-summary-save-parts-default-mime "image/.*"
928 "*A regexp to match MIME parts when saving multiple parts of a message
929 with gnus-summary-save-parts (X m). This regexp will be used by default
930 when prompting the user for which type of files to save."
935 ;;; Internal variables
937 (defvar gnus-article-mime-handles nil)
938 (defvar gnus-article-decoded-p nil)
939 (defvar gnus-article-charset nil)
940 (defvar gnus-article-ignored-charsets nil)
941 (defvar gnus-scores-exclude-files nil)
942 (defvar gnus-page-broken nil)
943 (defvar gnus-inhibit-mime-unbuttonizing nil)
945 (defvar gnus-original-article nil)
946 (defvar gnus-article-internal-prepare-hook nil)
947 (defvar gnus-newsgroup-process-stack nil)
949 (defvar gnus-thread-indent-array nil)
950 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
951 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
952 "Function called to sort the articles within a thread after it has been gathered together.")
954 (defvar gnus-summary-save-parts-type-history nil)
955 (defvar gnus-summary-save-parts-last-directory nil)
957 (defvar gnus-summary-save-parts-type-history nil)
958 (defvar gnus-summary-save-parts-last-directory nil)
960 ;; Avoid highlighting in kill files.
961 (defvar gnus-summary-inhibit-highlight nil)
962 (defvar gnus-newsgroup-selected-overlay nil)
963 (defvar gnus-inhibit-limiting nil)
964 (defvar gnus-newsgroup-adaptive-score-file nil)
965 (defvar gnus-current-score-file nil)
966 (defvar gnus-current-move-group nil)
967 (defvar gnus-current-copy-group nil)
968 (defvar gnus-current-crosspost-group nil)
970 (defvar gnus-newsgroup-dependencies nil)
971 (defvar gnus-newsgroup-adaptive nil)
972 (defvar gnus-summary-display-article-function nil)
973 (defvar gnus-summary-highlight-line-function nil
974 "Function called after highlighting a summary line.")
976 (defvar gnus-summary-line-format-alist
977 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
978 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
979 (?s gnus-tmp-subject-or-nil ?s)
980 (?n gnus-tmp-name ?s)
981 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
983 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
985 (?F gnus-tmp-from ?s)
986 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
987 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
988 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
989 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
990 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
991 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
992 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
993 (?L gnus-tmp-lines ?d)
994 (?I gnus-tmp-indentation ?s)
995 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
996 (?R gnus-tmp-replied ?c)
997 (?\[ gnus-tmp-opening-bracket ?c)
998 (?\] gnus-tmp-closing-bracket ?c)
999 (?\> (make-string gnus-tmp-level ? ) ?s)
1000 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1001 (?i gnus-tmp-score ?d)
1002 (?z gnus-tmp-score-char ?c)
1003 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1004 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1005 (?U gnus-tmp-unread ?c)
1006 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header) ?s)
1007 (?t (gnus-summary-number-of-articles-in-thread
1008 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1010 (?e (gnus-summary-number-of-articles-in-thread
1011 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1013 (?u gnus-tmp-user-defined ?s)
1014 (?P (gnus-pick-line-number) ?d))
1015 "An alist of format specifications that can appear in summary lines.
1016 These are paired with what variables they correspond with, along with
1017 the type of the variable (string, integer, character, etc).")
1019 (defvar gnus-summary-dummy-line-format-alist
1020 `((?S gnus-tmp-subject ?s)
1021 (?N gnus-tmp-number ?d)
1022 (?u gnus-tmp-user-defined ?s)))
1024 (defvar gnus-summary-mode-line-format-alist
1025 `((?G gnus-tmp-group-name ?s)
1026 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1027 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1028 (?A gnus-tmp-article-number ?d)
1029 (?Z gnus-tmp-unread-and-unselected ?s)
1030 (?V gnus-version ?s)
1031 (?U gnus-tmp-unread-and-unticked ?d)
1032 (?S gnus-tmp-subject ?s)
1033 (?e gnus-tmp-unselected ?d)
1034 (?u gnus-tmp-user-defined ?s)
1035 (?d (length gnus-newsgroup-dormant) ?d)
1036 (?t (length gnus-newsgroup-marked) ?d)
1037 (?r (length gnus-newsgroup-reads) ?d)
1038 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1039 (?E gnus-newsgroup-expunged-tally ?d)
1040 (?s (gnus-current-score-file-nondirectory) ?s)))
1042 (defvar gnus-last-search-regexp nil
1043 "Default regexp for article search command.")
1045 (defvar gnus-last-shell-command nil
1046 "Default shell command on article.")
1048 (defvar gnus-newsgroup-begin nil)
1049 (defvar gnus-newsgroup-end nil)
1050 (defvar gnus-newsgroup-last-rmail nil)
1051 (defvar gnus-newsgroup-last-mail nil)
1052 (defvar gnus-newsgroup-last-folder nil)
1053 (defvar gnus-newsgroup-last-file nil)
1054 (defvar gnus-newsgroup-auto-expire nil)
1055 (defvar gnus-newsgroup-active nil)
1057 (defvar gnus-newsgroup-data nil)
1058 (defvar gnus-newsgroup-data-reverse nil)
1059 (defvar gnus-newsgroup-limit nil)
1060 (defvar gnus-newsgroup-limits nil)
1062 (defvar gnus-newsgroup-unreads nil
1063 "List of unread articles in the current newsgroup.")
1065 (defvar gnus-newsgroup-unselected nil
1066 "List of unselected unread articles in the current newsgroup.")
1068 (defvar gnus-newsgroup-reads nil
1069 "Alist of read articles and article marks in the current newsgroup.")
1071 (defvar gnus-newsgroup-expunged-tally nil)
1073 (defvar gnus-newsgroup-marked nil
1074 "List of ticked articles in the current newsgroup (a subset of unread art).")
1076 (defvar gnus-newsgroup-killed nil
1077 "List of ranges of articles that have been through the scoring process.")
1079 (defvar gnus-newsgroup-cached nil
1080 "List of articles that come from the article cache.")
1082 (defvar gnus-newsgroup-saved nil
1083 "List of articles that have been saved.")
1085 (defvar gnus-newsgroup-kill-headers nil)
1087 (defvar gnus-newsgroup-replied nil
1088 "List of articles that have been replied to in the current newsgroup.")
1090 (defvar gnus-newsgroup-expirable nil
1091 "List of articles in the current newsgroup that can be expired.")
1093 (defvar gnus-newsgroup-processable nil
1094 "List of articles in the current newsgroup that can be processed.")
1096 (defvar gnus-newsgroup-downloadable nil
1097 "List of articles in the current newsgroup that can be processed.")
1099 (defvar gnus-newsgroup-undownloaded nil
1100 "List of articles in the current newsgroup that haven't been downloaded..")
1102 (defvar gnus-newsgroup-unsendable nil
1103 "List of articles in the current newsgroup that won't be sent.")
1105 (defvar gnus-newsgroup-bookmarks nil
1106 "List of articles in the current newsgroup that have bookmarks.")
1108 (defvar gnus-newsgroup-dormant nil
1109 "List of dormant articles in the current newsgroup.")
1111 (defvar gnus-newsgroup-scored nil
1112 "List of scored articles in the current newsgroup.")
1114 (defvar gnus-newsgroup-headers nil
1115 "List of article headers in the current newsgroup.")
1117 (defvar gnus-newsgroup-threads nil)
1119 (defvar gnus-newsgroup-prepared nil
1120 "Whether the current group has been prepared properly.")
1122 (defvar gnus-newsgroup-ancient nil
1123 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1125 (defvar gnus-newsgroup-sparse nil)
1127 (defvar gnus-current-article nil)
1128 (defvar gnus-article-current nil)
1129 (defvar gnus-current-headers nil)
1130 (defvar gnus-have-all-headers nil)
1131 (defvar gnus-last-article nil)
1132 (defvar gnus-newsgroup-history nil)
1133 (defvar gnus-newsgroup-charset nil)
1134 (defvar gnus-newsgroup-ephemeral-charset nil)
1135 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1137 (defvar gnus-article-before-search nil)
1139 (defconst gnus-summary-local-variables
1140 '(gnus-newsgroup-name
1141 gnus-newsgroup-begin gnus-newsgroup-end
1142 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1143 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1144 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1145 gnus-newsgroup-unselected gnus-newsgroup-marked
1146 gnus-newsgroup-reads gnus-newsgroup-saved
1147 gnus-newsgroup-replied gnus-newsgroup-expirable
1148 gnus-newsgroup-processable gnus-newsgroup-killed
1149 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1150 gnus-newsgroup-unsendable
1151 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1152 gnus-newsgroup-headers gnus-newsgroup-threads
1153 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1154 gnus-current-article gnus-current-headers gnus-have-all-headers
1155 gnus-last-article gnus-article-internal-prepare-hook
1156 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1157 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1158 gnus-thread-expunge-below
1159 gnus-score-alist gnus-current-score-file
1160 (gnus-summary-expunge-below . global)
1161 (gnus-summary-mark-below . global)
1162 (gnus-orphan-score . global)
1163 gnus-newsgroup-active gnus-scores-exclude-files
1164 gnus-newsgroup-history gnus-newsgroup-ancient
1165 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1166 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1167 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1168 (gnus-newsgroup-expunged-tally . 0)
1169 gnus-cache-removable-articles gnus-newsgroup-cached
1170 gnus-newsgroup-data gnus-newsgroup-data-reverse
1171 gnus-newsgroup-limit gnus-newsgroup-limits
1172 gnus-newsgroup-charset)
1173 "Variables that are buffer-local to the summary buffers.")
1175 (defvar gnus-newsgroup-variables nil
1176 "Variables that have separate values in the newsgroups.")
1178 ;; Byte-compiler warning.
1179 (eval-when-compile (defvar gnus-article-mode-map))
1183 (defvar gnus-decode-encoded-word-methods
1184 '(mail-decode-encoded-word-string)
1185 "List of methods used to decode encoded words.
1187 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item is
1188 FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1189 (REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
1190 whose names match REGEXP.
1193 ((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
1194 mail-decode-encoded-word-string
1195 (\"chinese\" . rfc1843-decode-string))")
1197 (defvar gnus-decode-encoded-word-methods-cache nil)
1199 (defun gnus-multi-decode-encoded-word-string (string)
1200 "Apply the functions from `gnus-encoded-word-methods' that match."
1201 (unless (and gnus-decode-encoded-word-methods-cache
1202 (eq gnus-newsgroup-name
1203 (car gnus-decode-encoded-word-methods-cache)))
1204 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
1207 (nconc gnus-decode-encoded-word-methods-cache (list x))
1208 (if (and gnus-newsgroup-name
1209 (string-match (car x) gnus-newsgroup-name))
1210 (nconc gnus-decode-encoded-word-methods-cache
1212 gnus-decode-encoded-word-methods))
1213 (let ((xlist gnus-decode-encoded-word-methods-cache))
1216 (setq string (funcall (pop xlist) string))))
1219 ;; Subject simplification.
1221 (defun gnus-simplify-whitespace (str)
1222 "Remove excessive whitespace from STR."
1225 (while (string-match "[ \t][ \t]+" mystr)
1226 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1228 (substring mystr (match-end 0)))))
1230 (when (string-match "^[ \t]+" mystr)
1231 (setq mystr (substring mystr (match-end 0))))
1233 (when (string-match "[ \t]+$" mystr)
1234 (setq mystr (substring mystr 0 (match-beginning 0))))
1237 (defsubst gnus-simplify-subject-re (subject)
1238 "Remove \"Re:\" from subject lines."
1239 (if (string-match message-subject-re-regexp subject)
1240 (substring subject (match-end 0))
1243 (defun gnus-simplify-subject (subject &optional re-only)
1244 "Remove `Re:' and words in parentheses.
1245 If RE-ONLY is non-nil, strip leading `Re:'s only."
1246 (let ((case-fold-search t)) ;Ignore case.
1247 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1248 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1249 (setq subject (substring subject (match-end 0))))
1250 ;; Remove uninteresting prefixes.
1251 (when (and (not re-only)
1252 gnus-simplify-ignored-prefixes
1253 (string-match gnus-simplify-ignored-prefixes subject))
1254 (setq subject (substring subject (match-end 0))))
1255 ;; Remove words in parentheses from end.
1257 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1258 (setq subject (substring subject 0 (match-beginning 0)))))
1259 ;; Return subject string.
1262 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1264 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1265 (goto-char (point-min))
1266 (while (re-search-forward regexp nil t)
1267 (replace-match (or newtext ""))))
1269 (defun gnus-simplify-buffer-fuzzy ()
1270 "Simplify string in the buffer fuzzily.
1271 The string in the accessible portion of the current buffer is simplified.
1272 It is assumed to be a single-line subject.
1273 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1274 matter is removed. Additional things can be deleted by setting
1275 `gnus-simplify-subject-fuzzy-regexp'."
1276 (let ((case-fold-search t)
1278 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1280 (while (not (eq modified-tick (buffer-modified-tick)))
1281 (setq modified-tick (buffer-modified-tick))
1283 ((listp gnus-simplify-subject-fuzzy-regexp)
1284 (mapcar 'gnus-simplify-buffer-fuzzy-step
1285 gnus-simplify-subject-fuzzy-regexp))
1286 (gnus-simplify-subject-fuzzy-regexp
1287 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1288 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1289 (gnus-simplify-buffer-fuzzy-step
1290 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1291 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1293 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1294 (gnus-simplify-buffer-fuzzy-step " +" " ")
1295 (gnus-simplify-buffer-fuzzy-step " $")
1296 (gnus-simplify-buffer-fuzzy-step "^ +")))
1298 (defun gnus-simplify-subject-fuzzy (subject)
1299 "Simplify a subject string fuzzily.
1300 See `gnus-simplify-buffer-fuzzy' for details."
1302 (gnus-set-work-buffer)
1303 (let ((case-fold-search t))
1304 ;; Remove uninteresting prefixes.
1305 (when (and gnus-simplify-ignored-prefixes
1306 (string-match gnus-simplify-ignored-prefixes subject))
1307 (setq subject (substring subject (match-end 0))))
1309 (inline (gnus-simplify-buffer-fuzzy))
1312 (defsubst gnus-simplify-subject-fully (subject)
1313 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1315 (gnus-simplify-subject-functions
1316 (gnus-map-function gnus-simplify-subject-functions subject))
1317 ((null gnus-summary-gather-subject-limit)
1318 (gnus-simplify-subject-re subject))
1319 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1320 (gnus-simplify-subject-fuzzy subject))
1321 ((numberp gnus-summary-gather-subject-limit)
1322 (gnus-limit-string (gnus-simplify-subject-re subject)
1323 gnus-summary-gather-subject-limit))
1327 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1328 "Check whether two subjects are equal.
1329 If optional argument simple-first is t, first argument is already
1332 ((null simple-first)
1333 (equal (gnus-simplify-subject-fully s1)
1334 (gnus-simplify-subject-fully s2)))
1337 (gnus-simplify-subject-fully s2)))))
1339 (defun gnus-summary-bubble-group ()
1340 "Increase the score of the current group.
1341 This is a handy function to add to `gnus-summary-exit-hook' to
1342 increase the score of each group you read."
1343 (gnus-group-add-score gnus-newsgroup-name))
1347 ;;; Gnus summary mode
1350 (put 'gnus-summary-mode 'mode-class 'special)
1352 (defvar gnus-article-commands-menu)
1355 ;; Non-orthogonal keys
1357 (gnus-define-keys gnus-summary-mode-map
1358 " " gnus-summary-next-page
1359 "\177" gnus-summary-prev-page
1360 [delete] gnus-summary-prev-page
1361 [backspace] gnus-summary-prev-page
1362 "\r" gnus-summary-scroll-up
1363 "\M-\r" gnus-summary-scroll-down
1364 "n" gnus-summary-next-unread-article
1365 "p" gnus-summary-prev-unread-article
1366 "N" gnus-summary-next-article
1367 "P" gnus-summary-prev-article
1368 "\M-\C-n" gnus-summary-next-same-subject
1369 "\M-\C-p" gnus-summary-prev-same-subject
1370 "\M-n" gnus-summary-next-unread-subject
1371 "\M-p" gnus-summary-prev-unread-subject
1372 "." gnus-summary-first-unread-article
1373 "," gnus-summary-best-unread-article
1374 "\M-s" gnus-summary-search-article-forward
1375 "\M-r" gnus-summary-search-article-backward
1376 "<" gnus-summary-beginning-of-article
1377 ">" gnus-summary-end-of-article
1378 "j" gnus-summary-goto-article
1379 "^" gnus-summary-refer-parent-article
1380 "\M-^" gnus-summary-refer-article
1381 "u" gnus-summary-tick-article-forward
1382 "!" gnus-summary-tick-article-forward
1383 "U" gnus-summary-tick-article-backward
1384 "d" gnus-summary-mark-as-read-forward
1385 "D" gnus-summary-mark-as-read-backward
1386 "E" gnus-summary-mark-as-expirable
1387 "\M-u" gnus-summary-clear-mark-forward
1388 "\M-U" gnus-summary-clear-mark-backward
1389 "k" gnus-summary-kill-same-subject-and-select
1390 "\C-k" gnus-summary-kill-same-subject
1391 "\M-\C-k" gnus-summary-kill-thread
1392 "\M-\C-l" gnus-summary-lower-thread
1393 "e" gnus-summary-edit-article
1394 "#" gnus-summary-mark-as-processable
1395 "\M-#" gnus-summary-unmark-as-processable
1396 "\M-\C-t" gnus-summary-toggle-threads
1397 "\M-\C-s" gnus-summary-show-thread
1398 "\M-\C-h" gnus-summary-hide-thread
1399 "\M-\C-f" gnus-summary-next-thread
1400 "\M-\C-b" gnus-summary-prev-thread
1401 [(meta down)] gnus-summary-next-thread
1402 [(meta up)] gnus-summary-prev-thread
1403 "\M-\C-u" gnus-summary-up-thread
1404 "\M-\C-d" gnus-summary-down-thread
1405 "&" gnus-summary-execute-command
1406 "c" gnus-summary-catchup-and-exit
1407 "\C-w" gnus-summary-mark-region-as-read
1408 "\C-t" gnus-summary-toggle-truncation
1409 "?" gnus-summary-mark-as-dormant
1410 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1411 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1412 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1413 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1414 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1415 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1416 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1417 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1418 "=" gnus-summary-expand-window
1419 "\C-x\C-s" gnus-summary-reselect-current-group
1420 "\M-g" gnus-summary-rescan-group
1421 "w" gnus-summary-stop-page-breaking
1422 "\C-c\C-r" gnus-summary-caesar-message
1423 "f" gnus-summary-followup
1424 "F" gnus-summary-followup-with-original
1425 "C" gnus-summary-cancel-article
1426 "r" gnus-summary-reply
1427 "R" gnus-summary-reply-with-original
1428 "\C-c\C-f" gnus-summary-mail-forward
1429 "o" gnus-summary-save-article
1430 "\C-o" gnus-summary-save-article-mail
1431 "|" gnus-summary-pipe-output
1432 "\M-k" gnus-summary-edit-local-kill
1433 "\M-K" gnus-summary-edit-global-kill
1435 "\C-c\C-d" gnus-summary-describe-group
1436 "q" gnus-summary-exit
1437 "Q" gnus-summary-exit-no-update
1438 "\C-c\C-i" gnus-info-find-node
1439 gnus-mouse-2 gnus-mouse-pick-article
1440 "m" gnus-summary-mail-other-window
1441 "a" gnus-summary-post-news
1442 "x" gnus-summary-limit-to-unread
1443 "s" gnus-summary-isearch-article
1444 "t" gnus-summary-toggle-header
1445 "g" gnus-summary-show-article
1446 "l" gnus-summary-goto-last-article
1447 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1448 "\C-d" gnus-summary-enter-digest-group
1449 "\M-\C-d" gnus-summary-read-document
1450 "\M-\C-e" gnus-summary-edit-parameters
1451 "\M-\C-a" gnus-summary-customize-parameters
1453 "*" gnus-cache-enter-article
1454 "\M-*" gnus-cache-remove-article
1455 "\M-&" gnus-summary-universal-argument
1456 "\C-l" gnus-recenter
1457 "I" gnus-summary-increase-score
1458 "L" gnus-summary-lower-score
1459 "\M-i" gnus-symbolic-argument
1460 "h" gnus-summary-select-article-buffer
1462 "b" gnus-article-view-part
1463 "\M-t" gnus-summary-toggle-display-buttonized
1465 "V" gnus-summary-score-map
1466 "X" gnus-uu-extract-map
1467 "S" gnus-summary-send-map)
1469 ;; Sort of orthogonal keymap
1470 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1471 "t" gnus-summary-tick-article-forward
1472 "!" gnus-summary-tick-article-forward
1473 "d" gnus-summary-mark-as-read-forward
1474 "r" gnus-summary-mark-as-read-forward
1475 "c" gnus-summary-clear-mark-forward
1476 " " gnus-summary-clear-mark-forward
1477 "e" gnus-summary-mark-as-expirable
1478 "x" gnus-summary-mark-as-expirable
1479 "?" gnus-summary-mark-as-dormant
1480 "b" gnus-summary-set-bookmark
1481 "B" gnus-summary-remove-bookmark
1482 "#" gnus-summary-mark-as-processable
1483 "\M-#" gnus-summary-unmark-as-processable
1484 "S" gnus-summary-limit-include-expunged
1485 "C" gnus-summary-catchup
1486 "H" gnus-summary-catchup-to-here
1487 "\C-c" gnus-summary-catchup-all
1488 "k" gnus-summary-kill-same-subject-and-select
1489 "K" gnus-summary-kill-same-subject
1490 "P" gnus-uu-mark-map)
1492 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1493 "c" gnus-summary-clear-above
1494 "u" gnus-summary-tick-above
1495 "m" gnus-summary-mark-above
1496 "k" gnus-summary-kill-below)
1498 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1499 "/" gnus-summary-limit-to-subject
1500 "n" gnus-summary-limit-to-articles
1501 "w" gnus-summary-pop-limit
1502 "s" gnus-summary-limit-to-subject
1503 "a" gnus-summary-limit-to-author
1504 "u" gnus-summary-limit-to-unread
1505 "m" gnus-summary-limit-to-marks
1506 "M" gnus-summary-limit-exclude-marks
1507 "v" gnus-summary-limit-to-score
1508 "*" gnus-summary-limit-include-cached
1509 "D" gnus-summary-limit-include-dormant
1510 "T" gnus-summary-limit-include-thread
1511 "d" gnus-summary-limit-exclude-dormant
1512 "t" gnus-summary-limit-to-age
1513 "x" gnus-summary-limit-to-extra
1514 "E" gnus-summary-limit-include-expunged
1515 "c" gnus-summary-limit-exclude-childless-dormant
1516 "C" gnus-summary-limit-mark-excluded-as-read)
1518 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1519 "n" gnus-summary-next-unread-article
1520 "p" gnus-summary-prev-unread-article
1521 "N" gnus-summary-next-article
1522 "P" gnus-summary-prev-article
1523 "\C-n" gnus-summary-next-same-subject
1524 "\C-p" gnus-summary-prev-same-subject
1525 "\M-n" gnus-summary-next-unread-subject
1526 "\M-p" gnus-summary-prev-unread-subject
1527 "f" gnus-summary-first-unread-article
1528 "b" gnus-summary-best-unread-article
1529 "j" gnus-summary-goto-article
1530 "g" gnus-summary-goto-subject
1531 "l" gnus-summary-goto-last-article
1532 "o" gnus-summary-pop-article)
1534 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1535 "k" gnus-summary-kill-thread
1536 "l" gnus-summary-lower-thread
1537 "i" gnus-summary-raise-thread
1538 "T" gnus-summary-toggle-threads
1539 "t" gnus-summary-rethread-current
1540 "^" gnus-summary-reparent-thread
1541 "s" gnus-summary-show-thread
1542 "S" gnus-summary-show-all-threads
1543 "h" gnus-summary-hide-thread
1544 "H" gnus-summary-hide-all-threads
1545 "n" gnus-summary-next-thread
1546 "p" gnus-summary-prev-thread
1547 "u" gnus-summary-up-thread
1548 "o" gnus-summary-top-thread
1549 "d" gnus-summary-down-thread
1550 "#" gnus-uu-mark-thread
1551 "\M-#" gnus-uu-unmark-thread)
1553 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1554 "g" gnus-summary-prepare
1555 "c" gnus-summary-insert-cached-articles)
1557 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1558 "c" gnus-summary-catchup-and-exit
1559 "C" gnus-summary-catchup-all-and-exit
1560 "E" gnus-summary-exit-no-update
1561 "Q" gnus-summary-exit
1562 "Z" gnus-summary-exit
1563 "n" gnus-summary-catchup-and-goto-next-group
1564 "R" gnus-summary-reselect-current-group
1565 "G" gnus-summary-rescan-group
1566 "N" gnus-summary-next-group
1567 "s" gnus-summary-save-newsrc
1568 "P" gnus-summary-prev-group)
1570 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1571 " " gnus-summary-next-page
1572 "n" gnus-summary-next-page
1573 "\177" gnus-summary-prev-page
1574 [delete] gnus-summary-prev-page
1575 "p" gnus-summary-prev-page
1576 "\r" gnus-summary-scroll-up
1577 "\M-\r" gnus-summary-scroll-down
1578 "<" gnus-summary-beginning-of-article
1579 ">" gnus-summary-end-of-article
1580 "b" gnus-summary-beginning-of-article
1581 "e" gnus-summary-end-of-article
1582 "^" gnus-summary-refer-parent-article
1583 "r" gnus-summary-refer-parent-article
1584 "D" gnus-summary-enter-digest-group
1585 "R" gnus-summary-refer-references
1586 "T" gnus-summary-refer-thread
1587 "g" gnus-summary-show-article
1588 "s" gnus-summary-isearch-article
1589 "P" gnus-summary-print-article
1590 "M" gnus-mailing-list-insinuate
1591 "t" gnus-article-babel)
1593 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1594 "b" gnus-article-add-buttons
1595 "B" gnus-article-add-buttons-to-head
1596 "o" gnus-article-treat-overstrike
1597 "e" gnus-article-emphasize
1598 "w" gnus-article-fill-cited-article
1599 "Q" gnus-article-fill-long-lines
1600 "C" gnus-article-capitalize-sentences
1601 "c" gnus-article-remove-cr
1602 "q" gnus-article-de-quoted-unreadable
1603 "6" gnus-article-de-base64-unreadable
1604 "Z" gnus-article-decode-HZ
1605 "h" gnus-article-wash-html
1606 "s" gnus-summary-force-verify-and-decrypt
1607 "f" gnus-article-display-x-face
1608 "l" gnus-summary-stop-page-breaking
1609 "r" gnus-summary-caesar-message
1610 "t" gnus-summary-toggle-header
1611 "v" gnus-summary-verbose-headers
1612 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
1613 "p" gnus-article-verify-x-pgp-sig
1614 "d" gnus-article-treat-dumbquotes)
1616 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1617 "a" gnus-article-hide
1618 "h" gnus-article-hide-headers
1619 "b" gnus-article-hide-boring-headers
1620 "s" gnus-article-hide-signature
1621 "c" gnus-article-hide-citation
1622 "C" gnus-article-hide-citation-in-followups
1623 "l" gnus-article-hide-list-identifiers
1624 "p" gnus-article-hide-pgp
1625 "B" gnus-article-strip-banner
1626 "P" gnus-article-hide-pem
1627 "\C-c" gnus-article-hide-citation-maybe)
1629 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1630 "a" gnus-article-highlight
1631 "h" gnus-article-highlight-headers
1632 "c" gnus-article-highlight-citation
1633 "s" gnus-article-highlight-signature)
1635 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
1636 "w" gnus-article-decode-mime-words
1637 "c" gnus-article-decode-charset
1638 "v" gnus-mime-view-all-parts
1639 "b" gnus-article-view-part)
1641 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1642 "z" gnus-article-date-ut
1643 "u" gnus-article-date-ut
1644 "l" gnus-article-date-local
1645 "p" gnus-article-date-english
1646 "e" gnus-article-date-lapsed
1647 "o" gnus-article-date-original
1648 "i" gnus-article-date-iso8601
1649 "s" gnus-article-date-user)
1651 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1652 "t" gnus-article-remove-trailing-blank-lines
1653 "l" gnus-article-strip-leading-blank-lines
1654 "m" gnus-article-strip-multiple-blank-lines
1655 "a" gnus-article-strip-blank-lines
1656 "A" gnus-article-strip-all-blank-lines
1657 "s" gnus-article-strip-leading-space
1658 "e" gnus-article-strip-trailing-space
1659 "w" gnus-article-remove-leading-whitespace)
1661 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1663 "f" gnus-summary-fetch-faq
1664 "d" gnus-summary-describe-group
1665 "h" gnus-summary-describe-briefly
1666 "i" gnus-info-find-node)
1668 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1669 "e" gnus-summary-expire-articles
1670 "\M-\C-e" gnus-summary-expire-articles-now
1671 "\177" gnus-summary-delete-article
1672 [delete] gnus-summary-delete-article
1673 [backspace] gnus-summary-delete-article
1674 "m" gnus-summary-move-article
1675 "r" gnus-summary-respool-article
1676 "w" gnus-summary-edit-article
1677 "c" gnus-summary-copy-article
1678 "B" gnus-summary-crosspost-article
1679 "q" gnus-summary-respool-query
1680 "t" gnus-summary-respool-trace
1681 "i" gnus-summary-import-article
1682 "p" gnus-summary-article-posted-p)
1684 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1685 "o" gnus-summary-save-article
1686 "m" gnus-summary-save-article-mail
1687 "F" gnus-summary-write-article-file
1688 "r" gnus-summary-save-article-rmail
1689 "f" gnus-summary-save-article-file
1690 "b" gnus-summary-save-article-body-file
1691 "h" gnus-summary-save-article-folder
1692 "v" gnus-summary-save-article-vm
1693 "p" gnus-summary-pipe-output
1694 "s" gnus-soup-add-article)
1696 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
1697 "b" gnus-summary-display-buttonized
1698 "m" gnus-summary-repair-multipart
1699 "v" gnus-article-view-part
1700 "o" gnus-article-save-part
1701 "c" gnus-article-copy-part
1702 "C" gnus-article-view-part-as-charset
1703 "e" gnus-article-externalize-part
1704 "E" gnus-article-encrypt-body
1705 "i" gnus-article-inline-part
1706 "|" gnus-article-pipe-part))
1708 (defun gnus-summary-make-menu-bar ()
1709 (gnus-turn-off-edit-menu 'summary)
1711 (unless (boundp 'gnus-summary-misc-menu)
1714 gnus-summary-kill-menu gnus-summary-mode-map ""
1719 ["Customize" gnus-score-customize t])
1720 (gnus-make-score-map 'increase)
1721 (gnus-make-score-map 'lower)
1723 ["Kill below" gnus-summary-kill-below t]
1724 ["Mark above" gnus-summary-mark-above t]
1725 ["Tick above" gnus-summary-tick-above t]
1726 ["Clear above" gnus-summary-clear-above t])
1727 ["Current score" gnus-summary-current-score t]
1728 ["Set score" gnus-summary-set-score t]
1729 ["Switch current score file..." gnus-score-change-score-file t]
1730 ["Set mark below..." gnus-score-set-mark-below t]
1731 ["Set expunge below..." gnus-score-set-expunge-below t]
1732 ["Edit current score file" gnus-score-edit-current-scores t]
1733 ["Edit score file" gnus-score-edit-file t]
1734 ["Trace score" gnus-score-find-trace t]
1735 ["Find words" gnus-score-find-favourite-words t]
1736 ["Rescore buffer" gnus-summary-rescore t]
1737 ["Increase score..." gnus-summary-increase-score t]
1738 ["Lower score..." gnus-summary-lower-score t]))))
1740 ;; Define both the Article menu in the summary buffer and the equivalent
1741 ;; Commands menu in the article buffer here for consistency.
1744 ["All" gnus-article-hide t]
1745 ["Headers" gnus-article-hide-headers t]
1746 ["Signature" gnus-article-hide-signature t]
1747 ["Citation" gnus-article-hide-citation t]
1748 ["List identifiers" gnus-article-hide-list-identifiers t]
1749 ["PGP" gnus-article-hide-pgp t]
1750 ["Banner" gnus-article-strip-banner t]
1751 ["Boring headers" gnus-article-hide-boring-headers t])
1753 ["All" gnus-article-highlight t]
1754 ["Headers" gnus-article-highlight-headers t]
1755 ["Signature" gnus-article-highlight-signature t]
1756 ["Citation" gnus-article-highlight-citation t])
1758 ["Words" gnus-article-decode-mime-words t]
1759 ["Charset" gnus-article-decode-charset t]
1760 ["QP" gnus-article-de-quoted-unreadable t]
1761 ["Base64" gnus-article-de-base64-unreadable t]
1762 ["View all" gnus-mime-view-all-parts t]
1763 ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t]
1764 ["Encrypt body" gnus-article-encrypt-body t])
1766 ["Local" gnus-article-date-local t]
1767 ["ISO8601" gnus-article-date-iso8601 t]
1768 ["UT" gnus-article-date-ut t]
1769 ["Original" gnus-article-date-original t]
1770 ["Lapsed" gnus-article-date-lapsed t]
1771 ["User-defined" gnus-article-date-user t])
1774 ["Leading" gnus-article-strip-leading-blank-lines t]
1775 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1776 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1777 ["All of the above" gnus-article-strip-blank-lines t]
1778 ["All" gnus-article-strip-all-blank-lines t]
1779 ["Leading space" gnus-article-strip-leading-space t]
1780 ["Trailing space" gnus-article-strip-trailing-space t]
1781 ["Leading space in headers"
1782 gnus-article-remove-leading-whitespace t])
1783 ["Overstrike" gnus-article-treat-overstrike t]
1784 ["Dumb quotes" gnus-article-treat-dumbquotes t]
1785 ["Emphasis" gnus-article-emphasize t]
1786 ["Word wrap" gnus-article-fill-cited-article t]
1787 ["Fill long lines" gnus-article-fill-long-lines t]
1788 ["Capitalize sentences" gnus-article-capitalize-sentences t]
1789 ["CR" gnus-article-remove-cr t]
1790 ["Show X-Face" gnus-article-display-x-face t]
1791 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
1792 ["Base64" gnus-article-de-base64-unreadable t]
1793 ["Rot 13" gnus-summary-caesar-message
1794 ,@(if (featurep 'xemacs) '(t)
1795 '(:help "\"Caesar rotate\" article by 13"))]
1796 ["Unix pipe" gnus-summary-pipe-message t]
1797 ["Add buttons" gnus-article-add-buttons t]
1798 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1799 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1800 ["Verbose header" gnus-summary-verbose-headers t]
1801 ["Toggle header" gnus-summary-toggle-header t]
1802 ["Html" gnus-article-wash-html t]
1803 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
1804 ["HZ" gnus-article-decode-HZ t])
1806 ["Save in default format" gnus-summary-save-article
1807 ,@(if (featurep 'xemacs) '(t)
1808 '(:help "Save article using default method"))]
1809 ["Save in file" gnus-summary-save-article-file
1810 ,@(if (featurep 'xemacs) '(t)
1811 '(:help "Save article in file"))]
1812 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1813 ["Save in MH folder" gnus-summary-save-article-folder t]
1814 ["Save in VM folder" gnus-summary-save-article-vm t]
1815 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1816 ["Save body in file" gnus-summary-save-article-body-file t]
1817 ["Pipe through a filter" gnus-summary-pipe-output t]
1818 ["Add to SOUP packet" gnus-soup-add-article t]
1819 ["Print" gnus-summary-print-article t])
1821 ["Respool article..." gnus-summary-respool-article t]
1822 ["Move article..." gnus-summary-move-article
1823 (gnus-check-backend-function
1824 'request-move-article gnus-newsgroup-name)]
1825 ["Copy article..." gnus-summary-copy-article t]
1826 ["Crosspost article..." gnus-summary-crosspost-article
1827 (gnus-check-backend-function
1828 'request-replace-article gnus-newsgroup-name)]
1829 ["Import file..." gnus-summary-import-article t]
1830 ["Check if posted" gnus-summary-article-posted-p t]
1831 ["Edit article" gnus-summary-edit-article
1832 (not (gnus-group-read-only-p))]
1833 ["Delete article" gnus-summary-delete-article
1834 (gnus-check-backend-function
1835 'request-expire-articles gnus-newsgroup-name)]
1836 ["Query respool" gnus-summary-respool-query t]
1837 ["Trace respool" gnus-summary-respool-trace t]
1838 ["Delete expirable articles" gnus-summary-expire-articles-now
1839 (gnus-check-backend-function
1840 'request-expire-articles gnus-newsgroup-name)])
1842 ["Uudecode" gnus-uu-decode-uu
1843 ,@(if (featurep 'xemacs) '(t)
1844 '(:help "Decode uuencoded article(s)"))]
1845 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1846 ["Unshar" gnus-uu-decode-unshar t]
1847 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1848 ["Save" gnus-uu-decode-save t]
1849 ["Binhex" gnus-uu-decode-binhex t]
1850 ["Postscript" gnus-uu-decode-postscript t])
1852 ["Enter article" gnus-cache-enter-article t]
1853 ["Remove article" gnus-cache-remove-article t])
1854 ["Translate" gnus-article-babel t]
1855 ["Select article buffer" gnus-summary-select-article-buffer t]
1856 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1857 ["Isearch article..." gnus-summary-isearch-article t]
1858 ["Beginning of the article" gnus-summary-beginning-of-article t]
1859 ["End of the article" gnus-summary-end-of-article t]
1860 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1861 ["Fetch referenced articles" gnus-summary-refer-references t]
1862 ["Fetch current thread" gnus-summary-refer-thread t]
1863 ["Fetch article with id..." gnus-summary-refer-article t]
1864 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
1865 ["Redisplay" gnus-summary-show-article t])))
1867 gnus-summary-article-menu gnus-summary-mode-map ""
1868 (cons "Article" innards))
1870 (if (not (keymapp gnus-summary-article-menu))
1872 gnus-article-commands-menu gnus-article-mode-map ""
1873 (cons "Commands" innards))
1874 ;; in Emacs, don't share menu.
1875 (setq gnus-article-commands-menu
1876 (copy-keymap gnus-summary-article-menu))
1877 (define-key gnus-article-mode-map [menu-bar commands]
1878 (cons "Commands" gnus-article-commands-menu))))
1881 gnus-summary-thread-menu gnus-summary-mode-map ""
1883 ["Toggle threading" gnus-summary-toggle-threads t]
1884 ["Hide threads" gnus-summary-hide-all-threads t]
1885 ["Show threads" gnus-summary-show-all-threads t]
1886 ["Hide thread" gnus-summary-hide-thread t]
1887 ["Show thread" gnus-summary-show-thread t]
1888 ["Go to next thread" gnus-summary-next-thread t]
1889 ["Go to previous thread" gnus-summary-prev-thread t]
1890 ["Go down thread" gnus-summary-down-thread t]
1891 ["Go up thread" gnus-summary-up-thread t]
1892 ["Top of thread" gnus-summary-top-thread t]
1893 ["Mark thread as read" gnus-summary-kill-thread t]
1894 ["Lower thread score" gnus-summary-lower-thread t]
1895 ["Raise thread score" gnus-summary-raise-thread t]
1896 ["Rethread current" gnus-summary-rethread-current t]))
1899 gnus-summary-post-menu gnus-summary-mode-map ""
1901 ["Post an article" gnus-summary-post-news
1902 ,@(if (featurep 'xemacs) '(t)
1903 '(:help "Post an article"))]
1904 ["Followup" gnus-summary-followup
1905 ,@(if (featurep 'xemacs) '(t)
1906 '(:help "Post followup to this article"))]
1907 ["Followup and yank" gnus-summary-followup-with-original
1908 ,@(if (featurep 'xemacs) '(t)
1909 '(:help "Post followup to this article, quoting its contents"))]
1910 ["Supersede article" gnus-summary-supersede-article t]
1911 ["Cancel article" gnus-summary-cancel-article
1912 ,@(if (featurep 'xemacs) '(t)
1913 '(:help "Cancel an article you posted"))]
1914 ["Reply" gnus-summary-reply t]
1915 ["Reply and yank" gnus-summary-reply-with-original t]
1916 ["Wide reply" gnus-summary-wide-reply t]
1917 ["Wide reply and yank" gnus-summary-wide-reply-with-original
1918 ,@(if (featurep 'xemacs) '(t)
1919 '(:help "Mail a reply, quoting this article"))]
1920 ["Mail forward" gnus-summary-mail-forward t]
1921 ["Post forward" gnus-summary-post-forward t]
1922 ["Digest and mail" gnus-uu-digest-mail-forward t]
1923 ["Digest and post" gnus-uu-digest-post-forward t]
1924 ["Resend message" gnus-summary-resend-message t]
1925 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
1926 ["Send a mail" gnus-summary-mail-other-window t]
1927 ["Uuencode and post" gnus-uu-post-news
1928 ,@(if (featurep 'xemacs) '(t)
1929 '(:help "Post a uuencoded article"))]
1930 ["Followup via news" gnus-summary-followup-to-mail t]
1931 ["Followup via news and yank"
1932 gnus-summary-followup-to-mail-with-original t]
1934 ;;["Send" gnus-summary-send-draft t]
1935 ;;["Send bounced" gnus-resend-bounced-mail t])
1939 gnus-summary-misc-menu gnus-summary-mode-map ""
1942 ["Mark as read" gnus-summary-mark-as-read-forward t]
1943 ["Mark same subject and select"
1944 gnus-summary-kill-same-subject-and-select t]
1945 ["Mark same subject" gnus-summary-kill-same-subject t]
1946 ["Catchup" gnus-summary-catchup
1947 ,@(if (featurep 'xemacs) '(t)
1948 '(:help "Mark unread articles in this group as read"))]
1949 ["Catchup all" gnus-summary-catchup-all t]
1950 ["Catchup to here" gnus-summary-catchup-to-here t]
1951 ["Catchup region" gnus-summary-mark-region-as-read t]
1952 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
1954 ["Tick" gnus-summary-tick-article-forward t]
1955 ["Mark as dormant" gnus-summary-mark-as-dormant t]
1956 ["Remove marks" gnus-summary-clear-mark-forward t]
1957 ["Set expirable mark" gnus-summary-mark-as-expirable t]
1958 ["Set bookmark" gnus-summary-set-bookmark t]
1959 ["Remove bookmark" gnus-summary-remove-bookmark t])
1961 ["Marks..." gnus-summary-limit-to-marks t]
1962 ["Subject..." gnus-summary-limit-to-subject t]
1963 ["Author..." gnus-summary-limit-to-author t]
1964 ["Age..." gnus-summary-limit-to-age t]
1965 ["Extra..." gnus-summary-limit-to-extra t]
1966 ["Score" gnus-summary-limit-to-score t]
1967 ["Unread" gnus-summary-limit-to-unread t]
1968 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
1969 ["Articles" gnus-summary-limit-to-articles t]
1970 ["Pop limit" gnus-summary-pop-limit t]
1971 ["Show dormant" gnus-summary-limit-include-dormant t]
1972 ["Hide childless dormant"
1973 gnus-summary-limit-exclude-childless-dormant t]
1974 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
1975 ["Hide marked" gnus-summary-limit-exclude-marks t]
1976 ["Show expunged" gnus-summary-show-all-expunged t])
1978 ["Set mark" gnus-summary-mark-as-processable t]
1979 ["Remove mark" gnus-summary-unmark-as-processable t]
1980 ["Remove all marks" gnus-summary-unmark-all-processable t]
1981 ["Mark above" gnus-uu-mark-over t]
1982 ["Mark series" gnus-uu-mark-series t]
1983 ["Mark region" gnus-uu-mark-region t]
1984 ["Unmark region" gnus-uu-unmark-region t]
1985 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
1986 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
1987 ["Mark all" gnus-uu-mark-all t]
1988 ["Mark buffer" gnus-uu-mark-buffer t]
1989 ["Mark sparse" gnus-uu-mark-sparse t]
1990 ["Mark thread" gnus-uu-mark-thread t]
1991 ["Unmark thread" gnus-uu-unmark-thread t]
1992 ("Process Mark Sets"
1993 ["Kill" gnus-summary-kill-process-mark t]
1994 ["Yank" gnus-summary-yank-process-mark
1995 gnus-newsgroup-process-stack]
1996 ["Save" gnus-summary-save-process-mark t]))
1998 ["Page forward" gnus-summary-next-page
1999 ,@(if (featurep 'xemacs) '(t)
2000 '(:help "Show next page of article"))]
2001 ["Page backward" gnus-summary-prev-page
2002 ,@(if (featurep 'xemacs) '(t)
2003 '(:help "Show previous page of article"))]
2004 ["Line forward" gnus-summary-scroll-up t])
2006 ["Next unread article" gnus-summary-next-unread-article t]
2007 ["Previous unread article" gnus-summary-prev-unread-article t]
2008 ["Next article" gnus-summary-next-article t]
2009 ["Previous article" gnus-summary-prev-article t]
2010 ["Next unread subject" gnus-summary-next-unread-subject t]
2011 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2012 ["Next article same subject" gnus-summary-next-same-subject t]
2013 ["Previous article same subject" gnus-summary-prev-same-subject t]
2014 ["First unread article" gnus-summary-first-unread-article t]
2015 ["Best unread article" gnus-summary-best-unread-article t]
2016 ["Go to subject number..." gnus-summary-goto-subject t]
2017 ["Go to article number..." gnus-summary-goto-article t]
2018 ["Go to the last article" gnus-summary-goto-last-article t]
2019 ["Pop article off history" gnus-summary-pop-article t])
2021 ["Sort by number" gnus-summary-sort-by-number t]
2022 ["Sort by author" gnus-summary-sort-by-author t]
2023 ["Sort by subject" gnus-summary-sort-by-subject t]
2024 ["Sort by date" gnus-summary-sort-by-date t]
2025 ["Sort by score" gnus-summary-sort-by-score t]
2026 ["Sort by lines" gnus-summary-sort-by-lines t]
2027 ["Sort by characters" gnus-summary-sort-by-chars t])
2029 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2030 ["Describe group" gnus-summary-describe-group t]
2031 ["Read manual" gnus-info-find-node t])
2033 ["Pick and read" gnus-pick-mode t]
2034 ["Binary" gnus-binary-mode t])
2036 ["Regenerate" gnus-summary-prepare t]
2037 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2038 ["Toggle threading" gnus-summary-toggle-threads t])
2039 ["Filter articles..." gnus-summary-execute-command t]
2040 ["Run command on subjects..." gnus-summary-universal-argument t]
2041 ["Search articles forward..." gnus-summary-search-article-forward t]
2042 ["Search articles backward..." gnus-summary-search-article-backward t]
2043 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2044 ["Expand window" gnus-summary-expand-window t]
2045 ["Expire expirable articles" gnus-summary-expire-articles
2046 (gnus-check-backend-function
2047 'request-expire-articles gnus-newsgroup-name)]
2048 ["Edit local kill file" gnus-summary-edit-local-kill t]
2049 ["Edit main kill file" gnus-summary-edit-global-kill t]
2050 ["Edit group parameters" gnus-summary-edit-parameters t]
2051 ["Customize group parameters" gnus-summary-customize-parameters t]
2052 ["Send a bug report" gnus-bug t]
2054 ["Catchup and exit" gnus-summary-catchup-and-exit
2055 ,@(if (featurep 'xemacs) '(t)
2056 '(:help "Mark unread articles in this group as read, then exit"))]
2057 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2058 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2059 ["Exit group" gnus-summary-exit
2060 ,@(if (featurep 'xemacs) '(t)
2061 '(:help "Exit current group, return to group selection mode"))]
2062 ["Exit group without updating" gnus-summary-exit-no-update t]
2063 ["Exit and goto next group" gnus-summary-next-group t]
2064 ["Exit and goto prev group" gnus-summary-prev-group t]
2065 ["Reselect group" gnus-summary-reselect-current-group t]
2066 ["Rescan group" gnus-summary-rescan-group t]
2067 ["Update dribble" gnus-summary-save-newsrc t])))
2069 (gnus-run-hooks 'gnus-summary-menu-hook)))
2071 (defvar gnus-summary-tool-bar-map nil)
2073 ;; Emacs 21 tool bar. Should be no-op otherwise.
2074 (defun gnus-summary-make-tool-bar ()
2075 (if (and (fboundp 'tool-bar-add-item-from-menu)
2076 (default-value 'tool-bar-mode)
2077 (not gnus-summary-tool-bar-map))
2078 (setq gnus-summary-tool-bar-map
2079 (let ((tool-bar-map (make-sparse-keymap))
2080 (load-path (mm-image-load-path)))
2081 (tool-bar-add-item-from-menu
2082 'gnus-summary-prev-unread "prev-ur" gnus-summary-mode-map)
2083 (tool-bar-add-item-from-menu
2084 'gnus-summary-next-unread "next-ur" gnus-summary-mode-map)
2085 (tool-bar-add-item-from-menu
2086 'gnus-summary-post-news "post" gnus-summary-mode-map)
2087 (tool-bar-add-item-from-menu
2088 'gnus-summary-followup-with-original "fuwo" gnus-summary-mode-map)
2089 (tool-bar-add-item-from-menu
2090 'gnus-summary-followup "followup" gnus-summary-mode-map)
2091 (tool-bar-add-item-from-menu
2092 'gnus-summary-reply-with-original "reply-wo" gnus-summary-mode-map)
2093 (tool-bar-add-item-from-menu
2094 'gnus-summary-reply "reply" gnus-summary-mode-map)
2095 (tool-bar-add-item-from-menu
2096 'gnus-summary-caesar-message "rot13" gnus-summary-mode-map)
2097 (tool-bar-add-item-from-menu
2098 'gnus-uu-decode-uu "uu-decode" gnus-summary-mode-map)
2099 (tool-bar-add-item-from-menu
2100 'gnus-summary-save-article-file "save-aif" gnus-summary-mode-map)
2101 (tool-bar-add-item-from-menu
2102 'gnus-summary-save-article "save-art" gnus-summary-mode-map)
2103 (tool-bar-add-item-from-menu
2104 'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2105 (tool-bar-add-item-from-menu
2106 'gnus-summary-catchup "catchup" gnus-summary-mode-map)
2107 (tool-bar-add-item-from-menu
2108 'gnus-summary-catchup-and-exit "cu-exit" gnus-summary-mode-map)
2109 (tool-bar-add-item-from-menu
2110 'gnus-summary-exit "exit-summ" gnus-summary-mode-map)
2112 (if gnus-summary-tool-bar-map
2113 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
2115 (defun gnus-score-set-default (var value)
2116 "A version of set that updates the GNU Emacs menu-bar."
2118 ;; It is the message that forces the active status to be updated.
2121 (defun gnus-make-score-map (type)
2122 "Make a summary score map of type TYPE."
2125 (let ((headers '(("author" "from" string)
2126 ("subject" "subject" string)
2127 ("article body" "body" string)
2128 ("article head" "head" string)
2129 ("xref" "xref" string)
2130 ("extra header" "extra" string)
2131 ("lines" "lines" number)
2132 ("followups to author" "followup" string)))
2133 (types '((number ("less than" <)
2136 (string ("substring" s)
2140 (perms '(("temporary" (current-time-string))
2148 (if (eq type 'lower)
2153 (setq header (car headers))
2159 (let ((ts (cdr (assoc (nth 2 header) types)))
2175 'gnus-summary-score-entry
2177 (if (or (string= (nth 1 header)
2179 (string= (nth 1 header)
2182 (list 'gnus-summary-header
2184 (list 'quote (nth 1 (car ts)))
2185 (list 'gnus-score-delta-default
2192 (list (nreverse outp))))
2195 (list (nreverse outt))))
2197 (setq headers (cdr headers)))
2198 (list (nreverse outh))))))))
2202 (defun gnus-summary-mode (&optional group)
2203 "Major mode for reading articles.
2205 All normal editing commands are switched off.
2206 \\<gnus-summary-mode-map>
2207 Each line in this buffer represents one article. To read an
2208 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2209 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2212 You can also post articles and send mail from this buffer. To
2213 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2214 of an article, type `\\[gnus-summary-reply]'.
2216 There are approx. one gazillion commands you can execute in this
2217 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2219 The following commands are available:
2221 \\{gnus-summary-mode-map}"
2223 (kill-all-local-variables)
2224 (when (gnus-visual-p 'summary-menu 'menu)
2225 (gnus-summary-make-menu-bar)
2226 (gnus-summary-make-tool-bar))
2227 (gnus-summary-make-local-variables)
2228 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2229 (gnus-summary-make-local-variables))
2230 (gnus-make-thread-indent-array)
2231 (gnus-simplify-mode-line)
2232 (setq major-mode 'gnus-summary-mode)
2233 (setq mode-name "Summary")
2234 (make-local-variable 'minor-mode-alist)
2235 (use-local-map gnus-summary-mode-map)
2236 (buffer-disable-undo)
2237 (setq buffer-read-only t) ;Disable modification
2238 (setq truncate-lines t)
2239 (setq selective-display t)
2240 (setq selective-display-ellipses t) ;Display `...'
2241 (gnus-summary-set-display-table)
2242 (gnus-set-default-directory)
2243 (setq gnus-newsgroup-name group)
2244 (make-local-variable 'gnus-summary-line-format)
2245 (make-local-variable 'gnus-summary-line-format-spec)
2246 (make-local-variable 'gnus-summary-dummy-line-format)
2247 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2248 (make-local-variable 'gnus-summary-mark-positions)
2249 (make-local-hook 'pre-command-hook)
2250 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2251 (gnus-run-hooks 'gnus-summary-mode-hook)
2252 (turn-on-gnus-mailing-list-mode)
2253 (mm-enable-multibyte-mule4)
2254 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2255 (gnus-update-summary-mark-positions))
2257 (defun gnus-summary-make-local-variables ()
2258 "Make all the local summary buffer variables."
2260 (dolist (local gnus-summary-local-variables)
2263 (if (eq (cdr local) 'global)
2264 ;; Copy the global value of the variable.
2265 (setq global (symbol-value (car local)))
2266 ;; Use the value from the list.
2267 (setq global (eval (cdr local))))
2268 (set (make-local-variable (car local)) global))
2269 ;; Simple nil-valued local variable.
2270 (set (make-local-variable local) nil)))))
2272 (defun gnus-summary-clear-local-variables ()
2273 (let ((locals gnus-summary-local-variables))
2275 (if (consp (car locals))
2276 (and (vectorp (caar locals))
2277 (set (caar locals) nil))
2278 (and (vectorp (car locals))
2279 (set (car locals) nil)))
2280 (setq locals (cdr locals)))))
2282 ;; Summary data functions.
2284 (defmacro gnus-data-number (data)
2287 (defmacro gnus-data-set-number (data number)
2288 `(setcar ,data ,number))
2290 (defmacro gnus-data-mark (data)
2293 (defmacro gnus-data-set-mark (data mark)
2294 `(setcar (nthcdr 1 ,data) ,mark))
2296 (defmacro gnus-data-pos (data)
2299 (defmacro gnus-data-set-pos (data pos)
2300 `(setcar (nthcdr 2 ,data) ,pos))
2302 (defmacro gnus-data-header (data)
2305 (defmacro gnus-data-set-header (data header)
2306 `(setf (nth 3 ,data) ,header))
2308 (defmacro gnus-data-level (data)
2311 (defmacro gnus-data-unread-p (data)
2312 `(= (nth 1 ,data) gnus-unread-mark))
2314 (defmacro gnus-data-read-p (data)
2315 `(/= (nth 1 ,data) gnus-unread-mark))
2317 (defmacro gnus-data-pseudo-p (data)
2318 `(consp (nth 3 ,data)))
2320 (defmacro gnus-data-find (number)
2321 `(assq ,number gnus-newsgroup-data))
2323 (defmacro gnus-data-find-list (number &optional data)
2324 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2325 (memq (assq ,number bdata)
2328 (defmacro gnus-data-make (number mark pos header level)
2329 `(list ,number ,mark ,pos ,header ,level))
2331 (defun gnus-data-enter (after-article number mark pos header level offset)
2332 (let ((data (gnus-data-find-list after-article)))
2334 (error "No such article: %d" after-article))
2335 (setcdr data (cons (gnus-data-make number mark pos header level)
2337 (setq gnus-newsgroup-data-reverse nil)
2338 (gnus-data-update-list (cddr data) offset)))
2340 (defun gnus-data-enter-list (after-article list &optional offset)
2342 (let ((data (and after-article (gnus-data-find-list after-article)))
2346 (let ((odata gnus-newsgroup-data))
2347 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2349 (gnus-data-update-list odata offset)))
2350 ;; Find the last element in the list to be spliced into the main
2353 (setq list (cdr list)))
2356 (setcdr list gnus-newsgroup-data)
2357 (setq gnus-newsgroup-data ilist)
2359 (gnus-data-update-list (cdr list) offset)))
2360 (setcdr list (cdr data))
2363 (gnus-data-update-list (cdr list) offset))))
2364 (setq gnus-newsgroup-data-reverse nil))))
2366 (defun gnus-data-remove (article &optional offset)
2367 (let ((data gnus-newsgroup-data))
2368 (if (= (gnus-data-number (car data)) article)
2370 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2371 gnus-newsgroup-data-reverse nil)
2373 (gnus-data-update-list gnus-newsgroup-data offset)))
2375 (when (= (gnus-data-number (cadr data)) article)
2376 (setcdr data (cddr data))
2378 (gnus-data-update-list (cdr data) offset))
2380 gnus-newsgroup-data-reverse nil))
2381 (setq data (cdr data))))))
2383 (defmacro gnus-data-list (backward)
2385 (or gnus-newsgroup-data-reverse
2386 (setq gnus-newsgroup-data-reverse
2387 (reverse gnus-newsgroup-data)))
2388 gnus-newsgroup-data))
2390 (defun gnus-data-update-list (data offset)
2391 "Add OFFSET to the POS of all data entries in DATA."
2392 (setq gnus-newsgroup-data-reverse nil)
2394 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2395 (setq data (cdr data))))
2397 (defun gnus-summary-article-pseudo-p (article)
2398 "Say whether this article is a pseudo article or not."
2399 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2401 (defmacro gnus-summary-article-sparse-p (article)
2402 "Say whether this article is a sparse article or not."
2403 `(memq ,article gnus-newsgroup-sparse))
2405 (defmacro gnus-summary-article-ancient-p (article)
2406 "Say whether this article is a sparse article or not."
2407 `(memq ,article gnus-newsgroup-ancient))
2409 (defun gnus-article-parent-p (number)
2410 "Say whether this article is a parent or not."
2411 (let ((data (gnus-data-find-list number)))
2412 (and (cdr data) ; There has to be an article after...
2413 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2414 (gnus-data-level (nth 1 data))))))
2416 (defun gnus-article-children (number)
2417 "Return a list of all children to NUMBER."
2418 (let* ((data (gnus-data-find-list number))
2419 (level (gnus-data-level (car data)))
2421 (setq data (cdr data))
2423 (= (gnus-data-level (car data)) (1+ level)))
2424 (push (gnus-data-number (car data)) children)
2425 (setq data (cdr data)))
2428 (defmacro gnus-summary-skip-intangible ()
2429 "If the current article is intangible, then jump to a different article."
2430 '(let ((to (get-text-property (point) 'gnus-intangible)))
2431 (and to (gnus-summary-goto-subject to))))
2433 (defmacro gnus-summary-article-intangible-p ()
2434 "Say whether this article is intangible or not."
2435 '(get-text-property (point) 'gnus-intangible))
2437 (defun gnus-article-read-p (article)
2438 "Say whether ARTICLE is read or not."
2439 (not (or (memq article gnus-newsgroup-marked)
2440 (memq article gnus-newsgroup-unreads)
2441 (memq article gnus-newsgroup-unselected)
2442 (memq article gnus-newsgroup-dormant))))
2444 ;; Some summary mode macros.
2446 (defmacro gnus-summary-article-number ()
2447 "The article number of the article on the current line.
2448 If there isn's an article number here, then we return the current
2451 (gnus-summary-skip-intangible)
2452 (or (get-text-property (point) 'gnus-number)
2453 (gnus-summary-last-subject))))
2455 (defmacro gnus-summary-article-header (&optional number)
2456 "Return the header of article NUMBER."
2457 `(gnus-data-header (gnus-data-find
2458 ,(or number '(gnus-summary-article-number)))))
2460 (defmacro gnus-summary-thread-level (&optional number)
2461 "Return the level of thread that starts with article NUMBER."
2462 `(if (and (eq gnus-summary-make-false-root 'dummy)
2463 (get-text-property (point) 'gnus-intangible))
2465 (gnus-data-level (gnus-data-find
2466 ,(or number '(gnus-summary-article-number))))))
2468 (defmacro gnus-summary-article-mark (&optional number)
2469 "Return the mark of article NUMBER."
2470 `(gnus-data-mark (gnus-data-find
2471 ,(or number '(gnus-summary-article-number)))))
2473 (defmacro gnus-summary-article-pos (&optional number)
2474 "Return the position of the line of article NUMBER."
2475 `(gnus-data-pos (gnus-data-find
2476 ,(or number '(gnus-summary-article-number)))))
2478 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2479 (defmacro gnus-summary-article-subject (&optional number)
2480 "Return current subject string or nil if nothing."
2483 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2484 '(gnus-data-header (assq (gnus-summary-article-number)
2485 gnus-newsgroup-data)))))
2488 (mail-header-subject headers))))
2490 (defmacro gnus-summary-article-score (&optional number)
2491 "Return current article score."
2492 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2493 gnus-newsgroup-scored))
2494 gnus-summary-default-score 0))
2496 (defun gnus-summary-article-children (&optional number)
2497 "Return a list of article numbers that are children of article NUMBER."
2498 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2499 (level (gnus-data-level (car data)))
2501 (while (and (setq data (cdr data))
2502 (> (setq l (gnus-data-level (car data))) level))
2503 (and (= (1+ level) l)
2504 (push (gnus-data-number (car data))
2506 (nreverse children)))
2508 (defun gnus-summary-article-parent (&optional number)
2509 "Return the article number of the parent of article NUMBER."
2510 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2511 (gnus-data-list t)))
2512 (level (gnus-data-level (car data))))
2514 () ; This is a root.
2515 ;; We search until we find an article with a level less than
2516 ;; this one. That function has to be the parent.
2517 (while (and (setq data (cdr data))
2518 (not (< (gnus-data-level (car data)) level))))
2519 (and data (gnus-data-number (car data))))))
2521 (defun gnus-unread-mark-p (mark)
2522 "Say whether MARK is the unread mark."
2523 (= mark gnus-unread-mark))
2525 (defun gnus-read-mark-p (mark)
2526 "Say whether MARK is one of the marks that mark as read.
2527 This is all marks except unread, ticked, dormant, and expirable."
2528 (not (or (= mark gnus-unread-mark)
2529 (= mark gnus-ticked-mark)
2530 (= mark gnus-dormant-mark)
2531 (= mark gnus-expirable-mark))))
2533 (defmacro gnus-article-mark (number)
2534 "Return the MARK of article NUMBER.
2535 This macro should only be used when computing the mark the \"first\"
2536 time; i.e., when generating the summary lines. After that,
2537 `gnus-summary-article-mark' should be used to examine the
2540 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2541 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2542 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2543 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2544 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2545 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2546 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2547 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2548 gnus-ancient-mark))))
2550 ;; Saving hidden threads.
2552 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2553 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2555 (defmacro gnus-save-hidden-threads (&rest forms)
2556 "Save hidden threads, eval FORMS, and restore the hidden threads."
2557 (let ((config (make-symbol "config")))
2558 `(let ((,config (gnus-hidden-threads-configuration)))
2562 (gnus-restore-hidden-threads-configuration ,config)))))
2564 (defun gnus-data-compute-positions ()
2565 "Compute the positions of all articles."
2566 (setq gnus-newsgroup-data-reverse nil)
2567 (let ((data gnus-newsgroup-data))
2569 (gnus-save-hidden-threads
2570 (gnus-summary-show-all-threads)
2571 (goto-char (point-min))
2573 (while (get-text-property (point) 'gnus-intangible)
2575 (gnus-data-set-pos (car data) (+ (point) 3))
2576 (setq data (cdr data))
2577 (forward-line 1))))))
2579 (defun gnus-hidden-threads-configuration ()
2580 "Return the current hidden threads configuration."
2583 (goto-char (point-min))
2584 (while (search-forward "\r" nil t)
2585 (push (1- (point)) config))
2588 (defun gnus-restore-hidden-threads-configuration (config)
2589 "Restore hidden threads configuration from CONFIG."
2591 (let (point buffer-read-only)
2592 (while (setq point (pop config))
2593 (when (and (< point (point-max))
2595 (eq (char-after) ?\n))
2596 (subst-char-in-region point (1+ point) ?\n ?\r))))))
2598 ;; Various summary mode internalish functions.
2600 (defun gnus-mouse-pick-article (e)
2603 (gnus-summary-next-page nil t))
2605 (defun gnus-summary-set-display-table ()
2606 "Change the display table.
2607 Odd characters have a tendency to mess
2608 up nicely formatted displays - we make all possible glyphs
2609 display only a single character."
2611 ;; We start from the standard display table, if any.
2612 (let ((table (or (copy-sequence standard-display-table)
2613 (make-display-table)))
2615 ;; Nix out all the control chars...
2616 (while (>= (setq i (1- i)) 0)
2617 (aset table i [??]))
2618 ;; ... but not newline and cr, of course. (cr is necessary for the
2619 ;; selective display).
2620 (aset table ?\n nil)
2621 (aset table ?\r nil)
2622 ;; We keep TAB as well.
2623 (aset table ?\t nil)
2624 ;; We nix out any glyphs over 126 that are not set already.
2626 (while (>= (setq i (1- i)) 127)
2627 ;; Only modify if the entry is nil.
2628 (unless (aref table i)
2629 (aset table i [??]))))
2630 (setq buffer-display-table table)))
2632 (defun gnus-summary-buffer-name (group)
2633 "Return the summary buffer name of GROUP."
2634 (concat "*Summary " group "*"))
2636 (defun gnus-summary-setup-buffer (group)
2637 "Initialize summary buffer."
2638 (let ((buffer (gnus-summary-buffer-name group)))
2639 (if (get-buffer buffer)
2642 (setq gnus-summary-buffer (current-buffer))
2643 (not gnus-newsgroup-prepared))
2644 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2645 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
2646 (gnus-summary-mode group)
2648 (gnus-carpal-setup-buffer 'summary))
2649 (unless gnus-single-article-buffer
2650 (make-local-variable 'gnus-article-buffer)
2651 (make-local-variable 'gnus-article-current)
2652 (make-local-variable 'gnus-original-article-buffer))
2653 (setq gnus-newsgroup-name group)
2656 (defun gnus-set-global-variables ()
2657 "Set the global equivalents of the buffer-local variables.
2658 They are set to the latest values they had. These reflect the summary
2659 buffer that was in action when the last article was fetched."
2660 (when (eq major-mode 'gnus-summary-mode)
2661 (setq gnus-summary-buffer (current-buffer))
2662 (let ((name gnus-newsgroup-name)
2663 (marked gnus-newsgroup-marked)
2664 (unread gnus-newsgroup-unreads)
2665 (headers gnus-current-headers)
2666 (data gnus-newsgroup-data)
2667 (summary gnus-summary-buffer)
2668 (article-buffer gnus-article-buffer)
2669 (original gnus-original-article-buffer)
2670 (gac gnus-article-current)
2671 (reffed gnus-reffed-article-number)
2672 (score-file gnus-current-score-file)
2673 (default-charset gnus-newsgroup-charset)
2675 (let ((locals gnus-newsgroup-variables))
2677 (if (consp (car locals))
2678 (push (eval (caar locals)) vlist)
2679 (push (eval (car locals)) vlist))
2680 (setq locals (cdr locals)))
2681 (setq vlist (nreverse vlist)))
2683 (set-buffer gnus-group-buffer)
2684 (setq gnus-newsgroup-name name
2685 gnus-newsgroup-marked marked
2686 gnus-newsgroup-unreads unread
2687 gnus-current-headers headers
2688 gnus-newsgroup-data data
2689 gnus-article-current gac
2690 gnus-summary-buffer summary
2691 gnus-article-buffer article-buffer
2692 gnus-original-article-buffer original
2693 gnus-reffed-article-number reffed
2694 gnus-current-score-file score-file
2695 gnus-newsgroup-charset default-charset)
2696 (let ((locals gnus-newsgroup-variables))
2698 (if (consp (car locals))
2699 (set (caar locals) (pop vlist))
2700 (set (car locals) (pop vlist)))
2701 (setq locals (cdr locals))))
2702 ;; The article buffer also has local variables.
2703 (when (gnus-buffer-live-p gnus-article-buffer)
2704 (set-buffer gnus-article-buffer)
2705 (setq gnus-summary-buffer summary))))))
2707 (defun gnus-summary-article-unread-p (article)
2708 "Say whether ARTICLE is unread or not."
2709 (memq article gnus-newsgroup-unreads))
2711 (defun gnus-summary-first-article-p (&optional article)
2712 "Return whether ARTICLE is the first article in the buffer."
2713 (if (not (setq article (or article (gnus-summary-article-number))))
2715 (eq article (caar gnus-newsgroup-data))))
2717 (defun gnus-summary-last-article-p (&optional article)
2718 "Return whether ARTICLE is the last article in the buffer."
2719 (if (not (setq article (or article (gnus-summary-article-number))))
2720 ;; All non-existent numbers are the last article. :-)
2722 (not (cdr (gnus-data-find-list article)))))
2724 (defun gnus-make-thread-indent-array ()
2726 (unless (and gnus-thread-indent-array
2727 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2728 (setq gnus-thread-indent-array (make-vector 201 "")
2729 gnus-thread-indent-array-level gnus-thread-indent-level)
2731 (aset gnus-thread-indent-array n
2732 (make-string (* n gnus-thread-indent-level) ? ))
2735 (defun gnus-update-summary-mark-positions ()
2736 "Compute where the summary marks are to go."
2738 (when (gnus-buffer-exists-p gnus-summary-buffer)
2739 (set-buffer gnus-summary-buffer))
2740 (let ((gnus-replied-mark 129)
2741 (gnus-score-below-mark 130)
2742 (gnus-score-over-mark 130)
2743 (gnus-download-mark 131)
2744 (spec gnus-summary-line-format-spec)
2747 (gnus-set-work-buffer)
2748 (let ((gnus-summary-line-format-spec spec)
2749 (gnus-newsgroup-downloadable '((0 . t))))
2750 (gnus-summary-insert-line
2751 [0 "" "" "" "" "" 0 0 "" nil] 0 nil 128 t nil "" nil 1)
2752 (goto-char (point-min))
2753 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2755 (goto-char (point-min))
2756 (push (cons 'replied (and (search-forward "\201" nil t)
2759 (goto-char (point-min))
2760 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2762 (goto-char (point-min))
2763 (push (cons 'download
2764 (and (search-forward "\203" nil t) (- (point) 2)))
2766 (setq gnus-summary-mark-positions pos))))
2768 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2769 "Insert a dummy root in the summary buffer."
2771 (gnus-add-text-properties
2772 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2773 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2775 (defun gnus-summary-from-or-to-or-newsgroups (header)
2776 (let ((to (cdr (assq 'To (mail-header-extra header))))
2777 (newsgroups (cdr (assq 'Newsgroups (mail-header-extra header))))
2778 (mail-parse-charset gnus-newsgroup-charset)
2779 (mail-parse-ignored-charsets
2780 (save-excursion (set-buffer gnus-summary-buffer)
2781 gnus-newsgroup-ignored-charsets)))
2784 gnus-ignored-from-addresses
2785 (string-match gnus-ignored-from-addresses
2786 (mail-header-from header)))
2788 (or (car (funcall gnus-extract-address-components
2790 gnus-decode-encoded-word-function to)))
2791 (funcall gnus-decode-encoded-word-function to))))
2793 gnus-ignored-from-addresses
2794 (string-match gnus-ignored-from-addresses
2795 (mail-header-from header)))
2796 (concat "=> " newsgroups))
2798 (or (car (funcall gnus-extract-address-components
2799 (mail-header-from header)))
2800 (mail-header-from header))))))
2802 (defun gnus-summary-insert-line (gnus-tmp-header
2803 gnus-tmp-level gnus-tmp-current
2804 gnus-tmp-unread gnus-tmp-replied
2805 gnus-tmp-expirable gnus-tmp-subject-or-nil
2806 &optional gnus-tmp-dummy gnus-tmp-score
2808 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2809 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2810 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2811 (gnus-tmp-score-char
2812 (if (or (null gnus-summary-default-score)
2813 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2814 gnus-summary-zcore-fuzz))
2816 (if (< gnus-tmp-score gnus-summary-default-score)
2817 gnus-score-below-mark gnus-score-over-mark)))
2819 (cond (gnus-tmp-process gnus-process-mark)
2820 ((memq gnus-tmp-current gnus-newsgroup-cached)
2822 (gnus-tmp-replied gnus-replied-mark)
2823 ((memq gnus-tmp-current gnus-newsgroup-saved)
2826 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2829 ((string-match "<[^>]+> *$" gnus-tmp-from)
2830 (let ((beg (match-beginning 0)))
2831 (or (and (string-match "^\".+\"" gnus-tmp-from)
2832 (substring gnus-tmp-from 1 (1- (match-end 0))))
2833 (substring gnus-tmp-from 0 beg))))
2834 ((string-match "(.+)" gnus-tmp-from)
2835 (substring gnus-tmp-from
2836 (1+ (match-beginning 0)) (1- (match-end 0))))
2838 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2839 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2840 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2841 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
2842 (buffer-read-only nil))
2843 (when (string= gnus-tmp-name "")
2844 (setq gnus-tmp-name gnus-tmp-from))
2845 (unless (numberp gnus-tmp-lines)
2846 (setq gnus-tmp-lines 0))
2847 (gnus-put-text-property
2849 (progn (eval gnus-summary-line-format-spec) (point))
2850 'gnus-number gnus-tmp-number)
2851 (when (gnus-visual-p 'summary-highlight 'highlight)
2853 (gnus-run-hooks 'gnus-summary-update-hook)
2856 (defun gnus-summary-update-line (&optional dont-update)
2857 "Update summary line after change."
2858 (when (and gnus-summary-default-score
2859 (not gnus-summary-inhibit-highlight))
2860 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
2861 (article (gnus-summary-article-number))
2862 (score (gnus-summary-article-score article)))
2864 (if (and gnus-summary-mark-below
2865 (< (gnus-summary-article-score)
2866 gnus-summary-mark-below))
2867 ;; This article has a low score, so we mark it as read.
2868 (when (memq article gnus-newsgroup-unreads)
2869 (gnus-summary-mark-article-as-read gnus-low-score-mark))
2870 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
2871 ;; This article was previously marked as read on account
2872 ;; of a low score, but now it has risen, so we mark it as
2874 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
2875 (gnus-summary-update-mark
2876 (if (or (null gnus-summary-default-score)
2877 (<= (abs (- score gnus-summary-default-score))
2878 gnus-summary-zcore-fuzz))
2880 (if (< score gnus-summary-default-score)
2881 gnus-score-below-mark gnus-score-over-mark))
2883 ;; Do visual highlighting.
2884 (when (gnus-visual-p 'summary-highlight 'highlight)
2885 (gnus-run-hooks 'gnus-summary-update-hook)))))
2887 (defvar gnus-tmp-new-adopts nil)
2889 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
2890 "Return the number of articles in THREAD.
2891 This may be 0 in some cases -- if none of the articles in
2892 the thread are to be displayed."
2894 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
2896 ((not (listp thread))
2898 ((and (consp thread) (cdr thread))
2901 'gnus-summary-number-of-articles-in-thread (cdr thread))))
2904 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
2907 (when (and level (zerop level) gnus-tmp-new-adopts)
2910 'gnus-summary-number-of-articles-in-thread
2911 gnus-tmp-new-adopts))))
2913 (if (> number 1) gnus-not-empty-thread-mark
2914 gnus-empty-thread-mark)
2917 (defun gnus-summary-set-local-parameters (group)
2918 "Go through the local params of GROUP and set all variable specs in that list."
2919 (let ((params (gnus-group-find-parameter group))
2922 (setq elem (car params)
2923 params (cdr params))
2924 (and (consp elem) ; Has to be a cons.
2925 (consp (cdr elem)) ; The cdr has to be a list.
2926 (symbolp (car elem)) ; Has to be a symbol in there.
2927 (not (memq (car elem) '(quit-config))) ; Ignore quit-config.
2928 (ignore-errors ; So we set it.
2929 (make-local-variable (car elem))
2930 (set (car elem) (eval (nth 1 elem))))))))
2932 (defun gnus-summary-read-group (group &optional show-all no-article
2933 kill-buffer no-display backward
2935 "Start reading news in newsgroup GROUP.
2936 If SHOW-ALL is non-nil, already read articles are also listed.
2937 If NO-ARTICLE is non-nil, no article is selected initially.
2938 If NO-DISPLAY, don't generate a summary buffer."
2942 (let ((gnus-auto-select-next nil))
2943 (or (gnus-summary-read-group-1
2944 group show-all no-article
2945 kill-buffer no-display
2948 select-articles nil)))))
2949 (eq gnus-auto-select-next 'quietly))
2950 (set-buffer gnus-group-buffer)
2951 ;; The entry function called above goes to the next
2952 ;; group automatically, so we go two groups back
2953 ;; if we are searching for the previous group.
2955 (gnus-group-prev-unread-group 2))
2956 (if (not (equal group (gnus-group-group-name)))
2957 (setq group (gnus-group-group-name))
2961 (defun gnus-summary-read-group-1 (group show-all no-article
2962 kill-buffer no-display
2963 &optional select-articles)
2964 ;; Killed foreign groups can't be entered.
2965 ;; (when (and (not (gnus-group-native-p group))
2966 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
2967 ;; (error "Dead non-native groups can't be entered"))
2968 (gnus-message 5 "Retrieving newsgroup: %s..." group)
2969 (let* ((new-group (gnus-summary-setup-buffer group))
2970 (quit-config (gnus-group-quit-config group))
2971 (did-select (and new-group (gnus-select-newsgroup
2972 group show-all select-articles))))
2974 ;; This summary buffer exists already, so we just select it.
2976 (gnus-set-global-variables)
2978 (gnus-kill-or-deaden-summary kill-buffer))
2979 (gnus-configure-windows 'summary 'force)
2980 (gnus-set-mode-line 'summary)
2981 (gnus-summary-position-point)
2984 ;; We couldn't select this group.
2986 (when (and (eq major-mode 'gnus-summary-mode)
2987 (not (equal (current-buffer) kill-buffer)))
2988 (kill-buffer (current-buffer))
2989 (if (not quit-config)
2991 ;; Update the info -- marks might need to be removed,
2993 (gnus-summary-update-info)
2994 (set-buffer gnus-group-buffer)
2995 (gnus-group-jump-to-group group)
2996 (gnus-group-next-unread-group 1))
2997 (gnus-handle-ephemeral-exit quit-config)))
2998 (let ((grpinfo (gnus-get-info group)))
2999 (if (null (gnus-info-read grpinfo))
3000 (gnus-message 3 "Group %s contains no messages" group)
3001 (gnus-message 3 "Can't select group")))
3003 ;; The user did a `C-g' while prompting for number of articles,
3004 ;; so we exit this group.
3005 ((eq did-select 'quit)
3006 (and (eq major-mode 'gnus-summary-mode)
3007 (not (equal (current-buffer) kill-buffer))
3008 (kill-buffer (current-buffer)))
3010 (gnus-kill-or-deaden-summary kill-buffer))
3011 (if (not quit-config)
3013 (set-buffer gnus-group-buffer)
3014 (gnus-group-jump-to-group group)
3015 (gnus-group-next-unread-group 1)
3016 (gnus-configure-windows 'group 'force))
3017 (gnus-handle-ephemeral-exit quit-config))
3018 ;; Finally signal the quit.
3020 ;; The group was successfully selected.
3022 (gnus-set-global-variables)
3023 ;; Save the active value in effect when the group was entered.
3024 (setq gnus-newsgroup-active
3026 (gnus-active gnus-newsgroup-name)))
3027 ;; You can change the summary buffer in some way with this hook.
3028 (gnus-run-hooks 'gnus-select-group-hook)
3029 ;; Set any local variables in the group parameters.
3030 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3031 (gnus-update-format-specifications
3032 nil 'summary 'summary-mode 'summary-dummy)
3033 (gnus-update-summary-mark-positions)
3034 ;; Do score processing.
3035 (when gnus-use-scoring
3036 (gnus-possibly-score-headers))
3037 ;; Check whether to fill in the gaps in the threads.
3038 (when gnus-build-sparse-threads
3039 (gnus-build-sparse-threads))
3040 ;; Find the initial limit.
3041 (if gnus-show-threads
3043 (let ((gnus-newsgroup-dormant nil))
3044 (gnus-summary-initial-limit show-all))
3045 (gnus-summary-initial-limit show-all))
3046 ;; When untreaded, all articles are always shown.
3047 (setq gnus-newsgroup-limit
3049 (lambda (header) (mail-header-number header))
3050 gnus-newsgroup-headers)))
3051 ;; Generate the summary buffer.
3053 (gnus-summary-prepare))
3054 (when gnus-use-trees
3055 (gnus-tree-open group)
3056 (setq gnus-summary-highlight-line-function
3057 'gnus-tree-highlight-article))
3058 ;; If the summary buffer is empty, but there are some low-scored
3059 ;; articles or some excluded dormants, we include these in the
3061 (when (and (zerop (buffer-size))
3063 (cond (gnus-newsgroup-dormant
3064 (gnus-summary-limit-include-dormant))
3065 ((and gnus-newsgroup-scored show-all)
3066 (gnus-summary-limit-include-expunged t))))
3067 ;; Function `gnus-apply-kill-file' must be called in this hook.
3068 (gnus-run-hooks 'gnus-apply-kill-hook)
3069 (if (and (zerop (buffer-size))
3072 ;; This newsgroup is empty.
3073 (gnus-summary-catchup-and-exit nil t)
3074 (gnus-message 6 "No unread news")
3076 (gnus-kill-or-deaden-summary kill-buffer))
3077 ;; Return nil from this function.
3079 ;; Hide conversation thread subtrees. We cannot do this in
3080 ;; gnus-summary-prepare-hook since kill processing may not
3081 ;; work with hidden articles.
3082 (and gnus-show-threads
3083 gnus-thread-hide-subtree
3084 (gnus-summary-hide-all-threads))
3086 (gnus-kill-or-deaden-summary kill-buffer))
3087 ;; Show first unread article if requested.
3088 (if (and (not no-article)
3090 gnus-newsgroup-unreads
3091 gnus-auto-select-first)
3093 (gnus-configure-windows 'summary)
3095 ((eq gnus-auto-select-first 'best)
3096 (gnus-summary-best-unread-article))
3097 ((eq gnus-auto-select-first t)
3098 (gnus-summary-first-unread-article))
3099 ((gnus-functionp gnus-auto-select-first)
3100 (funcall gnus-auto-select-first))))
3101 ;; Don't select any articles, just move point to the first
3102 ;; article in the group.
3103 (goto-char (point-min))
3104 (gnus-summary-position-point)
3105 (gnus-configure-windows 'summary 'force)
3106 (gnus-set-mode-line 'summary))
3107 (when (get-buffer-window gnus-group-buffer t)
3108 ;; Gotta use windows, because recenter does weird stuff if
3109 ;; the current buffer ain't the displayed window.
3110 (let ((owin (selected-window)))
3111 (select-window (get-buffer-window gnus-group-buffer t))
3112 (when (gnus-group-goto-group group)
3114 (select-window owin)))
3115 ;; Mark this buffer as "prepared".
3116 (setq gnus-newsgroup-prepared t)
3117 (gnus-run-hooks 'gnus-summary-prepared-hook)
3120 (defun gnus-summary-prepare ()
3121 "Generate the summary buffer."
3123 (let ((buffer-read-only nil))
3125 (setq gnus-newsgroup-data nil
3126 gnus-newsgroup-data-reverse nil)
3127 (gnus-run-hooks 'gnus-summary-generate-hook)
3128 ;; Generate the buffer, either with threads or without.
3129 (when gnus-newsgroup-headers
3130 (gnus-summary-prepare-threads
3131 (if gnus-show-threads
3132 (gnus-sort-gathered-threads
3133 (funcall gnus-summary-thread-gathering-function
3135 (gnus-cut-threads (gnus-make-threads)))))
3136 ;; Unthreaded display.
3137 (gnus-sort-articles gnus-newsgroup-headers))))
3138 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3139 ;; Call hooks for modifying summary buffer.
3140 (goto-char (point-min))
3141 (gnus-run-hooks 'gnus-summary-prepare-hook)))
3143 (defsubst gnus-general-simplify-subject (subject)
3144 "Simply subject by the same rules as gnus-gather-threads-by-subject."
3147 ;; Truncate the subject.
3148 (gnus-simplify-subject-functions
3149 (gnus-map-function gnus-simplify-subject-functions subject))
3150 ((numberp gnus-summary-gather-subject-limit)
3151 (setq subject (gnus-simplify-subject-re subject))
3152 (if (> (length subject) gnus-summary-gather-subject-limit)
3153 (substring subject 0 gnus-summary-gather-subject-limit)
3155 ;; Fuzzily simplify it.
3156 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3157 (gnus-simplify-subject-fuzzy subject))
3158 ;; Just remove the leading "Re:".
3160 (gnus-simplify-subject-re subject))))
3162 (if (and gnus-summary-gather-exclude-subject
3163 (string-match gnus-summary-gather-exclude-subject subject))
3164 nil ; This article shouldn't be gathered
3167 (defun gnus-summary-simplify-subject-query ()
3168 "Query where the respool algorithm would put this article."
3170 (gnus-summary-select-article)
3171 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
3173 (defun gnus-gather-threads-by-subject (threads)
3174 "Gather threads by looking at Subject headers."
3175 (if (not gnus-summary-make-false-root)
3177 (let ((hashtb (gnus-make-hashtable 1024))
3180 subject hthread whole-subject)
3182 (setq subject (gnus-general-simplify-subject
3183 (setq whole-subject (mail-header-subject
3186 (if (setq hthread (gnus-gethash subject hashtb))
3188 ;; We enter a dummy root into the thread, if we
3189 ;; haven't done that already.
3190 (unless (stringp (caar hthread))
3191 (setcar hthread (list whole-subject (car hthread))))
3192 ;; We add this new gathered thread to this gathered
3194 (setcdr (car hthread)
3195 (nconc (cdar hthread) (list (car threads))))
3196 ;; Remove it from the list of threads.
3197 (setcdr prev (cdr threads))
3198 (setq threads prev))
3199 ;; Enter this thread into the hash table.
3200 (gnus-sethash subject threads hashtb)))
3202 (setq threads (cdr threads)))
3205 (defun gnus-gather-threads-by-references (threads)
3206 "Gather threads by looking at References headers."
3207 (let ((idhashtb (gnus-make-hashtable 1024))
3208 (thhashtb (gnus-make-hashtable 1024))
3211 ids references id gthread gid entered ref)
3213 (when (setq references (mail-header-references (caar threads)))
3214 (setq id (mail-header-id (caar threads))
3215 ids (gnus-split-references references)
3217 (while (setq ref (pop ids))
3218 (setq ids (delete ref ids))
3219 (if (not (setq gid (gnus-gethash ref idhashtb)))
3221 (gnus-sethash ref id idhashtb)
3222 (gnus-sethash id threads thhashtb))
3223 (setq gthread (gnus-gethash gid thhashtb))
3225 ;; We enter a dummy root into the thread, if we
3226 ;; haven't done that already.
3227 (unless (stringp (caar gthread))
3228 (setcar gthread (list (mail-header-subject (caar gthread))
3230 ;; We add this new gathered thread to this gathered
3232 (setcdr (car gthread)
3233 (nconc (cdar gthread) (list (car threads)))))
3234 ;; Add it into the thread hash table.
3235 (gnus-sethash id gthread thhashtb)
3237 ;; Remove it from the list of threads.
3238 (setcdr prev (cdr threads))
3239 (setq threads prev))))
3241 (setq threads (cdr threads)))
3244 (defun gnus-sort-gathered-threads (threads)
3245 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
3246 (let ((result threads))
3248 (when (stringp (caar threads))
3249 (setcdr (car threads)
3250 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3251 (setq threads (cdr threads)))
3254 (defun gnus-thread-loop-p (root thread)
3255 "Say whether ROOT is in THREAD."
3256 (let ((stack (list thread))
3259 (while (setq thread (pop stack))
3260 (setq th (cdr thread))
3262 (not (eq (caar th) root)))
3265 ;; We have found a loop.
3267 (setcdr thread (delq (car th) (cdr thread)))
3268 (if (boundp (setq ref-dep (intern "none"
3269 gnus-newsgroup-dependencies)))
3270 (setcdr (symbol-value ref-dep)
3271 (nconc (cdr (symbol-value ref-dep))
3273 (set ref-dep (list nil (car th))))
3276 ;; Push all the subthreads onto the stack.
3277 (push (cdr thread) stack)))
3280 (defun gnus-make-threads ()
3281 "Go through the dependency hashtb and find the roots. Return all threads."
3283 (while (catch 'infloop
3286 ;; Deal with self-referencing References loops.
3287 (when (and (car (symbol-value refs))
3294 (car (symbol-value refs)) thread))
3295 (cdr (symbol-value refs)))))))
3298 (unless (car (symbol-value refs))
3299 ;; These threads do not refer back to any other articles,
3300 ;; so they're roots.
3301 (setq threads (append (cdr (symbol-value refs)) threads))))
3302 gnus-newsgroup-dependencies)))
3305 ;; Build the thread tree.
3306 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3307 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3309 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3310 if it was already present.
3312 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3313 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3314 Message-IDs will be renamed be renamed to a unique Message-ID before
3317 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3318 (let* ((id (mail-header-id header))
3319 (id-dep (and id (intern id dependencies)))
3320 ref ref-dep ref-header)
3321 ;; Enter this `header' in the `dependencies' table.
3325 ;; The first two cases do the normal part: enter a new `header'
3326 ;; in the `dependencies' table.
3327 ((not (boundp id-dep))
3328 (set id-dep (list header)))
3329 ((null (car (symbol-value id-dep)))
3330 (setcar (symbol-value id-dep) header))
3332 ;; From here the `header' was already present in the
3333 ;; `dependencies' table.
3335 ;; Overrides an existing entry;
3336 ;; just set the header part of the entry.
3337 (setcar (symbol-value id-dep) header))
3339 ;; Renames the existing `header' to a unique Message-ID.
3340 ((not gnus-summary-ignore-duplicates)
3341 ;; An article with this Message-ID has already been seen.
3342 ;; We rename the Message-ID.
3343 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3345 (mail-header-set-id header id))
3347 ;; The last case ignores an existing entry, except it adds any
3348 ;; additional Xrefs (in case the two articles came from different
3350 ;; Also sets `header' to `nil' meaning that the `dependencies'
3351 ;; table was *not* modified.
3353 (mail-header-set-xref
3354 (car (symbol-value id-dep))
3355 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3357 (or (mail-header-xref header) "")))
3361 ;; First check if that we are not creating a References loop.
3362 (setq ref (gnus-parent-id (mail-header-references header)))
3364 (setq ref-dep (intern-soft ref dependencies))
3366 (setq ref-header (car (symbol-value ref-dep))))
3367 (if (string= id ref)
3368 ;; Yuk! This is a reference loop. Make the article be a
3371 (mail-header-set-references (car (symbol-value id-dep)) "none")
3373 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3374 (setq ref (gnus-parent-id (mail-header-references header)))
3375 (setq ref-dep (intern (or ref "none") dependencies))
3376 (if (boundp ref-dep)
3377 (setcdr (symbol-value ref-dep)
3378 (nconc (cdr (symbol-value ref-dep))
3379 (list (symbol-value id-dep))))
3380 (set ref-dep (list nil (symbol-value id-dep)))))
3383 (defun gnus-build-sparse-threads ()
3384 (let ((headers gnus-newsgroup-headers)
3385 (mail-parse-charset gnus-newsgroup-charset)
3386 (gnus-summary-ignore-duplicates t)
3387 header references generation relations
3388 subject child end new-child date)
3389 ;; First we create an alist of generations/relations, where
3390 ;; generations is how much we trust the relation, and the relation
3392 (gnus-message 7 "Making sparse threads...")
3394 (nnheader-set-temp-buffer " *gnus sparse threads*")
3395 (while (setq header (pop headers))
3396 (when (and (setq references (mail-header-references header))
3397 (not (string= references "")))
3399 (setq child (mail-header-id header)
3400 subject (mail-header-subject header)
3401 date (mail-header-date header)
3403 (while (search-backward ">" nil t)
3404 (setq end (1+ (point)))
3405 (when (search-backward "<" nil t)
3406 (setq new-child (buffer-substring (point) end))
3407 (push (list (incf generation)
3408 child (setq child new-child)
3412 (push (list (1+ generation) child nil subject) relations))
3414 (kill-buffer (current-buffer)))
3415 ;; Sort over trustworthiness.
3418 (when (gnus-dependencies-add-header
3419 (make-full-mail-header
3420 gnus-reffed-article-number
3421 (nth 3 relation) "" (or (nth 4 relation) "")
3423 (or (nth 2 relation) "") 0 0 "")
3424 gnus-newsgroup-dependencies nil)
3425 (push gnus-reffed-article-number gnus-newsgroup-limit)
3426 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3427 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3428 gnus-newsgroup-reads)
3429 (decf gnus-reffed-article-number)))
3430 (sort relations 'car-less-than-car))
3431 (gnus-message 7 "Making sparse threads...done")))
3433 (defun gnus-build-old-threads ()
3434 ;; Look at all the articles that refer back to old articles, and
3435 ;; fetch the headers for the articles that aren't there. This will
3436 ;; build complete threads - if the roots haven't been expired by the
3438 (let ((mail-parse-charset gnus-newsgroup-charset)
3442 (when (not (car (symbol-value refs)))
3443 (setq heads (cdr (symbol-value refs)))
3445 (if (memq (mail-header-number (caar heads))
3446 gnus-newsgroup-dormant)
3447 (setq heads (cdr heads))
3448 (setq id (symbol-name refs))
3449 (while (and (setq id (gnus-build-get-header id))
3450 (not (car (gnus-id-to-thread id)))))
3451 (setq heads nil)))))
3452 gnus-newsgroup-dependencies)))
3454 ;; This function has to be called with point after the article number
3455 ;; on the beginning of the line.
3456 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3457 (let ((eol (gnus-point-at-eol))
3458 (buffer (current-buffer))
3461 ;; overview: [num subject from date id refs chars lines misc]
3464 (narrow-to-region (point) eol)
3469 (make-full-mail-header
3471 (funcall gnus-decode-encoded-word-function
3472 (nnheader-nov-field)) ; subject
3473 (funcall gnus-decode-encoded-word-function
3474 (nnheader-nov-field)) ; from
3475 (nnheader-nov-field) ; date
3476 (nnheader-nov-read-message-id) ; id
3477 (nnheader-nov-field) ; refs
3478 (nnheader-nov-read-integer) ; chars
3479 (nnheader-nov-read-integer) ; lines
3481 (if (looking-at "Xref: ")
3482 (goto-char (match-end 0)))
3483 (nnheader-nov-field)) ; Xref
3484 (nnheader-nov-parse-extra)))) ; extra
3488 (when gnus-alter-header-function
3489 (funcall gnus-alter-header-function header))
3490 (gnus-dependencies-add-header header dependencies force-new)))
3492 (defun gnus-build-get-header (id)
3493 "Look through the buffer of NOV lines and find the header to ID.
3494 Enter this line into the dependencies hash table, and return
3495 the id of the parent article (if any)."
3496 (let ((deps gnus-newsgroup-dependencies)
3500 (set-buffer nntp-server-buffer)
3501 (let ((case-fold-search nil))
3502 (goto-char (point-min))
3503 (while (and (not found)
3504 (search-forward id nil t))
3506 (setq found (looking-at
3507 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3508 (regexp-quote id))))
3509 (or found (beginning-of-line 2)))
3513 (setq header (gnus-nov-parse-line
3514 (read (current-buffer)) deps))
3515 (gnus-parent-id (mail-header-references header))))))
3517 (let ((number (mail-header-number header)))
3518 (push number gnus-newsgroup-limit)
3519 (push header gnus-newsgroup-headers)
3520 (if (memq number gnus-newsgroup-unselected)
3522 (push number gnus-newsgroup-unreads)
3523 (setq gnus-newsgroup-unselected
3524 (delq number gnus-newsgroup-unselected)))
3525 (push number gnus-newsgroup-ancient)))))))
3527 (defun gnus-build-all-threads ()
3528 "Read all the headers."
3529 (let ((gnus-summary-ignore-duplicates t)
3530 (mail-parse-charset gnus-newsgroup-charset)
3531 (dependencies gnus-newsgroup-dependencies)
3534 (set-buffer nntp-server-buffer)
3535 (let ((case-fold-search nil))
3536 (goto-char (point-min))
3539 (setq article (read (current-buffer))
3540 header (gnus-nov-parse-line article dependencies)))
3543 (set-buffer gnus-summary-buffer)
3544 (push header gnus-newsgroup-headers)
3545 (if (memq (setq article (mail-header-number header))
3546 gnus-newsgroup-unselected)
3548 (push article gnus-newsgroup-unreads)
3549 (setq gnus-newsgroup-unselected
3550 (delq article gnus-newsgroup-unselected)))
3551 (push article gnus-newsgroup-ancient)))
3552 (forward-line 1)))))))
3554 (defun gnus-summary-update-article-line (article header)
3555 "Update the line for ARTICLE using HEADERS."
3556 (let* ((id (mail-header-id header))
3557 (thread (gnus-id-to-thread id)))
3559 (error "Article in no thread"))
3560 ;; Update the thread.
3561 (setcar thread header)
3562 (gnus-summary-goto-subject article)
3563 (let* ((datal (gnus-data-find-list article))
3565 (length (when (cdr datal)
3566 (- (gnus-data-pos data)
3567 (gnus-data-pos (cadr datal)))))
3568 (buffer-read-only nil)
3569 (level (gnus-summary-thread-level)))
3571 (gnus-summary-insert-line
3572 header level nil (gnus-article-mark article)
3573 (memq article gnus-newsgroup-replied)
3574 (memq article gnus-newsgroup-expirable)
3575 ;; Only insert the Subject string when it's different
3576 ;; from the previous Subject string.
3581 (mail-header-subject
3584 (gnus-data-find-list
3586 (gnus-data-list t)))))
3587 ;; Error on the side of excessive subjects.
3589 (mail-header-subject header)))
3591 (mail-header-subject header))
3592 nil (cdr (assq article gnus-newsgroup-scored))
3593 (memq article gnus-newsgroup-processable))
3595 (gnus-data-update-list
3596 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3598 (defun gnus-summary-update-article (article &optional iheader)
3599 "Update ARTICLE in the summary buffer."
3600 (set-buffer gnus-summary-buffer)
3601 (let* ((header (gnus-summary-article-header article))
3602 (id (mail-header-id header))
3603 (data (gnus-data-find article))
3604 (thread (gnus-id-to-thread id))
3605 (references (mail-header-references header))
3609 (when (and references
3610 (not (equal "" references)))
3613 (buffer-read-only nil)
3619 (delq thread parent)))
3620 (if (gnus-summary-insert-subject id header)
3621 ;; Set the (possibly) new article number in the data structure.
3622 (gnus-data-set-number data (gnus-id-to-article id))
3626 (defun gnus-rebuild-thread (id &optional line)
3627 "Rebuild the thread containing ID.
3628 If LINE, insert the rebuilt thread starting on line LINE."
3629 (let ((buffer-read-only nil)
3630 old-pos current thread data)
3631 (if (not gnus-show-threads)
3632 (setq thread (list (car (gnus-id-to-thread id))))
3633 ;; Get the thread this article is part of.
3634 (setq thread (gnus-remove-thread id)))
3635 (setq old-pos (gnus-point-at-bol))
3636 (setq current (save-excursion
3637 (and (zerop (forward-line -1))
3638 (gnus-summary-article-number))))
3639 ;; If this is a gathered thread, we have to go some re-gathering.
3640 (when (stringp (car thread))
3641 (let ((subject (car thread))
3643 (setq thread (cdr thread))
3645 (unless (memq (setq thr (gnus-id-to-thread
3647 (mail-header-id (caar thread)))))
3650 (setq thread (cdr thread)))
3651 ;; We now have all (unique) roots.
3652 (if (= (length roots) 1)
3653 ;; All the loose roots are now one solid root.
3654 (setq thread (car roots))
3655 (setq thread (cons subject (gnus-sort-threads roots))))))
3657 ;; We then insert this thread into the summary buffer.
3659 (goto-char (point-min))
3660 (forward-line (1- line)))
3661 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3662 (if gnus-show-threads
3663 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3664 (gnus-summary-prepare-unthreaded thread))
3665 (setq data (nreverse gnus-newsgroup-data))
3666 (setq threads gnus-newsgroup-threads))
3667 ;; We splice the new data into the data structure.
3668 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
3669 ;;!!! then we want to insert at the beginning of the buffer.
3670 ;;!!! That happens to be true with Gnus now, but that may
3671 ;;!!! change in the future. Perhaps.
3672 (gnus-data-enter-list
3673 (if line nil current) data (- (point) old-pos))
3674 (setq gnus-newsgroup-threads
3675 (nconc threads gnus-newsgroup-threads))
3676 (gnus-data-compute-positions))))
3678 (defun gnus-number-to-header (number)
3679 "Return the header for article NUMBER."
3680 (let ((headers gnus-newsgroup-headers))
3682 (not (= number (mail-header-number (car headers)))))
3687 (defun gnus-parent-headers (in-headers &optional generation)
3688 "Return the headers of the GENERATIONeth parent of HEADERS."
3690 (setq generation 1))
3692 (headers in-headers)
3695 (not (zerop generation))
3696 (setq references (mail-header-references headers)))
3697 (setq headers (if (and references
3698 (setq parent (gnus-parent-id references)))
3699 (car (gnus-id-to-thread parent))
3702 (and (not (eq headers in-headers))
3705 (defun gnus-id-to-thread (id)
3706 "Return the (sub-)thread where ID appears."
3707 (gnus-gethash id gnus-newsgroup-dependencies))
3709 (defun gnus-id-to-article (id)
3710 "Return the article number of ID."
3711 (let ((thread (gnus-id-to-thread id)))
3714 (mail-header-number (car thread)))))
3716 (defun gnus-id-to-header (id)
3717 "Return the article headers of ID."
3718 (car (gnus-id-to-thread id)))
3720 (defun gnus-article-displayed-root-p (article)
3721 "Say whether ARTICLE is a root(ish) article."
3722 (let ((level (gnus-summary-thread-level article))
3723 (refs (mail-header-references (gnus-summary-article-header article)))
3729 ((null (gnus-parent-id refs)) t)
3731 (null (setq particle (gnus-id-to-article
3732 (gnus-parent-id refs))))
3733 (null (gnus-summary-thread-level particle)))))))
3735 (defun gnus-root-id (id)
3736 "Return the id of the root of the thread where ID appears."
3738 (while (and id (setq prev (car (gnus-id-to-thread id))))
3740 id (gnus-parent-id (mail-header-references prev))))
3743 (defun gnus-articles-in-thread (thread)
3744 "Return the list of articles in THREAD."
3745 (cons (mail-header-number (car thread))
3746 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
3748 (defun gnus-remove-thread (id &optional dont-remove)
3749 "Remove the thread that has ID in it."
3750 (let (headers thread last-id)
3751 ;; First go up in this thread until we find the root.
3752 (setq last-id (gnus-root-id id)
3753 headers (message-flatten-list (gnus-id-to-thread last-id)))
3754 ;; We have now found the real root of this thread. It might have
3755 ;; been gathered into some loose thread, so we have to search
3756 ;; through the threads to find the thread we wanted.
3757 (let ((threads gnus-newsgroup-threads)
3760 (setq sub (car threads))
3761 (if (stringp (car sub))
3762 ;; This is a gathered thread, so we look at the roots
3763 ;; below it to find whether this article is in this
3766 (setq sub (cdr sub))
3768 (when (member (caar sub) headers)
3769 (setq thread (car threads)
3772 (setq sub (cdr sub))))
3773 ;; It's an ordinary thread, so we check it.
3774 (when (eq (car sub) (car headers))
3777 (setq threads (cdr threads)))
3778 ;; If this article is in no thread, then it's a root.
3781 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
3782 (setq thread (gnus-id-to-thread last-id)))
3785 thread ; We return this thread.
3787 (if (stringp (car thread))
3789 ;; If we use dummy roots, then we have to remove the
3790 ;; dummy root as well.
3791 (when (eq gnus-summary-make-false-root 'dummy)
3792 ;; We go to the dummy root by going to
3793 ;; the first sub-"thread", and then one line up.
3794 (gnus-summary-goto-article
3795 (mail-header-number (caadr thread)))
3798 (gnus-data-compute-positions))
3799 (setq thread (cdr thread))
3801 (gnus-remove-thread-1 (car thread))
3802 (setq thread (cdr thread))))
3803 (gnus-remove-thread-1 thread))))))))
3805 (defun gnus-remove-thread-1 (thread)
3806 "Remove the thread THREAD recursively."
3807 (let ((number (mail-header-number (pop thread)))
3809 (setq thread (reverse thread))
3811 (gnus-remove-thread-1 (pop thread)))
3812 (when (setq d (gnus-data-find number))
3813 (goto-char (gnus-data-pos d))
3814 (gnus-summary-show-thread)
3817 (- (gnus-point-at-bol)
3819 (1+ (gnus-point-at-eol))
3820 (gnus-delete-line)))))))
3822 (defun gnus-sort-threads-1 (threads func)
3823 (sort (mapcar (lambda (thread)
3826 (gnus-sort-threads-1 (cdr thread) func))))
3829 (defun gnus-sort-threads (threads)
3831 (if (not gnus-thread-sort-functions)
3833 (gnus-message 8 "Sorting threads...")
3835 (gnus-sort-threads-1
3837 (gnus-make-sort-function gnus-thread-sort-functions))
3838 (gnus-message 8 "Sorting threads...done"))))
3840 (defun gnus-sort-articles (articles)
3842 (when gnus-article-sort-functions
3843 (gnus-message 7 "Sorting articles...")
3845 (setq gnus-newsgroup-headers
3846 (sort articles (gnus-make-sort-function
3847 gnus-article-sort-functions)))
3848 (gnus-message 7 "Sorting articles...done"))))
3850 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3851 (defmacro gnus-thread-header (thread)
3852 "Return header of first article in THREAD.
3853 Note that THREAD must never, ever be anything else than a variable -
3854 using some other form will lead to serious barfage."
3855 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
3856 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
3857 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
3860 (defsubst gnus-article-sort-by-number (h1 h2)
3861 "Sort articles by article number."
3862 (< (mail-header-number h1)
3863 (mail-header-number h2)))
3865 (defun gnus-thread-sort-by-number (h1 h2)
3866 "Sort threads by root article number."
3867 (gnus-article-sort-by-number
3868 (gnus-thread-header h1) (gnus-thread-header h2)))
3870 (defsubst gnus-article-sort-by-lines (h1 h2)
3871 "Sort articles by article Lines header."
3872 (< (mail-header-lines h1)
3873 (mail-header-lines h2)))
3875 (defun gnus-thread-sort-by-lines (h1 h2)
3876 "Sort threads by root article Lines header."
3877 (gnus-article-sort-by-lines
3878 (gnus-thread-header h1) (gnus-thread-header h2)))
3880 (defsubst gnus-article-sort-by-chars (h1 h2)
3881 "Sort articles by octet length."
3882 (< (mail-header-chars h1)
3883 (mail-header-chars h2)))
3885 (defun gnus-thread-sort-by-chars (h1 h2)
3886 "Sort threads by root article octet length."
3887 (gnus-article-sort-by-chars
3888 (gnus-thread-header h1) (gnus-thread-header h2)))
3890 (defsubst gnus-article-sort-by-author (h1 h2)
3891 "Sort articles by root author."
3893 (let ((extract (funcall
3894 gnus-extract-address-components
3895 (mail-header-from h1))))
3896 (or (car extract) (cadr extract) ""))
3897 (let ((extract (funcall
3898 gnus-extract-address-components
3899 (mail-header-from h2))))
3900 (or (car extract) (cadr extract) ""))))
3902 (defun gnus-thread-sort-by-author (h1 h2)
3903 "Sort threads by root author."
3904 (gnus-article-sort-by-author
3905 (gnus-thread-header h1) (gnus-thread-header h2)))
3907 (defsubst gnus-article-sort-by-subject (h1 h2)
3908 "Sort articles by root subject."
3910 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
3911 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
3913 (defun gnus-thread-sort-by-subject (h1 h2)
3914 "Sort threads by root subject."
3915 (gnus-article-sort-by-subject
3916 (gnus-thread-header h1) (gnus-thread-header h2)))
3918 (defsubst gnus-article-sort-by-date (h1 h2)
3919 "Sort articles by root article date."
3921 (gnus-date-get-time (mail-header-date h1))
3922 (gnus-date-get-time (mail-header-date h2))))
3924 (defun gnus-thread-sort-by-date (h1 h2)
3925 "Sort threads by root article date."
3926 (gnus-article-sort-by-date
3927 (gnus-thread-header h1) (gnus-thread-header h2)))
3929 (defsubst gnus-article-sort-by-score (h1 h2)
3930 "Sort articles by root article score.
3931 Unscored articles will be counted as having a score of zero."
3932 (> (or (cdr (assq (mail-header-number h1)
3933 gnus-newsgroup-scored))
3934 gnus-summary-default-score 0)
3935 (or (cdr (assq (mail-header-number h2)
3936 gnus-newsgroup-scored))
3937 gnus-summary-default-score 0)))
3939 (defun gnus-thread-sort-by-score (h1 h2)
3940 "Sort threads by root article score."
3941 (gnus-article-sort-by-score
3942 (gnus-thread-header h1) (gnus-thread-header h2)))
3944 (defun gnus-thread-sort-by-total-score (h1 h2)
3945 "Sort threads by the sum of all scores in the thread.
3946 Unscored articles will be counted as having a score of zero."
3947 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
3949 (defun gnus-thread-total-score (thread)
3950 ;; This function find the total score of THREAD.
3951 (cond ((null thread)
3954 (if (stringp (car thread))
3955 (apply gnus-thread-score-function 0
3956 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
3957 (gnus-thread-total-score-1 thread)))
3959 (gnus-thread-total-score-1 (list thread)))))
3961 (defun gnus-thread-total-score-1 (root)
3962 ;; This function find the total score of the thread below ROOT.
3963 (setq root (car root))
3964 (apply gnus-thread-score-function
3966 (mapcar 'gnus-thread-total-score
3967 (cdr (gnus-id-to-thread (mail-header-id root))))
3968 (when (> (mail-header-number root) 0)
3969 (list (or (cdr (assq (mail-header-number root)
3970 gnus-newsgroup-scored))
3971 gnus-summary-default-score 0))))
3972 (list gnus-summary-default-score)
3975 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
3976 (defvar gnus-tmp-prev-subject nil)
3977 (defvar gnus-tmp-false-parent nil)
3978 (defvar gnus-tmp-root-expunged nil)
3979 (defvar gnus-tmp-dummy-line nil)
3981 (eval-when-compile (defvar gnus-tmp-header))
3982 (defun gnus-extra-header (type &optional header)
3983 "Return the extra header of TYPE."
3984 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
3987 (defun gnus-summary-prepare-threads (threads)
3988 "Prepare summary buffer from THREADS and indentation LEVEL.
3989 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
3990 or a straight list of headers."
3991 (gnus-message 7 "Generating summary...")
3993 (setq gnus-newsgroup-threads threads)
3996 (let ((gnus-tmp-level 0)
3997 (default-score (or gnus-summary-default-score 0))
3998 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
3999 thread number subject stack state gnus-tmp-gathered beg-match
4000 new-roots gnus-tmp-new-adopts thread-end
4001 gnus-tmp-header gnus-tmp-unread
4002 gnus-tmp-replied gnus-tmp-subject-or-nil
4003 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
4004 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
4005 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
4007 (setq gnus-tmp-prev-subject nil)
4009 (if (vectorp (car threads))
4010 ;; If this is a straight (sic) list of headers, then a
4011 ;; threaded summary display isn't required, so we just create
4012 ;; an unthreaded one.
4013 (gnus-summary-prepare-unthreaded threads)
4015 ;; Do the threaded display.
4017 (while (or threads stack gnus-tmp-new-adopts new-roots)
4019 (if (and (= gnus-tmp-level 0)
4022 (not gnus-tmp-false-parent)
4023 (or gnus-tmp-new-adopts new-roots))
4024 (if gnus-tmp-new-adopts
4025 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
4026 thread (list (car gnus-tmp-new-adopts))
4027 gnus-tmp-header (caar thread)
4028 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
4030 (setq thread (list (car new-roots))
4031 gnus-tmp-header (caar thread)
4032 new-roots (cdr new-roots))))
4035 ;; If there are some threads, we do them before the
4036 ;; threads on the stack.
4037 (setq thread threads
4038 gnus-tmp-header (caar thread))
4039 ;; There were no current threads, so we pop something off
4041 (setq state (car stack)
4042 gnus-tmp-level (car state)
4045 gnus-tmp-header (caar thread))))
4047 (setq gnus-tmp-false-parent nil)
4048 (setq gnus-tmp-root-expunged nil)
4049 (setq thread-end nil)
4051 (if (stringp gnus-tmp-header)
4052 ;; The header is a dummy root.
4054 ((eq gnus-summary-make-false-root 'adopt)
4055 ;; We let the first article adopt the rest.
4056 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
4058 (setq gnus-tmp-gathered
4060 (lambda (h) (mail-header-number (car h)))
4063 (setq thread (cons (list (caar thread)
4066 (setq gnus-tmp-level -1
4067 gnus-tmp-false-parent t))
4068 ((eq gnus-summary-make-false-root 'empty)
4069 ;; We print adopted articles with empty subject fields.
4070 (setq gnus-tmp-gathered
4072 (lambda (h) (mail-header-number (car h)))
4075 (setq gnus-tmp-level -1))
4076 ((eq gnus-summary-make-false-root 'dummy)
4077 ;; We remember that we probably want to output a dummy
4079 (setq gnus-tmp-dummy-line gnus-tmp-header)
4080 (setq gnus-tmp-prev-subject gnus-tmp-header))
4082 ;; We do not make a root for the gathered
4083 ;; sub-threads at all.
4084 (setq gnus-tmp-level -1)))
4086 (setq number (mail-header-number gnus-tmp-header)
4087 subject (mail-header-subject gnus-tmp-header))
4090 ;; If the thread has changed subject, we might want to make
4091 ;; this subthread into a root.
4092 ((and (null gnus-thread-ignore-subject)
4093 (not (zerop gnus-tmp-level))
4094 gnus-tmp-prev-subject
4096 (gnus-subject-equal gnus-tmp-prev-subject subject))))
4097 (setq new-roots (nconc new-roots (list (car thread)))
4099 gnus-tmp-header nil))
4100 ;; If the article lies outside the current limit,
4101 ;; then we do not display it.
4102 ((not (memq number gnus-newsgroup-limit))
4103 (setq gnus-tmp-gathered
4105 (lambda (h) (mail-header-number (car h)))
4108 (setq gnus-tmp-new-adopts (if (cdar thread)
4109 (append gnus-tmp-new-adopts
4111 gnus-tmp-new-adopts)
4113 gnus-tmp-header nil)
4114 (when (zerop gnus-tmp-level)
4115 (setq gnus-tmp-root-expunged t)))
4116 ;; Perhaps this article is to be marked as read?
4117 ((and gnus-summary-mark-below
4118 (< (or (cdr (assq number gnus-newsgroup-scored))
4120 gnus-summary-mark-below)
4121 ;; Don't touch sparse articles.
4122 (not (gnus-summary-article-sparse-p number))
4123 (not (gnus-summary-article-ancient-p number)))
4124 (setq gnus-newsgroup-unreads
4125 (delq number gnus-newsgroup-unreads))
4126 (if gnus-newsgroup-auto-expire
4127 (push number gnus-newsgroup-expirable)
4128 (push (cons number gnus-low-score-mark)
4129 gnus-newsgroup-reads))))
4131 (when gnus-tmp-header
4132 ;; We may have an old dummy line to output before this
4134 (when (and gnus-tmp-dummy-line
4137 (mail-header-subject gnus-tmp-header)))
4138 (gnus-summary-insert-dummy-line
4139 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
4140 (setq gnus-tmp-dummy-line nil))
4142 ;; Compute the mark.
4143 (setq gnus-tmp-unread (gnus-article-mark number))
4145 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
4146 gnus-tmp-header gnus-tmp-level)
4147 gnus-newsgroup-data)
4149 ;; Actually insert the line.
4151 gnus-tmp-subject-or-nil
4153 ((and gnus-thread-ignore-subject
4154 gnus-tmp-prev-subject
4155 (not (inline (gnus-subject-equal
4156 gnus-tmp-prev-subject subject))))
4158 ((zerop gnus-tmp-level)
4159 (if (and (eq gnus-summary-make-false-root 'empty)
4160 (memq number gnus-tmp-gathered)
4161 gnus-tmp-prev-subject
4162 (inline (gnus-subject-equal
4163 gnus-tmp-prev-subject subject)))
4164 gnus-summary-same-subject
4166 (t gnus-summary-same-subject)))
4167 (if (and (eq gnus-summary-make-false-root 'adopt)
4168 (= gnus-tmp-level 1)
4169 (memq number gnus-tmp-gathered))
4170 (setq gnus-tmp-opening-bracket ?\<
4171 gnus-tmp-closing-bracket ?\>)
4172 (setq gnus-tmp-opening-bracket ?\[
4173 gnus-tmp-closing-bracket ?\]))
4175 gnus-tmp-indentation
4176 (aref gnus-thread-indent-array gnus-tmp-level)
4177 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4178 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4179 gnus-summary-default-score 0)
4181 (if (or (null gnus-summary-default-score)
4182 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
4183 gnus-summary-zcore-fuzz))
4185 (if (< gnus-tmp-score gnus-summary-default-score)
4186 gnus-score-below-mark gnus-score-over-mark))
4188 (cond ((memq number gnus-newsgroup-processable)
4190 ((memq number gnus-newsgroup-cached)
4192 ((memq number gnus-newsgroup-replied)
4194 ((memq number gnus-newsgroup-saved)
4197 gnus-tmp-from (mail-header-from gnus-tmp-header)
4200 ((string-match "<[^>]+> *$" gnus-tmp-from)
4201 (setq beg-match (match-beginning 0))
4202 (or (and (string-match "^\".+\"" gnus-tmp-from)
4203 (substring gnus-tmp-from 1 (1- (match-end 0))))
4204 (substring gnus-tmp-from 0 beg-match)))
4205 ((string-match "(.+)" gnus-tmp-from)
4206 (substring gnus-tmp-from
4207 (1+ (match-beginning 0)) (1- (match-end 0))))
4209 (when (string= gnus-tmp-name "")
4210 (setq gnus-tmp-name gnus-tmp-from))
4211 (unless (numberp gnus-tmp-lines)
4212 (setq gnus-tmp-lines 0))
4213 (gnus-put-text-property
4215 (progn (eval gnus-summary-line-format-spec) (point))
4216 'gnus-number number)
4219 (gnus-run-hooks 'gnus-summary-update-hook)
4222 (setq gnus-tmp-prev-subject subject)))
4224 (when (nth 1 thread)
4225 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
4226 (incf gnus-tmp-level)
4227 (setq threads (if thread-end nil (cdar thread)))
4229 (setq gnus-tmp-level 0)))))
4230 (gnus-message 7 "Generating summary...done"))
4232 (defun gnus-summary-prepare-unthreaded (headers)
4233 "Generate an unthreaded summary buffer based on HEADERS."
4234 (let (header number mark)
4239 ;; We may have to root out some bad articles...
4240 (when (memq (setq number (mail-header-number
4241 (setq header (pop headers))))
4242 gnus-newsgroup-limit)
4243 ;; Mark article as read when it has a low score.
4244 (when (and gnus-summary-mark-below
4245 (< (or (cdr (assq number gnus-newsgroup-scored))
4246 gnus-summary-default-score 0)
4247 gnus-summary-mark-below)
4248 (not (gnus-summary-article-ancient-p number)))
4249 (setq gnus-newsgroup-unreads
4250 (delq number gnus-newsgroup-unreads))
4251 (if gnus-newsgroup-auto-expire
4252 (push number gnus-newsgroup-expirable)
4253 (push (cons number gnus-low-score-mark)
4254 gnus-newsgroup-reads)))
4256 (setq mark (gnus-article-mark number))
4257 (push (gnus-data-make number mark (1+ (point)) header 0)
4258 gnus-newsgroup-data)
4259 (gnus-summary-insert-line
4261 mark (memq number gnus-newsgroup-replied)
4262 (memq number gnus-newsgroup-expirable)
4263 (mail-header-subject header) nil
4264 (cdr (assq number gnus-newsgroup-scored))
4265 (memq number gnus-newsgroup-processable))))))
4267 (defun gnus-summary-remove-list-identifiers ()
4268 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
4269 (let ((regexp (if (consp gnus-list-identifiers)
4270 (mapconcat 'identity gnus-list-identifiers " *\\|")
4271 gnus-list-identifiers))
4274 (dolist (header gnus-newsgroup-headers)
4275 (setq subject (mail-header-subject header)
4277 (while (string-match
4278 (concat "^\\(R[Ee]: +\\)*\\(" regexp " *\\)")
4281 (concat (substring subject 0 (match-beginning 2))
4282 (substring subject (match-end 0)))
4286 "^\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" subject))
4288 (concat (substring subject 0 (match-beginning 1))
4289 (substring subject (match-end 1)))))
4291 (mail-header-set-subject header subject))))))
4293 (defun gnus-select-newsgroup (group &optional read-all select-articles)
4294 "Select newsgroup GROUP.
4295 If READ-ALL is non-nil, all articles in the group are selected.
4296 If SELECT-ARTICLES, only select those articles from GROUP."
4297 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4298 ;;!!! Dirty hack; should be removed.
4299 (gnus-summary-ignore-duplicates
4300 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
4302 gnus-summary-ignore-duplicates))
4303 (info (nth 2 entry))
4304 articles fetched-articles cached)
4306 (unless (gnus-check-server
4307 (setq gnus-current-select-method
4308 (gnus-find-method-for-group group)))
4309 (error "Couldn't open server"))
4311 (or (and entry (not (eq (car entry) t))) ; Either it's active...
4312 (gnus-activate-group group) ; Or we can activate it...
4313 (progn ; Or we bug out.
4314 (when (equal major-mode 'gnus-summary-mode)
4315 (kill-buffer (current-buffer)))
4316 (error "Couldn't activate group %s: %s"
4317 group (gnus-status-message group))))
4319 (unless (gnus-request-group group t)
4320 (when (equal major-mode 'gnus-summary-mode)
4321 (kill-buffer (current-buffer)))
4322 (error "Couldn't request group %s: %s"
4323 group (gnus-status-message group)))
4325 (setq gnus-newsgroup-name group)
4326 (setq gnus-newsgroup-unselected nil)
4327 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
4328 (gnus-summary-setup-default-charset)
4330 ;; Adjust and set lists of article marks.
4332 (gnus-adjust-marked-articles info))
4334 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4335 (when (gnus-virtual-group-p group)
4336 (setq cached gnus-newsgroup-cached))
4338 (setq gnus-newsgroup-unreads
4339 (gnus-set-difference
4340 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
4341 gnus-newsgroup-dormant))
4343 (setq gnus-newsgroup-processable nil)
4345 (gnus-update-read-articles group gnus-newsgroup-unreads)
4347 (if (setq articles select-articles)
4348 (setq gnus-newsgroup-unselected
4349 (gnus-sorted-intersection
4350 gnus-newsgroup-unreads
4351 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4352 (setq articles (gnus-articles-to-read group read-all)))
4356 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
4358 ((eq articles 0) nil)
4360 ;; Init the dependencies hash table.
4361 (setq gnus-newsgroup-dependencies
4362 (gnus-make-hashtable (length articles)))
4363 (gnus-set-global-variables)
4364 ;; Retrieve the headers and read them in.
4365 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
4366 (setq gnus-newsgroup-headers
4368 (setq gnus-headers-retrieved-by
4369 (gnus-retrieve-headers
4370 articles gnus-newsgroup-name
4371 ;; We might want to fetch old headers, but
4372 ;; not if there is only 1 article.
4374 (not (eq gnus-fetch-old-headers 'some))
4375 (not (numberp gnus-fetch-old-headers)))
4376 (> (length articles) 1))
4377 gnus-fetch-old-headers))))
4378 (gnus-get-newsgroup-headers-xover
4379 articles nil nil gnus-newsgroup-name t)
4380 (gnus-get-newsgroup-headers)))
4381 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
4383 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4385 (setq gnus-newsgroup-cached cached))
4387 ;; Suppress duplicates?
4388 (when gnus-suppress-duplicates
4389 (gnus-dup-suppress-articles))
4391 ;; Set the initial limit.
4392 (setq gnus-newsgroup-limit (copy-sequence articles))
4393 ;; Remove canceled articles from the list of unread articles.
4394 (setq gnus-newsgroup-unreads
4395 (gnus-set-sorted-intersection
4396 gnus-newsgroup-unreads
4397 (setq fetched-articles
4398 (mapcar (lambda (headers) (mail-header-number headers))
4399 gnus-newsgroup-headers))))
4400 ;; Removed marked articles that do not exist.
4401 (gnus-update-missing-marks
4402 (gnus-sorted-complement fetched-articles articles))
4403 ;; We might want to build some more threads first.
4404 (when (and gnus-fetch-old-headers
4405 (eq gnus-headers-retrieved-by 'nov))
4406 (if (eq gnus-fetch-old-headers 'invisible)
4407 (gnus-build-all-threads)
4408 (gnus-build-old-threads)))
4409 ;; Let the Gnus agent mark articles as read.
4411 (gnus-agent-get-undownloaded-list))
4412 ;; Remove list identifiers from subject
4413 (when gnus-list-identifiers
4414 (gnus-summary-remove-list-identifiers))
4415 ;; Check whether auto-expire is to be done in this group.
4416 (setq gnus-newsgroup-auto-expire
4417 (gnus-group-auto-expirable-p group))
4418 ;; Set up the article buffer now, if necessary.
4419 (unless gnus-single-article-buffer
4420 (gnus-article-setup-buffer))
4421 ;; First and last article in this newsgroup.
4422 (when gnus-newsgroup-headers
4423 (setq gnus-newsgroup-begin
4424 (mail-header-number (car gnus-newsgroup-headers))
4427 (gnus-last-element gnus-newsgroup-headers))))
4428 ;; GROUP is successfully selected.
4429 (or gnus-newsgroup-headers t)))))
4431 (defun gnus-articles-to-read (group &optional read-all)
4432 "Find out what articles the user wants to read."
4434 ;; Select all articles if `read-all' is non-nil, or if there
4435 ;; are no unread articles.
4437 (and (zerop (length gnus-newsgroup-marked))
4438 (zerop (length gnus-newsgroup-unreads)))
4439 (eq (gnus-group-find-parameter group 'display)
4442 (gnus-uncompress-range (gnus-active group))
4443 (gnus-cache-articles-in-group group))
4444 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
4445 (copy-sequence gnus-newsgroup-unreads))
4447 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
4448 (scored (length scored-list))
4449 (number (length articles))
4450 (marked (+ (length gnus-newsgroup-marked)
4451 (length gnus-newsgroup-dormant)))
4459 ((and (or (<= scored marked) (= scored number))
4460 (numberp gnus-large-newsgroup)
4461 (> number gnus-large-newsgroup))
4465 "How many articles from %s (default %d): "
4466 (gnus-limit-string gnus-newsgroup-name 35)
4468 (if (string-match "^[ \t]*$" input) number input)))
4469 ((and (> scored marked) (< scored number)
4470 (> (- scored number) 20))
4473 (format "%s %s (%d scored, %d total): "
4474 "How many articles from"
4475 group scored number))))
4476 (if (string-match "^[ \t]*$" input)
4480 (message "Quit getting the articles to read")
4482 (setq select (if (stringp select) (string-to-number select) select))
4483 (if (or (null select) (zerop select))
4485 (if (and (not (zerop scored)) (<= (abs select) scored))
4487 (setq articles (sort scored-list '<))
4488 (setq number (length articles)))
4489 (setq articles (copy-sequence articles)))
4491 (when (< (abs select) number)
4493 ;; Select the N oldest articles.
4494 (setcdr (nthcdr (1- (abs select)) articles) nil)
4495 ;; Select the N most recent articles.
4496 (setq articles (nthcdr (- number select) articles))))
4497 (setq gnus-newsgroup-unselected
4498 (gnus-sorted-intersection
4499 gnus-newsgroup-unreads
4500 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4501 (when gnus-alter-articles-to-read-function
4502 (setq gnus-newsgroup-unreads
4504 (funcall gnus-alter-articles-to-read-function
4505 gnus-newsgroup-name gnus-newsgroup-unreads)
4509 (defun gnus-killed-articles (killed articles)
4512 (when (inline (gnus-member-of-range (car articles) killed))
4513 (push (car articles) out))
4514 (setq articles (cdr articles)))
4517 (defun gnus-uncompress-marks (marks)
4518 "Uncompress the mark ranges in MARKS."
4519 (let ((uncompressed '(score bookmark))
4522 (if (memq (caar marks) uncompressed)
4523 (push (car marks) out)
4524 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
4525 (setq marks (cdr marks)))
4528 (defun gnus-adjust-marked-articles (info)
4529 "Set all article lists and remove all marks that are no longer valid."
4530 (let* ((marked-lists (gnus-info-marks info))
4531 (active (gnus-active (gnus-info-group info)))
4534 (types gnus-article-mark-lists)
4535 (uncompressed '(score bookmark killed))
4536 marks var articles article mark)
4539 (setq marks (pop marked-lists))
4540 (set (setq var (intern (format "gnus-newsgroup-%s"
4541 (car (rassq (setq mark (car marks))
4543 (if (memq (car marks) uncompressed) (cdr marks)
4544 (gnus-uncompress-range (cdr marks))))
4546 (setq articles (symbol-value var))
4548 ;; All articles have to be subsets of the active articles.
4550 ;; Adjust "simple" lists.
4551 ((memq mark '(tick dormant expire reply save))
4553 (when (or (< (setq article (pop articles)) min) (> article max))
4554 (set var (delq article (symbol-value var))))))
4556 ((memq mark uncompressed)
4557 (when (not (listp (cdr (symbol-value var))))
4558 (set var (list (symbol-value var))))
4559 (when (not (listp (cdr articles)))
4560 (setq articles (list articles)))
4562 (when (or (not (consp (setq article (pop articles))))
4563 (< (car article) min)
4564 (> (car article) max))
4565 (set var (delq article (symbol-value var))))))))))
4567 (defun gnus-update-missing-marks (missing)
4568 "Go through the list of MISSING articles and remove them from the mark lists."
4570 (let ((types gnus-article-mark-lists)
4572 ;; Go through all types.
4574 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
4575 (when (symbol-value var)
4576 ;; This list has articles. So we delete all missing articles
4580 (set var (delq (pop m) (symbol-value var)))))))))
4582 (defun gnus-update-marks ()
4583 "Enter the various lists of marked articles into the newsgroup info list."
4584 (let ((types gnus-article-mark-lists)
4585 (info (gnus-get-info gnus-newsgroup-name))
4586 (uncompressed '(score bookmark killed))
4587 type list newmarked symbol delta-marks)
4589 ;; Add all marks lists to the list of marks lists.
4590 (while (setq type (pop types))
4591 (setq list (symbol-value
4593 (intern (format "gnus-newsgroup-%s"
4597 ;; Get rid of the entries of the articles that have the
4599 (when (and (eq (cdr type) 'score)
4603 (prev (cons nil list))
4606 (if (or (not (consp (car arts)))
4607 (= (cdar arts) gnus-summary-default-score))
4608 (setcdr prev (cdr arts))
4610 (setq arts (cdr arts)))
4611 (setq list (cdr all)))))
4613 (unless (memq (cdr type) uncompressed)
4614 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
4616 (when (gnus-check-backend-function
4617 'request-set-mark gnus-newsgroup-name)
4618 ;; propagate flags to server, with the following exceptions:
4619 ;; uncompressed:s are not proper flags (they are cons cells)
4620 ;; cache is a internal gnus flag
4621 ;; download are local to one gnus installation (well)
4622 ;; unsend are for nndraft groups only
4623 ;; xxx: generality of this? this suits nnimap anyway
4624 (unless (memq (cdr type) (append '(cache download unsend)
4626 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
4627 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
4628 (add (gnus-remove-from-range
4629 (gnus-copy-sequence list) old)))
4631 (push (list add 'add (list (cdr type))) delta-marks))
4633 (push (list del 'del (list (cdr type))) delta-marks)))))
4636 (push (cons (cdr type) list) newmarked)))
4639 (unless (gnus-check-group gnus-newsgroup-name)
4640 (error "Can't open server for %s" gnus-newsgroup-name))
4641 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
4643 ;; Enter these new marks into the info of the group.
4645 (setcar (nthcdr 3 info) newmarked)
4646 ;; Add the marks lists to the end of the info.
4648 (setcdr (nthcdr 2 info) (list newmarked))))
4650 ;; Cut off the end of the info if there's nothing else there.
4654 (when (nthcdr (decf i) info)
4655 (setcdr (nthcdr i info) nil)))))))
4657 (defun gnus-set-mode-line (where)
4658 "Set the mode line of the article or summary buffers.
4659 If WHERE is `summary', the summary mode line format will be used."
4660 ;; Is this mode line one we keep updated?
4661 (when (and (memq where gnus-updated-mode-lines)
4663 (intern (format "gnus-%s-mode-line-format-spec" where))))
4666 ;; We evaluate this in the summary buffer since these
4667 ;; variables are buffer-local to that buffer.
4668 (set-buffer gnus-summary-buffer)
4669 ;; We bind all these variables that are used in the `eval' form
4671 (let* ((mformat (symbol-value
4673 (format "gnus-%s-mode-line-format-spec" where))))
4674 (gnus-tmp-group-name (gnus-group-name-decode
4676 (gnus-group-name-charset
4678 gnus-newsgroup-name)))
4679 (gnus-tmp-article-number (or gnus-current-article 0))
4680 (gnus-tmp-unread gnus-newsgroup-unreads)
4681 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
4682 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
4683 (gnus-tmp-unread-and-unselected
4684 (cond ((and (zerop gnus-tmp-unread-and-unticked)
4685 (zerop gnus-tmp-unselected))
4687 ((zerop gnus-tmp-unselected)
4688 (format "{%d more}" gnus-tmp-unread-and-unticked))
4689 (t (format "{%d(+%d) more}"
4690 gnus-tmp-unread-and-unticked
4691 gnus-tmp-unselected))))
4693 (if (and gnus-current-headers
4694 (vectorp gnus-current-headers))
4695 (gnus-mode-string-quote
4696 (mail-header-subject gnus-current-headers))
4698 bufname-length max-len
4699 gnus-tmp-header);; passed as argument to any user-format-funcs
4700 (setq mode-string (eval mformat))
4701 (setq bufname-length (if (string-match "%b" mode-string)
4704 (if (eq where 'summary)
4706 (get-buffer gnus-article-buffer))))
4709 (setq max-len (max 4 (if gnus-mode-non-string-length
4711 gnus-mode-non-string-length
4713 (length mode-string))))
4714 ;; We might have to chop a bit of the string off...
4715 (when (> (length mode-string) max-len)
4717 (concat (truncate-string-to-width mode-string (- max-len 3))
4719 ;; Pad the mode string a bit.
4720 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
4721 ;; Update the mode line.
4722 (setq mode-line-buffer-identification
4723 (gnus-mode-line-buffer-identification (list mode-string)))
4724 (set-buffer-modified-p t))))
4726 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
4727 "Go through the HEADERS list and add all Xrefs to a hash table.
4728 The resulting hash table is returned, or nil if no Xrefs were found."
4729 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
4730 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
4731 (xref-hashtb (gnus-make-hashtable))
4732 start group entry number xrefs header)
4734 (setq header (pop headers))
4735 (when (and (setq xrefs (mail-header-xref header))
4736 (not (memq (setq number (mail-header-number header))
4739 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
4740 (setq start (match-end 0))
4741 (setq group (if prefix
4742 (concat prefix (substring xrefs (match-beginning 1)
4744 (substring xrefs (match-beginning 1) (match-end 1))))
4746 (string-to-int (substring xrefs (match-beginning 2)
4748 (if (setq entry (gnus-gethash group xref-hashtb))
4749 (setcdr entry (cons number (cdr entry)))
4750 (gnus-sethash group (cons number nil) xref-hashtb)))))
4751 (and start xref-hashtb)))
4753 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
4754 "Look through all the headers and mark the Xrefs as read."
4755 (let ((virtual (gnus-virtual-group-p from-newsgroup))
4756 name entry info xref-hashtb idlist method nth4)
4758 (set-buffer gnus-group-buffer)
4759 (when (setq xref-hashtb
4760 (gnus-create-xref-hashtb from-newsgroup headers unreads))
4763 (unless (string= from-newsgroup (setq name (symbol-name group)))
4764 (setq idlist (symbol-value group))
4765 ;; Dead groups are not updated.
4767 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
4769 (when (stringp (setq nth4 (gnus-info-method info)))
4770 (setq nth4 (gnus-server-to-method nth4))))
4771 ;; Only do the xrefs if the group has the same
4772 ;; select method as the group we have just read.
4773 (or (gnus-methods-equal-p
4774 nth4 (gnus-find-method-for-group from-newsgroup))
4776 (equal nth4 (setq method (gnus-find-method-for-group
4778 (and (equal (car nth4) (car method))
4779 (equal (nth 1 nth4) (nth 1 method))))
4780 gnus-use-cross-reference
4781 (or (not (eq gnus-use-cross-reference t))
4783 ;; Only do cross-references on subscribed
4784 ;; groups, if that is what is wanted.
4785 (<= (gnus-info-level info) gnus-level-subscribed))
4786 (gnus-group-make-articles-read name idlist))))
4789 (defun gnus-compute-read-articles (group articles)
4790 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4791 (info (nth 2 entry))
4792 (active (gnus-active group))
4795 ;; First peel off all invalid article numbers.
4797 (let ((ids articles)
4799 (while (setq id (pop ids))
4800 (when (and first (> id (cdr active)))
4801 ;; We'll end up in this situation in one particular
4802 ;; obscure situation. If you re-scan a group and get
4803 ;; a new article that is cross-posted to a different
4804 ;; group that has not been re-scanned, you might get
4805 ;; crossposted article that has a higher number than
4806 ;; Gnus believes possible. So we re-activate this
4807 ;; group as well. This might mean doing the
4808 ;; crossposting thingy will *increase* the number
4809 ;; of articles in some groups. Tsk, tsk.
4810 (setq active (or (gnus-activate-group group) active)))
4811 (when (or (> id (cdr active))
4812 (< id (car active)))
4813 (setq articles (delq id articles))))))
4814 ;; If the read list is nil, we init it.
4816 (null (gnus-info-read info))
4818 (setq ninfo (cons 1 (1- (car active))))
4819 (setq ninfo (gnus-info-read info)))
4820 ;; Then we add the read articles to the range.
4822 ninfo (setq articles (sort articles '<))))))
4824 (defun gnus-group-make-articles-read (group articles)
4825 "Update the info of GROUP to say that ARTICLES are read."
4827 (entry (gnus-gethash group gnus-newsrc-hashtb))
4828 (info (nth 2 entry))
4829 (active (gnus-active group))
4832 (setq range (gnus-compute-read-articles group articles))
4834 (set-buffer gnus-group-buffer)
4837 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
4838 (gnus-info-set-read ',info ',(gnus-info-read info))
4839 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
4840 (gnus-group-update-group ,group t))))
4841 ;; Add the read articles to the range.
4842 (gnus-info-set-read info range)
4843 ;; Then we have to re-compute how many unread
4844 ;; articles there are in this group.
4848 (setq num (- (1+ (cdr active)) (car active))))
4849 ((not (listp (cdr range)))
4850 (setq num (- (cdr active) (- (1+ (cdr range))
4854 (if (numberp (car range))
4856 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
4857 (setq range (cdr range)))
4858 (setq num (- (cdr active) num))))
4859 ;; Update the number of unread articles.
4861 ;; Update the group buffer.
4862 (gnus-group-update-group group t)))))
4864 (defvar gnus-newsgroup-none-id 0)
4866 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
4867 (let ((cur nntp-server-buffer)
4870 (save-excursion (set-buffer gnus-summary-buffer)
4871 gnus-newsgroup-dependencies)))
4873 (mail-parse-charset gnus-newsgroup-charset)
4874 (mail-parse-ignored-charsets
4875 (save-excursion (condition-case nil
4876 (set-buffer gnus-summary-buffer)
4878 gnus-newsgroup-ignored-charsets)))
4880 (set-buffer nntp-server-buffer)
4881 ;; Translate all TAB characters into SPACE characters.
4882 (subst-char-in-region (point-min) (point-max) ?\t ? t)
4883 (subst-char-in-region (point-min) (point-max) ?\r ? t)
4884 (gnus-run-hooks 'gnus-parse-headers-hook)
4885 (let ((case-fold-search t)
4886 in-reply-to header p lines chars)
4887 (goto-char (point-min))
4888 ;; Search to the beginning of the next header. Error messages
4889 ;; do not begin with 2 or 3.
4890 (while (re-search-forward "^[23][0-9]+ " nil t)
4893 ;; This implementation of this function, with nine
4894 ;; search-forwards instead of the one re-search-forward and
4895 ;; a case (which basically was the old function) is actually
4896 ;; about twice as fast, even though it looks messier. You
4897 ;; can't have everything, I guess. Speed and elegance
4898 ;; doesn't always go hand in hand.
4907 (narrow-to-region (point)
4908 (or (and (search-forward "\n.\n" nil t)
4914 (if (search-forward "\nsubject: " nil t)
4915 (funcall gnus-decode-encoded-word-function
4916 (nnheader-header-value))
4921 (if (or (search-forward "\nfrom: " nil t)
4922 (search-forward "\nfrom:" nil t))
4923 (funcall gnus-decode-encoded-word-function
4924 (nnheader-header-value))
4929 (if (search-forward "\ndate: " nil t)
4930 (nnheader-header-value) ""))
4934 (setq id (if (re-search-forward
4935 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
4936 ;; We do it this way to make sure the Message-ID
4937 ;; is (somewhat) syntactically valid.
4938 (buffer-substring (match-beginning 1)
4940 ;; If there was no message-id, we just fake one
4941 ;; to make subsequent routines simpler.
4942 (nnheader-generate-fake-message-id))))
4946 (if (search-forward "\nreferences: " nil t)
4950 (nnheader-header-value)
4955 (search-backward ">" end t)
4958 (search-backward "<" end t)
4960 ;; Get the references from the in-reply-to header if there
4961 ;; were no references and the in-reply-to header looks
4963 (if (and (search-forward "\nin-reply-to: " nil t)
4964 (setq in-reply-to (nnheader-header-value))
4965 (string-match "<[^>]+>" in-reply-to))
4967 (setq ref (substring in-reply-to (match-beginning 0)
4969 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
4970 (setq ref2 (substring in-reply-to (match-beginning 0)
4972 (when (> (length ref2) (length ref))
4979 (if (search-forward "\nchars: " nil t)
4980 (if (numberp (setq chars (ignore-errors (read cur))))
4986 (if (search-forward "\nlines: " nil t)
4987 (if (numberp (setq lines (ignore-errors (read cur))))
4993 (and (search-forward "\nxref: " nil t)
4994 (nnheader-header-value)))
4996 (when gnus-extra-headers
4997 (let ((extra gnus-extra-headers)
5001 (when (search-forward
5002 (concat "\n" (symbol-name (car extra)) ": ") nil t)
5003 (push (cons (car extra) (nnheader-header-value))
5007 (when (equal id ref)
5010 (when gnus-alter-header-function
5011 (funcall gnus-alter-header-function header)
5012 (setq id (mail-header-id header)
5013 ref (gnus-parent-id (mail-header-references header))))
5016 (gnus-dependencies-add-header
5017 header dependencies force-new))
5018 (push header headers))
5019 (goto-char (point-max))
5021 (nreverse headers)))))
5023 ;; Goes through the xover lines and returns a list of vectors
5024 (defun gnus-get-newsgroup-headers-xover (sequence &optional
5025 force-new dependencies
5026 group also-fetch-heads)
5027 "Parse the news overview data in the server buffer.
5028 Return a list of headers that match SEQUENCE (see
5029 `nntp-retrieve-headers')."
5030 ;; Get the Xref when the users reads the articles since most/some
5031 ;; NNTP servers do not include Xrefs when using XOVER.
5032 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
5033 (let ((mail-parse-charset gnus-newsgroup-charset)
5034 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
5035 (cur nntp-server-buffer)
5036 (dependencies (or dependencies gnus-newsgroup-dependencies))
5037 number headers header)
5039 (set-buffer nntp-server-buffer)
5040 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5041 ;; Allow the user to mangle the headers before parsing them.
5042 (gnus-run-hooks 'gnus-parse-headers-hook)
5043 (goto-char (point-min))
5046 (while (and sequence (not (eobp)))
5047 (setq number (read cur))
5048 (while (and sequence
5049 (< (car sequence) number))
5050 (setq sequence (cdr sequence)))
5052 (eq number (car sequence))
5054 (setq sequence (cdr sequence))
5055 (setq header (inline
5056 (gnus-nov-parse-line
5057 number dependencies force-new))))
5058 (push header headers))
5061 (gnus-error 4 "Strange nov line (%d)"
5062 (count-lines (point-min) (point)))))
5064 ;; A common bug in inn is that if you have posted an article and
5065 ;; then retrieves the active file, it will answer correctly --
5066 ;; the new article is included. However, a NOV entry for the
5067 ;; article may not have been generated yet, so this may fail.
5068 ;; We work around this problem by retrieving the last few
5069 ;; headers using HEAD.
5070 (if (or (not also-fetch-heads)
5072 ;; We (probably) got all the headers.
5074 (let ((gnus-nov-is-evil t))
5077 (when (gnus-retrieve-headers sequence group)
5078 (gnus-get-newsgroup-headers))))))))
5080 (defun gnus-article-get-xrefs ()
5081 "Fill in the Xref value in `gnus-current-headers', if necessary.
5082 This is meant to be called in `gnus-article-internal-prepare-hook'."
5083 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
5084 gnus-current-headers)))
5085 (or (not gnus-use-cross-reference)
5087 (and (mail-header-xref headers)
5088 (not (string= (mail-header-xref headers) "")))
5089 (let ((case-fold-search t)
5092 (nnheader-narrow-to-headers)
5093 (goto-char (point-min))
5094 (when (or (and (not (eobp))
5095 (eq (downcase (char-after)) ?x)
5096 (looking-at "Xref:"))
5097 (search-forward "\nXref:" nil t))
5098 (goto-char (1+ (match-end 0)))
5099 (setq xref (buffer-substring (point)
5100 (progn (end-of-line) (point))))
5101 (mail-header-set-xref headers xref)))))))
5103 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
5104 "Find article ID and insert the summary line for that article.
5105 OLD-HEADER can either be a header or a line number to insert
5106 the subject line on."
5107 (let* ((line (and (numberp old-header) old-header))
5108 (old-header (and (vectorp old-header) old-header))
5109 (header (cond ((and old-header use-old-header)
5112 (gnus-number-to-header id))
5113 (gnus-number-to-header id))
5115 (gnus-read-header id))))
5116 (number (and (numberp id) id))
5119 ;; Rebuild the thread that this article is part of and go to the
5120 ;; article we have fetched.
5121 (when (and (not gnus-show-threads)
5124 (setq d (gnus-data-find (mail-header-number old-header))))
5125 (goto-char (gnus-data-pos d))
5128 (- (gnus-point-at-bol)
5130 (1+ (gnus-point-at-eol))
5131 (gnus-delete-line))))))
5133 (mail-header-set-number header (mail-header-number old-header)))
5134 (setq gnus-newsgroup-sparse
5135 (delq (setq number (mail-header-number header))
5136 gnus-newsgroup-sparse))
5137 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
5138 (push number gnus-newsgroup-limit)
5139 (gnus-rebuild-thread (mail-header-id header) line)
5140 (gnus-summary-goto-subject number nil t))
5141 (when (and (numberp number)
5143 ;; We have to update the boundaries even if we can't fetch the
5144 ;; article if ID is a number -- so that the next `P' or `N'
5145 ;; command will fetch the previous (or next) article even
5146 ;; if the one we tried to fetch this time has been canceled.
5147 (when (> number gnus-newsgroup-end)
5148 (setq gnus-newsgroup-end number))
5149 (when (< number gnus-newsgroup-begin)
5150 (setq gnus-newsgroup-begin number))
5151 (setq gnus-newsgroup-unselected
5152 (delq number gnus-newsgroup-unselected)))
5153 ;; Report back a success?
5154 (and header (mail-header-number header))))
5156 ;;; Process/prefix in the summary buffer
5158 (defun gnus-summary-work-articles (n)
5159 "Return a list of articles to be worked upon.
5160 The prefix argument, the list of process marked articles, and the
5161 current article will be taken into consideration."
5163 (set-buffer gnus-summary-buffer)
5166 ;; A numerical prefix has been given.
5167 (setq n (prefix-numeric-value n))
5168 (let ((backward (< n 0))
5169 (n (abs (prefix-numeric-value n)))
5174 (push (setq article (gnus-summary-article-number))
5177 (gnus-summary-find-prev nil article)
5178 (gnus-summary-find-next nil article)))
5180 (nreverse articles)))
5181 ((and (gnus-region-active-p) (mark))
5182 (message "region active")
5183 ;; Work on the region between point and mark.
5184 (let ((max (max (point) (mark)))
5187 (goto-char (min (min (point) (mark))))
5190 (push (setq article (gnus-summary-article-number)) articles)
5191 (gnus-summary-find-next nil article)
5193 (nreverse articles))))
5194 (gnus-newsgroup-processable
5195 ;; There are process-marked articles present.
5196 ;; Save current state.
5197 (gnus-summary-save-process-mark)
5199 (reverse gnus-newsgroup-processable))
5201 ;; Just return the current article.
5202 (list (gnus-summary-article-number))))))
5204 (defmacro gnus-summary-iterate (arg &rest forms)
5205 "Iterate over the process/prefixed articles and do FORMS.
5206 ARG is the interactive prefix given to the command. FORMS will be
5207 executed with point over the summary line of the articles."
5208 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
5209 `(let ((,articles (gnus-summary-work-articles ,arg)))
5211 (gnus-summary-goto-subject (car ,articles))
5215 (put 'gnus-summary-iterate 'lisp-indent-function 1)
5216 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
5218 (defun gnus-summary-save-process-mark ()
5219 "Push the current set of process marked articles on the stack."
5221 (push (copy-sequence gnus-newsgroup-processable)
5222 gnus-newsgroup-process-stack))
5224 (defun gnus-summary-kill-process-mark ()
5225 "Push the current set of process marked articles on the stack and unmark."
5227 (gnus-summary-save-process-mark)
5228 (gnus-summary-unmark-all-processable))
5230 (defun gnus-summary-yank-process-mark ()
5231 "Pop the last process mark state off the stack and restore it."
5233 (unless gnus-newsgroup-process-stack
5234 (error "Empty mark stack"))
5235 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
5237 (defun gnus-summary-process-mark-set (set)
5238 "Make SET into the current process marked articles."
5239 (gnus-summary-unmark-all-processable)
5241 (gnus-summary-set-process-mark (pop set))))
5243 ;;; Searching and stuff
5245 (defun gnus-summary-search-group (&optional backward use-level)
5246 "Search for next unread newsgroup.
5247 If optional argument BACKWARD is non-nil, search backward instead."
5249 (set-buffer gnus-group-buffer)
5250 (when (gnus-group-search-forward
5251 backward nil (if use-level (gnus-group-group-level) nil))
5252 (gnus-group-group-name))))
5254 (defun gnus-summary-best-group (&optional exclude-group)
5255 "Find the name of the best unread group.
5256 If EXCLUDE-GROUP, do not go to this group."
5258 (set-buffer gnus-group-buffer)
5260 (gnus-group-best-unread-group exclude-group))))
5262 (defun gnus-summary-find-next (&optional unread article backward undownloaded)
5263 (if backward (gnus-summary-find-prev)
5264 (let* ((dummy (gnus-summary-article-intangible-p))
5265 (article (or article (gnus-summary-article-number)))
5266 (arts (gnus-data-find-list article))
5268 (when (and (not dummy)
5269 (or (not gnus-summary-check-current)
5271 (not (gnus-data-unread-p (car arts)))))
5272 (setq arts (cdr arts)))
5277 (when (or (and undownloaded
5278 (eq gnus-undownloaded-mark
5279 (gnus-data-mark (car arts))))
5280 (gnus-data-unread-p (car arts)))
5281 (setq result (car arts)
5283 (setq arts (cdr arts)))
5286 (goto-char (gnus-data-pos result))
5287 (gnus-data-number result)))))
5289 (defun gnus-summary-find-prev (&optional unread article)
5290 (let* ((eobp (eobp))
5291 (article (or article (gnus-summary-article-number)))
5292 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
5294 (when (and (not eobp)
5295 (or (not gnus-summary-check-current)
5297 (not (gnus-data-unread-p (car arts)))))
5298 (setq arts (cdr arts)))
5303 (when (gnus-data-unread-p (car arts))
5304 (setq result (car arts)
5306 (setq arts (cdr arts)))
5309 (goto-char (gnus-data-pos result))
5310 (gnus-data-number result))))
5312 (defun gnus-summary-find-subject (subject &optional unread backward article)
5313 (let* ((simp-subject (gnus-simplify-subject-fully subject))
5314 (article (or article (gnus-summary-article-number)))
5315 (articles (gnus-data-list backward))
5316 (arts (gnus-data-find-list article articles))
5318 (when (or (not gnus-summary-check-current)
5320 (not (gnus-data-unread-p (car arts))))
5321 (setq arts (cdr arts)))
5323 (and (or (not unread)
5324 (gnus-data-unread-p (car arts)))
5325 (vectorp (gnus-data-header (car arts)))
5327 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
5328 (setq result (car arts)
5330 (setq arts (cdr arts)))
5332 (goto-char (gnus-data-pos result))
5333 (gnus-data-number result))))
5335 (defun gnus-summary-search-forward (&optional unread subject backward)
5336 "Search forward for an article.
5337 If UNREAD, look for unread articles. If SUBJECT, look for
5338 articles with that subject. If BACKWARD, search backward instead."
5339 (cond (subject (gnus-summary-find-subject subject unread backward))
5340 (backward (gnus-summary-find-prev unread))
5341 (t (gnus-summary-find-next unread))))
5343 (defun gnus-recenter (&optional n)
5344 "Center point in window and redisplay frame.
5345 Also do horizontal recentering."
5347 (when (and gnus-auto-center-summary
5348 (not (eq gnus-auto-center-summary 'vertical)))
5349 (gnus-horizontal-recenter))
5352 (defun gnus-summary-recenter ()
5353 "Center point in the summary window.
5354 If `gnus-auto-center-summary' is nil, or the article buffer isn't
5355 displayed, no centering will be performed."
5356 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
5357 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
5359 (let* ((top (cond ((< (window-height) 4) 0)
5360 ((< (window-height) 7) 1)
5361 (t (if (numberp gnus-auto-center-summary)
5362 gnus-auto-center-summary
5364 (height (1- (window-height)))
5365 (bottom (save-excursion (goto-char (point-max))
5366 (forward-line (- height))
5368 (window (get-buffer-window (current-buffer))))
5369 ;; The user has to want it.
5370 (when gnus-auto-center-summary
5371 (when (get-buffer-window gnus-article-buffer)
5372 ;; Only do recentering when the article buffer is displayed,
5373 ;; Set the window start to either `bottom', which is the biggest
5374 ;; possible valid number, or the second line from the top,
5375 ;; whichever is the least.
5376 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
5377 (if (> bottom top-pos)
5378 ;; Keep the second line from the top visible
5379 (set-window-start window top-pos t)
5380 ;; Try to keep the bottom line visible; if it's partially
5381 ;; obscured, either scroll one more line to make it fully
5382 ;; visible, or revert to using TOP-POS.
5384 (goto-char (point-max))
5386 (let ((last-line-start (point)))
5388 (set-window-start window (point) t)
5389 (when (not (pos-visible-in-window-p last-line-start window))
5391 (set-window-start window (min (point) top-pos) t)))))))
5392 ;; Do horizontal recentering while we're at it.
5393 (when (and (get-buffer-window (current-buffer) t)
5394 (not (eq gnus-auto-center-summary 'vertical)))
5395 (let ((selected (selected-window)))
5396 (select-window (get-buffer-window (current-buffer) t))
5397 (gnus-summary-position-point)
5398 (gnus-horizontal-recenter)
5399 (select-window selected))))))
5401 (defun gnus-summary-jump-to-group (newsgroup)
5402 "Move point to NEWSGROUP in group mode buffer."
5403 ;; Keep update point of group mode buffer if visible.
5404 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
5405 (save-window-excursion
5406 ;; Take care of tree window mode.
5407 (when (get-buffer-window gnus-group-buffer)
5408 (pop-to-buffer gnus-group-buffer))
5409 (gnus-group-jump-to-group newsgroup))
5411 ;; Take care of tree window mode.
5412 (if (get-buffer-window gnus-group-buffer)
5413 (pop-to-buffer gnus-group-buffer)
5414 (set-buffer gnus-group-buffer))
5415 (gnus-group-jump-to-group newsgroup))))
5417 ;; This function returns a list of article numbers based on the
5418 ;; difference between the ranges of read articles in this group and
5419 ;; the range of active articles.
5420 (defun gnus-list-of-unread-articles (group)
5421 (let* ((read (gnus-info-read (gnus-get-info group)))
5422 (active (or (gnus-active group) (gnus-activate-group group)))
5425 ;; If none are read, then all are unread.
5427 (setq first (car active))
5428 ;; If the range of read articles is a single range, then the
5429 ;; first unread article is the article after the last read
5430 ;; article. Sounds logical, doesn't it?
5431 (if (and (not (listp (cdr read)))
5432 (or (< (car read) (car active))
5433 (progn (setq read (list read))
5435 (setq first (max (car active) (1+ (cdr read))))
5436 ;; `read' is a list of ranges.
5437 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
5440 (setq first (car active)))
5443 (while (< first nlast)
5445 (setq first (1+ first))))
5446 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
5447 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
5448 (setq read (cdr read)))))
5449 ;; And add the last unread articles.
5450 (while (<= first last)
5452 (setq first (1+ first)))
5453 ;; Return the list of unread articles.
5454 (delq 0 (nreverse unread))))
5456 (defun gnus-list-of-read-articles (group)
5457 "Return a list of unread, unticked and non-dormant articles."
5458 (let* ((info (gnus-get-info group))
5459 (marked (gnus-info-marks info))
5460 (active (gnus-active group)))
5462 (gnus-set-difference
5463 (gnus-sorted-complement
5464 (gnus-uncompress-range active)
5465 (gnus-list-of-unread-articles group))
5467 (gnus-uncompress-range (cdr (assq 'dormant marked)))
5468 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
5470 ;; Various summary commands
5472 (defun gnus-summary-select-article-buffer ()
5473 "Reconfigure windows to show article buffer."
5475 (if (not (gnus-buffer-live-p gnus-article-buffer))
5476 (error "There is no article buffer for this summary buffer")
5477 (gnus-configure-windows 'article)
5478 (select-window (get-buffer-window gnus-article-buffer))))
5480 (defun gnus-summary-universal-argument (arg)
5481 "Perform any operation on all articles that are process/prefixed."
5483 (let ((articles (gnus-summary-work-articles arg))
5490 (substitute-command-keys
5491 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
5493 (gnus-error 1 "Undefined key")
5496 (gnus-summary-goto-subject (setq article (pop articles)))
5497 (let (gnus-newsgroup-processable)
5498 (command-execute func))
5499 (gnus-summary-remove-process-mark article)))))
5500 (gnus-summary-position-point))
5502 (defun gnus-summary-toggle-truncation (&optional arg)
5503 "Toggle truncation of summary lines.
5504 With arg, turn line truncation on iff arg is positive."
5506 (setq truncate-lines
5507 (if (null arg) (not truncate-lines)
5508 (> (prefix-numeric-value arg) 0)))
5511 (defun gnus-summary-reselect-current-group (&optional all rescan)
5512 "Exit and then reselect the current newsgroup.
5513 The prefix argument ALL means to select all articles."
5515 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
5516 (error "Ephemeral groups can't be reselected"))
5517 (let ((current-subject (gnus-summary-article-number))
5518 (group gnus-newsgroup-name))
5519 (setq gnus-newsgroup-begin nil)
5521 ;; We have to adjust the point of group mode buffer because
5522 ;; point was moved to the next unread newsgroup by exiting.
5523 (gnus-summary-jump-to-group group)
5526 (gnus-group-get-new-news-this-group 1)))
5527 (gnus-group-read-group all t)
5528 (gnus-summary-goto-subject current-subject nil t)))
5530 (defun gnus-summary-rescan-group (&optional all)
5531 "Exit the newsgroup, ask for new articles, and select the newsgroup."
5533 (gnus-summary-reselect-current-group all t))
5535 (defun gnus-summary-update-info (&optional non-destructive)
5537 (let ((group gnus-newsgroup-name))
5539 (when gnus-newsgroup-kill-headers
5540 (setq gnus-newsgroup-killed
5541 (gnus-compress-sequence
5543 (gnus-set-sorted-intersection
5544 (gnus-uncompress-range gnus-newsgroup-killed)
5545 (setq gnus-newsgroup-unselected
5546 (sort gnus-newsgroup-unselected '<)))
5547 (setq gnus-newsgroup-unreads
5548 (sort gnus-newsgroup-unreads '<)))
5550 (unless (listp (cdr gnus-newsgroup-killed))
5551 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
5552 (let ((headers gnus-newsgroup-headers))
5553 ;; Set the new ranges of read articles.
5555 (set-buffer gnus-group-buffer)
5556 (gnus-undo-force-boundary))
5557 (gnus-update-read-articles
5558 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
5559 ;; Set the current article marks.
5560 (let ((gnus-newsgroup-scored
5561 (if (and (not gnus-save-score)
5562 (not non-destructive))
5564 gnus-newsgroup-scored)))
5566 (gnus-update-marks)))
5567 ;; Do the cross-ref thing.
5568 (when gnus-use-cross-reference
5569 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
5570 ;; Do not switch windows but change the buffer to work.
5571 (set-buffer gnus-group-buffer)
5572 (unless (gnus-ephemeral-group-p group)
5573 (gnus-group-update-group group)))))))
5575 (defun gnus-summary-save-newsrc (&optional force)
5576 "Save the current number of read/marked articles in the dribble buffer.
5577 The dribble buffer will then be saved.
5578 If FORCE (the prefix), also save the .newsrc file(s)."
5580 (gnus-summary-update-info t)
5582 (gnus-save-newsrc-file)
5583 (gnus-dribble-save)))
5585 (defun gnus-summary-exit (&optional temporary)
5586 "Exit reading current newsgroup, and then return to group selection mode.
5587 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
5589 (gnus-set-global-variables)
5590 (when (gnus-buffer-live-p gnus-article-buffer)
5592 (set-buffer gnus-article-buffer)
5593 (mm-destroy-parts gnus-article-mime-handles)
5594 ;; Set it to nil for safety reason.
5595 (setq gnus-article-mime-handle-alist nil)
5596 (setq gnus-article-mime-handles nil)))
5597 (gnus-kill-save-kill-buffer)
5598 (gnus-async-halt-prefetch)
5599 (let* ((group gnus-newsgroup-name)
5600 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
5603 (buf (current-buffer)))
5605 ;; Do adaptive scoring, and possibly save score files.
5606 (when gnus-newsgroup-adaptive
5607 (gnus-score-adaptive))
5608 (when gnus-use-scoring
5610 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
5611 ;; If we have several article buffers, we kill them at exit.
5612 (unless gnus-single-article-buffer
5613 (gnus-kill-buffer gnus-original-article-buffer)
5614 (setq gnus-article-current nil))
5615 (when gnus-use-cache
5616 (gnus-cache-possibly-remove-articles)
5617 (gnus-cache-save-buffers))
5618 (gnus-async-prefetch-remove-group group)
5619 (when gnus-suppress-duplicates
5620 (gnus-dup-enter-articles))
5621 (when gnus-use-trees
5622 (gnus-tree-close group))
5623 (when gnus-use-cache
5624 (gnus-cache-write-active))
5625 ;; Remove entries for this group.
5626 (nnmail-purge-split-history (gnus-group-real-name group))
5627 ;; Make all changes in this group permanent.
5629 (gnus-run-hooks 'gnus-exit-group-hook)
5630 (gnus-summary-update-info))
5631 (gnus-close-group group)
5632 ;; Make sure where we were, and go to next newsgroup.
5633 (set-buffer gnus-group-buffer)
5635 (gnus-group-jump-to-group group))
5636 (gnus-run-hooks 'gnus-summary-exit-hook)
5637 (unless (or quit-config
5638 ;; If this group has disappeared from the summary
5639 ;; buffer, don't skip forwards.
5640 (not (string= group (gnus-group-group-name))))
5641 (gnus-group-next-unread-group 1))
5642 (setq group-point (point))
5645 ;; If we have several article buffers, we kill them at exit.
5646 (unless gnus-single-article-buffer
5647 (gnus-kill-buffer gnus-article-buffer)
5648 (gnus-kill-buffer gnus-original-article-buffer)
5649 (setq gnus-article-current nil))
5651 (if (not gnus-kill-summary-on-exit)
5652 (gnus-deaden-summary)
5653 ;; We set all buffer-local variables to nil. It is unclear why
5654 ;; this is needed, but if we don't, buffer-local variables are
5655 ;; not garbage-collected, it seems. This would the lead to en
5656 ;; ever-growing Emacs.
5657 (gnus-summary-clear-local-variables)
5658 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
5659 (gnus-summary-clear-local-variables))
5660 (when (get-buffer gnus-article-buffer)
5661 (bury-buffer gnus-article-buffer))
5662 ;; We clear the global counterparts of the buffer-local
5663 ;; variables as well, just to be on the safe side.
5664 (set-buffer gnus-group-buffer)
5665 (gnus-summary-clear-local-variables)
5666 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
5667 (gnus-summary-clear-local-variables))
5668 ;; Return to group mode buffer.
5669 (when (eq mode 'gnus-summary-mode)
5670 (gnus-kill-buffer buf)))
5671 (setq gnus-current-select-method gnus-select-method)
5672 (pop-to-buffer gnus-group-buffer)
5673 (if (not quit-config)
5675 (goto-char group-point)
5676 (gnus-configure-windows 'group 'force))
5677 (gnus-handle-ephemeral-exit quit-config))
5678 ;; Clear the current group name.
5680 (setq gnus-newsgroup-name nil)))))
5682 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
5683 (defun gnus-summary-exit-no-update (&optional no-questions)
5684 "Quit reading current newsgroup without updating read article info."
5686 (let* ((group gnus-newsgroup-name)
5687 (quit-config (gnus-group-quit-config group)))
5688 (when (or no-questions
5690 (gnus-y-or-n-p "Discard changes to this group and exit? "))
5691 (gnus-async-halt-prefetch)
5693 (delq 'gnus-summary-expire-articles
5694 (copy-sequence gnus-summary-prepare-exit-hook)))
5695 (when (gnus-buffer-live-p gnus-article-buffer)
5697 (set-buffer gnus-article-buffer)
5698 (mm-destroy-parts gnus-article-mime-handles)
5699 ;; Set it to nil for safety reason.
5700 (setq gnus-article-mime-handle-alist nil)
5701 (setq gnus-article-mime-handles nil)))
5702 ;; If we have several article buffers, we kill them at exit.
5703 (unless gnus-single-article-buffer
5704 (gnus-kill-buffer gnus-article-buffer)
5705 (gnus-kill-buffer gnus-original-article-buffer)
5706 (setq gnus-article-current nil))
5707 (if (not gnus-kill-summary-on-exit)
5708 (gnus-deaden-summary)
5709 (gnus-close-group group)
5710 (gnus-summary-clear-local-variables)
5711 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
5712 (gnus-summary-clear-local-variables))
5713 (set-buffer gnus-group-buffer)
5714 (gnus-summary-clear-local-variables)
5715 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
5716 (gnus-summary-clear-local-variables))
5717 (when (get-buffer gnus-summary-buffer)
5718 (kill-buffer gnus-summary-buffer)))
5719 (unless gnus-single-article-buffer
5720 (setq gnus-article-current nil))
5721 (when gnus-use-trees
5722 (gnus-tree-close group))
5723 (gnus-async-prefetch-remove-group group)
5724 (when (get-buffer gnus-article-buffer)
5725 (bury-buffer gnus-article-buffer))
5726 ;; Return to the group buffer.
5727 (gnus-configure-windows 'group 'force)
5728 ;; Clear the current group name.
5729 (setq gnus-newsgroup-name nil)
5730 (when (equal (gnus-group-group-name) group)
5731 (gnus-group-next-unread-group 1))
5733 (gnus-handle-ephemeral-exit quit-config)))))
5735 (defun gnus-handle-ephemeral-exit (quit-config)
5736 "Handle movement when leaving an ephemeral group.
5737 The state which existed when entering the ephemeral is reset."
5738 (if (not (buffer-name (car quit-config)))
5739 (gnus-configure-windows 'group 'force)
5740 (set-buffer (car quit-config))
5741 (cond ((eq major-mode 'gnus-summary-mode)
5742 (gnus-set-global-variables))
5743 ((eq major-mode 'gnus-article-mode)
5745 ;; The `gnus-summary-buffer' variable may point
5746 ;; to the old summary buffer when using a single
5748 (unless (gnus-buffer-live-p gnus-summary-buffer)
5749 (set-buffer gnus-group-buffer))
5750 (set-buffer gnus-summary-buffer)
5751 (gnus-set-global-variables))))
5752 (if (or (eq (cdr quit-config) 'article)
5753 (eq (cdr quit-config) 'pick))
5755 ;; The current article may be from the ephemeral group
5756 ;; thus it is best that we reload this article
5757 (gnus-summary-show-article)
5758 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
5759 (gnus-configure-windows 'pick 'force)
5760 (gnus-configure-windows (cdr quit-config) 'force)))
5761 (gnus-configure-windows (cdr quit-config) 'force))
5762 (when (eq major-mode 'gnus-summary-mode)
5763 (gnus-summary-next-subject 1 nil t)
5764 (gnus-summary-recenter)
5765 (gnus-summary-position-point))))
5769 (defvar gnus-dead-summary-mode-map nil)
5771 (unless gnus-dead-summary-mode-map
5772 (setq gnus-dead-summary-mode-map (make-keymap))
5773 (suppress-keymap gnus-dead-summary-mode-map)
5774 (substitute-key-definition
5775 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
5776 (let ((keys '("\C-d" "\r" "\177" [delete])))
5778 (define-key gnus-dead-summary-mode-map
5779 (pop keys) 'gnus-summary-wake-up-the-dead))))
5781 (defvar gnus-dead-summary-mode nil
5782 "Minor mode for Gnus summary buffers.")
5784 (defun gnus-dead-summary-mode (&optional arg)
5785 "Minor mode for Gnus summary buffers."
5787 (when (eq major-mode 'gnus-summary-mode)
5788 (make-local-variable 'gnus-dead-summary-mode)
5789 (setq gnus-dead-summary-mode
5790 (if (null arg) (not gnus-dead-summary-mode)
5791 (> (prefix-numeric-value arg) 0)))
5792 (when gnus-dead-summary-mode
5793 (gnus-add-minor-mode
5794 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
5796 (defun gnus-deaden-summary ()
5797 "Make the current summary buffer into a dead summary buffer."
5798 ;; Kill any previous dead summary buffer.
5799 (when (and gnus-dead-summary
5800 (buffer-name gnus-dead-summary))
5802 (set-buffer gnus-dead-summary)
5803 (when gnus-dead-summary-mode
5804 (kill-buffer (current-buffer)))))
5805 ;; Make this the current dead summary.
5806 (setq gnus-dead-summary (current-buffer))
5807 (gnus-dead-summary-mode 1)
5808 (let ((name (buffer-name)))
5809 (when (string-match "Summary" name)
5811 (concat (substring name 0 (match-beginning 0)) "Dead "
5812 (substring name (match-beginning 0)))
5816 (defun gnus-kill-or-deaden-summary (buffer)
5817 "Kill or deaden the summary BUFFER."
5819 (when (and (buffer-name buffer)
5820 (not gnus-single-article-buffer))
5823 (gnus-kill-buffer gnus-article-buffer)
5824 (gnus-kill-buffer gnus-original-article-buffer)))
5825 (cond (gnus-kill-summary-on-exit
5826 (when (and gnus-use-trees
5827 (gnus-buffer-exists-p buffer))
5830 (gnus-tree-close gnus-newsgroup-name)))
5831 (gnus-kill-buffer buffer))
5832 ((gnus-buffer-exists-p buffer)
5835 (gnus-deaden-summary))))))
5837 (defun gnus-summary-wake-up-the-dead (&rest args)
5838 "Wake up the dead summary buffer."
5840 (gnus-dead-summary-mode -1)
5841 (let ((name (buffer-name)))
5842 (when (string-match "Dead " name)
5844 (concat (substring name 0 (match-beginning 0))
5845 (substring name (match-end 0)))
5847 (gnus-message 3 "This dead summary is now alive again"))
5849 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
5850 (defun gnus-summary-fetch-faq (&optional faq-dir)
5851 "Fetch the FAQ for the current group.
5852 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
5856 (when current-prefix-arg
5858 "Faq dir: " (and (listp gnus-group-faq-directory)
5859 (mapcar (lambda (file) (list file))
5860 gnus-group-faq-directory))))))
5861 (let (gnus-faq-buffer)
5862 (when (setq gnus-faq-buffer
5863 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
5864 (gnus-configure-windows 'summary-faq))))
5866 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
5867 (defun gnus-summary-describe-group (&optional force)
5868 "Describe the current newsgroup."
5870 (gnus-group-describe-group force gnus-newsgroup-name))
5872 (defun gnus-summary-describe-briefly ()
5873 "Describe summary mode commands briefly."
5875 (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")))
5877 ;; Walking around group mode buffer from summary mode.
5879 (defun gnus-summary-next-group (&optional no-article target-group backward)
5880 "Exit current newsgroup and then select next unread newsgroup.
5881 If prefix argument NO-ARTICLE is non-nil, no article is selected
5882 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
5883 previous group instead."
5885 ;; Stop pre-fetching.
5886 (gnus-async-halt-prefetch)
5887 (let ((current-group gnus-newsgroup-name)
5888 (current-buffer (current-buffer))
5890 ;; First we semi-exit this group to update Xrefs and all variables.
5891 ;; We can't do a real exit, because the window conf must remain
5892 ;; the same in case the user is prompted for info, and we don't
5893 ;; want the window conf to change before that...
5894 (gnus-summary-exit t)
5895 (while (not entered)
5896 ;; Then we find what group we are supposed to enter.
5897 (set-buffer gnus-group-buffer)
5898 (gnus-group-jump-to-group current-group)
5901 (if (eq gnus-keep-same-level 'best)
5902 (gnus-summary-best-group gnus-newsgroup-name)
5903 (gnus-summary-search-group backward gnus-keep-same-level))))
5904 (if (not target-group)
5905 ;; There are no further groups, so we return to the group
5908 (gnus-message 5 "Returning to the group buffer")
5910 (when (gnus-buffer-live-p current-buffer)
5911 (set-buffer current-buffer)
5912 (gnus-summary-exit))
5913 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
5914 ;; We try to enter the target group.
5915 (gnus-group-jump-to-group target-group)
5916 (let ((unreads (gnus-group-group-unread)))
5917 (if (and (or (eq t unreads)
5918 (and unreads (not (zerop unreads))))
5919 (gnus-summary-read-group
5920 target-group nil no-article
5921 (and (buffer-name current-buffer) current-buffer)
5924 (setq current-group target-group
5925 target-group nil)))))))
5927 (defun gnus-summary-prev-group (&optional no-article)
5928 "Exit current newsgroup and then select previous unread newsgroup.
5929 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
5931 (gnus-summary-next-group no-article nil t))
5933 ;; Walking around summary lines.
5935 (defun gnus-summary-first-subject (&optional unread undownloaded)
5936 "Go to the first unread subject.
5937 If UNREAD is non-nil, go to the first unread article.
5938 Returns the article selected or nil if there are no unread articles."
5943 ((null gnus-newsgroup-data)
5944 (gnus-message 3 "No articles in the group")
5946 ;; Pick the first article.
5948 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
5949 (gnus-data-number (car gnus-newsgroup-data)))
5950 ;; No unread articles.
5951 ((null gnus-newsgroup-unreads)
5952 (gnus-message 3 "No more unread articles")
5954 ;; Find the first unread article.
5956 (let ((data gnus-newsgroup-data))
5958 (and (not (and undownloaded
5959 (eq gnus-undownloaded-mark
5960 (gnus-data-mark (car data)))))
5961 (not (gnus-data-unread-p (car data)))))
5962 (setq data (cdr data)))
5964 (goto-char (gnus-data-pos (car data)))
5965 (gnus-data-number (car data))))))
5966 (gnus-summary-position-point)))
5968 (defun gnus-summary-next-subject (n &optional unread dont-display)
5969 "Go to next N'th summary line.
5970 If N is negative, go to the previous N'th subject line.
5971 If UNREAD is non-nil, only unread articles are selected.
5972 The difference between N and the actual number of steps taken is
5975 (let ((backward (< n 0))
5979 (gnus-summary-find-prev unread)
5980 (gnus-summary-find-next unread)))
5981 (unless (zerop (setq n (1- n)))
5982 (gnus-summary-show-thread)))
5984 (gnus-message 7 "No more%s articles"
5985 (if unread " unread" "")))
5986 (unless dont-display
5987 (gnus-summary-recenter)
5988 (gnus-summary-position-point))
5991 (defun gnus-summary-next-unread-subject (n)
5992 "Go to next N'th unread summary line."
5994 (gnus-summary-next-subject n t))
5996 (defun gnus-summary-prev-subject (n &optional unread)
5997 "Go to previous N'th summary line.
5998 If optional argument UNREAD is non-nil, only unread article is selected."
6000 (gnus-summary-next-subject (- n) unread))
6002 (defun gnus-summary-prev-unread-subject (n)
6003 "Go to previous N'th unread summary line."
6005 (gnus-summary-next-subject (- n) t))
6007 (defun gnus-summary-goto-subject (article &optional force silent)
6008 "Go the subject line of ARTICLE.
6009 If FORCE, also allow jumping to articles not currently shown."
6010 (interactive "nArticle number: ")
6012 (data (gnus-data-find article)))
6013 ;; We read in the article if we have to.
6016 (gnus-summary-insert-subject
6018 (if (or (numberp force) (vectorp force)) force)
6020 (setq data (gnus-data-find article)))
6025 (gnus-message 3 "Can't find article %d" article))
6027 (goto-char (gnus-data-pos data))
6028 (gnus-summary-position-point)
6031 ;; Walking around summary lines with displaying articles.
6033 (defun gnus-summary-expand-window (&optional arg)
6034 "Make the summary buffer take up the entire Emacs frame.
6035 Given a prefix, will force an `article' buffer configuration."
6038 (gnus-configure-windows 'article 'force)
6039 (gnus-configure-windows 'summary 'force)))
6041 (defun gnus-summary-display-article (article &optional all-header)
6042 "Display ARTICLE in article buffer."
6043 (when (gnus-buffer-live-p gnus-article-buffer)
6044 (with-current-buffer gnus-article-buffer
6045 (mm-enable-multibyte-mule4)))
6046 (gnus-set-global-variables)
6047 (when (gnus-buffer-live-p gnus-article-buffer)
6048 (with-current-buffer gnus-article-buffer
6049 (setq gnus-article-charset gnus-newsgroup-charset)
6050 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
6051 (mm-enable-multibyte-mule4)))
6055 (if gnus-summary-display-article-function
6056 (funcall gnus-summary-display-article-function article all-header)
6057 (gnus-article-prepare article all-header))
6058 (gnus-run-hooks 'gnus-select-article-hook)
6059 (when (and gnus-current-article
6060 (not (zerop gnus-current-article)))
6061 (gnus-summary-goto-subject gnus-current-article))
6062 (gnus-summary-recenter)
6063 (when (and gnus-use-trees gnus-show-threads)
6064 (gnus-possibly-generate-tree article)
6065 (gnus-highlight-selected-tree article))
6066 ;; Successfully display article.
6067 (gnus-article-set-window-start
6068 (cdr (assq article gnus-newsgroup-bookmarks))))))
6070 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
6071 "Select the current article.
6072 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
6073 non-nil, the article will be re-fetched even if it already present in
6074 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
6076 ;; Make sure we are in the summary buffer to work around bbdb bug.
6077 (unless (eq major-mode 'gnus-summary-mode)
6078 (set-buffer gnus-summary-buffer))
6079 (let ((article (or article (gnus-summary-article-number)))
6080 (all-headers (not (not all-headers))) ;Must be T or NIL.
6081 gnus-summary-display-article-function)
6083 (gnus-summary-article-pseudo-p article)
6084 (error "This is a pseudo-article"))
6086 (set-buffer gnus-summary-buffer)
6087 (if (or (and gnus-single-article-buffer
6088 (or (null gnus-current-article)
6089 (null gnus-article-current)
6090 (null (get-buffer gnus-article-buffer))
6091 (not (eq article (cdr gnus-article-current)))
6092 (not (equal (car gnus-article-current)
6093 gnus-newsgroup-name))))
6094 (and (not gnus-single-article-buffer)
6095 (or (null gnus-current-article)
6096 (not (eq gnus-current-article article))))
6098 ;; The requested article is different from the current article.
6100 (gnus-summary-display-article article all-headers)
6101 (when (gnus-buffer-live-p gnus-article-buffer)
6102 (with-current-buffer gnus-article-buffer
6103 (if (not gnus-article-decoded-p) ;; a local variable
6104 (mm-disable-multibyte-mule4))))
6105 (when (or all-headers gnus-show-all-headers)
6106 (gnus-article-show-all-headers))
6107 (gnus-article-set-window-start
6108 (cdr (assq article gnus-newsgroup-bookmarks)))
6110 (when (or all-headers gnus-show-all-headers)
6111 (gnus-article-show-all-headers))
6114 (defun gnus-summary-force-verify-and-decrypt ()
6116 (let ((mm-verify-option 'known)
6117 (mm-decrypt-option 'known))
6118 (gnus-summary-select-article nil 'force)))
6120 (defun gnus-summary-set-current-mark (&optional current-mark)
6121 "Obsolete function."
6124 (defun gnus-summary-next-article (&optional unread subject backward push)
6125 "Select the next article.
6126 If UNREAD, only unread articles are selected.
6127 If SUBJECT, only articles with SUBJECT are selected.
6128 If BACKWARD, the previous article is selected instead of the next."
6131 ;; Is there such an article?
6132 ((and (gnus-summary-search-forward unread subject backward)
6133 (or (gnus-summary-display-article (gnus-summary-article-number))
6134 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
6135 (gnus-summary-position-point))
6136 ;; If not, we try the first unread, if that is wanted.
6138 gnus-auto-select-same
6139 (gnus-summary-first-unread-article))
6140 (gnus-summary-position-point)
6141 (gnus-message 6 "Wrapped"))
6142 ;; Try to get next/previous article not displayed in this group.
6143 ((and gnus-auto-extend-newsgroup
6144 (not unread) (not subject))
6145 (gnus-summary-goto-article
6146 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
6147 nil (count-lines (point-min) (point))))
6148 ;; Go to next/previous group.
6150 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
6151 (gnus-summary-jump-to-group gnus-newsgroup-name))
6152 (let ((cmd last-command-char)
6155 (set-buffer gnus-group-buffer)
6158 (if (eq gnus-keep-same-level 'best)
6159 (gnus-summary-best-group gnus-newsgroup-name)
6160 (gnus-summary-search-group backward gnus-keep-same-level))))
6161 ;; For some reason, the group window gets selected. We change
6163 (select-window (get-buffer-window (current-buffer)))
6164 ;; Select next unread newsgroup automagically.
6166 ((or (not gnus-auto-select-next)
6168 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
6169 ((or (eq gnus-auto-select-next 'quietly)
6170 (and (eq gnus-auto-select-next 'slightly-quietly)
6172 (and (eq gnus-auto-select-next 'almost-quietly)
6173 (gnus-summary-last-article-p)))
6175 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
6177 (gnus-message 7 "No more%s articles (%s)..."
6178 (if unread " unread" "")
6179 (if group (concat "selecting " group)
6181 (gnus-summary-next-group nil group backward)))
6183 (when (gnus-key-press-event-p last-input-event)
6184 (gnus-summary-walk-group-buffer
6185 gnus-newsgroup-name cmd unread backward point))))))))
6187 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
6188 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
6189 (?\C-p (gnus-group-prev-unread-group 1))))
6190 (cursor-in-echo-area t)
6191 keve key group ended)
6193 (set-buffer gnus-group-buffer)
6196 (if (eq gnus-keep-same-level 'best)
6197 (gnus-summary-best-group gnus-newsgroup-name)
6198 (gnus-summary-search-group backward gnus-keep-same-level))))
6201 5 "No more%s articles%s" (if unread " unread" "")
6203 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
6204 (format " (Type %s for %s [%s])"
6205 (single-key-description cmd) group
6206 (car (gnus-gethash group gnus-newsrc-hashtb)))
6207 (format " (Type %s to exit %s)"
6208 (single-key-description cmd)
6209 gnus-newsgroup-name)))
6210 ;; Confirm auto selection.
6211 (setq key (car (setq keve (gnus-read-event-char))))
6214 ((assq key keystrokes)
6215 (let ((obuf (current-buffer)))
6216 (switch-to-buffer gnus-group-buffer)
6218 (gnus-group-jump-to-group group))
6219 (eval (cadr (assq key keystrokes)))
6220 (setq group (gnus-group-group-name))
6221 (switch-to-buffer obuf))
6225 (gnus-ephemeral-group-p gnus-newsgroup-name))
6227 (gnus-summary-next-group nil group backward)))
6229 (push (cdr keve) unread-command-events))))))
6231 (defun gnus-summary-next-unread-article ()
6232 "Select unread article after current one."
6234 (gnus-summary-next-article
6235 (or (not (eq gnus-summary-goto-unread 'never))
6236 (gnus-summary-last-article-p (gnus-summary-article-number)))
6237 (and gnus-auto-select-same
6238 (gnus-summary-article-subject))))
6240 (defun gnus-summary-prev-article (&optional unread subject)
6241 "Select the article after the current one.
6242 If UNREAD is non-nil, only unread articles are selected."
6244 (gnus-summary-next-article unread subject t))
6246 (defun gnus-summary-prev-unread-article ()
6247 "Select unread article before current one."
6249 (gnus-summary-prev-article
6250 (or (not (eq gnus-summary-goto-unread 'never))
6251 (gnus-summary-first-article-p (gnus-summary-article-number)))
6252 (and gnus-auto-select-same
6253 (gnus-summary-article-subject))))
6255 (defun gnus-summary-next-page (&optional lines circular)
6256 "Show next page of the selected article.
6257 If at the end of the current article, select the next article.
6258 LINES says how many lines should be scrolled up.
6260 If CIRCULAR is non-nil, go to the start of the article instead of
6261 selecting the next article when reaching the end of the current
6264 (setq gnus-summary-buffer (current-buffer))
6265 (gnus-set-global-variables)
6266 (let ((article (gnus-summary-article-number))
6267 (article-window (get-buffer-window gnus-article-buffer t))
6269 ;; If the buffer is empty, we have no article.
6271 (error "No article to select"))
6272 (gnus-configure-windows 'article)
6273 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
6274 (if (and (eq gnus-summary-goto-unread 'never)
6275 (not (gnus-summary-last-article-p article)))
6276 (gnus-summary-next-article)
6277 (gnus-summary-next-unread-article))
6278 (if (or (null gnus-current-article)
6279 (null gnus-article-current)
6280 (/= article (cdr gnus-article-current))
6281 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6282 ;; Selected subject is different from current article's.
6283 (gnus-summary-display-article article)
6284 (when article-window
6285 (gnus-eval-in-buffer-window gnus-article-buffer
6286 (setq endp (gnus-article-next-page lines)))
6289 (gnus-summary-beginning-of-article))
6291 (gnus-message 3 "End of message"))
6293 (if (and (eq gnus-summary-goto-unread 'never)
6294 (not (gnus-summary-last-article-p article)))
6295 (gnus-summary-next-article)
6296 (gnus-summary-next-unread-article))))))))
6297 (gnus-summary-recenter)
6298 (gnus-summary-position-point)))
6300 (defun gnus-summary-prev-page (&optional lines move)
6301 "Show previous page of selected article.
6302 Argument LINES specifies lines to be scrolled down.
6303 If MOVE, move to the previous unread article if point is at
6304 the beginning of the buffer."
6306 (let ((article (gnus-summary-article-number))
6307 (article-window (get-buffer-window gnus-article-buffer t))
6309 (gnus-configure-windows 'article)
6310 (if (or (null gnus-current-article)
6311 (null gnus-article-current)
6312 (/= article (cdr gnus-article-current))
6313 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6314 ;; Selected subject is different from current article's.
6315 (gnus-summary-display-article article)
6316 (gnus-summary-recenter)
6317 (when article-window
6318 (gnus-eval-in-buffer-window gnus-article-buffer
6319 (setq endp (gnus-article-prev-page lines)))
6320 (when (and move endp)
6322 (gnus-message 3 "Beginning of message"))
6324 (if (and (eq gnus-summary-goto-unread 'never)
6325 (not (gnus-summary-first-article-p article)))
6326 (gnus-summary-prev-article)
6327 (gnus-summary-prev-unread-article))))))))
6328 (gnus-summary-position-point))
6330 (defun gnus-summary-prev-page-or-article (&optional lines)
6331 "Show previous page of selected article.
6332 Argument LINES specifies lines to be scrolled down.
6333 If at the beginning of the article, go to the next article."
6335 (gnus-summary-prev-page lines t))
6337 (defun gnus-summary-scroll-up (lines)
6338 "Scroll up (or down) one line current article.
6339 Argument LINES specifies lines to be scrolled up (or down if negative)."
6341 (gnus-configure-windows 'article)
6342 (gnus-summary-show-thread)
6343 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
6344 (gnus-eval-in-buffer-window gnus-article-buffer
6346 (when (gnus-article-next-page lines)
6347 (gnus-message 3 "End of message")))
6349 (gnus-article-prev-page (- lines))))))
6350 (gnus-summary-recenter)
6351 (gnus-summary-position-point))
6353 (defun gnus-summary-scroll-down (lines)
6354 "Scroll down (or up) one line current article.
6355 Argument LINES specifies lines to be scrolled down (or up if negative)."
6357 (gnus-summary-scroll-up (- lines)))
6359 (defun gnus-summary-next-same-subject ()
6360 "Select next article which has the same subject as current one."
6362 (gnus-summary-next-article nil (gnus-summary-article-subject)))
6364 (defun gnus-summary-prev-same-subject ()
6365 "Select previous article which has the same subject as current one."
6367 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
6369 (defun gnus-summary-next-unread-same-subject ()
6370 "Select next unread article which has the same subject as current one."
6372 (gnus-summary-next-article t (gnus-summary-article-subject)))
6374 (defun gnus-summary-prev-unread-same-subject ()
6375 "Select previous unread article which has the same subject as current one."
6377 (gnus-summary-prev-article t (gnus-summary-article-subject)))
6379 (defun gnus-summary-first-unread-article ()
6380 "Select the first unread article.
6381 Return nil if there are no unread articles."
6384 (when (gnus-summary-first-subject t)
6385 (gnus-summary-show-thread)
6386 (gnus-summary-first-subject t)
6387 (gnus-summary-display-article (gnus-summary-article-number)))
6388 (gnus-summary-position-point)))
6390 (defun gnus-summary-first-unread-subject ()
6391 "Place the point on the subject line of the first unread article.
6392 Return nil if there are no unread articles."
6395 (when (gnus-summary-first-subject t)
6396 (gnus-summary-show-thread)
6397 (gnus-summary-first-subject t))
6398 (gnus-summary-position-point)))
6400 (defun gnus-summary-first-article ()
6401 "Select the first article.
6402 Return nil if there are no articles."
6405 (when (gnus-summary-first-subject)
6406 (gnus-summary-show-thread)
6407 (gnus-summary-first-subject)
6408 (gnus-summary-display-article (gnus-summary-article-number)))
6409 (gnus-summary-position-point)))
6411 (defun gnus-summary-best-unread-article ()
6412 "Select the unread article with the highest score."
6414 (let ((best -1000000)
6415 (data gnus-newsgroup-data)
6418 (and (gnus-data-unread-p (car data))
6420 (gnus-summary-article-score (gnus-data-number (car data))))
6423 article (gnus-data-number (car data))))
6424 (setq data (cdr data)))
6427 (gnus-summary-goto-article article)
6428 (error "No unread articles"))
6429 (gnus-summary-position-point))))
6431 (defun gnus-summary-last-subject ()
6432 "Go to the last displayed subject line in the group."
6433 (let ((article (gnus-data-number (car (gnus-data-list t)))))
6435 (gnus-summary-goto-subject article))))
6437 (defun gnus-summary-goto-article (article &optional all-headers force)
6438 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
6439 If ALL-HEADERS is non-nil, no header lines are hidden.
6440 If FORCE, go to the article even if it isn't displayed. If FORCE
6441 is a number, it is the line the article is to be displayed on."
6445 "Article number or Message-ID: "
6446 (mapcar (lambda (number) (list (int-to-string number)))
6447 gnus-newsgroup-limit))
6451 (if (and (stringp article)
6452 (string-match "@" article))
6453 (gnus-summary-refer-article article)
6454 (when (stringp article)
6455 (setq article (string-to-number article)))
6456 (if (gnus-summary-goto-subject article force)
6457 (gnus-summary-display-article article all-headers)
6458 (gnus-message 4 "Couldn't go to article %s" article) nil))
6459 (gnus-summary-position-point)))
6461 (defun gnus-summary-goto-last-article ()
6462 "Go to the previously read article."
6465 (when gnus-last-article
6466 (gnus-summary-goto-article gnus-last-article nil t))
6467 (gnus-summary-position-point)))
6469 (defun gnus-summary-pop-article (number)
6470 "Pop one article off the history and go to the previous.
6471 NUMBER articles will be popped off."
6474 (setq gnus-newsgroup-history
6475 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
6477 (gnus-summary-goto-article (car to) nil t)
6478 (error "Article history empty")))
6479 (gnus-summary-position-point))
6481 ;; Summary commands and functions for limiting the summary buffer.
6483 (defun gnus-summary-limit-to-articles (n)
6484 "Limit the summary buffer to the next N articles.
6485 If not given a prefix, use the process marked articles instead."
6488 (let ((articles (gnus-summary-work-articles n)))
6489 (setq gnus-newsgroup-processable nil)
6490 (gnus-summary-limit articles))
6491 (gnus-summary-position-point)))
6493 (defun gnus-summary-pop-limit (&optional total)
6494 "Restore the previous limit.
6495 If given a prefix, remove all limits."
6498 (setq gnus-newsgroup-limits
6499 (list (mapcar (lambda (h) (mail-header-number h))
6500 gnus-newsgroup-headers))))
6501 (unless gnus-newsgroup-limits
6502 (error "No limit to pop"))
6504 (gnus-summary-limit nil 'pop)
6505 (gnus-summary-position-point)))
6507 (defun gnus-summary-limit-to-subject (subject &optional header)
6508 "Limit the summary buffer to articles that have subjects that match a regexp."
6509 (interactive "sLimit to subject (regexp): ")
6511 (setq header "subject"))
6512 (when (not (equal "" subject))
6514 (let ((articles (gnus-summary-find-matching
6515 (or header "subject") subject 'all)))
6517 (error "Found no matches for \"%s\"" subject))
6518 (gnus-summary-limit articles))
6519 (gnus-summary-position-point))))
6521 (defun gnus-summary-limit-to-author (from)
6522 "Limit the summary buffer to articles that have authors that match a regexp."
6523 (interactive "sLimit to author (regexp): ")
6524 (gnus-summary-limit-to-subject from "from"))
6526 (defun gnus-summary-limit-to-age (age &optional younger-p)
6527 "Limit the summary buffer to articles that are older than (or equal) AGE days.
6528 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
6529 articles that are younger than AGE days."
6531 (let ((younger current-prefix-arg)
6534 (while (not days-got)
6535 (setq days (if younger
6536 (read-string "Limit to articles within (in days): ")
6537 (read-string "Limit to articles older than (in days): ")))
6538 (when (> (length days) 0)
6539 (setq days (read days)))
6542 (message "Please enter a number.")
6544 (list days younger)))
6546 (let ((data gnus-newsgroup-data)
6547 (cutoff (days-to-time age))
6548 articles d date is-younger)
6549 (while (setq d (pop data))
6550 (when (and (vectorp (gnus-data-header d))
6551 (setq date (mail-header-date (gnus-data-header d))))
6552 (setq is-younger (time-less-p
6553 (time-since (condition-case ()
6560 (push (gnus-data-number d) articles))))
6561 (gnus-summary-limit (nreverse articles)))
6562 (gnus-summary-position-point)))
6564 (defun gnus-summary-limit-to-extra (header regexp)
6565 "Limit the summary buffer to articles that match an 'extra' header."
6569 (gnus-completing-read
6570 (symbol-name (car gnus-extra-headers))
6571 "Limit extra header:"
6573 (cons (symbol-name x) x))
6578 (read-string (format "Limit to header %s (regexp): " header)))))
6579 (when (not (equal "" regexp))
6581 (let ((articles (gnus-summary-find-matching
6582 (cons 'extra header) regexp 'all)))
6584 (error "Found no matches for \"%s\"" regexp))
6585 (gnus-summary-limit articles))
6586 (gnus-summary-position-point))))
6588 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6590 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6592 (defun gnus-summary-limit-to-unread (&optional all)
6593 "Limit the summary buffer to articles that are not marked as read.
6594 If ALL is non-nil, limit strictly to unread articles."
6597 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
6598 (gnus-summary-limit-to-marks
6599 ;; Concat all the marks that say that an article is read and have
6601 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
6602 gnus-killed-mark gnus-kill-file-mark
6603 gnus-low-score-mark gnus-expirable-mark
6604 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
6605 gnus-duplicate-mark gnus-souped-mark)
6608 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
6609 (make-obsolete 'gnus-summary-delete-marked-with
6610 'gnus-summary-limit-exlude-marks)
6612 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
6613 "Exclude articles that are marked with MARKS (e.g. \"DK\").
6614 If REVERSE, limit the summary buffer to articles that are marked
6615 with MARKS. MARKS can either be a string of marks or a list of marks.
6616 Returns how many articles were removed."
6617 (interactive "sMarks: ")
6618 (gnus-summary-limit-to-marks marks t))
6620 (defun gnus-summary-limit-to-marks (marks &optional reverse)
6621 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
6622 If REVERSE (the prefix), limit the summary buffer to articles that are
6623 not marked with MARKS. MARKS can either be a string of marks or a
6625 Returns how many articles were removed."
6626 (interactive "sMarks: \nP")
6628 (let ((data gnus-newsgroup-data)
6629 (marks (if (listp marks) marks
6630 (append marks nil))) ; Transform to list.
6633 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
6634 (memq (gnus-data-mark (car data)) marks))
6635 (push (gnus-data-number (car data)) articles))
6636 (setq data (cdr data)))
6637 (gnus-summary-limit articles))
6638 (gnus-summary-position-point)))
6640 (defun gnus-summary-limit-to-score (&optional score)
6641 "Limit to articles with score at or above SCORE."
6643 (setq score (if score
6644 (prefix-numeric-value score)
6645 (or gnus-summary-default-score 0)))
6646 (let ((data gnus-newsgroup-data)
6649 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
6651 (push (gnus-data-number (car data)) articles))
6652 (setq data (cdr data)))
6654 (gnus-summary-limit articles)
6655 (gnus-summary-position-point))))
6657 (defun gnus-summary-limit-include-thread (id)
6658 "Display all the hidden articles that in the current thread."
6659 (interactive (list (mail-header-id (gnus-summary-article-header))))
6660 (let ((articles (gnus-articles-in-thread
6661 (gnus-id-to-thread (gnus-root-id id)))))
6663 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
6664 (gnus-summary-position-point))))
6666 (defun gnus-summary-limit-include-dormant ()
6667 "Display all the hidden articles that are marked as dormant.
6668 Note that this command only works on a subset of the articles currently
6669 fetched for this group."
6671 (unless gnus-newsgroup-dormant
6672 (error "There are no dormant articles in this group"))
6674 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
6675 (gnus-summary-position-point)))
6677 (defun gnus-summary-limit-exclude-dormant ()
6678 "Hide all dormant articles."
6681 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
6682 (gnus-summary-position-point)))
6684 (defun gnus-summary-limit-exclude-childless-dormant ()
6685 "Hide all dormant articles that have no children."
6687 (let ((data (gnus-data-list t))
6688 articles d children)
6689 ;; Find all articles that are either not dormant or have
6691 (while (setq d (pop data))
6692 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
6694 (gnus-article-children (gnus-data-number d)))
6697 (when (memq (car children) articles)
6702 (push (gnus-data-number d) articles)))
6705 (gnus-summary-limit articles)
6706 (gnus-summary-position-point))))
6708 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
6709 "Mark all unread excluded articles as read.
6710 If ALL, mark even excluded ticked and dormants as read."
6712 (let ((articles (gnus-sorted-complement
6714 (mapcar (lambda (h) (mail-header-number h))
6715 gnus-newsgroup-headers)
6717 (sort gnus-newsgroup-limit '<)))
6719 (setq gnus-newsgroup-unreads
6720 (gnus-intersection gnus-newsgroup-unreads gnus-newsgroup-limit))
6722 (setq gnus-newsgroup-dormant nil
6723 gnus-newsgroup-marked nil
6724 gnus-newsgroup-reads
6726 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
6727 gnus-newsgroup-reads))
6728 (while (setq article (pop articles))
6729 (unless (or (memq article gnus-newsgroup-dormant)
6730 (memq article gnus-newsgroup-marked))
6731 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
6733 (defun gnus-summary-limit (articles &optional pop)
6735 ;; We pop the previous limit off the stack and use that.
6736 (setq articles (car gnus-newsgroup-limits)
6737 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
6738 ;; We use the new limit, so we push the old limit on the stack.
6739 (push gnus-newsgroup-limit gnus-newsgroup-limits))
6741 (setq gnus-newsgroup-limit articles)
6742 (let ((total (length gnus-newsgroup-data))
6743 (data (gnus-data-find-list (gnus-summary-article-number)))
6744 (gnus-summary-mark-below nil) ; Inhibit this.
6746 ;; This will do all the work of generating the new summary buffer
6747 ;; according to the new limit.
6748 (gnus-summary-prepare)
6749 ;; Hide any threads, possibly.
6750 (and gnus-show-threads
6751 gnus-thread-hide-subtree
6752 (gnus-summary-hide-all-threads))
6753 ;; Try to return to the article you were at, or one in the
6756 ;; We try to find some article after the current one.
6758 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
6761 (setq data (cdr data))))
6763 ;; If there is no data, that means that we were after the last
6764 ;; article. The same goes when we can't find any articles
6765 ;; after the current one.
6766 (goto-char (point-max))
6767 (gnus-summary-find-prev))
6768 (gnus-set-mode-line 'summary)
6769 ;; We return how many articles were removed from the summary
6770 ;; buffer as a result of the new limit.
6771 (- total (length gnus-newsgroup-data))))
6773 (defsubst gnus-invisible-cut-children (threads)
6776 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
6781 (defsubst gnus-cut-thread (thread)
6782 "Go forwards in the thread until we find an article that we want to display."
6783 (when (or (eq gnus-fetch-old-headers 'some)
6784 (eq gnus-fetch-old-headers 'invisible)
6785 (numberp gnus-fetch-old-headers)
6786 (eq gnus-build-sparse-threads 'some)
6787 (eq gnus-build-sparse-threads 'more))
6788 ;; Deal with old-fetched headers and sparse threads.
6792 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
6793 (gnus-summary-article-ancient-p
6794 (mail-header-number (car thread))))
6795 (if (or (<= (length (cdr thread)) 1)
6796 (eq gnus-fetch-old-headers 'invisible))
6797 (setq gnus-newsgroup-limit
6798 (delq (mail-header-number (car thread))
6799 gnus-newsgroup-limit)
6800 thread (cadr thread))
6801 (when (gnus-invisible-cut-children (cdr thread))
6802 (let ((th (cdr thread)))
6804 (if (memq (mail-header-number (caar th))
6805 gnus-newsgroup-limit)
6806 (setq thread (car th)
6808 (setq th (cdr th))))))))))
6811 (defun gnus-cut-threads (threads)
6812 "Cut off all uninteresting articles from the beginning of threads."
6813 (when (or (eq gnus-fetch-old-headers 'some)
6814 (eq gnus-fetch-old-headers 'invisible)
6815 (numberp gnus-fetch-old-headers)
6816 (eq gnus-build-sparse-threads 'some)
6817 (eq gnus-build-sparse-threads 'more))
6820 (setcar th (gnus-cut-thread (car th)))
6821 (setq th (cdr th)))))
6822 ;; Remove nixed out threads.
6825 (defun gnus-summary-initial-limit (&optional show-if-empty)
6826 "Figure out what the initial limit is supposed to be on group entry.
6827 This entails weeding out unwanted dormants, low-scored articles,
6828 fetch-old-headers verbiage, and so on."
6829 ;; Most groups have nothing to remove.
6830 (if (or gnus-inhibit-limiting
6831 (and (null gnus-newsgroup-dormant)
6832 (not (eq gnus-fetch-old-headers 'some))
6833 (not (numberp gnus-fetch-old-headers))
6834 (not (eq gnus-fetch-old-headers 'invisible))
6835 (null gnus-summary-expunge-below)
6836 (not (eq gnus-build-sparse-threads 'some))
6837 (not (eq gnus-build-sparse-threads 'more))
6838 (null gnus-thread-expunge-below)
6839 (not gnus-use-nocem)))
6841 (push gnus-newsgroup-limit gnus-newsgroup-limits)
6842 (setq gnus-newsgroup-limit nil)
6845 (unless (car (symbol-value node))
6846 ;; These threads have no parents -- they are roots.
6847 (let ((nodes (cdr (symbol-value node)))
6850 (if (and gnus-thread-expunge-below
6851 (< (gnus-thread-total-score (car nodes))
6852 gnus-thread-expunge-below))
6853 (gnus-expunge-thread (pop nodes))
6854 (setq thread (pop nodes))
6855 (gnus-summary-limit-children thread))))))
6856 gnus-newsgroup-dependencies)
6857 ;; If this limitation resulted in an empty group, we might
6858 ;; pop the previous limit and use it instead.
6859 (when (and (not gnus-newsgroup-limit)
6861 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
6862 gnus-newsgroup-limit))
6864 (defun gnus-summary-limit-children (thread)
6865 "Return 1 if this subthread is visible and 0 if it is not."
6866 ;; First we get the number of visible children to this thread. This
6867 ;; is done by recursing down the thread using this function, so this
6868 ;; will really go down to a leaf article first, before slowly
6869 ;; working its way up towards the root.
6873 (apply '+ (mapcar 'gnus-summary-limit-children
6876 (number (mail-header-number (car thread)))
6879 (not (memq number gnus-newsgroup-marked))
6881 ;; If this article is dormant and has absolutely no visible
6882 ;; children, then this article isn't visible.
6883 (and (memq number gnus-newsgroup-dormant)
6885 ;; If this is "fetch-old-headered" and there is no
6886 ;; visible children, then we don't want this article.
6887 (and (or (eq gnus-fetch-old-headers 'some)
6888 (numberp gnus-fetch-old-headers))
6889 (gnus-summary-article-ancient-p number)
6891 ;; If this is "fetch-old-headered" and `invisible', then
6892 ;; we don't want this article.
6893 (and (eq gnus-fetch-old-headers 'invisible)
6894 (gnus-summary-article-ancient-p number))
6895 ;; If this is a sparsely inserted article with no children,
6896 ;; we don't want it.
6897 (and (eq gnus-build-sparse-threads 'some)
6898 (gnus-summary-article-sparse-p number)
6900 ;; If we use expunging, and this article is really
6901 ;; low-scored, then we don't want this article.
6902 (when (and gnus-summary-expunge-below
6904 (or (cdr (assq number gnus-newsgroup-scored))
6905 gnus-summary-default-score))
6906 gnus-summary-expunge-below))
6907 ;; We increase the expunge-tally here, but that has
6908 ;; nothing to do with the limits, really.
6909 (incf gnus-newsgroup-expunged-tally)
6910 ;; We also mark as read here, if that's wanted.
6911 (when (and gnus-summary-mark-below
6912 (< score gnus-summary-mark-below))
6913 (setq gnus-newsgroup-unreads
6914 (delq number gnus-newsgroup-unreads))
6915 (if gnus-newsgroup-auto-expire
6916 (push number gnus-newsgroup-expirable)
6917 (push (cons number gnus-low-score-mark)
6918 gnus-newsgroup-reads)))
6920 ;; Check NoCeM things.
6921 (if (and gnus-use-nocem
6922 (gnus-nocem-unwanted-article-p
6923 (mail-header-id (car thread))))
6925 (setq gnus-newsgroup-unreads
6926 (delq number gnus-newsgroup-unreads))
6928 ;; Nope, invisible article.
6930 ;; Ok, this article is to be visible, so we add it to the limit
6932 (push number gnus-newsgroup-limit)
6935 (defun gnus-expunge-thread (thread)
6936 "Mark all articles in THREAD as read."
6937 (let* ((number (mail-header-number (car thread))))
6938 (incf gnus-newsgroup-expunged-tally)
6939 ;; We also mark as read here, if that's wanted.
6940 (setq gnus-newsgroup-unreads
6941 (delq number gnus-newsgroup-unreads))
6942 (if gnus-newsgroup-auto-expire
6943 (push number gnus-newsgroup-expirable)
6944 (push (cons number gnus-low-score-mark)
6945 gnus-newsgroup-reads)))
6946 ;; Go recursively through all subthreads.
6947 (mapcar 'gnus-expunge-thread (cdr thread)))
6949 ;; Summary article oriented commands
6951 (defun gnus-summary-refer-parent-article (n)
6952 "Refer parent article N times.
6953 If N is negative, go to ancestor -N instead.
6954 The difference between N and the number of articles fetched is returned."
6958 (when (not (natnump n))
6963 (setq header (gnus-summary-article-header))
6964 (if (and (eq (mail-header-number header)
6965 (cdr gnus-article-current))
6966 (equal gnus-newsgroup-name
6967 (car gnus-article-current)))
6968 ;; If we try to find the parent of the currently
6969 ;; displayed article, then we take a look at the actual
6970 ;; References header, since this is slightly more
6971 ;; reliable than the References field we got from the
6974 (set-buffer gnus-original-article-buffer)
6975 (nnheader-narrow-to-headers)
6976 (unless (setq ref (message-fetch-field "references"))
6977 (setq ref (message-fetch-field "in-reply-to")))
6980 ;; It's not the current article, so we take a bet on
6981 ;; the value we got from the server.
6982 (mail-header-references header)))
6984 (not (equal ref "")))
6985 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
6986 (gnus-message 1 "Couldn't find parent"))
6987 (gnus-message 1 "No references in article %d"
6988 (gnus-summary-article-number))
6991 (gnus-summary-position-point)
6994 (defun gnus-summary-refer-references ()
6995 "Fetch all articles mentioned in the References header.
6996 Return the number of articles fetched."
6998 (let ((ref (mail-header-references (gnus-summary-article-header)))
6999 (current (gnus-summary-article-number))
7003 (error "No References in the current article")
7004 ;; For each Message-ID in the References header...
7005 (while (string-match "<[^>]*>" ref)
7007 ;; ... fetch that article.
7008 (gnus-summary-refer-article
7009 (prog1 (match-string 0 ref)
7010 (setq ref (substring ref (match-end 0))))))
7011 (gnus-summary-goto-subject current)
7012 (gnus-summary-position-point)
7015 (defun gnus-summary-refer-thread (&optional limit)
7016 "Fetch all articles in the current thread.
7017 If LIMIT (the numerical prefix), fetch that many old headers instead
7018 of what's specified by the `gnus-refer-thread-limit' variable."
7020 (let ((id (mail-header-id (gnus-summary-article-header)))
7021 (limit (if limit (prefix-numeric-value limit)
7022 gnus-refer-thread-limit)))
7023 ;; We want to fetch LIMIT *old* headers, but we also have to
7024 ;; re-fetch all the headers in the current buffer, because many of
7025 ;; them may be undisplayed. So we adjust LIMIT.
7026 (when (numberp limit)
7027 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
7028 (unless (eq gnus-fetch-old-headers 'invisible)
7029 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
7030 ;; Retrieve the headers and read them in.
7031 (if (eq (gnus-retrieve-headers
7032 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
7034 (gnus-build-all-threads)
7035 (error "Can't fetch thread from backends that don't support NOV"))
7036 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
7037 (gnus-summary-limit-include-thread id)))
7039 (defun gnus-summary-refer-article (message-id)
7040 "Fetch an article specified by MESSAGE-ID."
7041 (interactive "sMessage-ID: ")
7042 (when (and (stringp message-id)
7043 (not (zerop (length message-id))))
7044 ;; Construct the correct Message-ID if necessary.
7045 ;; Suggested by tale@pawl.rpi.edu.
7046 (unless (string-match "^<" message-id)
7047 (setq message-id (concat "<" message-id)))
7048 (unless (string-match ">$" message-id)
7049 (setq message-id (concat message-id ">")))
7050 (let* ((header (gnus-id-to-header message-id))
7052 (gnus-summary-article-sparse-p
7053 (mail-header-number header))
7054 (memq (mail-header-number header)
7055 gnus-newsgroup-limit)))
7058 ;; If the article is present in the buffer we just go to it.
7060 (or (not (gnus-summary-article-sparse-p
7061 (mail-header-number header)))
7064 (gnus-summary-goto-article
7065 (mail-header-number header) nil t)
7067 (gnus-summary-update-article (mail-header-number header)))))
7069 ;; We fetch the article.
7071 (dolist (gnus-override-method (gnus-refer-article-methods))
7072 (gnus-check-server gnus-override-method)
7073 ;; Fetch the header, and display the article.
7074 (when (setq number (gnus-summary-insert-subject message-id))
7075 (gnus-summary-select-article nil nil nil number)
7077 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
7079 (defun gnus-refer-article-methods ()
7080 "Return a list of referrable methods."
7082 ;; No method, so we default to current and native.
7083 ((null gnus-refer-article-method)
7084 (list gnus-current-select-method gnus-select-method))
7086 ((eq 'current gnus-refer-article-method)
7087 (list gnus-current-select-method))
7088 ;; List of select methods.
7089 ((not (and (symbolp (car gnus-refer-article-method))
7090 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
7092 (dolist (method gnus-refer-article-method)
7093 (push (if (eq 'current method)
7094 gnus-current-select-method
7098 ;; One single select method.
7100 (list gnus-refer-article-method))))
7102 (defun gnus-summary-edit-parameters ()
7103 "Edit the group parameters of the current group."
7105 (gnus-group-edit-group gnus-newsgroup-name 'params))
7107 (defun gnus-summary-customize-parameters ()
7108 "Customize the group parameters of the current group."
7110 (gnus-group-customize gnus-newsgroup-name))
7112 (defun gnus-summary-enter-digest-group (&optional force)
7113 "Enter an nndoc group based on the current article.
7114 If FORCE, force a digest interpretation. If not, try
7115 to guess what the document format is."
7117 (let ((conf gnus-current-window-configuration))
7119 (gnus-summary-select-article))
7120 (setq gnus-current-window-configuration conf)
7121 (let* ((name (format "%s-%d"
7122 (gnus-group-prefixed-name
7123 gnus-newsgroup-name (list 'nndoc ""))
7125 (set-buffer gnus-summary-buffer)
7126 gnus-current-article)))
7127 (ogroup gnus-newsgroup-name)
7128 (params (append (gnus-info-params (gnus-get-info ogroup))
7129 (list (cons 'to-group ogroup))
7130 (list (cons 'save-article-group ogroup))))
7131 (case-fold-search t)
7132 (buf (current-buffer))
7135 (set-buffer gnus-original-article-buffer)
7136 ;; Have the digest group inherit the main mail address of
7137 ;; the parent article.
7138 (when (setq to-address (or (message-fetch-field "reply-to")
7139 (message-fetch-field "from")))
7140 (setq params (append
7141 (list (cons 'to-address
7142 (funcall gnus-decode-encoded-word-function
7144 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
7145 (insert-buffer-substring gnus-original-article-buffer)
7146 ;; Remove lines that may lead nndoc to misinterpret the
7149 (goto-char (point-min))
7150 (or (search-forward "\n\n" nil t) (point)))
7151 (goto-char (point-min))
7152 (delete-matching-lines "^Path:\\|^From ")
7155 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
7156 (gnus-newsgroup-ephemeral-ignored-charsets
7157 gnus-newsgroup-ignored-charsets))
7158 (gnus-group-read-ephemeral-group
7159 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
7161 ,(if force 'mbox 'guess))) t))
7162 ;; Make all postings to this group go to the parent group.
7163 (nconc (gnus-info-params (gnus-get-info name))
7165 ;; Couldn't select this doc group.
7166 (switch-to-buffer buf)
7167 (gnus-set-global-variables)
7168 (gnus-configure-windows 'summary)
7169 (gnus-message 3 "Article couldn't be entered?"))
7170 (kill-buffer dig)))))
7172 (defun gnus-summary-read-document (n)
7173 "Open a new group based on the current article(s).
7174 This will allow you to read digests and other similar
7175 documents as newsgroups.
7176 Obeys the standard process/prefix convention."
7178 (let* ((articles (gnus-summary-work-articles n))
7179 (ogroup gnus-newsgroup-name)
7180 (params (append (gnus-info-params (gnus-get-info ogroup))
7181 (list (cons 'to-group ogroup))))
7182 article group egroup groups vgroup)
7183 (while (setq article (pop articles))
7184 (setq group (format "%s-%d" gnus-newsgroup-name article))
7185 (gnus-summary-remove-process-mark article)
7186 (when (gnus-summary-display-article article)
7189 (insert-buffer-substring gnus-original-article-buffer)
7190 ;; Remove some headers that may lead nndoc to make
7192 (message-narrow-to-head)
7193 (goto-char (point-min))
7194 (delete-matching-lines "^\\(Path\\):\\|^From ")
7197 (gnus-group-read-ephemeral-group
7198 group `(nndoc ,group (nndoc-address ,(current-buffer))
7199 (nndoc-article-type guess))
7202 ;; Make all postings to this group go to the parent group.
7203 (nconc (gnus-info-params (gnus-get-info egroup))
7205 (push egroup groups))
7206 ;; Couldn't select this doc group.
7207 (gnus-error 3 "Article couldn't be entered"))))))
7208 ;; Now we have selected all the documents.
7211 (error "None of the articles could be interpreted as documents"))
7212 ((gnus-group-read-ephemeral-group
7213 (setq vgroup (format
7214 "nnvirtual:%s-%s" gnus-newsgroup-name
7215 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
7216 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
7218 (cons (current-buffer) 'summary)))
7220 (error "Couldn't select virtual nndoc group")))))
7222 (defun gnus-summary-isearch-article (&optional regexp-p)
7223 "Do incremental search forward on the current article.
7224 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
7226 (gnus-summary-select-article)
7227 (gnus-configure-windows 'article)
7228 (gnus-eval-in-buffer-window gnus-article-buffer
7231 (isearch-forward regexp-p))))
7233 (defun gnus-summary-search-article-forward (regexp &optional backward)
7234 "Search for an article containing REGEXP forward.
7235 If BACKWARD, search backward instead."
7238 (format "Search article %s (regexp%s): "
7239 (if current-prefix-arg "backward" "forward")
7240 (if gnus-last-search-regexp
7241 (concat ", default " gnus-last-search-regexp)
7243 current-prefix-arg))
7244 (if (string-equal regexp "")
7245 (setq regexp (or gnus-last-search-regexp ""))
7246 (setq gnus-last-search-regexp regexp)
7247 (setq gnus-article-before-search gnus-current-article))
7248 ;; Intentionally set gnus-last-article.
7249 (setq gnus-last-article gnus-article-before-search)
7250 (let ((gnus-last-article gnus-last-article))
7251 (if (gnus-summary-search-article regexp backward)
7252 (gnus-summary-show-thread)
7253 (error "Search failed: \"%s\"" regexp))))
7255 (defun gnus-summary-search-article-backward (regexp)
7256 "Search for an article containing REGEXP backward."
7259 (format "Search article backward (regexp%s): "
7260 (if gnus-last-search-regexp
7261 (concat ", default " gnus-last-search-regexp)
7263 (gnus-summary-search-article-forward regexp 'backward))
7265 (defun gnus-summary-search-article (regexp &optional backward)
7266 "Search for an article containing REGEXP.
7267 Optional argument BACKWARD means do search for backward.
7268 `gnus-select-article-hook' is not called during the search."
7269 ;; We have to require this here to make sure that the following
7270 ;; dynamic binding isn't shadowed by autoloading.
7271 (require 'gnus-async)
7273 (let ((gnus-select-article-hook nil) ;Disable hook.
7274 (gnus-article-prepare-hook nil)
7275 (gnus-mark-article-hook nil) ;Inhibit marking as read.
7276 (gnus-use-article-prefetch nil)
7277 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
7278 (gnus-use-trees nil) ;Inhibit updating tree buffer.
7279 (sum (current-buffer))
7280 (gnus-display-mime-function nil)
7283 (gnus-save-hidden-threads
7284 (gnus-summary-select-article)
7285 (set-buffer gnus-article-buffer)
7286 (goto-char (window-point (get-buffer-window (current-buffer))))
7290 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
7292 (re-search-backward regexp nil t)
7293 (re-search-forward regexp nil t))
7294 ;; We found the regexp.
7299 (get-buffer-window (current-buffer))
7303 (get-buffer-window (current-buffer))
7306 (setq point (point)))
7307 ;; We didn't find it, so we go to the next article.
7310 (while (eq found 'not)
7311 (if (not (if backward (gnus-summary-find-prev)
7312 (gnus-summary-find-next)))
7313 ;; No more articles.
7315 ;; Select the next article and adjust point.
7316 (unless (gnus-summary-article-sparse-p
7317 (gnus-summary-article-number))
7319 (gnus-summary-select-article)
7320 (set-buffer gnus-article-buffer)
7322 (goto-char (if backward (point-max) (point-min))))))))
7323 (gnus-message 7 ""))
7324 ;; Return whether we found the regexp.
7325 (when (eq found 'found)
7327 (gnus-summary-show-thread)
7328 (gnus-summary-goto-subject gnus-current-article)
7329 (gnus-summary-position-point)
7332 (defun gnus-summary-find-matching (header regexp &optional backward unread
7334 "Return a list of all articles that match REGEXP on HEADER.
7335 The search stars on the current article and goes forwards unless
7336 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
7337 If UNREAD is non-nil, only unread articles will
7338 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
7339 in the comparisons."
7340 (let ((data (if (eq backward 'all) gnus-newsgroup-data
7341 (gnus-data-find-list
7342 (gnus-summary-article-number) (gnus-data-list backward))))
7343 (case-fold-search (not not-case-fold))
7346 (if (eq (car header) 'extra)
7349 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
7351 (error "%s is an invalid header" header))
7352 (unless (fboundp (intern (concat "mail-header-" header)))
7353 (error "%s is not a valid header" header))
7354 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
7357 (and (or (not unread) ; We want all articles...
7358 (gnus-data-unread-p d)) ; Or just unreads.
7359 (vectorp (gnus-data-header d)) ; It's not a pseudo.
7360 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
7361 (push (gnus-data-number d) articles)) ; Success!
7362 (setq data (cdr data)))
7363 (nreverse articles)))
7365 (defun gnus-summary-execute-command (header regexp command &optional backward)
7366 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
7367 If HEADER is an empty string (or nil), the match is done on the entire
7368 article. If BACKWARD (the prefix) is non-nil, search backward instead."
7370 (list (let ((completion-ignore-case t))
7373 (mapcar (lambda (string) (list string))
7374 '("Number" "Subject" "From" "Lines" "Date"
7375 "Message-ID" "Xref" "References" "Body"))
7376 nil 'require-match))
7377 (read-string "Regexp: ")
7378 (read-key-sequence "Command: ")
7379 current-prefix-arg))
7380 (when (equal header "Body")
7382 ;; Hidden thread subtrees must be searched as well.
7383 (gnus-summary-show-all-threads)
7384 ;; We don't want to change current point nor window configuration.
7386 (save-window-excursion
7387 (gnus-message 6 "Executing %s..." (key-description command))
7388 ;; We'd like to execute COMMAND interactively so as to give arguments.
7389 (gnus-execute header regexp
7390 `(call-interactively ',(key-binding command))
7392 (gnus-message 6 "Executing %s...done" (key-description command)))))
7394 (defun gnus-summary-beginning-of-article ()
7395 "Scroll the article back to the beginning."
7397 (gnus-summary-select-article)
7398 (gnus-configure-windows 'article)
7399 (gnus-eval-in-buffer-window gnus-article-buffer
7401 (goto-char (point-min))
7402 (when gnus-page-broken
7403 (gnus-narrow-to-page))))
7405 (defun gnus-summary-end-of-article ()
7406 "Scroll to the end of the article."
7408 (gnus-summary-select-article)
7409 (gnus-configure-windows 'article)
7410 (gnus-eval-in-buffer-window gnus-article-buffer
7412 (goto-char (point-max))
7414 (when gnus-page-broken
7415 (gnus-narrow-to-page))))
7417 (defun gnus-summary-print-article (&optional filename n)
7418 "Generate and print a PostScript image of the N next (mail) articles.
7420 If N is negative, print the N previous articles. If N is nil and articles
7421 have been marked with the process mark, print these instead.
7423 If the optional first argument FILENAME is nil, send the image to the
7424 printer. If FILENAME is a string, save the PostScript image in a file with
7425 that name. If FILENAME is a number, prompt the user for the name of the file
7427 (interactive (list (ps-print-preprint current-prefix-arg)))
7428 (dolist (article (gnus-summary-work-articles n))
7429 (gnus-summary-select-article nil nil 'pseudo article)
7430 (gnus-eval-in-buffer-window gnus-article-buffer
7431 (let ((buffer (generate-new-buffer " *print*")))
7434 (copy-to-buffer buffer (point-min) (point-max))
7436 (gnus-article-delete-invisible-text)
7437 (let ((ps-left-header
7440 (mail-header-subject gnus-current-headers) ")")
7442 (mail-header-from gnus-current-headers) ")")))
7445 "/pagenumberstring load"
7447 (mail-header-date gnus-current-headers) ")"))))
7448 (gnus-run-hooks 'gnus-ps-print-hook)
7450 (ps-spool-buffer-with-faces))))
7451 (kill-buffer buffer))))
7452 (gnus-summary-remove-process-mark article))
7453 (ps-despool filename))
7455 (defun gnus-summary-show-article (&optional arg)
7456 "Force re-fetching of the current article.
7457 If ARG (the prefix) is a number, show the article with the charset
7458 defined in `gnus-summary-show-article-charset-alist', or the charset
7460 If ARG (the prefix) is non-nil and not a number, show the raw article
7461 without any article massaging functions being run."
7465 (let ((gnus-newsgroup-charset
7466 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
7467 (read-coding-system "Charset: ")))
7468 (gnus-newsgroup-ignored-charsets 'gnus-all))
7469 (gnus-summary-select-article nil 'force)
7470 (let ((deps gnus-newsgroup-dependencies)
7473 (set-buffer gnus-original-article-buffer)
7475 (message-narrow-to-head)
7476 (setq head (buffer-string)))
7478 (insert (format "211 %d Article retrieved.\n"
7479 (cdr gnus-article-current)))
7482 (let ((nntp-server-buffer (current-buffer)))
7483 (setq header (car (gnus-get-newsgroup-headers deps t))))))
7484 (gnus-data-set-header
7485 (gnus-data-find (cdr gnus-article-current))
7487 (gnus-summary-update-article-line
7488 (cdr gnus-article-current) header))))
7490 ;; Select the article the normal way.
7491 (gnus-summary-select-article nil 'force))
7493 ;; We have to require this here to make sure that the following
7494 ;; dynamic binding isn't shadowed by autoloading.
7495 (require 'gnus-async)
7497 ;; Bind the article treatment functions to nil.
7498 (let ((gnus-have-all-headers t)
7499 gnus-article-prepare-hook
7500 gnus-article-decode-hook
7501 gnus-display-mime-function
7503 ;; Destroy any MIME parts.
7504 (when (gnus-buffer-live-p gnus-article-buffer)
7506 (set-buffer gnus-article-buffer)
7507 (mm-destroy-parts gnus-article-mime-handles)
7508 ;; Set it to nil for safety reason.
7509 (setq gnus-article-mime-handle-alist nil)
7510 (setq gnus-article-mime-handles nil)))
7511 (gnus-summary-select-article nil 'force))))
7512 (gnus-summary-goto-subject gnus-current-article)
7513 (gnus-summary-position-point))
7515 (defun gnus-summary-verbose-headers (&optional arg)
7516 "Toggle permanent full header display.
7517 If ARG is a positive number, turn header display on.
7518 If ARG is a negative number, turn header display off."
7520 (setq gnus-show-all-headers
7521 (cond ((or (not (numberp arg))
7523 (not gnus-show-all-headers))
7526 (gnus-summary-show-article))
7528 (defun gnus-summary-toggle-header (&optional arg)
7529 "Show the headers if they are hidden, or hide them if they are shown.
7530 If ARG is a positive number, show the entire header.
7531 If ARG is a negative number, hide the unwanted header lines."
7534 (set-buffer gnus-article-buffer)
7536 (let* ((buffer-read-only nil)
7537 (inhibit-point-motion-hooks t)
7543 (article-narrow-to-head)
7544 (gnus-article-hidden-text-p 'headers))))
7545 (goto-char (point-min))
7546 (when (search-forward "\n\n" nil t)
7547 (delete-region (point-min) (1- (point))))
7548 (goto-char (point-min))
7550 (set-buffer gnus-original-article-buffer)
7551 (goto-char (point-min))
7552 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
7553 (insert-buffer-substring gnus-original-article-buffer 1 e)
7555 (narrow-to-region (point-min) (point))
7556 (article-decode-encoded-words)
7558 (let ((gnus-treat-hide-headers nil)
7559 (gnus-treat-hide-boring-headers nil))
7560 (setq gnus-article-wash-types
7561 (delq 'headers gnus-article-wash-types))
7562 (gnus-treat-article 'head))
7563 (gnus-treat-article 'head)))
7564 (gnus-set-mode-line 'article)))))
7566 (defun gnus-summary-show-all-headers ()
7567 "Make all header lines visible."
7569 (gnus-article-show-all-headers))
7571 (defun gnus-summary-caesar-message (&optional arg)
7572 "Caesar rotate the current article by 13.
7573 The numerical prefix specifies how many places to rotate each letter
7576 (gnus-summary-select-article)
7577 (let ((mail-header-separator ""))
7578 (gnus-eval-in-buffer-window gnus-article-buffer
7581 (let ((start (window-start))
7583 (message-caesar-buffer-body arg)
7584 (set-window-start (get-buffer-window (current-buffer)) start))))))
7586 (defun gnus-summary-stop-page-breaking ()
7587 "Stop page breaking in the current article."
7589 (gnus-summary-select-article)
7590 (gnus-eval-in-buffer-window gnus-article-buffer
7592 (when (gnus-visual-p 'page-marker)
7593 (let ((buffer-read-only nil))
7594 (gnus-remove-text-with-property 'gnus-prev)
7595 (gnus-remove-text-with-property 'gnus-next))
7596 (setq gnus-page-broken nil))))
7598 (defun gnus-summary-move-article (&optional n to-newsgroup
7599 select-method action)
7600 "Move the current article to a different newsgroup.
7601 If N is a positive number, move the N next articles.
7602 If N is a negative number, move the N previous articles.
7603 If N is nil and any articles have been marked with the process mark,
7604 move those articles instead.
7605 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7606 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7607 re-spool using this method.
7609 For this function to work, both the current newsgroup and the
7610 newsgroup that you want to move to have to support the `request-move'
7611 and `request-accept' functions.
7613 ACTION can be either `move' (the default), `crosspost' or `copy'."
7616 (setq action 'move))
7617 ;; Disable marking as read.
7618 (let (gnus-mark-article-hook)
7619 (save-window-excursion
7620 (gnus-summary-select-article)))
7621 ;; Check whether the source group supports the required functions.
7622 (cond ((and (eq action 'move)
7623 (not (gnus-check-backend-function
7624 'request-move-article gnus-newsgroup-name)))
7625 (error "The current group does not support article moving"))
7626 ((and (eq action 'crosspost)
7627 (not (gnus-check-backend-function
7628 'request-replace-article gnus-newsgroup-name)))
7629 (error "The current group does not support article editing")))
7630 (let ((articles (gnus-summary-work-articles n))
7631 (prefix (if (gnus-check-backend-function
7632 'request-move-article gnus-newsgroup-name)
7633 (gnus-group-real-prefix gnus-newsgroup-name)
7635 (names '((move "Move" "Moving")
7636 (copy "Copy" "Copying")
7637 (crosspost "Crosspost" "Crossposting")))
7638 (copy-buf (save-excursion
7639 (nnheader-set-temp-buffer " *copy article*")))
7640 art-group to-method new-xref article to-groups)
7641 (unless (assq action names)
7642 (error "Unknown action %s" action))
7643 ;; Read the newsgroup name.
7644 (when (and (not to-newsgroup)
7645 (not select-method))
7647 (gnus-read-move-group-name
7648 (cadr (assq action names))
7649 (symbol-value (intern (format "gnus-current-%s-group" action)))
7651 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
7652 (setq to-method (or select-method
7653 (gnus-server-to-method
7654 (gnus-group-method to-newsgroup))))
7655 ;; Check the method we are to move this article to...
7656 (unless (gnus-check-backend-function
7657 'request-accept-article (car to-method))
7658 (error "%s does not support article copying" (car to-method)))
7659 (unless (gnus-check-server to-method)
7660 (error "Can't open server %s" (car to-method)))
7661 (gnus-message 6 "%s to %s: %s..."
7662 (caddr (assq action names))
7663 (or (car select-method) to-newsgroup) articles)
7665 (setq article (pop articles))
7669 ;; Move the article.
7671 ;; Remove this article from future suppression.
7672 (gnus-dup-unsuppress-article article)
7673 (gnus-request-move-article
7674 article ; Article to move
7675 gnus-newsgroup-name ; From newsgroup
7676 (nth 1 (gnus-find-method-for-group
7677 gnus-newsgroup-name)) ; Server
7678 (list 'gnus-request-accept-article
7679 to-newsgroup (list 'quote select-method)
7680 (not articles) t) ; Accept form
7681 (not articles))) ; Only save nov last time
7682 ;; Copy the article.
7685 (set-buffer copy-buf)
7686 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
7687 (gnus-request-accept-article
7688 to-newsgroup select-method (not articles) t))))
7689 ;; Crosspost the article.
7690 ((eq action 'crosspost)
7691 (let ((xref (message-tokenize-header
7692 (mail-header-xref (gnus-summary-article-header article))
7694 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
7697 (setq xref (list (system-name))))
7700 (mapconcat 'identity
7701 (delete "Xref:" (delete new-xref xref))
7705 (set-buffer copy-buf)
7706 ;; First put the article in the destination group.
7707 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7708 (when (consp (setq art-group
7709 (gnus-request-accept-article
7710 to-newsgroup select-method (not articles))))
7711 (setq new-xref (concat new-xref " " (car art-group)
7712 ":" (cdr art-group)))
7713 ;; Now we have the new Xrefs header, so we insert
7714 ;; it and replace the new article.
7715 (nnheader-replace-header "Xref" new-xref)
7716 (gnus-request-replace-article
7717 (cdr art-group) to-newsgroup (current-buffer))
7721 (gnus-message 1 "Couldn't %s article %s: %s"
7722 (cadr (assq action names)) article
7723 (nnheader-get-report (car to-method))))
7724 ((eq art-group 'junk)
7725 (when (eq action 'move)
7726 (gnus-summary-mark-article article gnus-canceled-mark)
7727 (gnus-message 4 "Deleted article %s" article)))
7729 (let* ((pto-group (gnus-group-prefixed-name
7730 (car art-group) to-method))
7732 (gnus-gethash pto-group gnus-newsrc-hashtb))
7733 (info (nth 2 entry))
7734 (to-group (gnus-info-group info))
7736 ;; Update the group that has been moved to.
7738 (memq action '(move copy)))
7739 (unless (member to-group to-groups)
7740 (push to-group to-groups))
7742 (unless (memq article gnus-newsgroup-unreads)
7743 (push 'read to-marks)
7745 info (gnus-add-to-range (gnus-info-read info)
7746 (list (cdr art-group)))))
7748 ;; See whether the article is to be put in the cache.
7749 (let ((marks gnus-article-mark-lists)
7750 (to-article (cdr art-group)))
7752 ;; Enter the article into the cache in the new group,
7753 ;; if that is required.
7754 (when gnus-use-cache
7755 (gnus-cache-possibly-enter-article
7757 (memq article gnus-newsgroup-marked)
7758 (memq article gnus-newsgroup-dormant)
7759 (memq article gnus-newsgroup-unreads)))
7761 (when gnus-preserve-marks
7762 ;; Copy any marks over to the new group.
7763 (when (and (equal to-group gnus-newsgroup-name)
7764 (not (memq article gnus-newsgroup-unreads)))
7765 ;; Mark this article as read in this group.
7766 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
7767 (setcdr (gnus-active to-group) to-article)
7768 (setcdr gnus-newsgroup-active to-article))
7771 (when (memq article (symbol-value
7772 (intern (format "gnus-newsgroup-%s"
7774 (push (cdar marks) to-marks)
7775 ;; If the other group is the same as this group,
7776 ;; then we have to add the mark to the list.
7777 (when (equal to-group gnus-newsgroup-name)
7778 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
7781 (intern (format "gnus-newsgroup-%s"
7783 ;; Copy the marks to other group.
7784 (gnus-add-marked-articles
7785 to-group (cdar marks) (list to-article) info))
7786 (setq marks (cdr marks)))
7788 (gnus-request-set-mark to-group (list (list (list to-article)
7793 (concat "(gnus-group-set-info '"
7794 (gnus-prin1-to-string (gnus-get-info to-group))
7797 ;; Update the Xref header in this article to point to
7798 ;; the new crossposted article we have just created.
7799 (when (eq action 'crosspost)
7801 (set-buffer copy-buf)
7802 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7803 (nnheader-replace-header "Xref" new-xref)
7804 (gnus-request-replace-article
7805 article gnus-newsgroup-name (current-buffer)))))
7807 ;;;!!!Why is this necessary?
7808 (set-buffer gnus-summary-buffer)
7810 (gnus-summary-goto-subject article)
7811 (when (eq action 'move)
7812 (gnus-summary-mark-article article gnus-canceled-mark))))
7813 (gnus-summary-remove-process-mark article))
7814 ;; Re-activate all groups that have been moved to.
7817 (set-buffer gnus-group-buffer)
7818 (when (gnus-group-goto-group (car to-groups) t)
7819 (gnus-group-get-new-news-this-group 1 t))
7822 (gnus-kill-buffer copy-buf)
7823 (gnus-summary-position-point)
7824 (gnus-set-mode-line 'summary)))
7826 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
7827 "Move the current article to a different newsgroup.
7828 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7829 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7830 re-spool using this method."
7832 (gnus-summary-move-article n to-newsgroup select-method 'copy))
7834 (defun gnus-summary-crosspost-article (&optional n)
7835 "Crosspost the current article to some other group."
7837 (gnus-summary-move-article n nil nil 'crosspost))
7839 (defcustom gnus-summary-respool-default-method nil
7840 "Default method for respooling an article.
7841 If nil, use to the current newsgroup method."
7842 :type '(choice (gnus-select-method :value (nnml ""))
7844 :group 'gnus-summary-mail)
7846 (defun gnus-summary-respool-article (&optional n method)
7847 "Respool the current article.
7848 The article will be squeezed through the mail spooling process again,
7849 which means that it will be put in some mail newsgroup or other
7850 depending on `nnmail-split-methods'.
7851 If N is a positive number, respool the N next articles.
7852 If N is a negative number, respool the N previous articles.
7853 If N is nil and any articles have been marked with the process mark,
7854 respool those articles instead.
7856 Respooling can be done both from mail groups and \"real\" newsgroups.
7857 In the former case, the articles in question will be moved from the
7858 current group into whatever groups they are destined to. In the
7859 latter case, they will be copied into the relevant groups."
7861 (list current-prefix-arg
7862 (let* ((methods (gnus-methods-using 'respool))
7864 (symbol-name (or gnus-summary-respool-default-method
7865 (car (gnus-find-method-for-group
7866 gnus-newsgroup-name)))))
7868 (gnus-completing-read
7869 methname "What backend do you want to use when respooling?"
7870 methods nil t nil 'gnus-mail-method-history))
7873 ((zerop (length (setq ms (gnus-servers-using-backend
7875 (list (intern method) ""))
7879 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
7880 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
7883 (error "No method given for respooling"))
7884 (if (assoc (symbol-name
7885 (car (gnus-find-method-for-group gnus-newsgroup-name)))
7886 (gnus-methods-using 'respool))
7887 (gnus-summary-move-article n nil method)
7888 (gnus-summary-copy-article n nil method)))
7890 (defun gnus-summary-import-article (file)
7891 "Import an arbitrary file into a mail newsgroup."
7892 (interactive "fImport file: ")
7893 (let ((group gnus-newsgroup-name)
7894 (now (current-time))
7896 (unless (gnus-check-backend-function 'request-accept-article group)
7897 (error "%s does not support article importing" group))
7898 (or (file-readable-p file)
7899 (not (file-regular-p file))
7900 (error "Can't read %s" file))
7902 (set-buffer (gnus-get-buffer-create " *import file*"))
7904 (nnheader-insert-file-contents file)
7905 (goto-char (point-min))
7906 (unless (nnheader-article-p)
7907 ;; This doesn't look like an article, so we fudge some headers.
7908 (setq atts (file-attributes file)
7909 lines (count-lines (point-min) (point-max)))
7910 (insert "From: " (read-string "From: ") "\n"
7911 "Subject: " (read-string "Subject: ") "\n"
7912 "Date: " (message-make-date (nth 5 atts))
7914 "Message-ID: " (message-make-message-id) "\n"
7915 "Lines: " (int-to-string lines) "\n"
7916 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
7917 (gnus-request-accept-article group nil t)
7918 (kill-buffer (current-buffer)))))
7920 (defun gnus-summary-article-posted-p ()
7921 "Say whether the current (mail) article is available from news as well.
7922 This will be the case if the article has both been mailed and posted."
7924 (let ((id (mail-header-references (gnus-summary-article-header)))
7925 (gnus-override-method (car (gnus-refer-article-methods))))
7926 (if (gnus-request-head id "")
7927 (gnus-message 2 "The current message was found on %s"
7928 gnus-override-method)
7929 (gnus-message 2 "The current message couldn't be found on %s"
7930 gnus-override-method)
7933 (defun gnus-summary-expire-articles (&optional now)
7934 "Expire all articles that are marked as expirable in the current group."
7936 (when (gnus-check-backend-function
7937 'request-expire-articles gnus-newsgroup-name)
7938 ;; This backend supports expiry.
7939 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
7940 (expirable (if total
7942 ;; We need to update the info for
7943 ;; this group for `gnus-list-of-read-articles'
7944 ;; to give us the right answer.
7945 (gnus-run-hooks 'gnus-exit-group-hook)
7946 (gnus-summary-update-info)
7947 (gnus-list-of-read-articles gnus-newsgroup-name))
7948 (setq gnus-newsgroup-expirable
7949 (sort gnus-newsgroup-expirable '<))))
7950 (expiry-wait (if now 'immediate
7951 (gnus-group-find-parameter
7952 gnus-newsgroup-name 'expiry-wait)))
7953 (nnmail-expiry-target
7954 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
7955 nnmail-expiry-target))
7958 ;; There are expirable articles in this group, so we run them
7959 ;; through the expiry process.
7960 (gnus-message 6 "Expiring articles...")
7961 (unless (gnus-check-group gnus-newsgroup-name)
7962 (error "Can't open server for %s" gnus-newsgroup-name))
7963 ;; The list of articles that weren't expired is returned.
7966 (let ((nnmail-expiry-wait-function nil)
7967 (nnmail-expiry-wait expiry-wait))
7968 (setq es (gnus-request-expire-articles
7969 expirable gnus-newsgroup-name)))
7970 (setq es (gnus-request-expire-articles
7971 expirable gnus-newsgroup-name)))
7973 (setq gnus-newsgroup-expirable es))
7974 ;; We go through the old list of expirable, and mark all
7975 ;; really expired articles as nonexistent.
7976 (unless (eq es expirable) ;If nothing was expired, we don't mark.
7977 (let ((gnus-use-cache nil))
7979 (unless (memq (car expirable) es)
7980 (when (gnus-data-find (car expirable))
7981 (gnus-summary-mark-article
7982 (car expirable) gnus-canceled-mark)))
7983 (setq expirable (cdr expirable))))))
7984 (gnus-message 6 "Expiring articles...done")))))
7986 (defun gnus-summary-expire-articles-now ()
7987 "Expunge all expirable articles in the current group.
7988 This means that *all* articles that are marked as expirable will be
7989 deleted forever, right now."
7991 (or gnus-expert-user
7993 "Are you really, really, really sure you want to delete all these messages? ")
7995 (gnus-summary-expire-articles t))
7997 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
7998 (defun gnus-summary-delete-article (&optional n)
7999 "Delete the N next (mail) articles.
8000 This command actually deletes articles. This is not a marking
8001 command. The article will disappear forever from your life, never to
8003 If N is negative, delete backwards.
8004 If N is nil and articles have been marked with the process mark,
8005 delete these instead."
8007 (unless (gnus-check-backend-function 'request-expire-articles
8008 gnus-newsgroup-name)
8009 (error "The current newsgroup does not support article deletion"))
8010 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
8011 (error "Couldn't open server"))
8012 ;; Compute the list of articles to delete.
8013 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
8015 (if (and gnus-novice-user
8016 (not (gnus-yes-or-no-p
8017 (format "Do you really want to delete %s forever? "
8018 (if (> (length articles) 1)
8019 (format "these %s articles" (length articles))
8022 ;; Delete the articles.
8023 (setq not-deleted (gnus-request-expire-articles
8024 articles gnus-newsgroup-name 'force))
8026 (gnus-summary-remove-process-mark (car articles))
8027 ;; The backend might not have been able to delete the article
8029 (unless (memq (car articles) not-deleted)
8030 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
8031 (setq articles (cdr articles)))
8033 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
8034 (gnus-summary-position-point)
8035 (gnus-set-mode-line 'summary)
8038 (defun gnus-summary-edit-article (&optional arg)
8039 "Edit the current article.
8040 This will have permanent effect only in mail groups.
8041 If ARG is nil, edit the decoded articles.
8042 If ARG is 1, edit the raw articles.
8043 If ARG is 2, edit the raw articles even in read-only groups.
8044 If ARG is 3, edit the articles with the current handles.
8045 Otherwise, allow editing of articles even in read-only
8048 (let (force raw current-handles)
8051 ((eq arg 1) (setq raw t))
8052 ((eq arg 2) (setq raw t
8054 ((eq arg 3) (setq current-handles
8055 (and (gnus-buffer-live-p gnus-article-buffer)
8056 (with-current-buffer gnus-article-buffer
8058 gnus-article-mime-handles
8059 (setq gnus-article-mime-handles nil))))))
8061 (if (and raw (not force) (equal gnus-newsgroup-name "nndraft:drafts"))
8062 (error "Can't edit the raw article in group nndraft:drafts."))
8064 (set-buffer gnus-summary-buffer)
8065 (let ((mail-parse-charset gnus-newsgroup-charset)
8066 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
8067 (gnus-set-global-variables)
8068 (when (and (not force)
8069 (gnus-group-read-only-p))
8070 (error "The current newsgroup does not support article editing"))
8071 (gnus-summary-show-article t)
8072 (when (and (not raw) (gnus-buffer-live-p gnus-article-buffer))
8073 (with-current-buffer gnus-article-buffer
8074 (mm-enable-multibyte-mule4)))
8075 (if (equal gnus-newsgroup-name "nndraft:drafts")
8077 (gnus-article-edit-article
8080 (let ((mbl mml-buffer-list))
8081 (setq mml-buffer-list nil)
8082 (mime-to-mml ,'current-handles)
8083 (make-local-hook 'kill-buffer-hook)
8084 (let ((mbl1 mml-buffer-list))
8085 (setq mml-buffer-list mbl)
8086 (set (make-local-variable 'mml-buffer-list) mbl1))
8087 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))))
8088 `(lambda (no-highlight)
8089 (let ((mail-parse-charset ',gnus-newsgroup-charset)
8090 (message-options message-options)
8091 (message-options-set-recipient)
8092 (mail-parse-ignored-charsets
8093 ',gnus-newsgroup-ignored-charsets))
8094 ,(if (not raw) '(progn
8096 (mml-destroy-buffers)
8097 (remove-hook 'kill-buffer-hook
8098 'mml-destroy-buffers t)
8099 (kill-local-variable 'mml-buffer-list)))
8100 (gnus-summary-edit-article-done
8101 ,(or (mail-header-references gnus-current-headers) "")
8102 ,(gnus-group-read-only-p)
8103 ,gnus-summary-buffer no-highlight))))))))
8105 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
8107 (defun gnus-summary-edit-article-done (&optional references read-only buffer
8109 "Make edits to the current article permanent."
8112 ;; The buffer restriction contains the entire article if it exists.
8113 (when (article-goto-body)
8114 (let ((lines (count-lines (point) (point-max)))
8115 (length (- (point-max) (point)))
8116 (case-fold-search t)
8117 (body (copy-marker (point))))
8118 (goto-char (point-min))
8119 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
8120 (delete-region (match-beginning 1) (match-end 1))
8121 (insert (number-to-string length)))
8122 (goto-char (point-min))
8123 (when (re-search-forward
8124 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
8125 (delete-region (match-beginning 1) (match-end 1))
8126 (insert (number-to-string length)))
8127 (goto-char (point-min))
8128 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
8129 (delete-region (match-beginning 1) (match-end 1))
8130 (insert (number-to-string lines))))))
8131 ;; Replace the article.
8132 (let ((buf (current-buffer)))
8134 (insert-buffer-substring buf)
8136 (if (and (not read-only)
8137 (not (gnus-request-replace-article
8138 (cdr gnus-article-current) (car gnus-article-current)
8139 (current-buffer) t)))
8140 (error "Couldn't replace article")
8141 ;; Update the summary buffer.
8143 (equal (message-tokenize-header references " ")
8144 (message-tokenize-header
8145 (or (message-fetch-field "references") "") " ")))
8146 ;; We only have to update this line.
8149 (message-narrow-to-head)
8150 (let ((head (buffer-string))
8153 (insert (format "211 %d Article retrieved.\n"
8154 (cdr gnus-article-current)))
8157 (let ((nntp-server-buffer (current-buffer)))
8158 (setq header (car (gnus-get-newsgroup-headers
8160 (set-buffer gnus-summary-buffer)
8161 gnus-newsgroup-dependencies)
8164 (set-buffer gnus-summary-buffer)
8165 (gnus-data-set-header
8166 (gnus-data-find (cdr gnus-article-current))
8168 (gnus-summary-update-article-line
8169 (cdr gnus-article-current) header))))))
8171 (set-buffer (or buffer gnus-summary-buffer))
8172 (gnus-summary-update-article (cdr gnus-article-current)))
8173 ;; Prettify the article buffer again.
8174 (unless no-highlight
8176 (set-buffer gnus-article-buffer)
8177 ;;;!!! Fix this -- article should be rehighlighted.
8178 ;;;(gnus-run-hooks 'gnus-article-display-hook)
8179 (set-buffer gnus-original-article-buffer)
8180 (gnus-request-article
8181 (cdr gnus-article-current)
8182 (car gnus-article-current) (current-buffer))))
8183 ;; Prettify the summary buffer line.
8184 (when (gnus-visual-p 'summary-highlight 'highlight)
8185 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
8187 (defun gnus-summary-edit-wash (key)
8188 "Perform editing command KEY in the article buffer."
8192 (message "%s" (concat (this-command-keys) "- "))
8195 (gnus-summary-edit-article)
8196 (execute-kbd-macro (concat (this-command-keys) key))
8197 (gnus-article-edit-done))
8201 (defun gnus-summary-respool-query (&optional silent trace)
8202 "Query where the respool algorithm would put this article."
8204 (let (gnus-mark-article-hook)
8205 (gnus-summary-select-article)
8207 (set-buffer gnus-original-article-buffer)
8209 (message-narrow-to-head)
8210 (let ((groups (nnmail-article-group 'identity trace)))
8213 (message "This message would go to %s"
8214 (mapconcat 'car groups ", "))
8215 (message "This message would go to no groups"))
8218 (defun gnus-summary-respool-trace ()
8219 "Trace where the respool algorithm would put this article.
8220 Display a buffer showing all fancy splitting patterns which matched."
8222 (gnus-summary-respool-query nil t))
8224 ;; Summary marking commands.
8226 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
8227 "Mark articles which has the same subject as read, and then select the next.
8228 If UNMARK is positive, remove any kind of mark.
8229 If UNMARK is negative, tick articles."
8232 (setq unmark (prefix-numeric-value unmark)))
8234 (gnus-summary-mark-same-subject
8235 (gnus-summary-article-subject) unmark)))
8236 ;; Select next unread article. If auto-select-same mode, should
8237 ;; select the first unread article.
8238 (gnus-summary-next-article t (and gnus-auto-select-same
8239 (gnus-summary-article-subject)))
8240 (gnus-message 7 "%d article%s marked as %s"
8241 count (if (= count 1) " is" "s are")
8242 (if unmark "unread" "read"))))
8244 (defun gnus-summary-kill-same-subject (&optional unmark)
8245 "Mark articles which has the same subject as read.
8246 If UNMARK is positive, remove any kind of mark.
8247 If UNMARK is negative, tick articles."
8250 (setq unmark (prefix-numeric-value unmark)))
8252 (gnus-summary-mark-same-subject
8253 (gnus-summary-article-subject) unmark)))
8254 ;; If marked as read, go to next unread subject.
8256 ;; Go to next unread subject.
8257 (gnus-summary-next-subject 1 t))
8258 (gnus-message 7 "%d articles are marked as %s"
8259 count (if unmark "unread" "read"))))
8261 (defun gnus-summary-mark-same-subject (subject &optional unmark)
8262 "Mark articles with same SUBJECT as read, and return marked number.
8263 If optional argument UNMARK is positive, remove any kinds of marks.
8264 If optional argument UNMARK is negative, mark articles as unread instead."
8268 ((null unmark) ; Mark as read.
8271 (gnus-summary-mark-article-as-read gnus-killed-mark)
8272 (gnus-summary-show-thread) t)
8273 (gnus-summary-find-subject subject))
8274 (setq count (1+ count))))
8275 ((> unmark 0) ; Tick.
8278 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
8279 (gnus-summary-show-thread) t)
8280 (gnus-summary-find-subject subject))
8281 (setq count (1+ count))))
8282 (t ; Mark as unread.
8285 (gnus-summary-mark-article-as-unread gnus-unread-mark)
8286 (gnus-summary-show-thread) t)
8287 (gnus-summary-find-subject subject))
8288 (setq count (1+ count)))))
8289 (gnus-set-mode-line 'summary)
8290 ;; Return the number of marked articles.
8293 (defun gnus-summary-mark-as-processable (n &optional unmark)
8294 "Set the process mark on the next N articles.
8295 If N is negative, mark backward instead. If UNMARK is non-nil, remove
8296 the process mark instead. The difference between N and the actual
8297 number of articles marked is returned."
8299 (if (and (null n) (gnus-region-active-p))
8300 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
8301 (setq n (prefix-numeric-value n))
8302 (let ((backward (< n 0))
8307 (gnus-summary-remove-process-mark
8308 (gnus-summary-article-number))
8309 (gnus-summary-set-process-mark (gnus-summary-article-number)))
8310 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
8313 (gnus-message 7 "No more articles"))
8314 (gnus-summary-recenter)
8315 (gnus-summary-position-point)
8318 (defun gnus-summary-unmark-as-processable (n)
8319 "Remove the process mark from the next N articles.
8320 If N is negative, unmark backward instead. The difference between N and
8321 the actual number of articles unmarked is returned."
8323 (gnus-summary-mark-as-processable n t))
8325 (defun gnus-summary-unmark-all-processable ()
8326 "Remove the process mark from all articles."
8329 (while gnus-newsgroup-processable
8330 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
8331 (gnus-summary-position-point))
8333 (defun gnus-summary-add-mark (article type)
8334 "Mark ARTICLE with a mark of TYPE."
8335 (let ((vtype (car (assq type gnus-article-mark-lists)))
8338 (error "No such mark type: %s" type)
8339 (setq var (intern (format "gnus-newsgroup-%s" type)))
8340 (set var (cons article (symbol-value var)))
8341 (if (memq type '(processable cached replied saved))
8342 (gnus-summary-update-secondary-mark article)
8343 ;;; !!! This is bobus. We should find out what primary
8344 ;;; !!! mark we want to set.
8345 (gnus-summary-update-mark gnus-del-mark 'unread)))))
8347 (defun gnus-summary-mark-as-expirable (n)
8348 "Mark N articles forward as expirable.
8349 If N is negative, mark backward instead. The difference between N and
8350 the actual number of articles marked is returned."
8352 (gnus-summary-mark-forward n gnus-expirable-mark))
8354 (defun gnus-summary-mark-article-as-replied (article)
8355 "Mark ARTICLE replied and update the summary line."
8356 (push article gnus-newsgroup-replied)
8357 (let ((buffer-read-only nil))
8358 (when (gnus-summary-goto-subject article nil t)
8359 (gnus-summary-update-secondary-mark article))))
8361 (defun gnus-summary-set-bookmark (article)
8362 "Set a bookmark in current article."
8363 (interactive (list (gnus-summary-article-number)))
8364 (when (or (not (get-buffer gnus-article-buffer))
8365 (not gnus-current-article)
8366 (not gnus-article-current)
8367 (not (equal gnus-newsgroup-name (car gnus-article-current))))
8368 (error "No current article selected"))
8369 ;; Remove old bookmark, if one exists.
8370 (let ((old (assq article gnus-newsgroup-bookmarks)))
8372 (setq gnus-newsgroup-bookmarks
8373 (delq old gnus-newsgroup-bookmarks))))
8374 ;; Set the new bookmark, which is on the form
8375 ;; (article-number . line-number-in-body).
8379 (set-buffer gnus-article-buffer)
8383 (goto-char (point-min))
8384 (search-forward "\n\n" nil t)
8387 gnus-newsgroup-bookmarks)
8388 (gnus-message 6 "A bookmark has been added to the current article."))
8390 (defun gnus-summary-remove-bookmark (article)
8391 "Remove the bookmark from the current article."
8392 (interactive (list (gnus-summary-article-number)))
8393 ;; Remove old bookmark, if one exists.
8394 (let ((old (assq article gnus-newsgroup-bookmarks)))
8397 (setq gnus-newsgroup-bookmarks
8398 (delq old gnus-newsgroup-bookmarks))
8399 (gnus-message 6 "Removed bookmark."))
8400 (gnus-message 6 "No bookmark in current article."))))
8402 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8403 (defun gnus-summary-mark-as-dormant (n)
8404 "Mark N articles forward as dormant.
8405 If N is negative, mark backward instead. The difference between N and
8406 the actual number of articles marked is returned."
8408 (gnus-summary-mark-forward n gnus-dormant-mark))
8410 (defun gnus-summary-set-process-mark (article)
8411 "Set the process mark on ARTICLE and update the summary line."
8412 (setq gnus-newsgroup-processable
8414 (delq article gnus-newsgroup-processable)))
8415 (when (gnus-summary-goto-subject article)
8416 (gnus-summary-show-thread)
8417 (gnus-summary-goto-subject article)
8418 (gnus-summary-update-secondary-mark article)))
8420 (defun gnus-summary-remove-process-mark (article)
8421 "Remove the process mark from ARTICLE and update the summary line."
8422 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
8423 (when (gnus-summary-goto-subject article)
8424 (gnus-summary-show-thread)
8425 (gnus-summary-goto-subject article)
8426 (gnus-summary-update-secondary-mark article)))
8428 (defun gnus-summary-set-saved-mark (article)
8429 "Set the process mark on ARTICLE and update the summary line."
8430 (push article gnus-newsgroup-saved)
8431 (when (gnus-summary-goto-subject article)
8432 (gnus-summary-update-secondary-mark article)))
8434 (defun gnus-summary-mark-forward (n &optional mark no-expire)
8435 "Mark N articles as read forwards.
8436 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
8437 The difference between N and the actual number of articles marked is
8439 Iff NO-EXPIRE, auto-expiry will be inhibited."
8441 (gnus-summary-show-thread)
8442 (let ((backward (< n 0))
8443 (gnus-summary-goto-unread
8444 (and gnus-summary-goto-unread
8445 (not (eq gnus-summary-goto-unread 'never))
8446 (not (memq mark (list gnus-unread-mark
8447 gnus-ticked-mark gnus-dormant-mark)))))
8449 (mark (or mark gnus-del-mark)))
8451 (gnus-summary-mark-article nil mark no-expire)
8452 (zerop (gnus-summary-next-subject
8454 (and gnus-summary-goto-unread
8455 (not (eq gnus-summary-goto-unread 'never)))
8459 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
8460 (gnus-summary-recenter)
8461 (gnus-summary-position-point)
8462 (gnus-set-mode-line 'summary)
8465 (defun gnus-summary-mark-article-as-read (mark)
8466 "Mark the current article quickly as read with MARK."
8467 (let ((article (gnus-summary-article-number)))
8468 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8469 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8470 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8471 (push (cons article mark) gnus-newsgroup-reads)
8472 ;; Possibly remove from cache, if that is used.
8473 (when gnus-use-cache
8474 (gnus-cache-enter-remove-article article))
8475 ;; Allow the backend to change the mark.
8476 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8477 ;; Check for auto-expiry.
8478 (when (and gnus-newsgroup-auto-expire
8479 (memq mark gnus-auto-expirable-marks))
8480 (setq mark gnus-expirable-mark)
8481 ;; Let the backend know about the mark change.
8482 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8483 (push article gnus-newsgroup-expirable))
8484 ;; Set the mark in the buffer.
8485 (gnus-summary-update-mark mark 'unread)
8488 (defun gnus-summary-mark-article-as-unread (mark)
8489 "Mark the current article quickly as unread with MARK."
8490 (let* ((article (gnus-summary-article-number))
8491 (old-mark (gnus-summary-article-mark article)))
8492 ;; Allow the backend to change the mark.
8493 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8494 (if (eq mark old-mark)
8498 (gnus-error 1 "Can't mark negative article numbers")
8500 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8501 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8502 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
8503 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
8504 (cond ((= mark gnus-ticked-mark)
8505 (push article gnus-newsgroup-marked))
8506 ((= mark gnus-dormant-mark)
8507 (push article gnus-newsgroup-dormant))
8509 (push article gnus-newsgroup-unreads)))
8510 (gnus-pull article gnus-newsgroup-reads)
8512 ;; See whether the article is to be put in the cache.
8514 (vectorp (gnus-summary-article-header article))
8516 (gnus-cache-possibly-enter-article
8517 gnus-newsgroup-name article
8518 (= mark gnus-ticked-mark)
8519 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
8522 (gnus-summary-update-mark mark 'unread)
8525 (defun gnus-summary-mark-article (&optional article mark no-expire)
8526 "Mark ARTICLE with MARK. MARK can be any character.
8527 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
8528 `??' (dormant) and `?E' (expirable).
8529 If MARK is nil, then the default character `?r' is used.
8530 If ARTICLE is nil, then the article on the current line will be
8532 Iff NO-EXPIRE, auto-expiry will be inhibited."
8533 ;; The mark might be a string.
8534 (when (stringp mark)
8535 (setq mark (aref mark 0)))
8536 ;; If no mark is given, then we check auto-expiring.
8538 (setq mark gnus-del-mark))
8539 (when (and (not no-expire)
8540 gnus-newsgroup-auto-expire
8541 (memq mark gnus-auto-expirable-marks))
8542 (setq mark gnus-expirable-mark))
8543 (let ((article (or article (gnus-summary-article-number)))
8544 (old-mark (gnus-summary-article-mark article)))
8545 ;; Allow the backend to change the mark.
8546 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8547 (if (eq mark old-mark)
8550 (error "No article on current line"))
8551 (if (not (if (or (= mark gnus-unread-mark)
8552 (= mark gnus-ticked-mark)
8553 (= mark gnus-dormant-mark))
8554 (gnus-mark-article-as-unread article mark)
8555 (gnus-mark-article-as-read article mark)))
8557 ;; See whether the article is to be put in the cache.
8559 (not (= mark gnus-canceled-mark))
8560 (vectorp (gnus-summary-article-header article))
8562 (gnus-cache-possibly-enter-article
8563 gnus-newsgroup-name article
8564 (= mark gnus-ticked-mark)
8565 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
8567 (when (gnus-summary-goto-subject article nil t)
8568 (let ((buffer-read-only nil))
8569 (gnus-summary-show-thread)
8571 (gnus-summary-update-mark mark 'unread)
8574 (defun gnus-summary-update-secondary-mark (article)
8575 "Update the secondary (read, process, cache) mark."
8576 (gnus-summary-update-mark
8577 (cond ((memq article gnus-newsgroup-processable)
8579 ((memq article gnus-newsgroup-cached)
8581 ((memq article gnus-newsgroup-replied)
8583 ((memq article gnus-newsgroup-saved)
8587 (when (gnus-visual-p 'summary-highlight 'highlight)
8588 (gnus-run-hooks 'gnus-summary-update-hook))
8591 (defun gnus-summary-update-mark (mark type)
8592 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
8593 (buffer-read-only nil))
8594 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
8596 (when (looking-at "\r")
8598 (when (<= (+ forward (point)) (point-max))
8599 ;; Go to the right position on the line.
8600 (goto-char (+ forward (point)))
8601 ;; Replace the old mark with the new mark.
8602 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
8603 ;; Optionally update the marks by some user rule.
8604 (when (eq type 'unread)
8606 (gnus-data-find (gnus-summary-article-number)) mark)
8607 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
8609 (defun gnus-mark-article-as-read (article &optional mark)
8610 "Enter ARTICLE in the pertinent lists and remove it from others."
8611 ;; Make the article expirable.
8612 (let ((mark (or mark gnus-del-mark)))
8613 (if (= mark gnus-expirable-mark)
8614 (push article gnus-newsgroup-expirable)
8615 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
8616 ;; Remove from unread and marked lists.
8617 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8618 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8619 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8620 (push (cons article mark) gnus-newsgroup-reads)
8621 ;; Possibly remove from cache, if that is used.
8622 (when gnus-use-cache
8623 (gnus-cache-enter-remove-article article))
8626 (defun gnus-mark-article-as-unread (article &optional mark)
8627 "Enter ARTICLE in the pertinent lists and remove it from others."
8628 (let ((mark (or mark gnus-ticked-mark)))
8631 (gnus-error 1 "Can't mark negative article numbers")
8633 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
8634 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
8635 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
8636 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8638 ;; Unsuppress duplicates?
8639 (when gnus-suppress-duplicates
8640 (gnus-dup-unsuppress-article article))
8642 (cond ((= mark gnus-ticked-mark)
8643 (push article gnus-newsgroup-marked))
8644 ((= mark gnus-dormant-mark)
8645 (push article gnus-newsgroup-dormant))
8647 (push article gnus-newsgroup-unreads)))
8648 (gnus-pull article gnus-newsgroup-reads)
8651 (defalias 'gnus-summary-mark-as-unread-forward
8652 'gnus-summary-tick-article-forward)
8653 (make-obsolete 'gnus-summary-mark-as-unread-forward
8654 'gnus-summary-tick-article-forward)
8655 (defun gnus-summary-tick-article-forward (n)
8656 "Tick N articles forwards.
8657 If N is negative, tick backwards instead.
8658 The difference between N and the number of articles ticked is returned."
8660 (gnus-summary-mark-forward n gnus-ticked-mark))
8662 (defalias 'gnus-summary-mark-as-unread-backward
8663 'gnus-summary-tick-article-backward)
8664 (make-obsolete 'gnus-summary-mark-as-unread-backward
8665 'gnus-summary-tick-article-backward)
8666 (defun gnus-summary-tick-article-backward (n)
8667 "Tick N articles backwards.
8668 The difference between N and the number of articles ticked is returned."
8670 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
8672 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8673 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8674 (defun gnus-summary-tick-article (&optional article clear-mark)
8675 "Mark current article as unread.
8676 Optional 1st argument ARTICLE specifies article number to be marked as unread.
8677 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
8679 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
8682 (defun gnus-summary-mark-as-read-forward (n)
8683 "Mark N articles as read forwards.
8684 If N is negative, mark backwards instead.
8685 The difference between N and the actual number of articles marked is
8688 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
8690 (defun gnus-summary-mark-as-read-backward (n)
8691 "Mark the N articles as read backwards.
8692 The difference between N and the actual number of articles marked is
8695 (gnus-summary-mark-forward
8696 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
8698 (defun gnus-summary-mark-as-read (&optional article mark)
8699 "Mark current article as read.
8700 ARTICLE specifies the article to be marked as read.
8701 MARK specifies a string to be inserted at the beginning of the line."
8702 (gnus-summary-mark-article article mark))
8704 (defun gnus-summary-clear-mark-forward (n)
8705 "Clear marks from N articles forward.
8706 If N is negative, clear backward instead.
8707 The difference between N and the number of marks cleared is returned."
8709 (gnus-summary-mark-forward n gnus-unread-mark))
8711 (defun gnus-summary-clear-mark-backward (n)
8712 "Clear marks from N articles backward.
8713 The difference between N and the number of marks cleared is returned."
8715 (gnus-summary-mark-forward (- n) gnus-unread-mark))
8717 (defun gnus-summary-mark-unread-as-read ()
8718 "Intended to be used by `gnus-summary-mark-article-hook'."
8719 (when (memq gnus-current-article gnus-newsgroup-unreads)
8720 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
8722 (defun gnus-summary-mark-read-and-unread-as-read ()
8723 "Intended to be used by `gnus-summary-mark-article-hook'."
8724 (let ((mark (gnus-summary-article-mark)))
8725 (when (or (gnus-unread-mark-p mark)
8726 (gnus-read-mark-p mark))
8727 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
8729 (defun gnus-summary-mark-unread-as-ticked ()
8730 "Intended to be used by `gnus-summary-mark-article-hook'."
8731 (when (memq gnus-current-article gnus-newsgroup-unreads)
8732 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
8734 (defun gnus-summary-mark-region-as-read (point mark all)
8735 "Mark all unread articles between point and mark as read.
8736 If given a prefix, mark all articles between point and mark as read,
8737 even ticked and dormant ones."
8738 (interactive "r\nP")
8747 (memq (setq article (gnus-summary-article-number))
8748 gnus-newsgroup-unreads))
8749 (gnus-summary-mark-article article gnus-del-mark))
8751 (gnus-summary-find-next))))))
8753 (defun gnus-summary-mark-below (score mark)
8754 "Mark articles with score less than SCORE with MARK."
8755 (interactive "P\ncMark: ")
8756 (setq score (if score
8757 (prefix-numeric-value score)
8758 (or gnus-summary-default-score 0)))
8760 (set-buffer gnus-summary-buffer)
8761 (goto-char (point-min))
8764 (and (< (gnus-summary-article-score) score)
8765 (gnus-summary-mark-article nil mark))
8766 (gnus-summary-find-next)))))
8768 (defun gnus-summary-kill-below (&optional score)
8769 "Mark articles with score below SCORE as read."
8771 (gnus-summary-mark-below score gnus-killed-mark))
8773 (defun gnus-summary-clear-above (&optional score)
8774 "Clear all marks from articles with score above SCORE."
8776 (gnus-summary-mark-above score gnus-unread-mark))
8778 (defun gnus-summary-tick-above (&optional score)
8779 "Tick all articles with score above SCORE."
8781 (gnus-summary-mark-above score gnus-ticked-mark))
8783 (defun gnus-summary-mark-above (score mark)
8784 "Mark articles with score over SCORE with MARK."
8785 (interactive "P\ncMark: ")
8786 (setq score (if score
8787 (prefix-numeric-value score)
8788 (or gnus-summary-default-score 0)))
8790 (set-buffer gnus-summary-buffer)
8791 (goto-char (point-min))
8793 (when (> (gnus-summary-article-score) score)
8794 (gnus-summary-mark-article nil mark))
8796 (gnus-summary-find-next)))))
8798 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8799 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
8800 (defun gnus-summary-limit-include-expunged (&optional no-error)
8801 "Display all the hidden articles that were expunged for low scores."
8803 (let ((buffer-read-only nil))
8804 (let ((scored gnus-newsgroup-scored)
8807 (unless (gnus-number-to-header (caar scored))
8808 (and (setq h (gnus-summary-article-header (caar scored)))
8809 (< (cdar scored) gnus-summary-expunge-below)
8811 (setq scored (cdr scored)))
8813 (when (not no-error)
8814 (error "No expunged articles hidden"))
8815 (goto-char (point-min))
8816 (gnus-summary-prepare-unthreaded (nreverse headers))
8817 (goto-char (point-min))
8818 (gnus-summary-position-point)
8821 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
8822 "Mark all unread articles in this newsgroup as read.
8823 If prefix argument ALL is non-nil, ticked and dormant articles will
8824 also be marked as read.
8825 If QUIETLY is non-nil, no questions will be asked.
8826 If TO-HERE is non-nil, it should be a point in the buffer. All
8827 articles before this point will be marked as read.
8828 Note that this function will only catch up the unread article
8829 in the current summary buffer limitation.
8830 The number of articles marked as read is returned."
8835 (not gnus-interactive-catchup) ;Without confirmation?
8839 "Mark absolutely all articles as read? "
8840 "Mark all unread articles as read? ")))
8842 (not gnus-newsgroup-adaptive)
8843 (not gnus-newsgroup-auto-expire)
8844 (not gnus-suppress-duplicates)
8845 (or (not gnus-use-cache)
8846 (eq gnus-use-cache 'passive)))
8849 (setq gnus-newsgroup-marked nil
8850 gnus-newsgroup-dormant nil))
8851 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
8852 ;; We actually mark all articles as canceled, which we
8853 ;; have to do when using auto-expiry or adaptive scoring.
8854 (gnus-summary-show-all-threads)
8855 (when (gnus-summary-first-subject (not all) t)
8857 (if to-here (< (point) to-here) t)
8858 (gnus-summary-mark-article-as-read gnus-catchup-mark)
8859 (gnus-summary-find-next (not all) nil nil t))))
8860 (gnus-set-mode-line 'summary))
8862 (gnus-summary-position-point)))
8864 (defun gnus-summary-catchup-to-here (&optional all)
8865 "Mark all unticked articles before the current one as read.
8866 If ALL is non-nil, also mark ticked and dormant articles as read."
8869 (gnus-save-hidden-threads
8870 (let ((beg (point)))
8871 ;; We check that there are unread articles.
8872 (when (or all (gnus-summary-find-prev))
8873 (gnus-summary-catchup all t beg)))))
8874 (gnus-summary-position-point))
8876 (defun gnus-summary-catchup-all (&optional quietly)
8877 "Mark all articles in this newsgroup as read."
8879 (gnus-summary-catchup t quietly))
8881 (defun gnus-summary-catchup-and-exit (&optional all quietly)
8882 "Mark all unread articles in this group as read, then exit.
8883 If prefix argument ALL is non-nil, all articles are marked as read."
8885 (when (gnus-summary-catchup all quietly nil 'fast)
8886 ;; Select next newsgroup or exit.
8887 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
8888 (eq gnus-auto-select-next 'quietly))
8889 (gnus-summary-next-group nil)
8890 (gnus-summary-exit))))
8892 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
8893 "Mark all articles in this newsgroup as read, and then exit."
8895 (gnus-summary-catchup-and-exit t quietly))
8897 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
8898 "Mark all articles in this group as read and select the next group.
8899 If given a prefix, mark all articles, unread as well as ticked, as
8903 (gnus-summary-catchup all))
8904 (gnus-summary-next-group))
8910 (defmacro gnus-with-article (article &rest forms)
8911 "Select ARTICLE and perform FORMS in the original article buffer.
8912 Then replace the article with the result."
8914 ;; We don't want the article to be marked as read.
8915 (let (gnus-mark-article-hook)
8916 (gnus-summary-select-article t t nil ,article))
8917 (set-buffer gnus-original-article-buffer)
8919 (if (not (gnus-check-backend-function
8920 'request-replace-article (car gnus-article-current)))
8921 (gnus-message 5 "Read-only group; not replacing")
8922 (unless (gnus-request-replace-article
8923 ,article (car gnus-article-current)
8925 (error "Couldn't replace article")))
8926 ;; The cache and backlog have to be flushed somewhat.
8927 (when gnus-keep-backlog
8928 (gnus-backlog-remove-article
8929 (car gnus-article-current) (cdr gnus-article-current)))
8930 (when gnus-use-cache
8931 (gnus-cache-update-article
8932 (car gnus-article-current) (cdr gnus-article-current)))))
8934 (put 'gnus-with-article 'lisp-indent-function 1)
8935 (put 'gnus-with-article 'edebug-form-spec '(form body))
8937 ;; Thread-based commands.
8939 (defun gnus-summary-articles-in-thread (&optional article)
8940 "Return a list of all articles in the current thread.
8941 If ARTICLE is non-nil, return all articles in the thread that starts
8943 (let* ((article (or article (gnus-summary-article-number)))
8944 (data (gnus-data-find-list article))
8945 (top-level (gnus-data-level (car data)))
8947 (cond ((null gnus-thread-operation-ignore-subject)
8948 (gnus-simplify-subject-re
8949 (mail-header-subject (gnus-data-header (car data)))))
8950 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
8951 (gnus-simplify-subject-fuzzy
8952 (mail-header-subject (gnus-data-header (car data)))))
8954 (end-point (save-excursion
8955 (if (gnus-summary-go-to-next-thread)
8956 (point) (point-max))))
8959 (< (gnus-data-pos (car data)) end-point))
8960 (when (or (not top-subject)
8961 (string= top-subject
8962 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
8963 (gnus-simplify-subject-fuzzy
8964 (mail-header-subject
8965 (gnus-data-header (car data))))
8966 (gnus-simplify-subject-re
8967 (mail-header-subject
8968 (gnus-data-header (car data)))))))
8969 (push (gnus-data-number (car data)) articles))
8970 (unless (and (setq data (cdr data))
8971 (> (gnus-data-level (car data)) top-level))
8973 ;; Return the list of articles.
8974 (nreverse articles)))
8976 (defun gnus-summary-rethread-current ()
8977 "Rethread the thread the current article is part of."
8979 (let* ((gnus-show-threads t)
8980 (article (gnus-summary-article-number))
8981 (id (mail-header-id (gnus-summary-article-header)))
8982 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
8984 (error "No article on the current line"))
8985 (gnus-rebuild-thread id)
8986 (gnus-summary-goto-subject article)))
8988 (defun gnus-summary-reparent-thread ()
8989 "Make the current article child of the marked (or previous) article.
8991 Note that the re-threading will only work if `gnus-thread-ignore-subject'
8992 is non-nil or the Subject: of both articles are the same."
8994 (unless (not (gnus-group-read-only-p))
8995 (error "The current newsgroup does not support article editing"))
8996 (unless (<= (length gnus-newsgroup-processable) 1)
8997 (error "No more than one article may be marked"))
8998 (save-window-excursion
8999 (let ((gnus-article-buffer " *reparent*")
9000 (current-article (gnus-summary-article-number))
9001 ;; First grab the marked article, otherwise one line up.
9002 (parent-article (if (not (null gnus-newsgroup-processable))
9003 (car gnus-newsgroup-processable)
9005 (if (eq (forward-line -1) 0)
9006 (gnus-summary-article-number)
9007 (error "Beginning of summary buffer"))))))
9008 (unless (not (eq current-article parent-article))
9009 (error "An article may not be self-referential"))
9010 (let ((message-id (mail-header-id
9011 (gnus-summary-article-header parent-article))))
9012 (unless (and message-id (not (equal message-id "")))
9013 (error "No message-id in desired parent"))
9014 (gnus-with-article current-article
9016 (goto-char (point-min))
9017 (message-narrow-to-head)
9018 (if (re-search-forward "^References: " nil t)
9020 (re-search-forward "^[^ \t]" nil t)
9023 (insert " " message-id))
9024 (insert "References: " message-id "\n"))))
9025 (set-buffer gnus-summary-buffer)
9026 (gnus-summary-unmark-all-processable)
9027 (gnus-summary-update-article current-article)
9028 (gnus-summary-rethread-current)
9029 (gnus-message 3 "Article %d is now the child of article %d"
9030 current-article parent-article)))))
9032 (defun gnus-summary-toggle-threads (&optional arg)
9033 "Toggle showing conversation threads.
9034 If ARG is positive number, turn showing conversation threads on."
9036 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
9037 (setq gnus-show-threads
9038 (if (null arg) (not gnus-show-threads)
9039 (> (prefix-numeric-value arg) 0)))
9040 (gnus-summary-prepare)
9041 (gnus-summary-goto-subject current)
9042 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
9043 (gnus-summary-position-point)))
9045 (defun gnus-summary-show-all-threads ()
9049 (let ((buffer-read-only nil))
9050 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
9051 (gnus-summary-position-point))
9053 (defun gnus-summary-show-thread ()
9054 "Show thread subtrees.
9055 Returns nil if no thread was there to be shown."
9057 (let ((buffer-read-only nil)
9059 ;; first goto end then to beg, to have point at beg after let
9060 (end (progn (end-of-line) (point)))
9061 (beg (progn (beginning-of-line) (point))))
9063 ;; Any hidden lines here?
9064 (search-forward "\r" end t)
9065 (subst-char-in-region beg end ?\^M ?\n t)
9067 (gnus-summary-position-point))))
9069 (defun gnus-summary-hide-all-threads ()
9070 "Hide all thread subtrees."
9073 (goto-char (point-min))
9074 (gnus-summary-hide-thread)
9075 (while (zerop (gnus-summary-next-thread 1 t))
9076 (gnus-summary-hide-thread)))
9077 (gnus-summary-position-point))
9079 (defun gnus-summary-hide-thread ()
9080 "Hide thread subtrees.
9081 Returns nil if no threads were there to be hidden."
9083 (let ((buffer-read-only nil)
9085 (article (gnus-summary-article-number)))
9087 ;; Go forward until either the buffer ends or the subthread
9089 (when (and (not (eobp))
9090 (or (zerop (gnus-summary-next-thread 1 t))
9091 (goto-char (point-max))))
9093 (if (and (> (point) start)
9094 (search-backward "\n" start t))
9096 (subst-char-in-region start (point) ?\n ?\^M)
9097 (gnus-summary-goto-subject article))
9101 (defun gnus-summary-go-to-next-thread (&optional previous)
9102 "Go to the same level (or less) next thread.
9103 If PREVIOUS is non-nil, go to previous thread instead.
9104 Return the article number moved to, or nil if moving was impossible."
9105 (let ((level (gnus-summary-thread-level))
9106 (way (if previous -1 1))
9109 (while (and (not (eobp))
9110 (< level (gnus-summary-thread-level)))
9118 (gnus-summary-article-number)
9121 (defun gnus-summary-next-thread (n &optional silent)
9122 "Go to the same level next N'th thread.
9123 If N is negative, search backward instead.
9124 Returns the difference between N and the number of skips actually
9127 If SILENT, don't output messages."
9129 (let ((backward (< n 0))
9132 (gnus-summary-go-to-next-thread backward))
9135 (gnus-summary-position-point))
9136 (when (and (not silent) (/= 0 n))
9137 (gnus-message 7 "No more threads"))
9140 (defun gnus-summary-prev-thread (n)
9141 "Go to the same level previous N'th thread.
9142 Returns the difference between N and the number of skips actually
9145 (gnus-summary-next-thread (- n)))
9147 (defun gnus-summary-go-down-thread ()
9148 "Go down one level in the current thread."
9149 (let ((children (gnus-summary-article-children)))
9151 (gnus-summary-goto-subject (car children)))))
9153 (defun gnus-summary-go-up-thread ()
9154 "Go up one level in the current thread."
9155 (let ((parent (gnus-summary-article-parent)))
9157 (gnus-summary-goto-subject parent))))
9159 (defun gnus-summary-down-thread (n)
9160 "Go down thread N steps.
9161 If N is negative, go up instead.
9162 Returns the difference between N and how many steps down that were
9168 (if up (gnus-summary-go-up-thread)
9169 (gnus-summary-go-down-thread)))
9171 (gnus-summary-position-point)
9173 (gnus-message 7 "Can't go further"))
9176 (defun gnus-summary-up-thread (n)
9177 "Go up thread N steps.
9178 If N is negative, go up instead.
9179 Returns the difference between N and how many steps down that were
9182 (gnus-summary-down-thread (- n)))
9184 (defun gnus-summary-top-thread ()
9185 "Go to the top of the thread."
9187 (while (gnus-summary-go-up-thread))
9188 (gnus-summary-article-number))
9190 (defun gnus-summary-kill-thread (&optional unmark)
9191 "Mark articles under current thread as read.
9192 If the prefix argument is positive, remove any kinds of marks.
9193 If the prefix argument is negative, tick articles instead."
9196 (setq unmark (prefix-numeric-value unmark)))
9197 (let ((articles (gnus-summary-articles-in-thread)))
9199 ;; Expand the thread.
9200 (gnus-summary-show-thread)
9201 ;; Mark all the articles.
9203 (gnus-summary-goto-subject (car articles))
9204 (cond ((null unmark)
9205 (gnus-summary-mark-article-as-read gnus-killed-mark))
9207 (gnus-summary-mark-article-as-unread gnus-unread-mark))
9209 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
9210 (setq articles (cdr articles))))
9211 ;; Hide killed subtrees.
9213 gnus-thread-hide-killed
9214 (gnus-summary-hide-thread))
9215 ;; If marked as read, go to next unread subject.
9217 ;; Go to next unread subject.
9218 (gnus-summary-next-subject 1 t)))
9219 (gnus-set-mode-line 'summary))
9221 ;; Summary sorting commands
9223 (defun gnus-summary-sort-by-number (&optional reverse)
9224 "Sort the summary buffer by article number.
9225 Argument REVERSE means reverse order."
9227 (gnus-summary-sort 'number reverse))
9229 (defun gnus-summary-sort-by-author (&optional reverse)
9230 "Sort the summary buffer by author name alphabetically.
9231 If `case-fold-search' is non-nil, case of letters is ignored.
9232 Argument REVERSE means reverse order."
9234 (gnus-summary-sort 'author reverse))
9236 (defun gnus-summary-sort-by-subject (&optional reverse)
9237 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
9238 If `case-fold-search' is non-nil, case of letters is ignored.
9239 Argument REVERSE means reverse order."
9241 (gnus-summary-sort 'subject reverse))
9243 (defun gnus-summary-sort-by-date (&optional reverse)
9244 "Sort the summary buffer by date.
9245 Argument REVERSE means reverse order."
9247 (gnus-summary-sort 'date reverse))
9249 (defun gnus-summary-sort-by-score (&optional reverse)
9250 "Sort the summary buffer by score.
9251 Argument REVERSE means reverse order."
9253 (gnus-summary-sort 'score reverse))
9255 (defun gnus-summary-sort-by-lines (&optional reverse)
9256 "Sort the summary buffer by the number of lines.
9257 Argument REVERSE means reverse order."
9259 (gnus-summary-sort 'lines reverse))
9261 (defun gnus-summary-sort-by-chars (&optional reverse)
9262 "Sort the summary buffer by article length.
9263 Argument REVERSE means reverse order."
9265 (gnus-summary-sort 'chars reverse))
9267 (defun gnus-summary-sort (predicate reverse)
9268 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
9269 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
9270 (article (intern (format "gnus-article-sort-by-%s" predicate)))
9271 (gnus-thread-sort-functions
9276 (gnus-sort-gathered-threads-function
9277 gnus-thread-sort-functions)
9278 (gnus-article-sort-functions
9284 (gnus-summary-prepare-hook nil))
9285 ;; We do the sorting by regenerating the threads.
9286 (gnus-summary-prepare)
9287 ;; Hide subthreads if needed.
9288 (when (and gnus-show-threads gnus-thread-hide-subtree)
9289 (gnus-summary-hide-all-threads))))
9291 ;; Summary saving commands.
9293 (defun gnus-summary-save-article (&optional n not-saved)
9294 "Save the current article using the default saver function.
9295 If N is a positive number, save the N next articles.
9296 If N is a negative number, save the N previous articles.
9297 If N is nil and any articles have been marked with the process mark,
9298 save those articles instead.
9299 The variable `gnus-default-article-saver' specifies the saver function."
9301 (let* ((articles (gnus-summary-work-articles n))
9302 (save-buffer (save-excursion
9303 (nnheader-set-temp-buffer " *Gnus Save*")))
9304 (num (length articles))
9306 (dolist (article articles)
9307 (setq header (gnus-summary-article-header article))
9308 (if (not (vectorp header))
9309 ;; This is a pseudo-article.
9310 (if (assq 'name header)
9311 (gnus-copy-file (cdr (assq 'name header)))
9312 (gnus-message 1 "Article %d is unsaveable" article))
9313 ;; This is a real article.
9314 (save-window-excursion
9315 (gnus-summary-select-article t nil nil article))
9317 (set-buffer save-buffer)
9319 (insert-buffer-substring gnus-original-article-buffer))
9320 (setq file (gnus-article-save save-buffer file num))
9321 (gnus-summary-remove-process-mark article)
9323 (gnus-summary-set-saved-mark article))))
9324 (gnus-kill-buffer save-buffer)
9325 (gnus-summary-position-point)
9326 (gnus-set-mode-line 'summary)
9329 (defun gnus-summary-pipe-output (&optional arg)
9330 "Pipe the current article to a subprocess.
9331 If N is a positive number, pipe the N next articles.
9332 If N is a negative number, pipe the N previous articles.
9333 If N is nil and any articles have been marked with the process mark,
9334 pipe those articles instead."
9337 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
9338 (gnus-summary-save-article arg t))
9339 (gnus-configure-windows 'pipe))
9341 (defun gnus-summary-save-article-mail (&optional arg)
9342 "Append the current article to an mail file.
9343 If N is a positive number, save the N next articles.
9344 If N is a negative number, save the N previous articles.
9345 If N is nil and any articles have been marked with the process mark,
9346 save those articles instead."
9349 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
9350 (gnus-summary-save-article arg)))
9352 (defun gnus-summary-save-article-rmail (&optional arg)
9353 "Append the current article to an rmail file.
9354 If N is a positive number, save the N next articles.
9355 If N is a negative number, save the N previous articles.
9356 If N is nil and any articles have been marked with the process mark,
9357 save those articles instead."
9360 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
9361 (gnus-summary-save-article arg)))
9363 (defun gnus-summary-save-article-file (&optional arg)
9364 "Append the current article to a file.
9365 If N is a positive number, save the N next articles.
9366 If N is a negative number, save the N previous articles.
9367 If N is nil and any articles have been marked with the process mark,
9368 save those articles instead."
9371 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
9372 (gnus-summary-save-article arg)))
9374 (defun gnus-summary-write-article-file (&optional arg)
9375 "Write the current article to a file, deleting the previous file.
9376 If N is a positive number, save the N next articles.
9377 If N is a negative number, save the N previous articles.
9378 If N is nil and any articles have been marked with the process mark,
9379 save those articles instead."
9382 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
9383 (gnus-summary-save-article arg)))
9385 (defun gnus-summary-save-article-body-file (&optional arg)
9386 "Append the current article body to a file.
9387 If N is a positive number, save the N next articles.
9388 If N is a negative number, save the N previous articles.
9389 If N is nil and any articles have been marked with the process mark,
9390 save those articles instead."
9393 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
9394 (gnus-summary-save-article arg)))
9396 (defun gnus-summary-pipe-message (program)
9397 "Pipe the current article through PROGRAM."
9398 (interactive "sProgram: ")
9399 (gnus-summary-select-article)
9400 (let ((mail-header-separator ""))
9401 (gnus-eval-in-buffer-window gnus-article-buffer
9404 (let ((start (window-start))
9406 (message-pipe-buffer-body program)
9407 (set-window-start (get-buffer-window (current-buffer)) start))))))
9409 (defun gnus-get-split-value (methods)
9410 "Return a value based on the split METHODS."
9411 (let (split-name method result match)
9414 (set-buffer gnus-original-article-buffer)
9416 (nnheader-narrow-to-headers)
9417 (while (and methods (not split-name))
9418 (goto-char (point-min))
9419 (setq method (pop methods))
9420 (setq match (car method))
9423 ;; Regular expression.
9425 (re-search-forward match nil t)))
9426 ((gnus-functionp match)
9430 (setq result (funcall match gnus-newsgroup-name))))
9435 (setq result (eval match)))))
9436 (setq split-name (cdr method))
9437 (cond ((stringp result)
9438 (push (expand-file-name
9439 result gnus-article-save-directory)
9442 (setq split-name (append result split-name)))))))))
9443 (nreverse split-name)))
9445 (defun gnus-valid-move-group-p (group)
9448 (symbol-value group)
9449 (gnus-get-function (gnus-find-method-for-group
9450 (symbol-name group)) 'request-accept-article t)))
9452 (defun gnus-read-move-group-name (prompt default articles prefix)
9453 "Read a group name."
9454 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
9455 (minibuffer-confirm-incomplete nil) ; XEmacs
9459 (if (> (length articles) 1)
9460 (format "these %d articles" (length articles))
9465 (gnus-completing-read default prom
9467 'gnus-valid-move-group-p
9469 'gnus-group-history))
9470 ((= 1 (length split-name))
9471 (gnus-completing-read (car split-name) prom
9473 'gnus-valid-move-group-p
9475 'gnus-group-history))
9477 (gnus-completing-read nil prom
9478 (mapcar (lambda (el) (list el))
9479 (nreverse split-name))
9481 'gnus-group-history))))
9482 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
9484 (if (or (string= to-newsgroup "")
9485 (string= to-newsgroup prefix))
9486 (setq to-newsgroup default))
9487 (unless to-newsgroup
9488 (error "No group name entered"))
9489 (or (gnus-active to-newsgroup)
9490 (gnus-activate-group to-newsgroup nil nil to-method)
9491 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
9493 (or (and (gnus-request-create-group to-newsgroup to-method)
9494 (gnus-activate-group
9495 to-newsgroup nil nil to-method)
9496 (gnus-subscribe-group to-newsgroup))
9497 (error "Couldn't create group %s" to-newsgroup)))
9498 (error "No such group: %s" to-newsgroup)))
9501 (defun gnus-summary-save-parts (type dir n &optional reverse)
9502 "Save parts matching TYPE to DIR.
9503 If REVERSE, save parts that do not match TYPE."
9505 (list (read-string "Save parts of type: "
9506 (or (car gnus-summary-save-parts-type-history)
9507 gnus-summary-save-parts-default-mime)
9508 'gnus-summary-save-parts-type-history)
9509 (setq gnus-summary-save-parts-last-directory
9510 (read-file-name "Save to directory: "
9511 gnus-summary-save-parts-last-directory
9513 current-prefix-arg))
9514 (gnus-summary-iterate n
9515 (let ((gnus-display-mime-function nil)
9516 (gnus-inhibit-treatment t))
9517 (gnus-summary-select-article))
9519 (set-buffer gnus-article-buffer)
9520 (let ((handles (or gnus-article-mime-handles
9521 (mm-dissect-buffer) (mm-uu-dissect))))
9523 (gnus-summary-save-parts-1 type dir handles reverse)
9524 (unless gnus-article-mime-handles ;; Don't destroy this case.
9525 (mm-destroy-parts handles)))))))
9527 (defun gnus-summary-save-parts-1 (type dir handle reverse)
9528 (if (stringp (car handle))
9529 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
9532 (not (string-match type (mm-handle-media-type handle)))
9533 (string-match type (mm-handle-media-type handle)))
9534 (let ((file (expand-file-name
9535 (file-name-nondirectory
9537 (mail-content-type-get
9538 (mm-handle-disposition handle) 'filename)
9539 (concat gnus-newsgroup-name
9540 "." (number-to-string
9541 (cdr gnus-article-current)))))
9543 (unless (file-exists-p file)
9544 (mm-save-part-to-file handle file))))))
9546 ;; Summary extract commands
9548 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
9549 (let ((buffer-read-only nil)
9550 (article (gnus-summary-article-number))
9552 (unless (gnus-summary-goto-subject article)
9553 (error "No such article: %d" article))
9554 (gnus-summary-position-point)
9555 ;; If all commands are to be bunched up on one line, we collect
9557 (unless gnus-view-pseudos-separately
9558 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
9561 (setq action (cdr (assq 'action (car ps))))
9562 (setq files (list (cdr (assq 'name (car ps)))))
9563 (while (and ps (cdr ps)
9564 (string= (or action "1")
9565 (or (cdr (assq 'action (cadr ps))) "2")))
9566 (push (cdr (assq 'name (cadr ps))) files)
9567 (setcdr ps (cddr ps)))
9569 (when (not (string-match "%s" action))
9572 (when (assq 'execute (car ps))
9573 (setcdr (assq 'execute (car ps))
9574 (funcall (if (string-match "%s" action)
9583 (setq ps (cdr ps)))))
9584 (if (and gnus-view-pseudos (not not-view))
9586 (when (assq 'execute (car pslist))
9587 (gnus-execute-command (cdr (assq 'execute (car pslist)))
9588 (eq gnus-view-pseudos 'not-confirm)))
9589 (setq pslist (cdr pslist)))
9592 (setq after-article (or (cdr (assq 'article (car pslist)))
9593 (gnus-summary-article-number)))
9594 (gnus-summary-goto-subject after-article)
9597 (insert " " (file-name-nondirectory
9598 (cdr (assq 'name (car pslist))))
9599 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
9601 (forward-line -1) ; back to `b'
9602 (gnus-add-text-properties
9603 b (1- e) (list 'gnus-number gnus-reffed-article-number
9604 gnus-mouse-face-prop gnus-mouse-face))
9606 after-article gnus-reffed-article-number
9607 gnus-unread-mark b (car pslist) 0 (- e b))
9608 (push gnus-reffed-article-number gnus-newsgroup-unreads)
9609 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
9610 (setq pslist (cdr pslist)))))))
9612 (defun gnus-pseudos< (p1 p2)
9613 (let ((c1 (cdr (assq 'action p1)))
9614 (c2 (cdr (assq 'action p2))))
9615 (and c1 c2 (string< c1 c2))))
9617 (defun gnus-request-pseudo-article (props)
9618 (cond ((assq 'execute props)
9619 (gnus-execute-command (cdr (assq 'execute props)))))
9620 (let ((gnus-current-article (gnus-summary-article-number)))
9621 (gnus-run-hooks 'gnus-mark-article-hook)))
9623 (defun gnus-execute-command (command &optional automatic)
9625 (gnus-article-setup-buffer)
9626 (set-buffer gnus-article-buffer)
9627 (setq buffer-read-only nil)
9628 (let ((command (if automatic command
9629 (read-string "Command: " (cons command 0)))))
9631 (insert "$ " command "\n\n")
9632 (if gnus-view-pseudo-asynchronously
9633 (start-process "gnus-execute" (current-buffer) shell-file-name
9634 shell-command-switch command)
9635 (call-process shell-file-name nil t nil
9636 shell-command-switch command)))))
9638 ;; Summary kill commands.
9640 (defun gnus-summary-edit-global-kill (article)
9641 "Edit the \"global\" kill file."
9642 (interactive (list (gnus-summary-article-number)))
9643 (gnus-group-edit-global-kill article))
9645 (defun gnus-summary-edit-local-kill ()
9646 "Edit a local kill file applied to the current newsgroup."
9648 (setq gnus-current-headers (gnus-summary-article-header))
9649 (gnus-group-edit-local-kill
9650 (gnus-summary-article-number) gnus-newsgroup-name))
9654 (defun gnus-read-header (id &optional header)
9655 "Read the headers of article ID and enter them into the Gnus system."
9656 (let ((group gnus-newsgroup-name)
9657 (gnus-override-method
9659 gnus-override-method
9660 (and (gnus-news-group-p gnus-newsgroup-name)
9661 (car (gnus-refer-article-methods)))))
9663 ;; First we check to see whether the header in question is already
9666 ;; This is a Message-ID.
9667 (setq header (or header (gnus-id-to-header id)))
9668 ;; This is an article number.
9669 (setq header (or header (gnus-summary-article-header id))))
9671 (not (gnus-summary-article-sparse-p (mail-header-number header))))
9672 ;; We have found the header.
9674 ;; If this is a sparse article, we have to nix out its
9675 ;; previous entry in the thread hashtb.
9677 (gnus-summary-article-sparse-p (mail-header-number header)))
9678 (let* ((parent (gnus-parent-id (mail-header-references header)))
9679 (thread (and parent (gnus-id-to-thread parent))))
9681 (delq (assq header thread) thread))))
9682 ;; We have to really fetch the header to this article.
9684 (set-buffer nntp-server-buffer)
9685 (when (setq where (gnus-request-head id group))
9686 (nnheader-fold-continuation-lines)
9687 (goto-char (point-max))
9689 (goto-char (point-min))
9693 ((cdr where) (cdr where))
9694 (header (mail-header-number header))
9695 (t gnus-reffed-article-number))
9697 (insert " Article retrieved.\n"))
9699 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
9700 () ; Malformed head.
9701 (unless (gnus-summary-article-sparse-p (mail-header-number header))
9702 (when (and (stringp id)
9703 (not (string= (gnus-group-real-name group)
9705 ;; If we fetched by Message-ID and the article came
9706 ;; from a different group, we fudge some bogus article
9707 ;; numbers for this article.
9708 (mail-header-set-number header gnus-reffed-article-number))
9710 (set-buffer gnus-summary-buffer)
9711 (decf gnus-reffed-article-number)
9712 (gnus-remove-header (mail-header-number header))
9713 (push header gnus-newsgroup-headers)
9714 (setq gnus-current-headers header)
9715 (push (mail-header-number header) gnus-newsgroup-limit)))
9718 (defun gnus-remove-header (number)
9719 "Remove header NUMBER from `gnus-newsgroup-headers'."
9720 (if (and gnus-newsgroup-headers
9721 (= number (mail-header-number (car gnus-newsgroup-headers))))
9722 (pop gnus-newsgroup-headers)
9723 (let ((headers gnus-newsgroup-headers))
9724 (while (and (cdr headers)
9725 (not (= number (mail-header-number (cadr headers)))))
9728 (setcdr headers (cddr headers))))))
9731 ;;; summary highlights
9734 (defun gnus-highlight-selected-summary ()
9735 "Highlight selected article in summary buffer."
9736 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
9737 (when gnus-summary-selected-face
9739 (let* ((beg (progn (beginning-of-line) (point)))
9740 (end (progn (end-of-line) (point)))
9741 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
9742 (from (if (get-text-property beg gnus-mouse-face-prop)
9744 (or (next-single-property-change
9745 beg gnus-mouse-face-prop nil end)
9750 (or (next-single-property-change
9751 from gnus-mouse-face-prop nil end)
9753 ;; If no mouse-face prop on line we will have to = from = end,
9754 ;; so we highlight the entire line instead.
9755 (when (= (+ to 2) from)
9758 (if gnus-newsgroup-selected-overlay
9759 ;; Move old overlay.
9761 gnus-newsgroup-selected-overlay from to (current-buffer))
9762 ;; Create new overlay.
9764 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
9765 'face gnus-summary-selected-face))))))
9767 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
9768 (defun gnus-summary-highlight-line ()
9769 "Highlight current line according to `gnus-summary-highlight'."
9770 (let* ((list gnus-summary-highlight)
9772 (end (progn (end-of-line) (point)))
9773 ;; now find out where the line starts and leave point there.
9774 (beg (progn (beginning-of-line) (point)))
9775 (article (gnus-summary-article-number))
9776 (score (or (cdr (assq (or article gnus-current-article)
9777 gnus-newsgroup-scored))
9778 gnus-summary-default-score 0))
9779 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
9780 (inhibit-read-only t))
9781 ;; Eval the cars of the lists until we find a match.
9782 (let ((default gnus-summary-default-score))
9784 (not (eval (caar list))))
9785 (setq list (cdr list))))
9786 (let ((face (cdar list)))
9787 (unless (eq face (get-text-property beg 'face))
9788 (gnus-put-text-property-excluding-characters-with-faces
9790 (setq face (if (boundp face) (symbol-value face) face)))
9791 (when gnus-summary-highlight-line-function
9792 (funcall gnus-summary-highlight-line-function article face))))
9795 (defun gnus-update-read-articles (group unread &optional compute)
9796 "Update the list of read articles in GROUP."
9797 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
9798 (entry (gnus-gethash group gnus-newsrc-hashtb))
9799 (info (nth 2 entry))
9801 (unread (sort (copy-sequence unread) '<))
9803 (if (or (not info) (not active))
9804 ;; There is no info on this group if it was, in fact,
9805 ;; killed. Gnus stores no information on killed groups, so
9806 ;; there's nothing to be done.
9807 ;; One could store the information somewhere temporarily,
9808 ;; perhaps... Hmmm...
9810 ;; Remove any negative articles numbers.
9811 (while (and unread (< (car unread) 0))
9812 (setq unread (cdr unread)))
9813 ;; Remove any expired article numbers
9814 (while (and unread (< (car unread) (car active)))
9815 (setq unread (cdr unread)))
9816 ;; Compute the ranges of read articles by looking at the list of
9819 (when (/= (car unread) prev)
9820 (push (if (= prev (1- (car unread))) prev
9821 (cons prev (1- (car unread))))
9823 (setq prev (1+ (car unread)))
9824 (setq unread (cdr unread)))
9825 (when (<= prev (cdr active))
9826 (push (cons prev (cdr active)) read))
9827 (setq read (if (> (length read) 1) (nreverse read) read))
9832 ;; Propagate the read marks to the backend.
9833 (when (gnus-check-backend-function 'request-set-mark group)
9834 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
9835 (add (gnus-remove-from-range read (gnus-info-read info))))
9837 (unless (gnus-check-group group)
9838 (error "Can't open server for %s" group))
9839 (gnus-request-set-mark
9840 group (delq nil (list (if add (list add 'add '(read)))
9841 (if del (list del 'del '(read))))))
9843 `(gnus-request-set-mark
9846 (if del (list del 'add '(read)))
9847 (if add (list add 'del '(read))))))))))
9848 (set-buffer gnus-group-buffer)
9851 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
9852 (gnus-info-set-read ',info ',(gnus-info-read info))
9853 (gnus-get-unread-articles-in-group ',info
9854 (gnus-active ,group))
9855 (gnus-group-update-group ,group t)
9857 ;; Enter this list into the group info.
9858 (gnus-info-set-read info read)
9859 ;; Set the number of unread articles in gnus-newsrc-hashtb.
9860 (gnus-get-unread-articles-in-group info (gnus-active group))
9863 (defun gnus-offer-save-summaries ()
9864 "Offer to save all active summary buffers."
9866 (let ((buflist (buffer-list))
9868 ;; Go through all buffers and find all summaries.
9870 (and (setq bufname (buffer-name (car buflist)))
9871 (string-match "Summary" bufname)
9873 (set-buffer bufname)
9874 ;; We check that this is, indeed, a summary buffer.
9875 (and (eq major-mode 'gnus-summary-mode)
9876 ;; Also make sure this isn't bogus.
9877 gnus-newsgroup-prepared
9878 ;; Also make sure that this isn't a dead summary buffer.
9879 (not gnus-dead-summary-mode)))
9880 (push bufname buffers))
9881 (setq buflist (cdr buflist)))
9882 ;; Go through all these summary buffers and offer to save them.
9885 "Update summary buffer %s? "
9887 (switch-to-buffer buf)
9888 (gnus-summary-exit))
9891 (defun gnus-summary-setup-default-charset ()
9892 "Setup newsgroup default charset."
9893 (if (equal gnus-newsgroup-name "nndraft:drafts")
9894 (setq gnus-newsgroup-charset nil)
9895 (let* ((name (and gnus-newsgroup-name
9896 (gnus-group-real-name gnus-newsgroup-name)))
9898 (or gnus-newsgroup-ephemeral-ignored-charsets
9900 (and gnus-newsgroup-name
9901 (or (gnus-group-find-parameter gnus-newsgroup-name
9902 'ignored-charsets t)
9903 (let ((alist gnus-group-ignored-charsets-alist)
9904 elem (charsets nil))
9905 (while (setq elem (pop alist))
9907 (string-match (car elem) name))
9909 charsets (cdr elem))))
9911 gnus-newsgroup-ignored-charsets))))
9912 (setq gnus-newsgroup-charset
9913 (or gnus-newsgroup-ephemeral-charset
9914 (and gnus-newsgroup-name
9915 (or (gnus-group-find-parameter gnus-newsgroup-name 'charset)
9916 (let ((alist gnus-group-charset-alist)
9918 (while (setq elem (pop alist))
9920 (string-match (car elem) name))
9922 charset (cadr elem))))
9924 gnus-default-charset))
9925 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
9926 ignored-charsets))))
9932 (defun gnus-summary-display-buttonized (&optional show-all-parts)
9933 "Display the current article buffer fully MIME-buttonized.
9934 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
9935 treated as multipart/mixed."
9938 (let ((gnus-unbuttonized-mime-types nil)
9939 (gnus-mime-display-multipart-as-mixed show-all-parts))
9940 (gnus-summary-show-article)))
9942 (defun gnus-summary-repair-multipart (article)
9943 "Add a Content-Type header to a multipart article without one."
9944 (interactive (list (gnus-summary-article-number)))
9945 (gnus-with-article article
9946 (message-narrow-to-head)
9947 (message-remove-header "Mime-Version")
9948 (goto-char (point-max))
9949 (insert "Mime-Version: 1.0\n")
9951 (when (search-forward "\n--" nil t)
9952 (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
9953 (message-narrow-to-head)
9954 (message-remove-header "Content-Type")
9955 (goto-char (point-max))
9956 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
9959 (let (gnus-mark-article-hook)
9960 (gnus-summary-select-article t t nil article)))
9962 (defun gnus-summary-toggle-display-buttonized ()
9963 "Toggle the buttonizing of the article buffer."
9966 (if (setq gnus-inhibit-mime-unbuttonizing
9967 (not gnus-inhibit-mime-unbuttonizing))
9968 (let ((gnus-unbuttonized-mime-types nil))
9969 (gnus-summary-show-article))
9970 (gnus-summary-show-article)))
9973 ;;; Generic summary marking commands
9976 (defvar gnus-summary-marking-alist
9977 '((read gnus-del-mark "d")
9978 (unread gnus-unread-mark "u")
9979 (ticked gnus-ticked-mark "!")
9980 (dormant gnus-dormant-mark "?")
9981 (expirable gnus-expirable-mark "e"))
9982 "An alist of names/marks/keystrokes.")
9984 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
9985 (defvar gnus-summary-mark-map)
9987 (defun gnus-summary-make-all-marking-commands ()
9988 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
9989 (dolist (elem gnus-summary-marking-alist)
9990 (apply 'gnus-summary-make-marking-command elem)))
9992 (defun gnus-summary-make-marking-command (name mark keystroke)
9993 (let ((map (make-sparse-keymap)))
9994 (define-key gnus-summary-generic-mark-map keystroke map)
9995 (dolist (lway `((next "next" next nil "n")
9996 (next-unread "next unread" next t "N")
9997 (prev "previous" prev nil "p")
9998 (prev-unread "previous unread" prev t "P")
9999 (nomove "" nil nil ,keystroke)))
10000 (let ((func (gnus-summary-make-marking-command-1
10001 mark (car lway) lway name)))
10002 (setq func (eval func))
10003 (define-key map (nth 4 lway) func)))))
10005 (defun gnus-summary-make-marking-command-1 (mark way lway name)
10007 (format "gnus-summary-put-mark-as-%s%s"
10008 name (if (eq way 'nomove)
10010 (concat "-" (symbol-name way)))))
10013 "Mark the current article as %s%s.
10014 If N, the prefix, then repeat N times.
10015 If N is negative, move in reverse order.
10016 The difference between N and the actual number of articles marked is
10020 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
10022 (defun gnus-summary-generic-mark (n mark move unread)
10023 "Mark N articles with MARK."
10024 (unless (eq major-mode 'gnus-summary-mode)
10025 (error "This command can only be used in the summary buffer"))
10026 (gnus-summary-show-thread)
10029 ((eq move 'next) 1)
10030 ((eq move 'prev) -1)
10032 (if (zerop nummove)
10036 nummove (* -1 nummove))))
10037 (while (and (> n 0)
10038 (gnus-summary-mark-article nil mark)
10039 (zerop (gnus-summary-next-subject nummove unread t)))
10042 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
10043 (gnus-summary-recenter)
10044 (gnus-summary-position-point)
10045 (gnus-set-mode-line 'summary)
10048 (gnus-summary-make-all-marking-commands)
10050 (gnus-ems-redefine)
10052 (provide 'gnus-sum)
10054 (run-hooks 'gnus-sum-load-hook)
10056 ;;; gnus-sum.el ends here