1 ;;; gnus-sum.el --- summary mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
29 (eval-when-compile (require 'cl))
40 ;; (require 'gnus-art)
42 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
43 (autoload 'gnus-cache-write-active "gnus-cache")
44 (autoload 'gnus-mailing-list-insinuate "gnus-ml" nil t)
45 (autoload 'turn-on-gnus-mailing-list-mode "gnus-ml" nil t)
46 (autoload 'mm-uu-dissect "mm-uu")
48 (defcustom gnus-kill-summary-on-exit t
49 "*If non-nil, kill the summary buffer when you exit from it.
50 If nil, the summary will become a \"*Dead Summary*\" buffer, and
51 it will be killed sometime later."
52 :group 'gnus-summary-exit
55 (defcustom gnus-fetch-old-headers nil
56 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
57 If an unread article in the group refers to an older, already read (or
58 just marked as read) article, the old article will not normally be
59 displayed in the Summary buffer. If this variable is non-nil, Gnus
60 will attempt to grab the headers to the old articles, and thereby
61 build complete threads. If it has the value `some', only enough
62 headers to connect otherwise loose threads will be displayed. This
63 variable can also be a number. In that case, no more than that number
64 of old headers will be fetched. If it has the value `invisible', all
65 old headers will be fetched, but none will be displayed.
67 The server has to support NOV for any of this to work."
69 :type '(choice (const :tag "off" nil)
72 (sexp :menu-tag "other" t)))
74 (defcustom gnus-refer-thread-limit 200
75 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
76 If t, fetch all the available old headers."
79 (sexp :menu-tag "other" t)))
81 (defcustom gnus-summary-make-false-root 'adopt
82 "*nil means that Gnus won't gather loose threads.
83 If the root of a thread has expired or been read in a previous
84 session, the information necessary to build a complete thread has been
85 lost. Instead of having many small sub-threads from this original thread
86 scattered all over the summary buffer, Gnus can gather them.
88 If non-nil, Gnus will try to gather all loose sub-threads from an
89 original thread into one large thread.
91 If this variable is non-nil, it should be one of `none', `adopt',
94 If this variable is `none', Gnus will not make a false root, but just
95 present the sub-threads after another.
96 If this variable is `dummy', Gnus will create a dummy root that will
97 have all the sub-threads as children.
98 If this variable is `adopt', Gnus will make one of the \"children\"
99 the parent and mark all the step-children as such.
100 If this variable is `empty', the \"children\" are printed with empty
101 subject fields. (Or rather, they will be printed with a string
102 given by the `gnus-summary-same-subject' variable.)"
104 :type '(choice (const :tag "off" nil)
110 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
111 "*A regexp to match subjects to be excluded from loose thread gathering.
112 As loose thread gathering is done on subjects only, that means that
113 there can be many false gatherings performed. By rooting out certain
114 common subjects, gathering might become saner."
118 (defcustom gnus-summary-gather-subject-limit nil
119 "*Maximum length of subject comparisons when gathering loose threads.
120 Use nil to compare full subjects. Setting this variable to a low
121 number will help gather threads that have been corrupted by
122 newsreaders chopping off subject lines, but it might also mean that
123 unrelated articles that have subject that happen to begin with the
124 same few characters will be incorrectly gathered.
126 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
129 :type '(choice (const :tag "off" nil)
131 (sexp :menu-tag "on" t)))
133 (defcustom gnus-simplify-subject-functions nil
134 "List of functions taking a string argument that simplify subjects.
135 The functions are applied recursively.
137 Useful functions to put in this list include: `gnus-simplify-subject-re',
138 `gnus-simplify-subject-fuzzy' and `gnus-simplify-whitespace'."
140 :type '(repeat function))
142 (defcustom gnus-simplify-ignored-prefixes nil
143 "*Regexp, matches for which are removed from subject lines when simplifying fuzzily."
145 :type '(choice (const :tag "off" nil)
148 (defcustom gnus-build-sparse-threads nil
149 "*If non-nil, fill in the gaps in threads.
150 If `some', only fill in the gaps that are needed to tie loose threads
151 together. If `more', fill in all leaf nodes that Gnus can find. If
152 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
154 :type '(choice (const :tag "off" nil)
157 (sexp :menu-tag "all" t)))
159 (defcustom gnus-summary-thread-gathering-function
160 'gnus-gather-threads-by-subject
161 "*Function used for gathering loose threads.
162 There are two pre-defined functions: `gnus-gather-threads-by-subject',
163 which only takes Subjects into consideration; and
164 `gnus-gather-threads-by-references', which compared the References
165 headers of the articles to find matches."
167 :type '(radio (function-item gnus-gather-threads-by-subject)
168 (function-item gnus-gather-threads-by-references)
169 (function :tag "other")))
171 (defcustom gnus-summary-same-subject ""
172 "*String indicating that the current article has the same subject as the previous.
173 This variable will only be used if the value of
174 `gnus-summary-make-false-root' is `empty'."
175 :group 'gnus-summary-format
178 (defcustom gnus-summary-goto-unread t
179 "*If t, many commands will go to the next unread article.
180 This applies to marking commands as well as other commands that
181 \"naturally\" select the next article, like, for instance, `SPC' at
182 the end of an article.
184 If nil, the marking commands do NOT go to the next unread article
185 (they go to the next article instead). If `never', commands that
186 usually go to the next unread article, will go to the next article,
187 whether it is read or not."
188 :group 'gnus-summary-marks
189 :link '(custom-manual "(gnus)Setting Marks")
190 :type '(choice (const :tag "off" nil)
192 (sexp :menu-tag "on" t)))
194 (defcustom gnus-summary-default-score 0
195 "*Default article score level.
196 All scores generated by the score files will be added to this score.
197 If this variable is nil, scoring will be disabled."
198 :group 'gnus-score-default
199 :type '(choice (const :tag "disable")
202 (defcustom gnus-summary-default-high-score 0
203 "*Default threshold for a high scored article.
204 An article will be highlighted as high scored if its score is greater
206 :group 'gnus-score-default
209 (defcustom gnus-summary-default-low-score 0
210 "*Default threshold for a low scored article.
211 An article will be highlighted as low scored if its score is smaller
213 :group 'gnus-score-default
216 (defcustom gnus-summary-zcore-fuzz 0
217 "*Fuzziness factor for the zcore in the summary buffer.
218 Articles with scores closer than this to `gnus-summary-default-score'
220 :group 'gnus-summary-format
223 (defcustom gnus-simplify-subject-fuzzy-regexp nil
224 "*Strings to be removed when doing fuzzy matches.
225 This can either be a regular expression or list of regular expressions
226 that will be removed from subject strings if fuzzy subject
227 simplification is selected."
229 :type '(repeat regexp))
231 (defcustom gnus-show-threads t
232 "*If non-nil, display threads in summary mode."
236 (defcustom gnus-thread-hide-subtree nil
237 "*If non-nil, hide all threads initially.
238 If threads are hidden, you have to run the command
239 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
240 to expose hidden threads."
244 (defcustom gnus-thread-hide-killed t
245 "*If non-nil, hide killed threads automatically."
249 (defcustom gnus-thread-ignore-subject t
250 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
251 If nil, articles that have different subjects from their parents will
252 start separate threads."
256 (defcustom gnus-thread-operation-ignore-subject t
257 "*If non-nil, subjects will be ignored when doing thread commands.
258 This affects commands like `gnus-summary-kill-thread' and
259 `gnus-summary-lower-thread'.
261 If this variable is nil, articles in the same thread with different
262 subjects will not be included in the operation in question. If this
263 variable is `fuzzy', only articles that have subjects that are fuzzily
264 equal will be included."
266 :type '(choice (const :tag "off" nil)
270 (defcustom gnus-thread-indent-level 4
271 "*Number that says how much each sub-thread should be indented."
275 (defcustom gnus-auto-extend-newsgroup t
276 "*If non-nil, extend newsgroup forward and backward when requested."
277 :group 'gnus-summary-choose
280 (defcustom gnus-auto-select-first t
281 "*If non-nil, select the article under point.
282 Which article this is is controlled by the `gnus-auto-select-subject'
285 If you want to prevent automatic selection of articles in some
286 newsgroups, set the variable to nil in `gnus-select-group-hook'."
287 :group 'gnus-group-select
288 :type '(choice (const :tag "none" nil)
289 (sexp :menu-tag "first" t)))
291 (defcustom gnus-auto-select-subject 'unread
292 "*Says what subject to place under point when entering a group.
294 This variable can either be the symbols `first' (place point on the
295 first subject), `unread' (place point on the subject line of the first
296 unread article), `best' (place point on the subject line of the
297 higest-scored article), `unseen' (place point on the subject line of
298 the first unseen article), or a function to be called to place point on
300 :group 'gnus-group-select
301 :type '(choice (const best)
306 (defcustom gnus-auto-select-next t
307 "*If non-nil, offer to go to the next group from the end of the previous.
308 If the value is t and the next newsgroup is empty, Gnus will exit
309 summary mode and go back to group mode. If the value is neither nil
310 nor t, Gnus will select the following unread newsgroup. In
311 particular, if the value is the symbol `quietly', the next unread
312 newsgroup will be selected without any confirmation, and if it is
313 `almost-quietly', the next group will be selected without any
314 confirmation if you are located on the last article in the group.
315 Finally, if this variable is `slightly-quietly', the `Z n' command
316 will go to the next group without confirmation."
317 :group 'gnus-summary-maneuvering
318 :type '(choice (const :tag "off" nil)
320 (const almost-quietly)
321 (const slightly-quietly)
322 (sexp :menu-tag "on" t)))
324 (defcustom gnus-auto-select-same nil
325 "*If non-nil, select the next article with the same subject.
326 If there are no more articles with the same subject, go to
327 the first unread article."
328 :group 'gnus-summary-maneuvering
331 (defcustom gnus-summary-check-current nil
332 "*If non-nil, consider the current article when moving.
333 The \"unread\" movement commands will stay on the same line if the
334 current article is unread."
335 :group 'gnus-summary-maneuvering
338 (defcustom gnus-auto-center-summary t
339 "*If non-nil, always center the current summary buffer.
340 In particular, if `vertical' do only vertical recentering. If non-nil
341 and non-`vertical', do both horizontal and vertical recentering."
342 :group 'gnus-summary-maneuvering
343 :type '(choice (const :tag "none" nil)
345 (integer :tag "height")
346 (sexp :menu-tag "both" t)))
348 (defcustom gnus-show-all-headers nil
349 "*If non-nil, don't hide any headers."
350 :group 'gnus-article-hiding
351 :group 'gnus-article-headers
354 (defcustom gnus-summary-ignore-duplicates nil
355 "*If non-nil, ignore articles with identical Message-ID headers."
359 (defcustom gnus-single-article-buffer t
360 "*If non-nil, display all articles in the same buffer.
361 If nil, each group will get its own article buffer."
362 :group 'gnus-article-various
365 (defcustom gnus-break-pages t
366 "*If non-nil, do page breaking on articles.
367 The page delimiter is specified by the `gnus-page-delimiter'
369 :group 'gnus-article-various
372 (defcustom gnus-move-split-methods nil
373 "*Variable used to suggest where articles are to be moved to.
374 It uses the same syntax as the `gnus-split-methods' variable.
375 However, whereas `gnus-split-methods' specifies file names as targets,
376 this variable specifies group names."
377 :group 'gnus-summary-mail
378 :type '(repeat (choice (list :value (fun) function)
379 (cons :value ("" "") regexp (repeat string))
382 (defcustom gnus-unread-mark ? ;Whitespace
383 "*Mark used for unread articles."
384 :group 'gnus-summary-marks
387 (defcustom gnus-ticked-mark ?!
388 "*Mark used for ticked articles."
389 :group 'gnus-summary-marks
392 (defcustom gnus-dormant-mark ??
393 "*Mark used for dormant articles."
394 :group 'gnus-summary-marks
397 (defcustom gnus-del-mark ?r
398 "*Mark used for del'd articles."
399 :group 'gnus-summary-marks
402 (defcustom gnus-read-mark ?R
403 "*Mark used for read articles."
404 :group 'gnus-summary-marks
407 (defcustom gnus-expirable-mark ?E
408 "*Mark used for expirable articles."
409 :group 'gnus-summary-marks
412 (defcustom gnus-killed-mark ?K
413 "*Mark used for killed articles."
414 :group 'gnus-summary-marks
417 (defcustom gnus-souped-mark ?F
418 "*Mark used for souped articles."
419 :group 'gnus-summary-marks
422 (defcustom gnus-kill-file-mark ?X
423 "*Mark used for articles killed by kill files."
424 :group 'gnus-summary-marks
427 (defcustom gnus-low-score-mark ?Y
428 "*Mark used for articles with a low score."
429 :group 'gnus-summary-marks
432 (defcustom gnus-catchup-mark ?C
433 "*Mark used for articles that are caught up."
434 :group 'gnus-summary-marks
437 (defcustom gnus-replied-mark ?A
438 "*Mark used for articles that have been replied to."
439 :group 'gnus-summary-marks
442 (defcustom gnus-forwarded-mark ?F
443 "*Mark used for articles that have been forwarded."
444 :group 'gnus-summary-marks
447 (defcustom gnus-recent-mark ?N
448 "*Mark used for articles that are recent."
449 :group 'gnus-summary-marks
452 (defcustom gnus-cached-mark ?*
453 "*Mark used for articles that are in the cache."
454 :group 'gnus-summary-marks
457 (defcustom gnus-saved-mark ?S
458 "*Mark used for articles that have been saved."
459 :group 'gnus-summary-marks
462 (defcustom gnus-unseen-mark ?.
463 "*Mark used for articles that haven't been seen."
464 :group 'gnus-summary-marks
467 (defcustom gnus-no-mark ? ;Whitespace
468 "*Mark used for articles that have no other secondary mark."
469 :group 'gnus-summary-marks
472 (defcustom gnus-ancient-mark ?O
473 "*Mark used for ancient articles."
474 :group 'gnus-summary-marks
477 (defcustom gnus-sparse-mark ?Q
478 "*Mark used for sparsely reffed articles."
479 :group 'gnus-summary-marks
482 (defcustom gnus-canceled-mark ?G
483 "*Mark used for canceled articles."
484 :group 'gnus-summary-marks
487 (defcustom gnus-duplicate-mark ?M
488 "*Mark used for duplicate articles."
489 :group 'gnus-summary-marks
492 (defcustom gnus-undownloaded-mark ?@
493 "*Mark used for articles that weren't downloaded."
494 :group 'gnus-summary-marks
497 (defcustom gnus-downloadable-mark ?%
498 "*Mark used for articles that are to be downloaded."
499 :group 'gnus-summary-marks
502 (defcustom gnus-unsendable-mark ?=
503 "*Mark used for articles that won't be sent."
504 :group 'gnus-summary-marks
507 (defcustom gnus-score-over-mark ?+
508 "*Score mark used for articles with high scores."
509 :group 'gnus-summary-marks
512 (defcustom gnus-score-below-mark ?-
513 "*Score mark used for articles with low scores."
514 :group 'gnus-summary-marks
517 (defcustom gnus-empty-thread-mark ? ;Whitespace
518 "*There is no thread under the article."
519 :group 'gnus-summary-marks
522 (defcustom gnus-not-empty-thread-mark ?=
523 "*There is a thread under the article."
524 :group 'gnus-summary-marks
527 (defcustom gnus-view-pseudo-asynchronously nil
528 "*If non-nil, Gnus will view pseudo-articles asynchronously."
529 :group 'gnus-extract-view
532 (defcustom gnus-auto-expirable-marks
533 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
534 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
535 gnus-souped-mark gnus-duplicate-mark)
536 "*The list of marks converted into expiration if a group is auto-expirable."
539 :type '(repeat character))
541 (defcustom gnus-inhibit-user-auto-expire t
542 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
547 (defcustom gnus-view-pseudos nil
548 "*If `automatic', pseudo-articles will be viewed automatically.
549 If `not-confirm', pseudos will be viewed automatically, and the user
550 will not be asked to confirm the command."
551 :group 'gnus-extract-view
552 :type '(choice (const :tag "off" nil)
554 (const not-confirm)))
556 (defcustom gnus-view-pseudos-separately t
557 "*If non-nil, one pseudo-article will be created for each file to be viewed.
558 If nil, all files that use the same viewing command will be given as a
559 list of parameters to that command."
560 :group 'gnus-extract-view
563 (defcustom gnus-insert-pseudo-articles t
564 "*If non-nil, insert pseudo-articles when decoding articles."
565 :group 'gnus-extract-view
568 (defcustom gnus-summary-dummy-line-format
570 "*The format specification for the dummy roots in the summary buffer.
571 It works along the same lines as a normal formatting string,
572 with some simple extensions.
575 :group 'gnus-threading
578 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
579 "*The format specification for the summary mode line.
580 It works along the same lines as a normal formatting string,
581 with some simple extensions:
584 %p Unprefixed group name
585 %A Current article number
586 %z Current article score
588 %U Number of unread articles in the group
589 %e Number of unselected articles in the group
590 %Z A string with unread/unselected article counts
591 %g Shortish group name
592 %S Subject of the current article
594 %s Current score file name
595 %d Number of dormant articles
596 %r Number of articles that have been marked as read in this session
597 %E Number of articles expunged by the score files"
598 :group 'gnus-summary-format
601 (defcustom gnus-list-identifiers nil
602 "Regexp that matches list identifiers to be removed from subject.
603 This can also be a list of regexps."
605 :group 'gnus-summary-format
606 :group 'gnus-article-hiding
607 :type '(choice (const :tag "none" nil)
609 (repeat :value (".*") regexp)))
611 (defcustom gnus-summary-mark-below 0
612 "*Mark all articles with a score below this variable as read.
613 This variable is local to each summary buffer and usually set by the
615 :group 'gnus-score-default
618 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
619 "*List of functions used for sorting articles in the summary buffer.
621 Each function takes two articles and returns non-nil if the first
622 article should be sorted before the other. If you use more than one
623 function, the primary sort function should be the last. You should
624 probably always include `gnus-article-sort-by-number' in the list of
625 sorting functions -- preferably first. Also note that sorting by date
626 is often much slower than sorting by number, and the sorting order is
627 very similar. (Sorting by date means sorting by the time the message
628 was sent, sorting by number means sorting by arrival time.)
630 Ready-made functions include `gnus-article-sort-by-number',
631 `gnus-article-sort-by-author', `gnus-article-sort-by-subject',
632 `gnus-article-sort-by-date' and `gnus-article-sort-by-score'.
634 When threading is turned on, the variable `gnus-thread-sort-functions'
635 controls how articles are sorted."
636 :group 'gnus-summary-sort
637 :type '(repeat (choice (function-item gnus-article-sort-by-number)
638 (function-item gnus-article-sort-by-author)
639 (function-item gnus-article-sort-by-subject)
640 (function-item gnus-article-sort-by-date)
641 (function-item gnus-article-sort-by-score)
642 (function :tag "other"))))
644 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
645 "*List of functions used for sorting threads in the summary buffer.
646 By default, threads are sorted by article number.
648 Each function takes two threads and returns non-nil if the first
649 thread should be sorted before the other. If you use more than one
650 function, the primary sort function should be the last. You should
651 probably always include `gnus-thread-sort-by-number' in the list of
652 sorting functions -- preferably first. Also note that sorting by date
653 is often much slower than sorting by number, and the sorting order is
654 very similar. (Sorting by date means sorting by the time the message
655 was sent, sorting by number means sorting by arrival time.)
657 Ready-made functions include `gnus-thread-sort-by-number',
658 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
659 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
660 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').
662 When threading is turned off, the variable
663 `gnus-article-sort-functions' controls how articles are sorted."
664 :group 'gnus-summary-sort
665 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
666 (function-item gnus-thread-sort-by-author)
667 (function-item gnus-thread-sort-by-subject)
668 (function-item gnus-thread-sort-by-date)
669 (function-item gnus-thread-sort-by-score)
670 (function-item gnus-thread-sort-by-total-score)
671 (function :tag "other"))))
673 (defcustom gnus-thread-score-function '+
674 "*Function used for calculating the total score of a thread.
676 The function is called with the scores of the article and each
677 subthread and should then return the score of the thread.
679 Some functions you can use are `+', `max', or `min'."
680 :group 'gnus-summary-sort
683 (defcustom gnus-summary-expunge-below nil
684 "All articles that have a score less than this variable will be expunged.
685 This variable is local to the summary buffers."
686 :group 'gnus-score-default
687 :type '(choice (const :tag "off" nil)
690 (defcustom gnus-thread-expunge-below nil
691 "All threads that have a total score less than this variable will be expunged.
692 See `gnus-thread-score-function' for en explanation of what a
695 This variable is local to the summary buffers."
696 :group 'gnus-threading
697 :group 'gnus-score-default
698 :type '(choice (const :tag "off" nil)
701 (defcustom gnus-summary-mode-hook nil
702 "*A hook for Gnus summary mode.
703 This hook is run before any variables are set in the summary buffer."
704 :options '(turn-on-gnus-mailing-list-mode gnus-pick-mode)
705 :group 'gnus-summary-various
708 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
709 (when (featurep 'xemacs)
710 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
711 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
712 (add-hook 'gnus-summary-mode-hook
713 'gnus-xmas-switch-horizontal-scrollbar-off))
715 (defcustom gnus-summary-menu-hook nil
716 "*Hook run after the creation of the summary mode menu."
717 :group 'gnus-summary-visual
720 (defcustom gnus-summary-exit-hook nil
721 "*A hook called on exit from the summary buffer.
722 It will be called with point in the group buffer."
723 :group 'gnus-summary-exit
726 (defcustom gnus-summary-prepare-hook nil
727 "*A hook called after the summary buffer has been generated.
728 If you want to modify the summary buffer, you can use this hook."
729 :group 'gnus-summary-various
732 (defcustom gnus-summary-prepared-hook nil
733 "*A hook called as the last thing after the summary buffer has been generated."
734 :group 'gnus-summary-various
737 (defcustom gnus-summary-generate-hook nil
738 "*A hook run just before generating the summary buffer.
739 This hook is commonly used to customize threading variables and the
741 :group 'gnus-summary-various
744 (defcustom gnus-select-group-hook nil
745 "*A hook called when a newsgroup is selected.
747 If you'd like to simplify subjects like the
748 `gnus-summary-next-same-subject' command does, you can use the
751 (setq gnus-select-group-hook
754 (mapcar (lambda (header)
755 (mail-header-set-subject
757 (gnus-simplify-subject
758 (mail-header-subject header) 're-only)))
759 gnus-newsgroup-headers))))"
760 :group 'gnus-group-select
763 (defcustom gnus-select-article-hook nil
764 "*A hook called when an article is selected."
765 :group 'gnus-summary-choose
768 (defcustom gnus-visual-mark-article-hook
769 (list 'gnus-highlight-selected-summary)
770 "*Hook run after selecting an article in the summary buffer.
771 It is meant to be used for highlighting the article in some way. It
772 is not run if `gnus-visual' is nil."
773 :group 'gnus-summary-visual
776 (defcustom gnus-parse-headers-hook nil
777 "*A hook called before parsing the headers."
781 (defcustom gnus-exit-group-hook nil
782 "*A hook called when exiting summary mode.
783 This hook is not called from the non-updating exit commands like `Q'."
787 (defcustom gnus-summary-update-hook
788 (list 'gnus-summary-highlight-line)
789 "*A hook called when a summary line is changed.
790 The hook will not be called if `gnus-visual' is nil.
792 The default function `gnus-summary-highlight-line' will
793 highlight the line according to the `gnus-summary-highlight'
795 :group 'gnus-summary-visual
798 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
799 "*A hook called when an article is selected for the first time.
800 The hook is intended to mark an article as read (or unread)
801 automatically when it is selected."
802 :group 'gnus-summary-choose
805 (defcustom gnus-group-no-more-groups-hook nil
806 "*A hook run when returning to group mode having no more (unread) groups."
807 :group 'gnus-group-select
810 (defcustom gnus-ps-print-hook nil
811 "*A hook run before ps-printing something from Gnus."
815 (defcustom gnus-summary-display-arrow
816 (and (fboundp 'display-graphic-p)
818 "*If non-nil, display an arrow highlighting the current article."
823 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
824 "Face used for highlighting the current article in the summary buffer."
825 :group 'gnus-summary-visual
828 (defcustom gnus-summary-highlight
829 '(((= mark gnus-canceled-mark)
830 . gnus-summary-cancelled-face)
831 ((and (> score default-high)
832 (or (= mark gnus-dormant-mark)
833 (= mark gnus-ticked-mark)))
834 . gnus-summary-high-ticked-face)
835 ((and (< score default-low)
836 (or (= mark gnus-dormant-mark)
837 (= mark gnus-ticked-mark)))
838 . gnus-summary-low-ticked-face)
839 ((or (= mark gnus-dormant-mark)
840 (= mark gnus-ticked-mark))
841 . gnus-summary-normal-ticked-face)
842 ((and (> score default-high) (= mark gnus-ancient-mark))
843 . gnus-summary-high-ancient-face)
844 ((and (< score default-low) (= mark gnus-ancient-mark))
845 . gnus-summary-low-ancient-face)
846 ((= mark gnus-ancient-mark)
847 . gnus-summary-normal-ancient-face)
848 ((and (> score default-high) (= mark gnus-unread-mark))
849 . gnus-summary-high-unread-face)
850 ((and (< score default-low) (= mark gnus-unread-mark))
851 . gnus-summary-low-unread-face)
852 ((= mark gnus-unread-mark)
853 . gnus-summary-normal-unread-face)
854 ((and (> score default-high) (memq mark (list gnus-downloadable-mark
855 gnus-undownloaded-mark)))
856 . gnus-summary-high-unread-face)
857 ((and (< score default-low) (memq mark (list gnus-downloadable-mark
858 gnus-undownloaded-mark)))
859 . gnus-summary-low-unread-face)
860 ((and (memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
861 (memq article gnus-newsgroup-unreads))
862 . gnus-summary-normal-unread-face)
863 ((memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
864 . gnus-summary-normal-read-face)
865 ((> score default-high)
866 . gnus-summary-high-read-face)
867 ((< score default-low)
868 . gnus-summary-low-read-face)
870 . gnus-summary-normal-read-face))
871 "*Controls the highlighting of summary buffer lines.
873 A list of (FORM . FACE) pairs. When deciding how a a particular
874 summary line should be displayed, each form is evaluated. The content
875 of the face field after the first true form is used. You can change
876 how those summary lines are displayed, by editing the face field.
878 You can use the following variables in the FORM field.
880 score: The article's score
881 default: The default article score.
882 default-high: The default score for high scored articles.
883 default-low: The default score for low scored articles.
884 below: The score below which articles are automatically marked as read.
885 mark: The articles mark."
886 :group 'gnus-summary-visual
887 :type '(repeat (cons (sexp :tag "Form" nil)
890 (defcustom gnus-alter-header-function nil
891 "Function called to allow alteration of article header structures.
892 The function is called with one parameter, the article header vector,
893 which it may alter in any way.")
895 (defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string
896 "Variable that says which function should be used to decode a string with encoded words.")
898 (defcustom gnus-extra-headers nil
899 "*Extra headers to parse."
902 :type '(repeat symbol))
904 (defcustom gnus-ignored-from-addresses
905 (and user-mail-address (regexp-quote user-mail-address))
906 "*Regexp of From headers that may be suppressed in favor of To headers."
911 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
912 "List of charsets that should be ignored.
913 When these charsets are used in the \"charset\" parameter, the
914 default charset will be used instead."
916 :type '(repeat symbol)
917 :group 'gnus-charset)
919 (gnus-define-group-parameter
923 "Return the ignored charsets of GROUP."
924 :variable gnus-group-ignored-charsets-alist
926 '(("alt\\.chinese\\.text" iso-8859-1))
928 "Alist of regexps (to match group names) and charsets that should be ignored.
929 When these charsets are used in the \"charset\" parameter, the
930 default charset will be used instead."
931 :variable-group gnus-charset
932 :variable-type '(repeat (cons (regexp :tag "Group")
934 :parameter-type '(choice :tag "Ignored charsets"
937 :parameter-document "\
938 List of charsets that should be ignored.
940 When these charsets are used in the \"charset\" parameter, the
941 default charset will be used instead.")
943 (defcustom gnus-group-highlight-words-alist nil
944 "Alist of group regexps and highlight regexps.
945 This variable uses the same syntax as `gnus-emphasis-alist'."
947 :type '(repeat (cons (regexp :tag "Group")
948 (repeat (list (regexp :tag "Highlight regexp")
949 (number :tag "Group for entire word" 0)
950 (number :tag "Group for displayed part" 0)
952 gnus-emphasis-highlight-words)))))
953 :group 'gnus-summary-visual)
955 (defcustom gnus-summary-show-article-charset-alist
957 "Alist of number and charset.
958 The article will be shown with the charset corresponding to the
960 For example: ((1 . cn-gb-2312) (2 . big5))."
962 :type '(repeat (cons (number :tag "Argument" 1)
963 (symbol :tag "Charset")))
964 :group 'gnus-charset)
966 (defcustom gnus-preserve-marks t
967 "Whether marks are preserved when moving, copying and respooling messages."
970 :group 'gnus-summary-marks)
972 (defcustom gnus-alter-articles-to-read-function nil
973 "Function to be called to alter the list of articles to be selected."
974 :type '(choice (const nil) function)
975 :group 'gnus-summary)
977 (defcustom gnus-orphan-score nil
978 "*All orphans get this score added. Set in the score file."
979 :group 'gnus-score-default
980 :type '(choice (const nil)
983 (defcustom gnus-summary-save-parts-default-mime "image/.*"
984 "*A regexp to match MIME parts when saving multiple parts of a message
985 with gnus-summary-save-parts (X m). This regexp will be used by default
986 when prompting the user for which type of files to save."
991 (defcustom gnus-summary-save-parts-default-mime "image/.*"
992 "*A regexp to match MIME parts when saving multiple parts of a message
993 with gnus-summary-save-parts (X m). This regexp will be used by default
994 when prompting the user for which type of files to save."
998 (defcustom gnus-read-all-available-headers nil
999 "Whether Gnus should parse all headers made available to it.
1000 This is mostly relevant for slow backends where the user may
1001 wish to widen the summary buffer to include all headers
1002 that were fetched. Say, for nnultimate groups."
1003 :group 'gnus-summary
1004 :type '(choice boolean regexp))
1006 (defcustom gnus-summary-muttprint-program "muttprint"
1007 "Command (and optional arguments) used to run Muttprint."
1008 :group 'gnus-summary
1011 ;;; Internal variables
1013 (defvar gnus-summary-display-cache nil)
1014 (defvar gnus-article-mime-handles nil)
1015 (defvar gnus-article-decoded-p nil)
1016 (defvar gnus-article-charset nil)
1017 (defvar gnus-article-ignored-charsets nil)
1018 (defvar gnus-scores-exclude-files nil)
1019 (defvar gnus-page-broken nil)
1020 (defvar gnus-inhibit-mime-unbuttonizing nil)
1022 (defvar gnus-original-article nil)
1023 (defvar gnus-article-internal-prepare-hook nil)
1024 (defvar gnus-newsgroup-process-stack nil)
1026 (defvar gnus-thread-indent-array nil)
1027 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1028 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1029 "Function called to sort the articles within a thread after it has been gathered together.")
1031 (defvar gnus-summary-save-parts-type-history nil)
1032 (defvar gnus-summary-save-parts-last-directory nil)
1034 (defvar gnus-summary-save-parts-type-history nil)
1035 (defvar gnus-summary-save-parts-last-directory nil)
1037 ;; Avoid highlighting in kill files.
1038 (defvar gnus-summary-inhibit-highlight nil)
1039 (defvar gnus-newsgroup-selected-overlay nil)
1040 (defvar gnus-inhibit-limiting nil)
1041 (defvar gnus-newsgroup-adaptive-score-file nil)
1042 (defvar gnus-current-score-file nil)
1043 (defvar gnus-current-move-group nil)
1044 (defvar gnus-current-copy-group nil)
1045 (defvar gnus-current-crosspost-group nil)
1046 (defvar gnus-newsgroup-display nil)
1048 (defvar gnus-newsgroup-dependencies nil)
1049 (defvar gnus-newsgroup-adaptive nil)
1050 (defvar gnus-summary-display-article-function nil)
1051 (defvar gnus-summary-highlight-line-function nil
1052 "Function called after highlighting a summary line.")
1054 (defvar gnus-summary-line-format-alist
1055 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1056 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1057 (?s gnus-tmp-subject-or-nil ?s)
1058 (?n gnus-tmp-name ?s)
1059 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1061 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1063 (?F gnus-tmp-from ?s)
1064 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1065 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1066 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1067 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1068 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1069 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1070 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1071 (?L gnus-tmp-lines ?s)
1072 (?I gnus-tmp-indentation ?s)
1073 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1074 (?R gnus-tmp-replied ?c)
1075 (?\[ gnus-tmp-opening-bracket ?c)
1076 (?\] gnus-tmp-closing-bracket ?c)
1077 (?\> (make-string gnus-tmp-level ? ) ?s)
1078 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1079 (?i gnus-tmp-score ?d)
1080 (?z gnus-tmp-score-char ?c)
1081 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1082 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1083 (?U gnus-tmp-unread ?c)
1084 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1086 (?t (gnus-summary-number-of-articles-in-thread
1087 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1089 (?e (gnus-summary-number-of-articles-in-thread
1090 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1092 (?u gnus-tmp-user-defined ?s)
1093 (?P (gnus-pick-line-number) ?d)
1094 (?B gnus-tmp-thread-tree-header-string ?s)
1095 (user-date (gnus-user-date
1096 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
1097 "An alist of format specifications that can appear in summary lines.
1098 These are paired with what variables they correspond with, along with
1099 the type of the variable (string, integer, character, etc).")
1101 (defvar gnus-summary-dummy-line-format-alist
1102 `((?S gnus-tmp-subject ?s)
1103 (?N gnus-tmp-number ?d)
1104 (?u gnus-tmp-user-defined ?s)))
1106 (defvar gnus-summary-mode-line-format-alist
1107 `((?G gnus-tmp-group-name ?s)
1108 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1109 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1110 (?A gnus-tmp-article-number ?d)
1111 (?Z gnus-tmp-unread-and-unselected ?s)
1112 (?V gnus-version ?s)
1113 (?U gnus-tmp-unread-and-unticked ?d)
1114 (?S gnus-tmp-subject ?s)
1115 (?e gnus-tmp-unselected ?d)
1116 (?u gnus-tmp-user-defined ?s)
1117 (?d (length gnus-newsgroup-dormant) ?d)
1118 (?t (length gnus-newsgroup-marked) ?d)
1119 (?r (length gnus-newsgroup-reads) ?d)
1120 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1121 (?E gnus-newsgroup-expunged-tally ?d)
1122 (?s (gnus-current-score-file-nondirectory) ?s)))
1124 (defvar gnus-last-search-regexp nil
1125 "Default regexp for article search command.")
1127 (defvar gnus-last-shell-command nil
1128 "Default shell command on article.")
1130 (defvar gnus-newsgroup-begin nil)
1131 (defvar gnus-newsgroup-end nil)
1132 (defvar gnus-newsgroup-last-rmail nil)
1133 (defvar gnus-newsgroup-last-mail nil)
1134 (defvar gnus-newsgroup-last-folder nil)
1135 (defvar gnus-newsgroup-last-file nil)
1136 (defvar gnus-newsgroup-auto-expire nil)
1137 (defvar gnus-newsgroup-active nil)
1139 (defvar gnus-newsgroup-data nil)
1140 (defvar gnus-newsgroup-data-reverse nil)
1141 (defvar gnus-newsgroup-limit nil)
1142 (defvar gnus-newsgroup-limits nil)
1144 (defvar gnus-newsgroup-unreads nil
1145 "List of unread articles in the current newsgroup.")
1147 (defvar gnus-newsgroup-unselected nil
1148 "List of unselected unread articles in the current newsgroup.")
1150 (defvar gnus-newsgroup-reads nil
1151 "Alist of read articles and article marks in the current newsgroup.")
1153 (defvar gnus-newsgroup-expunged-tally nil)
1155 (defvar gnus-newsgroup-marked nil
1156 "List of ticked articles in the current newsgroup (a subset of unread art).")
1158 (defvar gnus-newsgroup-killed nil
1159 "List of ranges of articles that have been through the scoring process.")
1161 (defvar gnus-newsgroup-cached nil
1162 "List of articles that come from the article cache.")
1164 (defvar gnus-newsgroup-saved nil
1165 "List of articles that have been saved.")
1167 (defvar gnus-newsgroup-kill-headers nil)
1169 (defvar gnus-newsgroup-replied nil
1170 "List of articles that have been replied to in the current newsgroup.")
1172 (defvar gnus-newsgroup-forwarded nil
1173 "List of articles that have been forwarded in the current newsgroup.")
1175 (defvar gnus-newsgroup-recent nil
1176 "List of articles that have are recent in the current newsgroup.")
1178 (defvar gnus-newsgroup-expirable nil
1179 "List of articles in the current newsgroup that can be expired.")
1181 (defvar gnus-newsgroup-processable nil
1182 "List of articles in the current newsgroup that can be processed.")
1184 (defvar gnus-newsgroup-downloadable nil
1185 "List of articles in the current newsgroup that can be processed.")
1187 (defvar gnus-newsgroup-undownloaded nil
1188 "List of articles in the current newsgroup that haven't been downloaded..")
1190 (defvar gnus-newsgroup-unsendable nil
1191 "List of articles in the current newsgroup that won't be sent.")
1193 (defvar gnus-newsgroup-bookmarks nil
1194 "List of articles in the current newsgroup that have bookmarks.")
1196 (defvar gnus-newsgroup-dormant nil
1197 "List of dormant articles in the current newsgroup.")
1199 (defvar gnus-newsgroup-unseen nil
1200 "List of unseen articles in the current newsgroup.")
1202 (defvar gnus-newsgroup-seen nil
1203 "Range of seen articles in the current newsgroup.")
1205 (defvar gnus-newsgroup-articles nil
1206 "List of articles in the current newsgroup.")
1208 (defvar gnus-newsgroup-scored nil
1209 "List of scored articles in the current newsgroup.")
1211 (defvar gnus-newsgroup-headers nil
1212 "List of article headers in the current newsgroup.")
1214 (defvar gnus-newsgroup-threads nil)
1216 (defvar gnus-newsgroup-prepared nil
1217 "Whether the current group has been prepared properly.")
1219 (defvar gnus-newsgroup-ancient nil
1220 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1222 (defvar gnus-newsgroup-sparse nil)
1224 (defvar gnus-current-article nil)
1225 (defvar gnus-article-current nil)
1226 (defvar gnus-current-headers nil)
1227 (defvar gnus-have-all-headers nil)
1228 (defvar gnus-last-article nil)
1229 (defvar gnus-newsgroup-history nil)
1230 (defvar gnus-newsgroup-charset nil)
1231 (defvar gnus-newsgroup-ephemeral-charset nil)
1232 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1234 (defvar gnus-article-before-search nil)
1236 (defconst gnus-summary-local-variables
1237 '(gnus-newsgroup-name
1238 gnus-newsgroup-begin gnus-newsgroup-end
1239 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1240 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1241 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1242 gnus-newsgroup-unselected gnus-newsgroup-marked
1243 gnus-newsgroup-reads gnus-newsgroup-saved
1244 gnus-newsgroup-replied gnus-newsgroup-forwarded
1245 gnus-newsgroup-recent
1246 gnus-newsgroup-expirable
1247 gnus-newsgroup-processable gnus-newsgroup-killed
1248 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1249 gnus-newsgroup-unsendable gnus-newsgroup-unseen
1250 gnus-newsgroup-seen gnus-newsgroup-articles
1251 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1252 gnus-newsgroup-headers gnus-newsgroup-threads
1253 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1254 gnus-current-article gnus-current-headers gnus-have-all-headers
1255 gnus-last-article gnus-article-internal-prepare-hook
1256 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1257 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1258 gnus-thread-expunge-below
1259 gnus-score-alist gnus-current-score-file
1260 (gnus-summary-expunge-below . global)
1261 (gnus-summary-mark-below . global)
1262 (gnus-orphan-score . global)
1263 gnus-newsgroup-active gnus-scores-exclude-files
1264 gnus-newsgroup-history gnus-newsgroup-ancient
1265 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1266 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1267 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1268 (gnus-newsgroup-expunged-tally . 0)
1269 gnus-cache-removable-articles gnus-newsgroup-cached
1270 gnus-newsgroup-data gnus-newsgroup-data-reverse
1271 gnus-newsgroup-limit gnus-newsgroup-limits
1272 gnus-newsgroup-charset gnus-newsgroup-display)
1273 "Variables that are buffer-local to the summary buffers.")
1275 (defvar gnus-newsgroup-variables nil
1276 "A list of variables that have separate values in different newsgroups.
1277 A list of newsgroup (summary buffer) local variables, or cons of
1278 variables and their default values (when the default values are not
1279 nil), that should be made global while the summary buffer is active.
1280 These variables can be used to set variables in the group parameters
1281 while still allowing them to affect operations done in other
1282 buffers. For example:
1284 \(setq gnus-newsgroup-variables
1285 '(message-use-followup-to
1286 (gnus-visible-headers .
1287 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1290 ;; Byte-compiler warning.
1291 (eval-when-compile (defvar gnus-article-mode-map))
1295 (defvar gnus-decode-encoded-word-methods
1296 '(mail-decode-encoded-word-string)
1297 "List of methods used to decode encoded words.
1299 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
1300 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1301 \(REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
1302 whose names match REGEXP.
1305 \((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
1306 mail-decode-encoded-word-string
1307 (\"chinese\" . rfc1843-decode-string))")
1309 (defvar gnus-decode-encoded-word-methods-cache nil)
1311 (defun gnus-multi-decode-encoded-word-string (string)
1312 "Apply the functions from `gnus-encoded-word-methods' that match."
1313 (unless (and gnus-decode-encoded-word-methods-cache
1314 (eq gnus-newsgroup-name
1315 (car gnus-decode-encoded-word-methods-cache)))
1316 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
1319 (nconc gnus-decode-encoded-word-methods-cache (list x))
1320 (if (and gnus-newsgroup-name
1321 (string-match (car x) gnus-newsgroup-name))
1322 (nconc gnus-decode-encoded-word-methods-cache
1324 gnus-decode-encoded-word-methods))
1325 (let ((xlist gnus-decode-encoded-word-methods-cache))
1328 (setq string (funcall (pop xlist) string))))
1331 ;; Subject simplification.
1333 (defun gnus-simplify-whitespace (str)
1334 "Remove excessive whitespace from STR."
1337 (while (string-match "[ \t][ \t]+" mystr)
1338 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1340 (substring mystr (match-end 0)))))
1342 (when (string-match "^[ \t]+" mystr)
1343 (setq mystr (substring mystr (match-end 0))))
1345 (when (string-match "[ \t]+$" mystr)
1346 (setq mystr (substring mystr 0 (match-beginning 0))))
1349 (defsubst gnus-simplify-subject-re (subject)
1350 "Remove \"Re:\" from subject lines."
1351 (if (string-match message-subject-re-regexp subject)
1352 (substring subject (match-end 0))
1355 (defun gnus-simplify-subject (subject &optional re-only)
1356 "Remove `Re:' and words in parentheses.
1357 If RE-ONLY is non-nil, strip leading `Re:'s only."
1358 (let ((case-fold-search t)) ;Ignore case.
1359 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1360 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1361 (setq subject (substring subject (match-end 0))))
1362 ;; Remove uninteresting prefixes.
1363 (when (and (not re-only)
1364 gnus-simplify-ignored-prefixes
1365 (string-match gnus-simplify-ignored-prefixes subject))
1366 (setq subject (substring subject (match-end 0))))
1367 ;; Remove words in parentheses from end.
1369 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1370 (setq subject (substring subject 0 (match-beginning 0)))))
1371 ;; Return subject string.
1374 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1376 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1377 (goto-char (point-min))
1378 (while (re-search-forward regexp nil t)
1379 (replace-match (or newtext ""))))
1381 (defun gnus-simplify-buffer-fuzzy ()
1382 "Simplify string in the buffer fuzzily.
1383 The string in the accessible portion of the current buffer is simplified.
1384 It is assumed to be a single-line subject.
1385 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1386 matter is removed. Additional things can be deleted by setting
1387 `gnus-simplify-subject-fuzzy-regexp'."
1388 (let ((case-fold-search t)
1390 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1392 (while (not (eq modified-tick (buffer-modified-tick)))
1393 (setq modified-tick (buffer-modified-tick))
1395 ((listp gnus-simplify-subject-fuzzy-regexp)
1396 (mapcar 'gnus-simplify-buffer-fuzzy-step
1397 gnus-simplify-subject-fuzzy-regexp))
1398 (gnus-simplify-subject-fuzzy-regexp
1399 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1400 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1401 (gnus-simplify-buffer-fuzzy-step
1402 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1403 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1405 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1406 (gnus-simplify-buffer-fuzzy-step " +" " ")
1407 (gnus-simplify-buffer-fuzzy-step " $")
1408 (gnus-simplify-buffer-fuzzy-step "^ +")))
1410 (defun gnus-simplify-subject-fuzzy (subject)
1411 "Simplify a subject string fuzzily.
1412 See `gnus-simplify-buffer-fuzzy' for details."
1414 (gnus-set-work-buffer)
1415 (let ((case-fold-search t))
1416 ;; Remove uninteresting prefixes.
1417 (when (and gnus-simplify-ignored-prefixes
1418 (string-match gnus-simplify-ignored-prefixes subject))
1419 (setq subject (substring subject (match-end 0))))
1421 (inline (gnus-simplify-buffer-fuzzy))
1424 (defsubst gnus-simplify-subject-fully (subject)
1425 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1427 (gnus-simplify-subject-functions
1428 (gnus-map-function gnus-simplify-subject-functions subject))
1429 ((null gnus-summary-gather-subject-limit)
1430 (gnus-simplify-subject-re subject))
1431 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1432 (gnus-simplify-subject-fuzzy subject))
1433 ((numberp gnus-summary-gather-subject-limit)
1434 (gnus-limit-string (gnus-simplify-subject-re subject)
1435 gnus-summary-gather-subject-limit))
1439 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1440 "Check whether two subjects are equal.
1441 If optional argument simple-first is t, first argument is already
1444 ((null simple-first)
1445 (equal (gnus-simplify-subject-fully s1)
1446 (gnus-simplify-subject-fully s2)))
1449 (gnus-simplify-subject-fully s2)))))
1451 (defun gnus-summary-bubble-group ()
1452 "Increase the score of the current group.
1453 This is a handy function to add to `gnus-summary-exit-hook' to
1454 increase the score of each group you read."
1455 (gnus-group-add-score gnus-newsgroup-name))
1459 ;;; Gnus summary mode
1462 (put 'gnus-summary-mode 'mode-class 'special)
1464 (defvar gnus-article-commands-menu)
1467 ;; Non-orthogonal keys
1469 (gnus-define-keys gnus-summary-mode-map
1470 " " gnus-summary-next-page
1471 "\177" gnus-summary-prev-page
1472 [delete] gnus-summary-prev-page
1473 [backspace] gnus-summary-prev-page
1474 "\r" gnus-summary-scroll-up
1475 "\M-\r" gnus-summary-scroll-down
1476 "n" gnus-summary-next-unread-article
1477 "p" gnus-summary-prev-unread-article
1478 "N" gnus-summary-next-article
1479 "P" gnus-summary-prev-article
1480 "\M-\C-n" gnus-summary-next-same-subject
1481 "\M-\C-p" gnus-summary-prev-same-subject
1482 "\M-n" gnus-summary-next-unread-subject
1483 "\M-p" gnus-summary-prev-unread-subject
1484 "." gnus-summary-first-unread-article
1485 "," gnus-summary-best-unread-article
1486 "\M-s" gnus-summary-search-article-forward
1487 "\M-r" gnus-summary-search-article-backward
1488 "<" gnus-summary-beginning-of-article
1489 ">" gnus-summary-end-of-article
1490 "j" gnus-summary-goto-article
1491 "^" gnus-summary-refer-parent-article
1492 "\M-^" gnus-summary-refer-article
1493 "u" gnus-summary-tick-article-forward
1494 "!" gnus-summary-tick-article-forward
1495 "U" gnus-summary-tick-article-backward
1496 "d" gnus-summary-mark-as-read-forward
1497 "D" gnus-summary-mark-as-read-backward
1498 "E" gnus-summary-mark-as-expirable
1499 "\M-u" gnus-summary-clear-mark-forward
1500 "\M-U" gnus-summary-clear-mark-backward
1501 "k" gnus-summary-kill-same-subject-and-select
1502 "\C-k" gnus-summary-kill-same-subject
1503 "\M-\C-k" gnus-summary-kill-thread
1504 "\M-\C-l" gnus-summary-lower-thread
1505 "e" gnus-summary-edit-article
1506 "#" gnus-summary-mark-as-processable
1507 "\M-#" gnus-summary-unmark-as-processable
1508 "\M-\C-t" gnus-summary-toggle-threads
1509 "\M-\C-s" gnus-summary-show-thread
1510 "\M-\C-h" gnus-summary-hide-thread
1511 "\M-\C-f" gnus-summary-next-thread
1512 "\M-\C-b" gnus-summary-prev-thread
1513 [(meta down)] gnus-summary-next-thread
1514 [(meta up)] gnus-summary-prev-thread
1515 "\M-\C-u" gnus-summary-up-thread
1516 "\M-\C-d" gnus-summary-down-thread
1517 "&" gnus-summary-execute-command
1518 "c" gnus-summary-catchup-and-exit
1519 "\C-w" gnus-summary-mark-region-as-read
1520 "\C-t" gnus-summary-toggle-truncation
1521 "?" gnus-summary-mark-as-dormant
1522 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1523 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1524 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1525 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1526 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1527 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1528 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1529 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1530 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1531 "=" gnus-summary-expand-window
1532 "\C-x\C-s" gnus-summary-reselect-current-group
1533 "\M-g" gnus-summary-rescan-group
1534 "w" gnus-summary-stop-page-breaking
1535 "\C-c\C-r" gnus-summary-caesar-message
1536 "f" gnus-summary-followup
1537 "F" gnus-summary-followup-with-original
1538 "C" gnus-summary-cancel-article
1539 "r" gnus-summary-reply
1540 "R" gnus-summary-reply-with-original
1541 "\C-c\C-f" gnus-summary-mail-forward
1542 "o" gnus-summary-save-article
1543 "\C-o" gnus-summary-save-article-mail
1544 "|" gnus-summary-pipe-output
1545 "\M-k" gnus-summary-edit-local-kill
1546 "\M-K" gnus-summary-edit-global-kill
1548 "\C-c\C-d" gnus-summary-describe-group
1549 "q" gnus-summary-exit
1550 "Q" gnus-summary-exit-no-update
1551 "\C-c\C-i" gnus-info-find-node
1552 gnus-mouse-2 gnus-mouse-pick-article
1553 "m" gnus-summary-mail-other-window
1554 "a" gnus-summary-post-news
1555 "i" gnus-summary-news-other-window
1556 "x" gnus-summary-limit-to-unread
1557 "s" gnus-summary-isearch-article
1558 "t" gnus-summary-toggle-header
1559 "g" gnus-summary-show-article
1560 "l" gnus-summary-goto-last-article
1561 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1562 "\C-d" gnus-summary-enter-digest-group
1563 "\M-\C-d" gnus-summary-read-document
1564 "\M-\C-e" gnus-summary-edit-parameters
1565 "\M-\C-a" gnus-summary-customize-parameters
1567 "*" gnus-cache-enter-article
1568 "\M-*" gnus-cache-remove-article
1569 "\M-&" gnus-summary-universal-argument
1570 "\C-l" gnus-recenter
1571 "I" gnus-summary-increase-score
1572 "L" gnus-summary-lower-score
1573 "\M-i" gnus-symbolic-argument
1574 "h" gnus-summary-select-article-buffer
1576 "b" gnus-article-view-part
1577 "\M-t" gnus-summary-toggle-display-buttonized
1579 "V" gnus-summary-score-map
1580 "X" gnus-uu-extract-map
1581 "S" gnus-summary-send-map)
1583 ;; Sort of orthogonal keymap
1584 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1585 "t" gnus-summary-tick-article-forward
1586 "!" gnus-summary-tick-article-forward
1587 "d" gnus-summary-mark-as-read-forward
1588 "r" gnus-summary-mark-as-read-forward
1589 "c" gnus-summary-clear-mark-forward
1590 " " gnus-summary-clear-mark-forward
1591 "e" gnus-summary-mark-as-expirable
1592 "x" gnus-summary-mark-as-expirable
1593 "?" gnus-summary-mark-as-dormant
1594 "b" gnus-summary-set-bookmark
1595 "B" gnus-summary-remove-bookmark
1596 "#" gnus-summary-mark-as-processable
1597 "\M-#" gnus-summary-unmark-as-processable
1598 "S" gnus-summary-limit-include-expunged
1599 "C" gnus-summary-catchup
1600 "H" gnus-summary-catchup-to-here
1601 "h" gnus-summary-catchup-from-here
1602 "\C-c" gnus-summary-catchup-all
1603 "k" gnus-summary-kill-same-subject-and-select
1604 "K" gnus-summary-kill-same-subject
1605 "P" gnus-uu-mark-map)
1607 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1608 "c" gnus-summary-clear-above
1609 "u" gnus-summary-tick-above
1610 "m" gnus-summary-mark-above
1611 "k" gnus-summary-kill-below)
1613 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1614 "/" gnus-summary-limit-to-subject
1615 "n" gnus-summary-limit-to-articles
1616 "w" gnus-summary-pop-limit
1617 "s" gnus-summary-limit-to-subject
1618 "a" gnus-summary-limit-to-author
1619 "u" gnus-summary-limit-to-unread
1620 "m" gnus-summary-limit-to-marks
1621 "M" gnus-summary-limit-exclude-marks
1622 "v" gnus-summary-limit-to-score
1623 "*" gnus-summary-limit-include-cached
1624 "D" gnus-summary-limit-include-dormant
1625 "T" gnus-summary-limit-include-thread
1626 "d" gnus-summary-limit-exclude-dormant
1627 "t" gnus-summary-limit-to-age
1628 "x" gnus-summary-limit-to-extra
1629 "p" gnus-summary-limit-to-display-predicate
1630 "E" gnus-summary-limit-include-expunged
1631 "c" gnus-summary-limit-exclude-childless-dormant
1632 "C" gnus-summary-limit-mark-excluded-as-read
1633 "o" gnus-summary-insert-old-articles
1634 "N" gnus-summary-insert-new-articles)
1636 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1637 "n" gnus-summary-next-unread-article
1638 "p" gnus-summary-prev-unread-article
1639 "N" gnus-summary-next-article
1640 "P" gnus-summary-prev-article
1641 "\C-n" gnus-summary-next-same-subject
1642 "\C-p" gnus-summary-prev-same-subject
1643 "\M-n" gnus-summary-next-unread-subject
1644 "\M-p" gnus-summary-prev-unread-subject
1645 "f" gnus-summary-first-unread-article
1646 "b" gnus-summary-best-unread-article
1647 "j" gnus-summary-goto-article
1648 "g" gnus-summary-goto-subject
1649 "l" gnus-summary-goto-last-article
1650 "o" gnus-summary-pop-article)
1652 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1653 "k" gnus-summary-kill-thread
1654 "l" gnus-summary-lower-thread
1655 "i" gnus-summary-raise-thread
1656 "T" gnus-summary-toggle-threads
1657 "t" gnus-summary-rethread-current
1658 "^" gnus-summary-reparent-thread
1659 "s" gnus-summary-show-thread
1660 "S" gnus-summary-show-all-threads
1661 "h" gnus-summary-hide-thread
1662 "H" gnus-summary-hide-all-threads
1663 "n" gnus-summary-next-thread
1664 "p" gnus-summary-prev-thread
1665 "u" gnus-summary-up-thread
1666 "o" gnus-summary-top-thread
1667 "d" gnus-summary-down-thread
1668 "#" gnus-uu-mark-thread
1669 "\M-#" gnus-uu-unmark-thread)
1671 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1672 "g" gnus-summary-prepare
1673 "c" gnus-summary-insert-cached-articles)
1675 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1676 "c" gnus-summary-catchup-and-exit
1677 "C" gnus-summary-catchup-all-and-exit
1678 "E" gnus-summary-exit-no-update
1679 "Q" gnus-summary-exit
1680 "Z" gnus-summary-exit
1681 "n" gnus-summary-catchup-and-goto-next-group
1682 "R" gnus-summary-reselect-current-group
1683 "G" gnus-summary-rescan-group
1684 "N" gnus-summary-next-group
1685 "s" gnus-summary-save-newsrc
1686 "P" gnus-summary-prev-group)
1688 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1689 " " gnus-summary-next-page
1690 "n" gnus-summary-next-page
1691 "\177" gnus-summary-prev-page
1692 [delete] gnus-summary-prev-page
1693 "p" gnus-summary-prev-page
1694 "\r" gnus-summary-scroll-up
1695 "\M-\r" gnus-summary-scroll-down
1696 "<" gnus-summary-beginning-of-article
1697 ">" gnus-summary-end-of-article
1698 "b" gnus-summary-beginning-of-article
1699 "e" gnus-summary-end-of-article
1700 "^" gnus-summary-refer-parent-article
1701 "r" gnus-summary-refer-parent-article
1702 "D" gnus-summary-enter-digest-group
1703 "R" gnus-summary-refer-references
1704 "T" gnus-summary-refer-thread
1705 "g" gnus-summary-show-article
1706 "s" gnus-summary-isearch-article
1707 "P" gnus-summary-print-article
1708 "M" gnus-mailing-list-insinuate
1709 "t" gnus-article-babel)
1711 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1712 "b" gnus-article-add-buttons
1713 "B" gnus-article-add-buttons-to-head
1714 "o" gnus-article-treat-overstrike
1715 "e" gnus-article-emphasize
1716 "w" gnus-article-fill-cited-article
1717 "Q" gnus-article-fill-long-lines
1718 "C" gnus-article-capitalize-sentences
1719 "c" gnus-article-remove-cr
1720 "q" gnus-article-de-quoted-unreadable
1721 "6" gnus-article-de-base64-unreadable
1722 "Z" gnus-article-decode-HZ
1723 "h" gnus-article-wash-html
1724 "s" gnus-summary-force-verify-and-decrypt
1725 "f" gnus-article-display-x-face
1726 "l" gnus-summary-stop-page-breaking
1727 "r" gnus-summary-caesar-message
1728 "t" gnus-summary-toggle-header
1729 "g" gnus-summary-toggle-smiley
1730 "u" gnus-article-treat-unfold-headers
1731 "n" gnus-article-treat-fold-newsgroups
1732 "v" gnus-summary-verbose-headers
1733 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
1734 "p" gnus-article-verify-x-pgp-sig
1735 "d" gnus-article-treat-dumbquotes)
1737 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1738 "a" gnus-article-hide
1739 "h" gnus-article-hide-headers
1740 "b" gnus-article-hide-boring-headers
1741 "s" gnus-article-hide-signature
1742 "c" gnus-article-hide-citation
1743 "C" gnus-article-hide-citation-in-followups
1744 "l" gnus-article-hide-list-identifiers
1745 "p" gnus-article-hide-pgp
1746 "B" gnus-article-strip-banner
1747 "P" gnus-article-hide-pem
1748 "\C-c" gnus-article-hide-citation-maybe)
1750 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1751 "a" gnus-article-highlight
1752 "h" gnus-article-highlight-headers
1753 "c" gnus-article-highlight-citation
1754 "s" gnus-article-highlight-signature)
1756 (gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
1757 "x" gnus-article-display-x-face
1758 "s" gnus-summary-toggle-smiley
1759 "f" gnus-treat-from-picon
1760 "m" gnus-treat-mail-picon
1761 "n" gnus-treat-newsgroups-picon)
1763 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
1764 "w" gnus-article-decode-mime-words
1765 "c" gnus-article-decode-charset
1766 "v" gnus-mime-view-all-parts
1767 "b" gnus-article-view-part)
1769 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1770 "z" gnus-article-date-ut
1771 "u" gnus-article-date-ut
1772 "l" gnus-article-date-local
1773 "p" gnus-article-date-english
1774 "e" gnus-article-date-lapsed
1775 "o" gnus-article-date-original
1776 "i" gnus-article-date-iso8601
1777 "s" gnus-article-date-user)
1779 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1780 "t" gnus-article-remove-trailing-blank-lines
1781 "l" gnus-article-strip-leading-blank-lines
1782 "m" gnus-article-strip-multiple-blank-lines
1783 "a" gnus-article-strip-blank-lines
1784 "A" gnus-article-strip-all-blank-lines
1785 "s" gnus-article-strip-leading-space
1786 "e" gnus-article-strip-trailing-space
1787 "w" gnus-article-remove-leading-whitespace)
1789 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1791 "f" gnus-summary-fetch-faq
1792 "d" gnus-summary-describe-group
1793 "h" gnus-summary-describe-briefly
1794 "i" gnus-info-find-node)
1796 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1797 "e" gnus-summary-expire-articles
1798 "\M-\C-e" gnus-summary-expire-articles-now
1799 "\177" gnus-summary-delete-article
1800 [delete] gnus-summary-delete-article
1801 [backspace] gnus-summary-delete-article
1802 "m" gnus-summary-move-article
1803 "r" gnus-summary-respool-article
1804 "w" gnus-summary-edit-article
1805 "c" gnus-summary-copy-article
1806 "B" gnus-summary-crosspost-article
1807 "q" gnus-summary-respool-query
1808 "t" gnus-summary-respool-trace
1809 "i" gnus-summary-import-article
1810 "I" gnus-summary-create-article
1811 "p" gnus-summary-article-posted-p)
1813 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1814 "o" gnus-summary-save-article
1815 "m" gnus-summary-save-article-mail
1816 "F" gnus-summary-write-article-file
1817 "r" gnus-summary-save-article-rmail
1818 "f" gnus-summary-save-article-file
1819 "b" gnus-summary-save-article-body-file
1820 "h" gnus-summary-save-article-folder
1821 "v" gnus-summary-save-article-vm
1822 "p" gnus-summary-pipe-output
1823 "P" gnus-summary-muttprint
1824 "s" gnus-soup-add-article)
1826 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
1827 "b" gnus-summary-display-buttonized
1828 "m" gnus-summary-repair-multipart
1829 "v" gnus-article-view-part
1830 "o" gnus-article-save-part
1831 "c" gnus-article-copy-part
1832 "C" gnus-article-view-part-as-charset
1833 "e" gnus-article-externalize-part
1834 "E" gnus-article-encrypt-body
1835 "i" gnus-article-inline-part
1836 "|" gnus-article-pipe-part))
1838 (defvar gnus-article-post-menu nil)
1840 (defun gnus-summary-make-menu-bar ()
1841 (gnus-turn-off-edit-menu 'summary)
1843 (unless (boundp 'gnus-summary-misc-menu)
1846 gnus-summary-kill-menu gnus-summary-mode-map ""
1851 ["Customize" gnus-score-customize t])
1852 (gnus-make-score-map 'increase)
1853 (gnus-make-score-map 'lower)
1855 ["Kill below" gnus-summary-kill-below t]
1856 ["Mark above" gnus-summary-mark-above t]
1857 ["Tick above" gnus-summary-tick-above t]
1858 ["Clear above" gnus-summary-clear-above t])
1859 ["Current score" gnus-summary-current-score t]
1860 ["Set score" gnus-summary-set-score t]
1861 ["Switch current score file..." gnus-score-change-score-file t]
1862 ["Set mark below..." gnus-score-set-mark-below t]
1863 ["Set expunge below..." gnus-score-set-expunge-below t]
1864 ["Edit current score file" gnus-score-edit-current-scores t]
1865 ["Edit score file" gnus-score-edit-file t]
1866 ["Trace score" gnus-score-find-trace t]
1867 ["Find words" gnus-score-find-favourite-words t]
1868 ["Rescore buffer" gnus-summary-rescore t]
1869 ["Increase score..." gnus-summary-increase-score t]
1870 ["Lower score..." gnus-summary-lower-score t]))))
1872 ;; Define both the Article menu in the summary buffer and the
1873 ;; equivalent Commands menu in the article buffer here for
1877 ["All" gnus-article-hide t]
1878 ["Headers" gnus-article-hide-headers t]
1879 ["Signature" gnus-article-hide-signature t]
1880 ["Citation" gnus-article-hide-citation t]
1881 ["List identifiers" gnus-article-hide-list-identifiers t]
1882 ["PGP" gnus-article-hide-pgp t]
1883 ["Banner" gnus-article-strip-banner t]
1884 ["Boring headers" gnus-article-hide-boring-headers t])
1886 ["All" gnus-article-highlight t]
1887 ["Headers" gnus-article-highlight-headers t]
1888 ["Signature" gnus-article-highlight-signature t]
1889 ["Citation" gnus-article-highlight-citation t])
1891 ["Words" gnus-article-decode-mime-words t]
1892 ["Charset" gnus-article-decode-charset t]
1893 ["QP" gnus-article-de-quoted-unreadable t]
1894 ["Base64" gnus-article-de-base64-unreadable t]
1895 ["View all" gnus-mime-view-all-parts t]
1896 ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t]
1897 ["Encrypt body" gnus-article-encrypt-body t])
1899 ["Local" gnus-article-date-local t]
1900 ["ISO8601" gnus-article-date-iso8601 t]
1901 ["UT" gnus-article-date-ut t]
1902 ["Original" gnus-article-date-original t]
1903 ["Lapsed" gnus-article-date-lapsed t]
1904 ["User-defined" gnus-article-date-user t])
1906 ["Toggle smiley" gnus-summary-toggle-smiley t]
1907 ["Show X-Face" gnus-article-display-x-face t]
1908 ["Show picons in From" gnus-treat-from-picon t]
1909 ["Show picons in mail headers" gnus-treat-mail-picon t]
1910 ["Show picons in news headers" gnus-treat-newsgroups-picon t])
1913 ["Leading" gnus-article-strip-leading-blank-lines t]
1914 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1915 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1916 ["All of the above" gnus-article-strip-blank-lines t]
1917 ["All" gnus-article-strip-all-blank-lines t]
1918 ["Leading space" gnus-article-strip-leading-space t]
1919 ["Trailing space" gnus-article-strip-trailing-space t]
1920 ["Leading space in headers"
1921 gnus-article-remove-leading-whitespace t])
1922 ["Overstrike" gnus-article-treat-overstrike t]
1923 ["Dumb quotes" gnus-article-treat-dumbquotes t]
1924 ["Emphasis" gnus-article-emphasize t]
1925 ["Word wrap" gnus-article-fill-cited-article t]
1926 ["Fill long lines" gnus-article-fill-long-lines t]
1927 ["Capitalize sentences" gnus-article-capitalize-sentences t]
1928 ["CR" gnus-article-remove-cr t]
1929 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
1930 ["Base64" gnus-article-de-base64-unreadable t]
1931 ["Rot 13" gnus-summary-caesar-message
1932 ,@(if (featurep 'xemacs) '(t)
1933 '(:help "\"Caesar rotate\" article by 13"))]
1934 ["Unix pipe" gnus-summary-pipe-message t]
1935 ["Add buttons" gnus-article-add-buttons t]
1936 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1937 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1938 ["Verbose header" gnus-summary-verbose-headers t]
1939 ["Toggle header" gnus-summary-toggle-header t]
1940 ["Unfold headers" gnus-article-treat-unfold-headers t]
1941 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
1942 ["Html" gnus-article-wash-html t]
1943 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
1944 ["HZ" gnus-article-decode-HZ t])
1946 ["Save in default format" gnus-summary-save-article
1947 ,@(if (featurep 'xemacs) '(t)
1948 '(:help "Save article using default method"))]
1949 ["Save in file" gnus-summary-save-article-file
1950 ,@(if (featurep 'xemacs) '(t)
1951 '(:help "Save article in file"))]
1952 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1953 ["Save in MH folder" gnus-summary-save-article-folder t]
1954 ["Save in VM folder" gnus-summary-save-article-vm t]
1955 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1956 ["Save body in file" gnus-summary-save-article-body-file t]
1957 ["Pipe through a filter" gnus-summary-pipe-output t]
1958 ["Add to SOUP packet" gnus-soup-add-article t]
1959 ["Print with Muttprint" gnus-summary-muttprint t]
1960 ["Print" gnus-summary-print-article t])
1962 ["Respool article..." gnus-summary-respool-article t]
1963 ["Move article..." gnus-summary-move-article
1964 (gnus-check-backend-function
1965 'request-move-article gnus-newsgroup-name)]
1966 ["Copy article..." gnus-summary-copy-article t]
1967 ["Crosspost article..." gnus-summary-crosspost-article
1968 (gnus-check-backend-function
1969 'request-replace-article gnus-newsgroup-name)]
1970 ["Import file..." gnus-summary-import-article t]
1971 ["Create article..." gnus-summary-create-article t]
1972 ["Check if posted" gnus-summary-article-posted-p t]
1973 ["Edit article" gnus-summary-edit-article
1974 (not (gnus-group-read-only-p))]
1975 ["Delete article" gnus-summary-delete-article
1976 (gnus-check-backend-function
1977 'request-expire-articles gnus-newsgroup-name)]
1978 ["Query respool" gnus-summary-respool-query t]
1979 ["Trace respool" gnus-summary-respool-trace t]
1980 ["Delete expirable articles" gnus-summary-expire-articles-now
1981 (gnus-check-backend-function
1982 'request-expire-articles gnus-newsgroup-name)])
1984 ["Uudecode" gnus-uu-decode-uu
1985 ,@(if (featurep 'xemacs) '(t)
1986 '(:help "Decode uuencoded article(s)"))]
1987 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1988 ["Unshar" gnus-uu-decode-unshar t]
1989 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1990 ["Save" gnus-uu-decode-save t]
1991 ["Binhex" gnus-uu-decode-binhex t]
1992 ["Postscript" gnus-uu-decode-postscript t])
1994 ["Enter article" gnus-cache-enter-article t]
1995 ["Remove article" gnus-cache-remove-article t])
1996 ["Translate" gnus-article-babel t]
1997 ["Select article buffer" gnus-summary-select-article-buffer t]
1998 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1999 ["Isearch article..." gnus-summary-isearch-article t]
2000 ["Beginning of the article" gnus-summary-beginning-of-article t]
2001 ["End of the article" gnus-summary-end-of-article t]
2002 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2003 ["Fetch referenced articles" gnus-summary-refer-references t]
2004 ["Fetch current thread" gnus-summary-refer-thread t]
2005 ["Fetch article with id..." gnus-summary-refer-article t]
2006 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2007 ["Redisplay" gnus-summary-show-article t]
2008 ["Raw article" gnus-summary-show-raw-article t])))
2010 gnus-summary-article-menu gnus-summary-mode-map ""
2011 (cons "Article" innards))
2013 (if (not (keymapp gnus-summary-article-menu))
2015 gnus-article-commands-menu gnus-article-mode-map ""
2016 (cons "Commands" innards))
2017 ;; in Emacs, don't share menu.
2018 (setq gnus-article-commands-menu
2019 (copy-keymap gnus-summary-article-menu))
2020 (define-key gnus-article-mode-map [menu-bar commands]
2021 (cons "Commands" gnus-article-commands-menu))))
2024 gnus-summary-thread-menu gnus-summary-mode-map ""
2026 ["Toggle threading" gnus-summary-toggle-threads t]
2027 ["Hide threads" gnus-summary-hide-all-threads t]
2028 ["Show threads" gnus-summary-show-all-threads t]
2029 ["Hide thread" gnus-summary-hide-thread t]
2030 ["Show thread" gnus-summary-show-thread t]
2031 ["Go to next thread" gnus-summary-next-thread t]
2032 ["Go to previous thread" gnus-summary-prev-thread t]
2033 ["Go down thread" gnus-summary-down-thread t]
2034 ["Go up thread" gnus-summary-up-thread t]
2035 ["Top of thread" gnus-summary-top-thread t]
2036 ["Mark thread as read" gnus-summary-kill-thread t]
2037 ["Lower thread score" gnus-summary-lower-thread t]
2038 ["Raise thread score" gnus-summary-raise-thread t]
2039 ["Rethread current" gnus-summary-rethread-current t]))
2042 gnus-summary-post-menu gnus-summary-mode-map ""
2044 ["Send a message (mail or news)" gnus-summary-post-news
2045 ,@(if (featurep 'xemacs) '(t)
2046 '(:help "Post an article"))]
2047 ["Followup" gnus-summary-followup
2048 ,@(if (featurep 'xemacs) '(t)
2049 '(:help "Post followup to this article"))]
2050 ["Followup and yank" gnus-summary-followup-with-original
2051 ,@(if (featurep 'xemacs) '(t)
2052 '(:help "Post followup to this article, quoting its contents"))]
2053 ["Supersede article" gnus-summary-supersede-article t]
2054 ["Cancel article" gnus-summary-cancel-article
2055 ,@(if (featurep 'xemacs) '(t)
2056 '(:help "Cancel an article you posted"))]
2057 ["Reply" gnus-summary-reply t]
2058 ["Reply and yank" gnus-summary-reply-with-original t]
2059 ["Wide reply" gnus-summary-wide-reply t]
2060 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2061 ,@(if (featurep 'xemacs) '(t)
2062 '(:help "Mail a reply, quoting this article"))]
2063 ["Mail forward" gnus-summary-mail-forward t]
2064 ["Post forward" gnus-summary-post-forward t]
2065 ["Digest and mail" gnus-uu-digest-mail-forward t]
2066 ["Digest and post" gnus-uu-digest-post-forward t]
2067 ["Resend message" gnus-summary-resend-message t]
2068 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2069 ["Send a mail" gnus-summary-mail-other-window t]
2070 ["Create a local message" gnus-summary-news-other-window t]
2071 ["Uuencode and post" gnus-uu-post-news
2072 ,@(if (featurep 'xemacs) '(t)
2073 '(:help "Post a uuencoded article"))]
2074 ["Followup via news" gnus-summary-followup-to-mail t]
2075 ["Followup via news and yank"
2076 gnus-summary-followup-to-mail-with-original t]
2078 ;;["Send" gnus-summary-send-draft t]
2079 ;;["Send bounced" gnus-resend-bounced-mail t])
2083 ((not (keymapp gnus-summary-post-menu))
2084 (setq gnus-article-post-menu gnus-summary-post-menu))
2085 ((not gnus-article-post-menu)
2086 ;; Don't share post menu.
2087 (setq gnus-article-post-menu
2088 (copy-keymap gnus-summary-post-menu))))
2089 (define-key gnus-article-mode-map [menu-bar post]
2090 (cons "Post" gnus-article-post-menu))
2093 gnus-summary-misc-menu gnus-summary-mode-map ""
2096 ["Mark as read" gnus-summary-mark-as-read-forward t]
2097 ["Mark same subject and select"
2098 gnus-summary-kill-same-subject-and-select t]
2099 ["Mark same subject" gnus-summary-kill-same-subject t]
2100 ["Catchup" gnus-summary-catchup
2101 ,@(if (featurep 'xemacs) '(t)
2102 '(:help "Mark unread articles in this group as read"))]
2103 ["Catchup all" gnus-summary-catchup-all t]
2104 ["Catchup to here" gnus-summary-catchup-to-here t]
2105 ["Catchup from here" gnus-summary-catchup-from-here t]
2106 ["Catchup region" gnus-summary-mark-region-as-read t]
2107 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2109 ["Tick" gnus-summary-tick-article-forward t]
2110 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2111 ["Remove marks" gnus-summary-clear-mark-forward t]
2112 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2113 ["Set bookmark" gnus-summary-set-bookmark t]
2114 ["Remove bookmark" gnus-summary-remove-bookmark t])
2116 ["Marks..." gnus-summary-limit-to-marks t]
2117 ["Subject..." gnus-summary-limit-to-subject t]
2118 ["Author..." gnus-summary-limit-to-author t]
2119 ["Age..." gnus-summary-limit-to-age t]
2120 ["Extra..." gnus-summary-limit-to-extra t]
2121 ["Score" gnus-summary-limit-to-score t]
2122 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2123 ["Unread" gnus-summary-limit-to-unread t]
2124 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2125 ["Articles" gnus-summary-limit-to-articles t]
2126 ["Pop limit" gnus-summary-pop-limit t]
2127 ["Show dormant" gnus-summary-limit-include-dormant t]
2128 ["Hide childless dormant"
2129 gnus-summary-limit-exclude-childless-dormant t]
2130 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2131 ["Hide marked" gnus-summary-limit-exclude-marks t]
2132 ["Show expunged" gnus-summary-limit-include-expunged t])
2134 ["Set mark" gnus-summary-mark-as-processable t]
2135 ["Remove mark" gnus-summary-unmark-as-processable t]
2136 ["Remove all marks" gnus-summary-unmark-all-processable t]
2137 ["Mark above" gnus-uu-mark-over t]
2138 ["Mark series" gnus-uu-mark-series t]
2139 ["Mark region" gnus-uu-mark-region t]
2140 ["Unmark region" gnus-uu-unmark-region t]
2141 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2142 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2143 ["Mark all" gnus-uu-mark-all t]
2144 ["Mark buffer" gnus-uu-mark-buffer t]
2145 ["Mark sparse" gnus-uu-mark-sparse t]
2146 ["Mark thread" gnus-uu-mark-thread t]
2147 ["Unmark thread" gnus-uu-unmark-thread t]
2148 ("Process Mark Sets"
2149 ["Kill" gnus-summary-kill-process-mark t]
2150 ["Yank" gnus-summary-yank-process-mark
2151 gnus-newsgroup-process-stack]
2152 ["Save" gnus-summary-save-process-mark t]))
2154 ["Page forward" gnus-summary-next-page
2155 ,@(if (featurep 'xemacs) '(t)
2156 '(:help "Show next page of article"))]
2157 ["Page backward" gnus-summary-prev-page
2158 ,@(if (featurep 'xemacs) '(t)
2159 '(:help "Show previous page of article"))]
2160 ["Line forward" gnus-summary-scroll-up t])
2162 ["Next unread article" gnus-summary-next-unread-article t]
2163 ["Previous unread article" gnus-summary-prev-unread-article t]
2164 ["Next article" gnus-summary-next-article t]
2165 ["Previous article" gnus-summary-prev-article t]
2166 ["Next unread subject" gnus-summary-next-unread-subject t]
2167 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2168 ["Next article same subject" gnus-summary-next-same-subject t]
2169 ["Previous article same subject" gnus-summary-prev-same-subject t]
2170 ["First unread article" gnus-summary-first-unread-article t]
2171 ["Best unread article" gnus-summary-best-unread-article t]
2172 ["Go to subject number..." gnus-summary-goto-subject t]
2173 ["Go to article number..." gnus-summary-goto-article t]
2174 ["Go to the last article" gnus-summary-goto-last-article t]
2175 ["Pop article off history" gnus-summary-pop-article t])
2177 ["Sort by number" gnus-summary-sort-by-number t]
2178 ["Sort by author" gnus-summary-sort-by-author t]
2179 ["Sort by subject" gnus-summary-sort-by-subject t]
2180 ["Sort by date" gnus-summary-sort-by-date t]
2181 ["Sort by score" gnus-summary-sort-by-score t]
2182 ["Sort by lines" gnus-summary-sort-by-lines t]
2183 ["Sort by characters" gnus-summary-sort-by-chars t]
2184 ["Original sort" gnus-summary-sort-by-original t])
2186 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2187 ["Describe group" gnus-summary-describe-group t]
2188 ["Read manual" gnus-info-find-node t])
2190 ["Pick and read" gnus-pick-mode t]
2191 ["Binary" gnus-binary-mode t])
2193 ["Regenerate" gnus-summary-prepare t]
2194 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2195 ["Toggle threading" gnus-summary-toggle-threads t])
2196 ["See old articles" gnus-summary-insert-old-articles t]
2197 ["See new articles" gnus-summary-insert-new-articles t]
2198 ["Filter articles..." gnus-summary-execute-command t]
2199 ["Run command on subjects..." gnus-summary-universal-argument t]
2200 ["Search articles forward..." gnus-summary-search-article-forward t]
2201 ["Search articles backward..." gnus-summary-search-article-backward t]
2202 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2203 ["Expand window" gnus-summary-expand-window t]
2204 ["Expire expirable articles" gnus-summary-expire-articles
2205 (gnus-check-backend-function
2206 'request-expire-articles gnus-newsgroup-name)]
2207 ["Edit local kill file" gnus-summary-edit-local-kill t]
2208 ["Edit main kill file" gnus-summary-edit-global-kill t]
2209 ["Edit group parameters" gnus-summary-edit-parameters t]
2210 ["Customize group parameters" gnus-summary-customize-parameters t]
2211 ["Send a bug report" gnus-bug t]
2213 ["Catchup and exit" gnus-summary-catchup-and-exit
2214 ,@(if (featurep 'xemacs) '(t)
2215 '(:help "Mark unread articles in this group as read, then exit"))]
2216 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2217 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2218 ["Exit group" gnus-summary-exit
2219 ,@(if (featurep 'xemacs) '(t)
2220 '(:help "Exit current group, return to group selection mode"))]
2221 ["Exit group without updating" gnus-summary-exit-no-update t]
2222 ["Exit and goto next group" gnus-summary-next-group t]
2223 ["Exit and goto prev group" gnus-summary-prev-group t]
2224 ["Reselect group" gnus-summary-reselect-current-group t]
2225 ["Rescan group" gnus-summary-rescan-group t]
2226 ["Update dribble" gnus-summary-save-newsrc t])))
2228 (gnus-run-hooks 'gnus-summary-menu-hook)))
2230 (defvar gnus-summary-tool-bar-map nil)
2232 ;; Emacs 21 tool bar. Should be no-op otherwise.
2233 (defun gnus-summary-make-tool-bar ()
2234 (if (and (fboundp 'tool-bar-add-item-from-menu)
2235 (default-value 'tool-bar-mode)
2236 (not gnus-summary-tool-bar-map))
2237 (setq gnus-summary-tool-bar-map
2238 (let ((tool-bar-map (make-sparse-keymap))
2239 (load-path (mm-image-load-path)))
2240 (tool-bar-add-item-from-menu
2241 'gnus-summary-prev-unread "prev-ur" gnus-summary-mode-map)
2242 (tool-bar-add-item-from-menu
2243 'gnus-summary-next-unread "next-ur" gnus-summary-mode-map)
2244 (tool-bar-add-item-from-menu
2245 'gnus-summary-post-news "post" gnus-summary-mode-map)
2246 (tool-bar-add-item-from-menu
2247 'gnus-summary-followup-with-original "fuwo" gnus-summary-mode-map)
2248 (tool-bar-add-item-from-menu
2249 'gnus-summary-followup "followup" gnus-summary-mode-map)
2250 (tool-bar-add-item-from-menu
2251 'gnus-summary-reply-with-original "reply-wo" gnus-summary-mode-map)
2252 (tool-bar-add-item-from-menu
2253 'gnus-summary-reply "reply" gnus-summary-mode-map)
2254 (tool-bar-add-item-from-menu
2255 'gnus-summary-caesar-message "rot13" gnus-summary-mode-map)
2256 (tool-bar-add-item-from-menu
2257 'gnus-uu-decode-uu "uu-decode" gnus-summary-mode-map)
2258 (tool-bar-add-item-from-menu
2259 'gnus-summary-save-article-file "save-aif" gnus-summary-mode-map)
2260 (tool-bar-add-item-from-menu
2261 'gnus-summary-save-article "save-art" gnus-summary-mode-map)
2262 (tool-bar-add-item-from-menu
2263 'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2264 (tool-bar-add-item-from-menu
2265 'gnus-summary-catchup "catchup" gnus-summary-mode-map)
2266 (tool-bar-add-item-from-menu
2267 'gnus-summary-catchup-and-exit "cu-exit" gnus-summary-mode-map)
2268 (tool-bar-add-item-from-menu
2269 'gnus-summary-exit "exit-summ" gnus-summary-mode-map)
2271 (if gnus-summary-tool-bar-map
2272 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
2274 (defun gnus-score-set-default (var value)
2275 "A version of set that updates the GNU Emacs menu-bar."
2277 ;; It is the message that forces the active status to be updated.
2280 (defun gnus-make-score-map (type)
2281 "Make a summary score map of type TYPE."
2284 (let ((headers '(("author" "from" string)
2285 ("subject" "subject" string)
2286 ("article body" "body" string)
2287 ("article head" "head" string)
2288 ("xref" "xref" string)
2289 ("extra header" "extra" string)
2290 ("lines" "lines" number)
2291 ("followups to author" "followup" string)))
2292 (types '((number ("less than" <)
2295 (string ("substring" s)
2299 (perms '(("temporary" (current-time-string))
2307 (if (eq type 'lower)
2312 (setq header (car headers))
2318 (let ((ts (cdr (assoc (nth 2 header) types)))
2334 'gnus-summary-score-entry
2336 (if (or (string= (nth 1 header)
2338 (string= (nth 1 header)
2341 (list 'gnus-summary-header
2343 (list 'quote (nth 1 (car ts)))
2344 (list 'gnus-score-delta-default
2351 (list (nreverse outp))))
2354 (list (nreverse outt))))
2356 (setq headers (cdr headers)))
2357 (list (nreverse outh))))))))
2361 (defun gnus-summary-mode (&optional group)
2362 "Major mode for reading articles.
2364 All normal editing commands are switched off.
2365 \\<gnus-summary-mode-map>
2366 Each line in this buffer represents one article. To read an
2367 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2368 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2371 You can also post articles and send mail from this buffer. To
2372 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2373 of an article, type `\\[gnus-summary-reply]'.
2375 There are approx. one gazillion commands you can execute in this
2376 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2378 The following commands are available:
2380 \\{gnus-summary-mode-map}"
2382 (kill-all-local-variables)
2383 (when (gnus-visual-p 'summary-menu 'menu)
2384 (gnus-summary-make-menu-bar)
2385 (gnus-summary-make-tool-bar))
2386 (gnus-summary-make-local-variables)
2387 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2388 (gnus-summary-make-local-variables))
2389 (gnus-make-thread-indent-array)
2390 (gnus-simplify-mode-line)
2391 (setq major-mode 'gnus-summary-mode)
2392 (setq mode-name "Summary")
2393 (make-local-variable 'minor-mode-alist)
2394 (use-local-map gnus-summary-mode-map)
2395 (buffer-disable-undo)
2396 (setq buffer-read-only t) ;Disable modification
2397 (setq truncate-lines t)
2398 (setq selective-display t)
2399 (setq selective-display-ellipses t) ;Display `...'
2400 (gnus-summary-set-display-table)
2401 (gnus-set-default-directory)
2402 (setq gnus-newsgroup-name group)
2403 (make-local-variable 'gnus-summary-line-format)
2404 (make-local-variable 'gnus-summary-line-format-spec)
2405 (make-local-variable 'gnus-summary-dummy-line-format)
2406 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2407 (make-local-variable 'gnus-summary-mark-positions)
2408 (make-local-hook 'pre-command-hook)
2409 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2410 (gnus-run-hooks 'gnus-summary-mode-hook)
2411 (turn-on-gnus-mailing-list-mode)
2412 (mm-enable-multibyte-mule4)
2413 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2414 (gnus-update-summary-mark-positions))
2416 (defun gnus-summary-make-local-variables ()
2417 "Make all the local summary buffer variables."
2419 (dolist (local gnus-summary-local-variables)
2422 (if (eq (cdr local) 'global)
2423 ;; Copy the global value of the variable.
2424 (setq global (symbol-value (car local)))
2425 ;; Use the value from the list.
2426 (setq global (eval (cdr local))))
2427 (set (make-local-variable (car local)) global))
2428 ;; Simple nil-valued local variable.
2429 (set (make-local-variable local) nil)))))
2431 (defun gnus-summary-clear-local-variables ()
2432 (let ((locals gnus-summary-local-variables))
2434 (if (consp (car locals))
2435 (and (vectorp (caar locals))
2436 (set (caar locals) nil))
2437 (and (vectorp (car locals))
2438 (set (car locals) nil)))
2439 (setq locals (cdr locals)))))
2441 ;; Summary data functions.
2443 (defmacro gnus-data-number (data)
2446 (defmacro gnus-data-set-number (data number)
2447 `(setcar ,data ,number))
2449 (defmacro gnus-data-mark (data)
2452 (defmacro gnus-data-set-mark (data mark)
2453 `(setcar (nthcdr 1 ,data) ,mark))
2455 (defmacro gnus-data-pos (data)
2458 (defmacro gnus-data-set-pos (data pos)
2459 `(setcar (nthcdr 2 ,data) ,pos))
2461 (defmacro gnus-data-header (data)
2464 (defmacro gnus-data-set-header (data header)
2465 `(setf (nth 3 ,data) ,header))
2467 (defmacro gnus-data-level (data)
2470 (defmacro gnus-data-unread-p (data)
2471 `(= (nth 1 ,data) gnus-unread-mark))
2473 (defmacro gnus-data-read-p (data)
2474 `(/= (nth 1 ,data) gnus-unread-mark))
2476 (defmacro gnus-data-pseudo-p (data)
2477 `(consp (nth 3 ,data)))
2479 (defmacro gnus-data-find (number)
2480 `(assq ,number gnus-newsgroup-data))
2482 (defmacro gnus-data-find-list (number &optional data)
2483 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2484 (memq (assq ,number bdata)
2487 (defmacro gnus-data-make (number mark pos header level)
2488 `(list ,number ,mark ,pos ,header ,level))
2490 (defun gnus-data-enter (after-article number mark pos header level offset)
2491 (let ((data (gnus-data-find-list after-article)))
2493 (error "No such article: %d" after-article))
2494 (setcdr data (cons (gnus-data-make number mark pos header level)
2496 (setq gnus-newsgroup-data-reverse nil)
2497 (gnus-data-update-list (cddr data) offset)))
2499 (defun gnus-data-enter-list (after-article list &optional offset)
2501 (let ((data (and after-article (gnus-data-find-list after-article)))
2505 (let ((odata gnus-newsgroup-data))
2506 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2508 (gnus-data-update-list odata offset)))
2509 ;; Find the last element in the list to be spliced into the main
2512 (setq list (cdr list)))
2515 (setcdr list gnus-newsgroup-data)
2516 (setq gnus-newsgroup-data ilist)
2518 (gnus-data-update-list (cdr list) offset)))
2519 (setcdr list (cdr data))
2522 (gnus-data-update-list (cdr list) offset))))
2523 (setq gnus-newsgroup-data-reverse nil))))
2525 (defun gnus-data-remove (article &optional offset)
2526 (let ((data gnus-newsgroup-data))
2527 (if (= (gnus-data-number (car data)) article)
2529 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2530 gnus-newsgroup-data-reverse nil)
2532 (gnus-data-update-list gnus-newsgroup-data offset)))
2534 (when (= (gnus-data-number (cadr data)) article)
2535 (setcdr data (cddr data))
2537 (gnus-data-update-list (cdr data) offset))
2539 gnus-newsgroup-data-reverse nil))
2540 (setq data (cdr data))))))
2542 (defmacro gnus-data-list (backward)
2544 (or gnus-newsgroup-data-reverse
2545 (setq gnus-newsgroup-data-reverse
2546 (reverse gnus-newsgroup-data)))
2547 gnus-newsgroup-data))
2549 (defun gnus-data-update-list (data offset)
2550 "Add OFFSET to the POS of all data entries in DATA."
2551 (setq gnus-newsgroup-data-reverse nil)
2553 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2554 (setq data (cdr data))))
2556 (defun gnus-summary-article-pseudo-p (article)
2557 "Say whether this article is a pseudo article or not."
2558 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2560 (defmacro gnus-summary-article-sparse-p (article)
2561 "Say whether this article is a sparse article or not."
2562 `(memq ,article gnus-newsgroup-sparse))
2564 (defmacro gnus-summary-article-ancient-p (article)
2565 "Say whether this article is a sparse article or not."
2566 `(memq ,article gnus-newsgroup-ancient))
2568 (defun gnus-article-parent-p (number)
2569 "Say whether this article is a parent or not."
2570 (let ((data (gnus-data-find-list number)))
2571 (and (cdr data) ; There has to be an article after...
2572 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2573 (gnus-data-level (nth 1 data))))))
2575 (defun gnus-article-children (number)
2576 "Return a list of all children to NUMBER."
2577 (let* ((data (gnus-data-find-list number))
2578 (level (gnus-data-level (car data)))
2580 (setq data (cdr data))
2582 (= (gnus-data-level (car data)) (1+ level)))
2583 (push (gnus-data-number (car data)) children)
2584 (setq data (cdr data)))
2587 (defmacro gnus-summary-skip-intangible ()
2588 "If the current article is intangible, then jump to a different article."
2589 '(let ((to (get-text-property (point) 'gnus-intangible)))
2590 (and to (gnus-summary-goto-subject to))))
2592 (defmacro gnus-summary-article-intangible-p ()
2593 "Say whether this article is intangible or not."
2594 '(get-text-property (point) 'gnus-intangible))
2596 (defun gnus-article-read-p (article)
2597 "Say whether ARTICLE is read or not."
2598 (not (or (memq article gnus-newsgroup-marked)
2599 (memq article gnus-newsgroup-unreads)
2600 (memq article gnus-newsgroup-unselected)
2601 (memq article gnus-newsgroup-dormant))))
2603 ;; Some summary mode macros.
2605 (defmacro gnus-summary-article-number ()
2606 "The article number of the article on the current line.
2607 If there isn's an article number here, then we return the current
2610 (gnus-summary-skip-intangible)
2611 (or (get-text-property (point) 'gnus-number)
2612 (gnus-summary-last-subject))))
2614 (defmacro gnus-summary-article-header (&optional number)
2615 "Return the header of article NUMBER."
2616 `(gnus-data-header (gnus-data-find
2617 ,(or number '(gnus-summary-article-number)))))
2619 (defmacro gnus-summary-thread-level (&optional number)
2620 "Return the level of thread that starts with article NUMBER."
2621 `(if (and (eq gnus-summary-make-false-root 'dummy)
2622 (get-text-property (point) 'gnus-intangible))
2624 (gnus-data-level (gnus-data-find
2625 ,(or number '(gnus-summary-article-number))))))
2627 (defmacro gnus-summary-article-mark (&optional number)
2628 "Return the mark of article NUMBER."
2629 `(gnus-data-mark (gnus-data-find
2630 ,(or number '(gnus-summary-article-number)))))
2632 (defmacro gnus-summary-article-pos (&optional number)
2633 "Return the position of the line of article NUMBER."
2634 `(gnus-data-pos (gnus-data-find
2635 ,(or number '(gnus-summary-article-number)))))
2637 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2638 (defmacro gnus-summary-article-subject (&optional number)
2639 "Return current subject string or nil if nothing."
2642 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2643 '(gnus-data-header (assq (gnus-summary-article-number)
2644 gnus-newsgroup-data)))))
2647 (mail-header-subject headers))))
2649 (defmacro gnus-summary-article-score (&optional number)
2650 "Return current article score."
2651 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2652 gnus-newsgroup-scored))
2653 gnus-summary-default-score 0))
2655 (defun gnus-summary-article-children (&optional number)
2656 "Return a list of article numbers that are children of article NUMBER."
2657 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2658 (level (gnus-data-level (car data)))
2660 (while (and (setq data (cdr data))
2661 (> (setq l (gnus-data-level (car data))) level))
2662 (and (= (1+ level) l)
2663 (push (gnus-data-number (car data))
2665 (nreverse children)))
2667 (defun gnus-summary-article-parent (&optional number)
2668 "Return the article number of the parent of article NUMBER."
2669 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2670 (gnus-data-list t)))
2671 (level (gnus-data-level (car data))))
2673 () ; This is a root.
2674 ;; We search until we find an article with a level less than
2675 ;; this one. That function has to be the parent.
2676 (while (and (setq data (cdr data))
2677 (not (< (gnus-data-level (car data)) level))))
2678 (and data (gnus-data-number (car data))))))
2680 (defun gnus-unread-mark-p (mark)
2681 "Say whether MARK is the unread mark."
2682 (= mark gnus-unread-mark))
2684 (defun gnus-read-mark-p (mark)
2685 "Say whether MARK is one of the marks that mark as read.
2686 This is all marks except unread, ticked, dormant, and expirable."
2687 (not (or (= mark gnus-unread-mark)
2688 (= mark gnus-ticked-mark)
2689 (= mark gnus-dormant-mark)
2690 (= mark gnus-expirable-mark))))
2692 (defmacro gnus-article-mark (number)
2693 "Return the MARK of article NUMBER.
2694 This macro should only be used when computing the mark the \"first\"
2695 time; i.e., when generating the summary lines. After that,
2696 `gnus-summary-article-mark' should be used to examine the
2699 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2700 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2701 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2702 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2703 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2704 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2705 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2706 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2707 gnus-ancient-mark))))
2709 ;; Saving hidden threads.
2711 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2712 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2714 (defmacro gnus-save-hidden-threads (&rest forms)
2715 "Save hidden threads, eval FORMS, and restore the hidden threads."
2716 (let ((config (make-symbol "config")))
2717 `(let ((,config (gnus-hidden-threads-configuration)))
2721 (gnus-restore-hidden-threads-configuration ,config)))))
2723 (defun gnus-data-compute-positions ()
2724 "Compute the positions of all articles."
2725 (setq gnus-newsgroup-data-reverse nil)
2726 (let ((data gnus-newsgroup-data))
2728 (gnus-save-hidden-threads
2729 (gnus-summary-show-all-threads)
2730 (goto-char (point-min))
2732 (while (get-text-property (point) 'gnus-intangible)
2734 (gnus-data-set-pos (car data) (+ (point) 3))
2735 (setq data (cdr data))
2736 (forward-line 1))))))
2738 (defun gnus-hidden-threads-configuration ()
2739 "Return the current hidden threads configuration."
2742 (goto-char (point-min))
2743 (while (search-forward "\r" nil t)
2744 (push (1- (point)) config))
2747 (defun gnus-restore-hidden-threads-configuration (config)
2748 "Restore hidden threads configuration from CONFIG."
2750 (let (point buffer-read-only)
2751 (while (setq point (pop config))
2752 (when (and (< point (point-max))
2754 (eq (char-after) ?\n))
2755 (subst-char-in-region point (1+ point) ?\n ?\r))))))
2757 ;; Various summary mode internalish functions.
2759 (defun gnus-mouse-pick-article (e)
2762 (gnus-summary-next-page nil t))
2764 (defun gnus-summary-set-display-table ()
2765 "Change the display table.
2766 Odd characters have a tendency to mess
2767 up nicely formatted displays - we make all possible glyphs
2768 display only a single character."
2770 ;; We start from the standard display table, if any.
2771 (let ((table (or (copy-sequence standard-display-table)
2772 (make-display-table)))
2774 ;; Nix out all the control chars...
2775 (while (>= (setq i (1- i)) 0)
2776 (aset table i [??]))
2777 ;; ... but not newline and cr, of course. (cr is necessary for the
2778 ;; selective display).
2779 (aset table ?\n nil)
2780 (aset table ?\r nil)
2781 ;; We keep TAB as well.
2782 (aset table ?\t nil)
2783 ;; We nix out any glyphs over 126 that are not set already.
2785 (while (>= (setq i (1- i)) 127)
2786 ;; Only modify if the entry is nil.
2787 (unless (aref table i)
2788 (aset table i [??]))))
2789 (setq buffer-display-table table)))
2791 (defun gnus-summary-set-article-display-arrow (pos)
2792 "Update the overlay arrow to point to line at position POS."
2793 (when (and gnus-summary-display-arrow
2794 (boundp 'overlay-arrow-position)
2795 (boundp 'overlay-arrow-string))
2799 (unless overlay-arrow-position
2800 (setq overlay-arrow-position (make-marker)))
2801 (setq overlay-arrow-string "=>"
2802 overlay-arrow-position (set-marker overlay-arrow-position
2804 (current-buffer))))))
2806 (defun gnus-summary-buffer-name (group)
2807 "Return the summary buffer name of GROUP."
2808 (concat "*Summary " (gnus-group-decoded-name group) "*"))
2810 (defun gnus-summary-setup-buffer (group)
2811 "Initialize summary buffer."
2812 (let ((buffer (gnus-summary-buffer-name group)))
2813 (if (get-buffer buffer)
2816 (setq gnus-summary-buffer (current-buffer))
2817 (not gnus-newsgroup-prepared))
2818 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2819 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
2820 (gnus-summary-mode group)
2822 (gnus-carpal-setup-buffer 'summary))
2823 (unless gnus-single-article-buffer
2824 (make-local-variable 'gnus-article-buffer)
2825 (make-local-variable 'gnus-article-current)
2826 (make-local-variable 'gnus-original-article-buffer))
2827 (setq gnus-newsgroup-name group)
2828 ;; Set any local variables in the group parameters.
2829 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2832 (defun gnus-set-global-variables ()
2833 "Set the global equivalents of the buffer-local variables.
2834 They are set to the latest values they had. These reflect the summary
2835 buffer that was in action when the last article was fetched."
2836 (when (eq major-mode 'gnus-summary-mode)
2837 (setq gnus-summary-buffer (current-buffer))
2838 (let ((name gnus-newsgroup-name)
2839 (marked gnus-newsgroup-marked)
2840 (unread gnus-newsgroup-unreads)
2841 (headers gnus-current-headers)
2842 (data gnus-newsgroup-data)
2843 (summary gnus-summary-buffer)
2844 (article-buffer gnus-article-buffer)
2845 (original gnus-original-article-buffer)
2846 (gac gnus-article-current)
2847 (reffed gnus-reffed-article-number)
2848 (score-file gnus-current-score-file)
2849 (default-charset gnus-newsgroup-charset)
2851 (let ((locals gnus-newsgroup-variables))
2853 (if (consp (car locals))
2854 (push (eval (caar locals)) vlist)
2855 (push (eval (car locals)) vlist))
2856 (setq locals (cdr locals)))
2857 (setq vlist (nreverse vlist)))
2859 (set-buffer gnus-group-buffer)
2860 (setq gnus-newsgroup-name name
2861 gnus-newsgroup-marked marked
2862 gnus-newsgroup-unreads unread
2863 gnus-current-headers headers
2864 gnus-newsgroup-data data
2865 gnus-article-current gac
2866 gnus-summary-buffer summary
2867 gnus-article-buffer article-buffer
2868 gnus-original-article-buffer original
2869 gnus-reffed-article-number reffed
2870 gnus-current-score-file score-file
2871 gnus-newsgroup-charset default-charset)
2872 (let ((locals gnus-newsgroup-variables))
2874 (if (consp (car locals))
2875 (set (caar locals) (pop vlist))
2876 (set (car locals) (pop vlist)))
2877 (setq locals (cdr locals))))
2878 ;; The article buffer also has local variables.
2879 (when (gnus-buffer-live-p gnus-article-buffer)
2880 (set-buffer gnus-article-buffer)
2881 (setq gnus-summary-buffer summary))))))
2883 (defun gnus-summary-article-unread-p (article)
2884 "Say whether ARTICLE is unread or not."
2885 (memq article gnus-newsgroup-unreads))
2887 (defun gnus-summary-first-article-p (&optional article)
2888 "Return whether ARTICLE is the first article in the buffer."
2889 (if (not (setq article (or article (gnus-summary-article-number))))
2891 (eq article (caar gnus-newsgroup-data))))
2893 (defun gnus-summary-last-article-p (&optional article)
2894 "Return whether ARTICLE is the last article in the buffer."
2895 (if (not (setq article (or article (gnus-summary-article-number))))
2896 ;; All non-existent numbers are the last article. :-)
2898 (not (cdr (gnus-data-find-list article)))))
2900 (defun gnus-make-thread-indent-array ()
2902 (unless (and gnus-thread-indent-array
2903 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2904 (setq gnus-thread-indent-array (make-vector 201 "")
2905 gnus-thread-indent-array-level gnus-thread-indent-level)
2907 (aset gnus-thread-indent-array n
2908 (make-string (* n gnus-thread-indent-level) ? ))
2911 (defun gnus-update-summary-mark-positions ()
2912 "Compute where the summary marks are to go."
2914 (when (gnus-buffer-exists-p gnus-summary-buffer)
2915 (set-buffer gnus-summary-buffer))
2916 (let ((gnus-replied-mark 129)
2917 (gnus-score-below-mark 130)
2918 (gnus-score-over-mark 130)
2919 (gnus-download-mark 131)
2920 (spec gnus-summary-line-format-spec)
2923 (gnus-set-work-buffer)
2924 (let ((gnus-summary-line-format-spec spec)
2925 (gnus-newsgroup-downloadable '((0 . t))))
2926 (gnus-summary-insert-line
2927 [0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil]
2928 0 nil 128 t nil "" nil 1)
2929 (goto-char (point-min))
2930 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2932 (goto-char (point-min))
2933 (push (cons 'replied (and (search-forward "\201" nil t)
2936 (goto-char (point-min))
2937 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2939 (goto-char (point-min))
2940 (push (cons 'download
2941 (and (search-forward "\203" nil t) (- (point) 2)))
2943 (setq gnus-summary-mark-positions pos))))
2945 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2946 "Insert a dummy root in the summary buffer."
2948 (gnus-add-text-properties
2949 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2950 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2952 (defun gnus-summary-extract-address-component (from)
2953 (or (car (funcall gnus-extract-address-components from))
2956 (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
2957 (let ((mail-parse-charset gnus-newsgroup-charset)
2958 ; Is it really necessary to do this next part for each summary line?
2959 ; Luckily, doesn't seem to slow things down much.
2960 (mail-parse-ignored-charsets
2961 (save-excursion (set-buffer gnus-summary-buffer)
2962 gnus-newsgroup-ignored-charsets)))
2964 (and gnus-ignored-from-addresses
2965 (string-match gnus-ignored-from-addresses gnus-tmp-from)
2966 (let ((extra-headers (mail-header-extra header))
2970 ((setq to (cdr (assq 'To extra-headers)))
2972 (gnus-summary-extract-address-component
2973 (funcall gnus-decode-encoded-word-function to))))
2974 ((setq newsgroups (cdr (assq 'Newsgroups extra-headers)))
2975 (concat "=> " newsgroups)))))
2976 (gnus-summary-extract-address-component gnus-tmp-from))))
2978 (defun gnus-summary-insert-line (gnus-tmp-header
2979 gnus-tmp-level gnus-tmp-current
2980 gnus-tmp-unread gnus-tmp-replied
2981 gnus-tmp-expirable gnus-tmp-subject-or-nil
2982 &optional gnus-tmp-dummy gnus-tmp-score
2984 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2985 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2986 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2987 (gnus-tmp-score-char
2988 (if (or (null gnus-summary-default-score)
2989 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2990 gnus-summary-zcore-fuzz))
2992 (if (< gnus-tmp-score gnus-summary-default-score)
2993 gnus-score-below-mark gnus-score-over-mark)))
2994 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2996 (cond (gnus-tmp-process gnus-process-mark)
2997 ((memq gnus-tmp-current gnus-newsgroup-cached)
2999 (gnus-tmp-replied gnus-replied-mark)
3000 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3001 gnus-forwarded-mark)
3002 ((memq gnus-tmp-current gnus-newsgroup-saved)
3004 ((memq gnus-tmp-number gnus-newsgroup-recent)
3006 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3009 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3012 ((string-match "<[^>]+> *$" gnus-tmp-from)
3013 (let ((beg (match-beginning 0)))
3014 (or (and (string-match "^\".+\"" gnus-tmp-from)
3015 (substring gnus-tmp-from 1 (1- (match-end 0))))
3016 (substring gnus-tmp-from 0 beg))))
3017 ((string-match "(.+)" gnus-tmp-from)
3018 (substring gnus-tmp-from
3019 (1+ (match-beginning 0)) (1- (match-end 0))))
3021 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
3022 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3023 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3024 (buffer-read-only nil))
3025 (when (string= gnus-tmp-name "")
3026 (setq gnus-tmp-name gnus-tmp-from))
3027 (unless (numberp gnus-tmp-lines)
3028 (setq gnus-tmp-lines -1))
3029 (if (= gnus-tmp-lines -1)
3030 (setq gnus-tmp-lines "?")
3031 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3032 (gnus-put-text-property
3034 (progn (eval gnus-summary-line-format-spec) (point))
3035 'gnus-number gnus-tmp-number)
3036 (when (gnus-visual-p 'summary-highlight 'highlight)
3038 (gnus-run-hooks 'gnus-summary-update-hook)
3041 (defun gnus-summary-update-line (&optional dont-update)
3042 "Update summary line after change."
3043 (when (and gnus-summary-default-score
3044 (not gnus-summary-inhibit-highlight))
3045 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3046 (article (gnus-summary-article-number))
3047 (score (gnus-summary-article-score article)))
3049 (if (and gnus-summary-mark-below
3050 (< (gnus-summary-article-score)
3051 gnus-summary-mark-below))
3052 ;; This article has a low score, so we mark it as read.
3053 (when (memq article gnus-newsgroup-unreads)
3054 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3055 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3056 ;; This article was previously marked as read on account
3057 ;; of a low score, but now it has risen, so we mark it as
3059 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3060 (gnus-summary-update-mark
3061 (if (or (null gnus-summary-default-score)
3062 (<= (abs (- score gnus-summary-default-score))
3063 gnus-summary-zcore-fuzz))
3065 (if (< score gnus-summary-default-score)
3066 gnus-score-below-mark gnus-score-over-mark))
3068 ;; Do visual highlighting.
3069 (when (gnus-visual-p 'summary-highlight 'highlight)
3070 (gnus-run-hooks 'gnus-summary-update-hook)))))
3072 (defvar gnus-tmp-new-adopts nil)
3074 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3075 "Return the number of articles in THREAD.
3076 This may be 0 in some cases -- if none of the articles in
3077 the thread are to be displayed."
3079 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3081 ((not (listp thread))
3083 ((and (consp thread) (cdr thread))
3086 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3089 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3092 (when (and level (zerop level) gnus-tmp-new-adopts)
3095 'gnus-summary-number-of-articles-in-thread
3096 gnus-tmp-new-adopts))))
3098 (if (> number 1) gnus-not-empty-thread-mark
3099 gnus-empty-thread-mark)
3102 (defun gnus-summary-set-local-parameters (group)
3103 "Go through the local params of GROUP and set all variable specs in that list."
3104 (let ((params (gnus-group-find-parameter group))
3105 (vars '(quit-config)) ; Ignore quit-config.
3108 (setq elem (car params)
3109 params (cdr params))
3110 (and (consp elem) ; Has to be a cons.
3111 (consp (cdr elem)) ; The cdr has to be a list.
3112 (symbolp (car elem)) ; Has to be a symbol in there.
3113 (not (memq (car elem) vars))
3114 (ignore-errors ; So we set it.
3115 (push (car elem) vars)
3116 (make-local-variable (car elem))
3117 (set (car elem) (eval (nth 1 elem))))))))
3119 (defun gnus-summary-read-group (group &optional show-all no-article
3120 kill-buffer no-display backward
3122 "Start reading news in newsgroup GROUP.
3123 If SHOW-ALL is non-nil, already read articles are also listed.
3124 If NO-ARTICLE is non-nil, no article is selected initially.
3125 If NO-DISPLAY, don't generate a summary buffer."
3129 (let ((gnus-auto-select-next nil))
3130 (or (gnus-summary-read-group-1
3131 group show-all no-article
3132 kill-buffer no-display
3135 select-articles nil)))))
3136 (eq gnus-auto-select-next 'quietly))
3137 (set-buffer gnus-group-buffer)
3138 ;; The entry function called above goes to the next
3139 ;; group automatically, so we go two groups back
3140 ;; if we are searching for the previous group.
3142 (gnus-group-prev-unread-group 2))
3143 (if (not (equal group (gnus-group-group-name)))
3144 (setq group (gnus-group-group-name))
3148 (defun gnus-summary-read-group-1 (group show-all no-article
3149 kill-buffer no-display
3150 &optional select-articles)
3151 ;; Killed foreign groups can't be entered.
3152 ;; (when (and (not (gnus-group-native-p group))
3153 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3154 ;; (error "Dead non-native groups can't be entered"))
3155 (gnus-message 5 "Retrieving newsgroup: %s..."
3156 (gnus-group-decoded-name group))
3157 (let* ((new-group (gnus-summary-setup-buffer group))
3158 (quit-config (gnus-group-quit-config group))
3159 (did-select (and new-group (gnus-select-newsgroup
3160 group show-all select-articles))))
3162 ;; This summary buffer exists already, so we just select it.
3164 (gnus-set-global-variables)
3166 (gnus-kill-or-deaden-summary kill-buffer))
3167 (gnus-configure-windows 'summary 'force)
3168 (gnus-set-mode-line 'summary)
3169 (gnus-summary-position-point)
3172 ;; We couldn't select this group.
3174 (when (and (eq major-mode 'gnus-summary-mode)
3175 (not (equal (current-buffer) kill-buffer)))
3176 (kill-buffer (current-buffer))
3177 (if (not quit-config)
3179 ;; Update the info -- marks might need to be removed,
3181 (gnus-summary-update-info)
3182 (set-buffer gnus-group-buffer)
3183 (gnus-group-jump-to-group group)
3184 (gnus-group-next-unread-group 1))
3185 (gnus-handle-ephemeral-exit quit-config)))
3186 (let ((grpinfo (gnus-get-info group)))
3187 (if (null (gnus-info-read grpinfo))
3188 (gnus-message 3 "Group %s contains no messages"
3189 (gnus-group-decoded-name group))
3190 (gnus-message 3 "Can't select group")))
3192 ;; The user did a `C-g' while prompting for number of articles,
3193 ;; so we exit this group.
3194 ((eq did-select 'quit)
3195 (and (eq major-mode 'gnus-summary-mode)
3196 (not (equal (current-buffer) kill-buffer))
3197 (kill-buffer (current-buffer)))
3199 (gnus-kill-or-deaden-summary kill-buffer))
3200 (if (not quit-config)
3202 (set-buffer gnus-group-buffer)
3203 (gnus-group-jump-to-group group)
3204 (gnus-group-next-unread-group 1)
3205 (gnus-configure-windows 'group 'force))
3206 (gnus-handle-ephemeral-exit quit-config))
3207 ;; Finally signal the quit.
3209 ;; The group was successfully selected.
3211 (gnus-set-global-variables)
3212 ;; Save the active value in effect when the group was entered.
3213 (setq gnus-newsgroup-active
3215 (gnus-active gnus-newsgroup-name)))
3216 ;; You can change the summary buffer in some way with this hook.
3217 (gnus-run-hooks 'gnus-select-group-hook)
3218 (gnus-update-format-specifications
3219 nil 'summary 'summary-mode 'summary-dummy)
3220 (gnus-update-summary-mark-positions)
3221 ;; Do score processing.
3222 (when gnus-use-scoring
3223 (gnus-possibly-score-headers))
3224 ;; Check whether to fill in the gaps in the threads.
3225 (when gnus-build-sparse-threads
3226 (gnus-build-sparse-threads))
3227 ;; Find the initial limit.
3228 (if gnus-show-threads
3230 (let ((gnus-newsgroup-dormant nil))
3231 (gnus-summary-initial-limit show-all))
3232 (gnus-summary-initial-limit show-all))
3233 ;; When untreaded, all articles are always shown.
3234 (setq gnus-newsgroup-limit
3236 (lambda (header) (mail-header-number header))
3237 gnus-newsgroup-headers)))
3238 ;; Generate the summary buffer.
3240 (gnus-summary-prepare))
3241 (when gnus-use-trees
3242 (gnus-tree-open group)
3243 (setq gnus-summary-highlight-line-function
3244 'gnus-tree-highlight-article))
3245 ;; If the summary buffer is empty, but there are some low-scored
3246 ;; articles or some excluded dormants, we include these in the
3248 (when (and (zerop (buffer-size))
3250 (cond (gnus-newsgroup-dormant
3251 (gnus-summary-limit-include-dormant))
3252 ((and gnus-newsgroup-scored show-all)
3253 (gnus-summary-limit-include-expunged t))))
3254 ;; Function `gnus-apply-kill-file' must be called in this hook.
3255 (gnus-run-hooks 'gnus-apply-kill-hook)
3256 (if (and (zerop (buffer-size))
3259 ;; This newsgroup is empty.
3260 (gnus-summary-catchup-and-exit nil t)
3261 (gnus-message 6 "No unread news")
3263 (gnus-kill-or-deaden-summary kill-buffer))
3264 ;; Return nil from this function.
3266 ;; Hide conversation thread subtrees. We cannot do this in
3267 ;; gnus-summary-prepare-hook since kill processing may not
3268 ;; work with hidden articles.
3269 (and gnus-show-threads
3270 gnus-thread-hide-subtree
3271 (gnus-summary-hide-all-threads))
3273 (gnus-kill-or-deaden-summary kill-buffer))
3274 (gnus-summary-auto-select-subject)
3275 ;; Show first unread article if requested.
3276 (if (and (not no-article)
3278 gnus-newsgroup-unreads
3279 gnus-auto-select-first)
3281 (gnus-configure-windows 'summary)
3282 (gnus-summary-goto-article (gnus-summary-article-number)))
3283 ;; Don't select any articles.
3284 (gnus-summary-position-point)
3285 (gnus-configure-windows 'summary 'force)
3286 (gnus-set-mode-line 'summary))
3287 (when (get-buffer-window gnus-group-buffer t)
3288 ;; Gotta use windows, because recenter does weird stuff if
3289 ;; the current buffer ain't the displayed window.
3290 (let ((owin (selected-window)))
3291 (select-window (get-buffer-window gnus-group-buffer t))
3292 (when (gnus-group-goto-group group)
3294 (select-window owin)))
3295 ;; Mark this buffer as "prepared".
3296 (setq gnus-newsgroup-prepared t)
3297 (gnus-run-hooks 'gnus-summary-prepared-hook)
3300 (defun gnus-summary-auto-select-subject ()
3301 "Select the subject line on initial group entry."
3302 (goto-char (point-min))
3304 ((eq gnus-auto-select-subject 'best)
3305 (gnus-summary-best-unread-subject))
3306 ((eq gnus-auto-select-subject 'unread)
3307 (gnus-summary-first-unread-subject))
3308 ((eq gnus-auto-select-subject 'unseen)
3309 (gnus-summary-first-unseen-subject))
3310 ((eq gnus-auto-select-subject 'first)
3313 ((gnus-functionp gnus-auto-select-subject)
3314 (funcall gnus-auto-select-subject))))
3316 (defun gnus-summary-prepare ()
3317 "Generate the summary buffer."
3319 (let ((buffer-read-only nil))
3321 (setq gnus-newsgroup-data nil
3322 gnus-newsgroup-data-reverse nil)
3323 (gnus-run-hooks 'gnus-summary-generate-hook)
3324 ;; Generate the buffer, either with threads or without.
3325 (when gnus-newsgroup-headers
3326 (gnus-summary-prepare-threads
3327 (if gnus-show-threads
3328 (gnus-sort-gathered-threads
3329 (funcall gnus-summary-thread-gathering-function
3331 (gnus-cut-threads (gnus-make-threads)))))
3332 ;; Unthreaded display.
3333 (gnus-sort-articles gnus-newsgroup-headers))))
3334 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3335 ;; Call hooks for modifying summary buffer.
3336 (goto-char (point-min))
3337 (gnus-run-hooks 'gnus-summary-prepare-hook)))
3339 (defsubst gnus-general-simplify-subject (subject)
3340 "Simply subject by the same rules as gnus-gather-threads-by-subject."
3343 ;; Truncate the subject.
3344 (gnus-simplify-subject-functions
3345 (gnus-map-function gnus-simplify-subject-functions subject))
3346 ((numberp gnus-summary-gather-subject-limit)
3347 (setq subject (gnus-simplify-subject-re subject))
3348 (if (> (length subject) gnus-summary-gather-subject-limit)
3349 (substring subject 0 gnus-summary-gather-subject-limit)
3351 ;; Fuzzily simplify it.
3352 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3353 (gnus-simplify-subject-fuzzy subject))
3354 ;; Just remove the leading "Re:".
3356 (gnus-simplify-subject-re subject))))
3358 (if (and gnus-summary-gather-exclude-subject
3359 (string-match gnus-summary-gather-exclude-subject subject))
3360 nil ; This article shouldn't be gathered
3363 (defun gnus-summary-simplify-subject-query ()
3364 "Query where the respool algorithm would put this article."
3366 (gnus-summary-select-article)
3367 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
3369 (defun gnus-gather-threads-by-subject (threads)
3370 "Gather threads by looking at Subject headers."
3371 (if (not gnus-summary-make-false-root)
3373 (let ((hashtb (gnus-make-hashtable 1024))
3376 subject hthread whole-subject)
3378 (setq subject (gnus-general-simplify-subject
3379 (setq whole-subject (mail-header-subject
3382 (if (setq hthread (gnus-gethash subject hashtb))
3384 ;; We enter a dummy root into the thread, if we
3385 ;; haven't done that already.
3386 (unless (stringp (caar hthread))
3387 (setcar hthread (list whole-subject (car hthread))))
3388 ;; We add this new gathered thread to this gathered
3390 (setcdr (car hthread)
3391 (nconc (cdar hthread) (list (car threads))))
3392 ;; Remove it from the list of threads.
3393 (setcdr prev (cdr threads))
3394 (setq threads prev))
3395 ;; Enter this thread into the hash table.
3396 (gnus-sethash subject threads hashtb)))
3398 (setq threads (cdr threads)))
3401 (defun gnus-gather-threads-by-references (threads)
3402 "Gather threads by looking at References headers."
3403 (let ((idhashtb (gnus-make-hashtable 1024))
3404 (thhashtb (gnus-make-hashtable 1024))
3407 ids references id gthread gid entered ref)
3409 (when (setq references (mail-header-references (caar threads)))
3410 (setq id (mail-header-id (caar threads))
3411 ids (gnus-split-references references)
3413 (while (setq ref (pop ids))
3414 (setq ids (delete ref ids))
3415 (if (not (setq gid (gnus-gethash ref idhashtb)))
3417 (gnus-sethash ref id idhashtb)
3418 (gnus-sethash id threads thhashtb))
3419 (setq gthread (gnus-gethash gid thhashtb))
3421 ;; We enter a dummy root into the thread, if we
3422 ;; haven't done that already.
3423 (unless (stringp (caar gthread))
3424 (setcar gthread (list (mail-header-subject (caar gthread))
3426 ;; We add this new gathered thread to this gathered
3428 (setcdr (car gthread)
3429 (nconc (cdar gthread) (list (car threads)))))
3430 ;; Add it into the thread hash table.
3431 (gnus-sethash id gthread thhashtb)
3433 ;; Remove it from the list of threads.
3434 (setcdr prev (cdr threads))
3435 (setq threads prev))))
3437 (setq threads (cdr threads)))
3440 (defun gnus-sort-gathered-threads (threads)
3441 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
3442 (let ((result threads))
3444 (when (stringp (caar threads))
3445 (setcdr (car threads)
3446 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3447 (setq threads (cdr threads)))
3450 (defun gnus-thread-loop-p (root thread)
3451 "Say whether ROOT is in THREAD."
3452 (let ((stack (list thread))
3455 (while (setq thread (pop stack))
3456 (setq th (cdr thread))
3458 (not (eq (caar th) root)))
3461 ;; We have found a loop.
3463 (setcdr thread (delq (car th) (cdr thread)))
3464 (if (boundp (setq ref-dep (intern "none"
3465 gnus-newsgroup-dependencies)))
3466 (setcdr (symbol-value ref-dep)
3467 (nconc (cdr (symbol-value ref-dep))
3469 (set ref-dep (list nil (car th))))
3472 ;; Push all the subthreads onto the stack.
3473 (push (cdr thread) stack)))
3476 (defun gnus-make-threads ()
3477 "Go through the dependency hashtb and find the roots. Return all threads."
3479 (while (catch 'infloop
3482 ;; Deal with self-referencing References loops.
3483 (when (and (car (symbol-value refs))
3490 (car (symbol-value refs)) thread))
3491 (cdr (symbol-value refs)))))))
3494 (unless (car (symbol-value refs))
3495 ;; These threads do not refer back to any other articles,
3496 ;; so they're roots.
3497 (setq threads (append (cdr (symbol-value refs)) threads))))
3498 gnus-newsgroup-dependencies)))
3501 ;; Build the thread tree.
3502 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3503 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3505 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3506 if it was already present.
3508 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3509 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3510 Message-IDs will be renamed be renamed to a unique Message-ID before
3513 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3514 (let* ((id (mail-header-id header))
3515 (id-dep (and id (intern id dependencies)))
3516 ref ref-dep ref-header)
3517 ;; Enter this `header' in the `dependencies' table.
3521 ;; The first two cases do the normal part: enter a new `header'
3522 ;; in the `dependencies' table.
3523 ((not (boundp id-dep))
3524 (set id-dep (list header)))
3525 ((null (car (symbol-value id-dep)))
3526 (setcar (symbol-value id-dep) header))
3528 ;; From here the `header' was already present in the
3529 ;; `dependencies' table.
3531 ;; Overrides an existing entry;
3532 ;; just set the header part of the entry.
3533 (setcar (symbol-value id-dep) header))
3535 ;; Renames the existing `header' to a unique Message-ID.
3536 ((not gnus-summary-ignore-duplicates)
3537 ;; An article with this Message-ID has already been seen.
3538 ;; We rename the Message-ID.
3539 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3541 (mail-header-set-id header id))
3543 ;; The last case ignores an existing entry, except it adds any
3544 ;; additional Xrefs (in case the two articles came from different
3546 ;; Also sets `header' to `nil' meaning that the `dependencies'
3547 ;; table was *not* modified.
3549 (mail-header-set-xref
3550 (car (symbol-value id-dep))
3551 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3553 (or (mail-header-xref header) "")))
3557 ;; First check if that we are not creating a References loop.
3558 (setq ref (gnus-parent-id (mail-header-references header)))
3560 (setq ref-dep (intern-soft ref dependencies))
3562 (setq ref-header (car (symbol-value ref-dep))))
3563 (if (string= id ref)
3564 ;; Yuk! This is a reference loop. Make the article be a
3567 (mail-header-set-references (car (symbol-value id-dep)) "none")
3569 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3570 (setq ref (gnus-parent-id (mail-header-references header)))
3571 (setq ref-dep (intern (or ref "none") dependencies))
3572 (if (boundp ref-dep)
3573 (setcdr (symbol-value ref-dep)
3574 (nconc (cdr (symbol-value ref-dep))
3575 (list (symbol-value id-dep))))
3576 (set ref-dep (list nil (symbol-value id-dep)))))
3579 (defun gnus-build-sparse-threads ()
3580 (let ((headers gnus-newsgroup-headers)
3581 (mail-parse-charset gnus-newsgroup-charset)
3582 (gnus-summary-ignore-duplicates t)
3583 header references generation relations
3584 subject child end new-child date)
3585 ;; First we create an alist of generations/relations, where
3586 ;; generations is how much we trust the relation, and the relation
3588 (gnus-message 7 "Making sparse threads...")
3590 (nnheader-set-temp-buffer " *gnus sparse threads*")
3591 (while (setq header (pop headers))
3592 (when (and (setq references (mail-header-references header))
3593 (not (string= references "")))
3595 (setq child (mail-header-id header)
3596 subject (mail-header-subject header)
3597 date (mail-header-date header)
3599 (while (search-backward ">" nil t)
3600 (setq end (1+ (point)))
3601 (when (search-backward "<" nil t)
3602 (setq new-child (buffer-substring (point) end))
3603 (push (list (incf generation)
3604 child (setq child new-child)
3608 (push (list (1+ generation) child nil subject) relations))
3610 (kill-buffer (current-buffer)))
3611 ;; Sort over trustworthiness.
3614 (when (gnus-dependencies-add-header
3615 (make-full-mail-header
3616 gnus-reffed-article-number
3617 (nth 3 relation) "" (or (nth 4 relation) "")
3619 (or (nth 2 relation) "") 0 0 "")
3620 gnus-newsgroup-dependencies nil)
3621 (push gnus-reffed-article-number gnus-newsgroup-limit)
3622 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3623 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3624 gnus-newsgroup-reads)
3625 (decf gnus-reffed-article-number)))
3626 (sort relations 'car-less-than-car))
3627 (gnus-message 7 "Making sparse threads...done")))
3629 (defun gnus-build-old-threads ()
3630 ;; Look at all the articles that refer back to old articles, and
3631 ;; fetch the headers for the articles that aren't there. This will
3632 ;; build complete threads - if the roots haven't been expired by the
3634 (let ((mail-parse-charset gnus-newsgroup-charset)
3638 (when (not (car (symbol-value refs)))
3639 (setq heads (cdr (symbol-value refs)))
3641 (if (memq (mail-header-number (caar heads))
3642 gnus-newsgroup-dormant)
3643 (setq heads (cdr heads))
3644 (setq id (symbol-name refs))
3645 (while (and (setq id (gnus-build-get-header id))
3646 (not (car (gnus-id-to-thread id)))))
3647 (setq heads nil)))))
3648 gnus-newsgroup-dependencies)))
3650 ;; This function has to be called with point after the article number
3651 ;; on the beginning of the line.
3652 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3653 (let ((eol (gnus-point-at-eol))
3654 (buffer (current-buffer))
3657 ;; overview: [num subject from date id refs chars lines misc]
3660 (narrow-to-region (point) eol)
3665 (make-full-mail-header
3667 (funcall gnus-decode-encoded-word-function
3668 (nnheader-nov-field)) ; subject
3669 (funcall gnus-decode-encoded-word-function
3670 (nnheader-nov-field)) ; from
3671 (nnheader-nov-field) ; date
3672 (nnheader-nov-read-message-id) ; id
3673 (nnheader-nov-field) ; refs
3674 (nnheader-nov-read-integer) ; chars
3675 (nnheader-nov-read-integer) ; lines
3677 (if (looking-at "Xref: ")
3678 (goto-char (match-end 0)))
3679 (nnheader-nov-field)) ; Xref
3680 (nnheader-nov-parse-extra)))) ; extra
3684 (when gnus-alter-header-function
3685 (funcall gnus-alter-header-function header))
3686 (gnus-dependencies-add-header header dependencies force-new)))
3688 (defun gnus-build-get-header (id)
3689 "Look through the buffer of NOV lines and find the header to ID.
3690 Enter this line into the dependencies hash table, and return
3691 the id of the parent article (if any)."
3692 (let ((deps gnus-newsgroup-dependencies)
3696 (set-buffer nntp-server-buffer)
3697 (let ((case-fold-search nil))
3698 (goto-char (point-min))
3699 (while (and (not found)
3700 (search-forward id nil t))
3702 (setq found (looking-at
3703 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3704 (regexp-quote id))))
3705 (or found (beginning-of-line 2)))
3709 (setq header (gnus-nov-parse-line
3710 (read (current-buffer)) deps))
3711 (gnus-parent-id (mail-header-references header))))))
3713 (let ((number (mail-header-number header)))
3714 (push number gnus-newsgroup-limit)
3715 (push header gnus-newsgroup-headers)
3716 (if (memq number gnus-newsgroup-unselected)
3718 (push number gnus-newsgroup-unreads)
3719 (setq gnus-newsgroup-unselected
3720 (delq number gnus-newsgroup-unselected)))
3721 (push number gnus-newsgroup-ancient)))))))
3723 (defun gnus-build-all-threads ()
3724 "Read all the headers."
3725 (let ((gnus-summary-ignore-duplicates t)
3726 (mail-parse-charset gnus-newsgroup-charset)
3727 (dependencies gnus-newsgroup-dependencies)
3730 (set-buffer nntp-server-buffer)
3731 (let ((case-fold-search nil))
3732 (goto-char (point-min))
3735 (setq article (read (current-buffer))
3736 header (gnus-nov-parse-line article dependencies)))
3739 (set-buffer gnus-summary-buffer)
3740 (push header gnus-newsgroup-headers)
3741 (if (memq (setq article (mail-header-number header))
3742 gnus-newsgroup-unselected)
3744 (push article gnus-newsgroup-unreads)
3745 (setq gnus-newsgroup-unselected
3746 (delq article gnus-newsgroup-unselected)))
3747 (push article gnus-newsgroup-ancient)))
3748 (forward-line 1)))))))
3750 (defun gnus-summary-update-article-line (article header)
3751 "Update the line for ARTICLE using HEADERS."
3752 (let* ((id (mail-header-id header))
3753 (thread (gnus-id-to-thread id)))
3755 (error "Article in no thread"))
3756 ;; Update the thread.
3757 (setcar thread header)
3758 (gnus-summary-goto-subject article)
3759 (let* ((datal (gnus-data-find-list article))
3761 (length (when (cdr datal)
3762 (- (gnus-data-pos data)
3763 (gnus-data-pos (cadr datal)))))
3764 (buffer-read-only nil)
3765 (level (gnus-summary-thread-level)))
3767 (gnus-summary-insert-line
3768 header level nil (gnus-article-mark article)
3769 (memq article gnus-newsgroup-replied)
3770 (memq article gnus-newsgroup-expirable)
3771 ;; Only insert the Subject string when it's different
3772 ;; from the previous Subject string.
3777 (mail-header-subject
3780 (gnus-data-find-list
3782 (gnus-data-list t)))))
3783 ;; Error on the side of excessive subjects.
3785 (mail-header-subject header)))
3787 (mail-header-subject header))
3788 nil (cdr (assq article gnus-newsgroup-scored))
3789 (memq article gnus-newsgroup-processable))
3791 (gnus-data-update-list
3792 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3794 (defun gnus-summary-update-article (article &optional iheader)
3795 "Update ARTICLE in the summary buffer."
3796 (set-buffer gnus-summary-buffer)
3797 (let* ((header (gnus-summary-article-header article))
3798 (id (mail-header-id header))
3799 (data (gnus-data-find article))
3800 (thread (gnus-id-to-thread id))
3801 (references (mail-header-references header))
3805 (when (and references
3806 (not (equal "" references)))
3809 (buffer-read-only nil)
3815 (delq thread parent)))
3816 (if (gnus-summary-insert-subject id header)
3817 ;; Set the (possibly) new article number in the data structure.
3818 (gnus-data-set-number data (gnus-id-to-article id))
3822 (defun gnus-rebuild-thread (id &optional line)
3823 "Rebuild the thread containing ID.
3824 If LINE, insert the rebuilt thread starting on line LINE."
3825 (let ((buffer-read-only nil)
3826 old-pos current thread data)
3827 (if (not gnus-show-threads)
3828 (setq thread (list (car (gnus-id-to-thread id))))
3829 ;; Get the thread this article is part of.
3830 (setq thread (gnus-remove-thread id)))
3831 (setq old-pos (gnus-point-at-bol))
3832 (setq current (save-excursion
3833 (and (re-search-backward "[\r\n]" nil t)
3834 (gnus-summary-article-number))))
3835 ;; If this is a gathered thread, we have to go some re-gathering.
3836 (when (stringp (car thread))
3837 (let ((subject (car thread))
3839 (setq thread (cdr thread))
3841 (unless (memq (setq thr (gnus-id-to-thread
3843 (mail-header-id (caar thread)))))
3846 (setq thread (cdr thread)))
3847 ;; We now have all (unique) roots.
3848 (if (= (length roots) 1)
3849 ;; All the loose roots are now one solid root.
3850 (setq thread (car roots))
3851 (setq thread (cons subject (gnus-sort-threads roots))))))
3853 ;; We then insert this thread into the summary buffer.
3855 (goto-char (point-min))
3856 (forward-line (1- line)))
3857 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3858 (if gnus-show-threads
3859 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3860 (gnus-summary-prepare-unthreaded thread))
3861 (setq data (nreverse gnus-newsgroup-data))
3862 (setq threads gnus-newsgroup-threads))
3863 ;; We splice the new data into the data structure.
3864 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
3865 ;;!!! then we want to insert at the beginning of the buffer.
3866 ;;!!! That happens to be true with Gnus now, but that may
3867 ;;!!! change in the future. Perhaps.
3868 (gnus-data-enter-list
3869 (if line nil current) data (- (point) old-pos))
3870 (setq gnus-newsgroup-threads
3871 (nconc threads gnus-newsgroup-threads))
3872 (gnus-data-compute-positions))))
3874 (defun gnus-number-to-header (number)
3875 "Return the header for article NUMBER."
3876 (let ((headers gnus-newsgroup-headers))
3878 (not (= number (mail-header-number (car headers)))))
3883 (defun gnus-parent-headers (in-headers &optional generation)
3884 "Return the headers of the GENERATIONeth parent of HEADERS."
3886 (setq generation 1))
3888 (headers in-headers)
3891 (not (zerop generation))
3892 (setq references (mail-header-references headers)))
3893 (setq headers (if (and references
3894 (setq parent (gnus-parent-id references)))
3895 (car (gnus-id-to-thread parent))
3898 (and (not (eq headers in-headers))
3901 (defun gnus-id-to-thread (id)
3902 "Return the (sub-)thread where ID appears."
3903 (gnus-gethash id gnus-newsgroup-dependencies))
3905 (defun gnus-id-to-article (id)
3906 "Return the article number of ID."
3907 (let ((thread (gnus-id-to-thread id)))
3910 (mail-header-number (car thread)))))
3912 (defun gnus-id-to-header (id)
3913 "Return the article headers of ID."
3914 (car (gnus-id-to-thread id)))
3916 (defun gnus-article-displayed-root-p (article)
3917 "Say whether ARTICLE is a root(ish) article."
3918 (let ((level (gnus-summary-thread-level article))
3919 (refs (mail-header-references (gnus-summary-article-header article)))
3925 ((null (gnus-parent-id refs)) t)
3927 (null (setq particle (gnus-id-to-article
3928 (gnus-parent-id refs))))
3929 (null (gnus-summary-thread-level particle)))))))
3931 (defun gnus-root-id (id)
3932 "Return the id of the root of the thread where ID appears."
3934 (while (and id (setq prev (car (gnus-id-to-thread id))))
3936 id (gnus-parent-id (mail-header-references prev))))
3939 (defun gnus-articles-in-thread (thread)
3940 "Return the list of articles in THREAD."
3941 (cons (mail-header-number (car thread))
3942 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
3944 (defun gnus-remove-thread (id &optional dont-remove)
3945 "Remove the thread that has ID in it."
3946 (let (headers thread last-id)
3947 ;; First go up in this thread until we find the root.
3948 (setq last-id (gnus-root-id id)
3949 headers (message-flatten-list (gnus-id-to-thread last-id)))
3950 ;; We have now found the real root of this thread. It might have
3951 ;; been gathered into some loose thread, so we have to search
3952 ;; through the threads to find the thread we wanted.
3953 (let ((threads gnus-newsgroup-threads)
3956 (setq sub (car threads))
3957 (if (stringp (car sub))
3958 ;; This is a gathered thread, so we look at the roots
3959 ;; below it to find whether this article is in this
3962 (setq sub (cdr sub))
3964 (when (member (caar sub) headers)
3965 (setq thread (car threads)
3968 (setq sub (cdr sub))))
3969 ;; It's an ordinary thread, so we check it.
3970 (when (eq (car sub) (car headers))
3973 (setq threads (cdr threads)))
3974 ;; If this article is in no thread, then it's a root.
3977 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
3978 (setq thread (gnus-id-to-thread last-id)))
3981 thread ; We return this thread.
3983 (if (stringp (car thread))
3985 ;; If we use dummy roots, then we have to remove the
3986 ;; dummy root as well.
3987 (when (eq gnus-summary-make-false-root 'dummy)
3988 ;; We go to the dummy root by going to
3989 ;; the first sub-"thread", and then one line up.
3990 (gnus-summary-goto-article
3991 (mail-header-number (caadr thread)))
3994 (gnus-data-compute-positions))
3995 (setq thread (cdr thread))
3997 (gnus-remove-thread-1 (car thread))
3998 (setq thread (cdr thread))))
3999 (gnus-remove-thread-1 thread))))))))
4001 (defun gnus-remove-thread-1 (thread)
4002 "Remove the thread THREAD recursively."
4003 (let ((number (mail-header-number (pop thread)))
4005 (setq thread (reverse thread))
4007 (gnus-remove-thread-1 (pop thread)))
4008 (when (setq d (gnus-data-find number))
4009 (goto-char (gnus-data-pos d))
4010 (gnus-summary-show-thread)
4013 (- (gnus-point-at-bol)
4015 (1+ (gnus-point-at-eol))
4016 (gnus-delete-line)))))))
4018 (defun gnus-sort-threads-1 (threads func)
4019 (sort (mapcar (lambda (thread)
4022 (gnus-sort-threads-1 (cdr thread) func))))
4025 (defun gnus-sort-threads (threads)
4027 (if (not gnus-thread-sort-functions)
4029 (gnus-message 8 "Sorting threads...")
4031 (gnus-sort-threads-1
4033 (gnus-make-sort-function gnus-thread-sort-functions))
4034 (gnus-message 8 "Sorting threads...done"))))
4036 (defun gnus-sort-articles (articles)
4038 (when gnus-article-sort-functions
4039 (gnus-message 7 "Sorting articles...")
4041 (setq gnus-newsgroup-headers
4042 (sort articles (gnus-make-sort-function
4043 gnus-article-sort-functions)))
4044 (gnus-message 7 "Sorting articles...done"))))
4046 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4047 (defmacro gnus-thread-header (thread)
4048 "Return header of first article in THREAD.
4049 Note that THREAD must never, ever be anything else than a variable -
4050 using some other form will lead to serious barfage."
4051 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4052 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4053 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4056 (defsubst gnus-article-sort-by-number (h1 h2)
4057 "Sort articles by article number."
4058 (< (mail-header-number h1)
4059 (mail-header-number h2)))
4061 (defun gnus-thread-sort-by-number (h1 h2)
4062 "Sort threads by root article number."
4063 (gnus-article-sort-by-number
4064 (gnus-thread-header h1) (gnus-thread-header h2)))
4066 (defsubst gnus-article-sort-by-lines (h1 h2)
4067 "Sort articles by article Lines header."
4068 (< (mail-header-lines h1)
4069 (mail-header-lines h2)))
4071 (defun gnus-thread-sort-by-lines (h1 h2)
4072 "Sort threads by root article Lines header."
4073 (gnus-article-sort-by-lines
4074 (gnus-thread-header h1) (gnus-thread-header h2)))
4076 (defsubst gnus-article-sort-by-chars (h1 h2)
4077 "Sort articles by octet length."
4078 (< (mail-header-chars h1)
4079 (mail-header-chars h2)))
4081 (defun gnus-thread-sort-by-chars (h1 h2)
4082 "Sort threads by root article octet length."
4083 (gnus-article-sort-by-chars
4084 (gnus-thread-header h1) (gnus-thread-header h2)))
4086 (defsubst gnus-article-sort-by-author (h1 h2)
4087 "Sort articles by root author."
4089 (let ((extract (funcall
4090 gnus-extract-address-components
4091 (mail-header-from h1))))
4092 (or (car extract) (cadr extract) ""))
4093 (let ((extract (funcall
4094 gnus-extract-address-components
4095 (mail-header-from h2))))
4096 (or (car extract) (cadr extract) ""))))
4098 (defun gnus-thread-sort-by-author (h1 h2)
4099 "Sort threads by root author."
4100 (gnus-article-sort-by-author
4101 (gnus-thread-header h1) (gnus-thread-header h2)))
4103 (defsubst gnus-article-sort-by-subject (h1 h2)
4104 "Sort articles by root subject."
4106 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4107 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4109 (defun gnus-thread-sort-by-subject (h1 h2)
4110 "Sort threads by root subject."
4111 (gnus-article-sort-by-subject
4112 (gnus-thread-header h1) (gnus-thread-header h2)))
4114 (defsubst gnus-article-sort-by-date (h1 h2)
4115 "Sort articles by root article date."
4117 (gnus-date-get-time (mail-header-date h1))
4118 (gnus-date-get-time (mail-header-date h2))))
4120 (defun gnus-thread-sort-by-date (h1 h2)
4121 "Sort threads by root article date."
4122 (gnus-article-sort-by-date
4123 (gnus-thread-header h1) (gnus-thread-header h2)))
4125 (defsubst gnus-article-sort-by-score (h1 h2)
4126 "Sort articles by root article score.
4127 Unscored articles will be counted as having a score of zero."
4128 (> (or (cdr (assq (mail-header-number h1)
4129 gnus-newsgroup-scored))
4130 gnus-summary-default-score 0)
4131 (or (cdr (assq (mail-header-number h2)
4132 gnus-newsgroup-scored))
4133 gnus-summary-default-score 0)))
4135 (defun gnus-thread-sort-by-score (h1 h2)
4136 "Sort threads by root article score."
4137 (gnus-article-sort-by-score
4138 (gnus-thread-header h1) (gnus-thread-header h2)))
4140 (defun gnus-thread-sort-by-total-score (h1 h2)
4141 "Sort threads by the sum of all scores in the thread.
4142 Unscored articles will be counted as having a score of zero."
4143 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4145 (defun gnus-thread-total-score (thread)
4146 ;; This function find the total score of THREAD.
4147 (cond ((null thread)
4150 (if (stringp (car thread))
4151 (apply gnus-thread-score-function 0
4152 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4153 (gnus-thread-total-score-1 thread)))
4155 (gnus-thread-total-score-1 (list thread)))))
4157 (defun gnus-thread-total-score-1 (root)
4158 ;; This function find the total score of the thread below ROOT.
4159 (setq root (car root))
4160 (apply gnus-thread-score-function
4162 (mapcar 'gnus-thread-total-score
4163 (cdr (gnus-id-to-thread (mail-header-id root))))
4164 (when (> (mail-header-number root) 0)
4165 (list (or (cdr (assq (mail-header-number root)
4166 gnus-newsgroup-scored))
4167 gnus-summary-default-score 0))))
4168 (list gnus-summary-default-score)
4171 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
4172 (defvar gnus-tmp-prev-subject nil)
4173 (defvar gnus-tmp-false-parent nil)
4174 (defvar gnus-tmp-root-expunged nil)
4175 (defvar gnus-tmp-dummy-line nil)
4177 (eval-when-compile (defvar gnus-tmp-header))
4178 (defun gnus-extra-header (type &optional header)
4179 "Return the extra header of TYPE."
4180 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
4183 (defvar gnus-tmp-thread-tree-header-string "")
4185 (defvar gnus-sum-thread-tree-root "> "
4186 "With %B spec, used for the root of a thread.
4187 If nil, use subject instead.")
4188 (defvar gnus-sum-thread-tree-single-indent ""
4189 "With %B spec, used for a thread with just one message.
4190 If nil, use subject instead.")
4191 (defvar gnus-sum-thread-tree-vertical "| "
4192 "With %B spec, used for drawing a vertical line.")
4193 (defvar gnus-sum-thread-tree-indent " "
4194 "With %B spec, used for indenting.")
4195 (defvar gnus-sum-thread-tree-leaf-with-other "+-> "
4196 "With %B spec, used for a leaf with brothers.")
4197 (defvar gnus-sum-thread-tree-single-leaf "\\-> "
4198 "With %B spec, used for a leaf without brothers.")
4200 (defun gnus-summary-prepare-threads (threads)
4201 "Prepare summary buffer from THREADS and indentation LEVEL.
4202 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
4203 or a straight list of headers."
4204 (gnus-message 7 "Generating summary...")
4206 (setq gnus-newsgroup-threads threads)
4209 (let ((gnus-tmp-level 0)
4210 (default-score (or gnus-summary-default-score 0))
4211 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
4212 thread number subject stack state gnus-tmp-gathered beg-match
4213 new-roots gnus-tmp-new-adopts thread-end
4214 gnus-tmp-header gnus-tmp-unread
4215 gnus-tmp-replied gnus-tmp-subject-or-nil
4216 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
4217 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
4218 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
4221 (setq gnus-tmp-prev-subject nil)
4223 (if (vectorp (car threads))
4224 ;; If this is a straight (sic) list of headers, then a
4225 ;; threaded summary display isn't required, so we just create
4226 ;; an unthreaded one.
4227 (gnus-summary-prepare-unthreaded threads)
4229 ;; Do the threaded display.
4231 (while (or threads stack gnus-tmp-new-adopts new-roots)
4233 (if (and (= gnus-tmp-level 0)
4236 (not gnus-tmp-false-parent)
4237 (or gnus-tmp-new-adopts new-roots))
4238 (if gnus-tmp-new-adopts
4239 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
4240 thread (list (car gnus-tmp-new-adopts))
4241 gnus-tmp-header (caar thread)
4242 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
4244 (setq thread (list (car new-roots))
4245 gnus-tmp-header (caar thread)
4246 new-roots (cdr new-roots))))
4249 ;; If there are some threads, we do them before the
4250 ;; threads on the stack.
4251 (setq thread threads
4252 gnus-tmp-header (caar thread))
4253 ;; There were no current threads, so we pop something off
4255 (setq state (car stack)
4256 gnus-tmp-level (car state)
4257 tree-stack (cadr state)
4258 thread (caddr state)
4260 gnus-tmp-header (caar thread))))
4262 (setq gnus-tmp-false-parent nil)
4263 (setq gnus-tmp-root-expunged nil)
4264 (setq thread-end nil)
4266 (if (stringp gnus-tmp-header)
4267 ;; The header is a dummy root.
4269 ((eq gnus-summary-make-false-root 'adopt)
4270 ;; We let the first article adopt the rest.
4271 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
4273 (setq gnus-tmp-gathered
4275 (lambda (h) (mail-header-number (car h)))
4278 (setq thread (cons (list (caar thread)
4281 (setq gnus-tmp-level -1
4282 gnus-tmp-false-parent t))
4283 ((eq gnus-summary-make-false-root 'empty)
4284 ;; We print adopted articles with empty subject fields.
4285 (setq gnus-tmp-gathered
4287 (lambda (h) (mail-header-number (car h)))
4290 (setq gnus-tmp-level -1))
4291 ((eq gnus-summary-make-false-root 'dummy)
4292 ;; We remember that we probably want to output a dummy
4294 (setq gnus-tmp-dummy-line gnus-tmp-header)
4295 (setq gnus-tmp-prev-subject gnus-tmp-header))
4297 ;; We do not make a root for the gathered
4298 ;; sub-threads at all.
4299 (setq gnus-tmp-level -1)))
4301 (setq number (mail-header-number gnus-tmp-header)
4302 subject (mail-header-subject gnus-tmp-header))
4305 ;; If the thread has changed subject, we might want to make
4306 ;; this subthread into a root.
4307 ((and (null gnus-thread-ignore-subject)
4308 (not (zerop gnus-tmp-level))
4309 gnus-tmp-prev-subject
4311 (gnus-subject-equal gnus-tmp-prev-subject subject))))
4312 (setq new-roots (nconc new-roots (list (car thread)))
4314 gnus-tmp-header nil))
4315 ;; If the article lies outside the current limit,
4316 ;; then we do not display it.
4317 ((not (memq number gnus-newsgroup-limit))
4318 (setq gnus-tmp-gathered
4320 (lambda (h) (mail-header-number (car h)))
4323 (setq gnus-tmp-new-adopts (if (cdar thread)
4324 (append gnus-tmp-new-adopts
4326 gnus-tmp-new-adopts)
4328 gnus-tmp-header nil)
4329 (when (zerop gnus-tmp-level)
4330 (setq gnus-tmp-root-expunged t)))
4331 ;; Perhaps this article is to be marked as read?
4332 ((and gnus-summary-mark-below
4333 (< (or (cdr (assq number gnus-newsgroup-scored))
4335 gnus-summary-mark-below)
4336 ;; Don't touch sparse articles.
4337 (not (gnus-summary-article-sparse-p number))
4338 (not (gnus-summary-article-ancient-p number)))
4339 (setq gnus-newsgroup-unreads
4340 (delq number gnus-newsgroup-unreads))
4341 (if gnus-newsgroup-auto-expire
4342 (push number gnus-newsgroup-expirable)
4343 (push (cons number gnus-low-score-mark)
4344 gnus-newsgroup-reads))))
4346 (when gnus-tmp-header
4347 ;; We may have an old dummy line to output before this
4349 (when (and gnus-tmp-dummy-line
4352 (mail-header-subject gnus-tmp-header)))
4353 (gnus-summary-insert-dummy-line
4354 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
4355 (setq gnus-tmp-dummy-line nil))
4357 ;; Compute the mark.
4358 (setq gnus-tmp-unread (gnus-article-mark number))
4360 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
4361 gnus-tmp-header gnus-tmp-level)
4362 gnus-newsgroup-data)
4364 ;; Actually insert the line.
4366 gnus-tmp-subject-or-nil
4368 ((and gnus-thread-ignore-subject
4369 gnus-tmp-prev-subject
4370 (not (inline (gnus-subject-equal
4371 gnus-tmp-prev-subject subject))))
4373 ((zerop gnus-tmp-level)
4374 (if (and (eq gnus-summary-make-false-root 'empty)
4375 (memq number gnus-tmp-gathered)
4376 gnus-tmp-prev-subject
4377 (inline (gnus-subject-equal
4378 gnus-tmp-prev-subject subject)))
4379 gnus-summary-same-subject
4381 (t gnus-summary-same-subject)))
4382 (if (and (eq gnus-summary-make-false-root 'adopt)
4383 (= gnus-tmp-level 1)
4384 (memq number gnus-tmp-gathered))
4385 (setq gnus-tmp-opening-bracket ?\<
4386 gnus-tmp-closing-bracket ?\>)
4387 (setq gnus-tmp-opening-bracket ?\[
4388 gnus-tmp-closing-bracket ?\]))
4390 gnus-tmp-indentation
4391 (aref gnus-thread-indent-array gnus-tmp-level)
4392 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4393 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4394 gnus-summary-default-score 0)
4396 (if (or (null gnus-summary-default-score)
4397 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
4398 gnus-summary-zcore-fuzz))
4400 (if (< gnus-tmp-score gnus-summary-default-score)
4401 gnus-score-below-mark gnus-score-over-mark))
4403 (cond ((memq number gnus-newsgroup-processable)
4405 ((memq number gnus-newsgroup-cached)
4407 ((memq number gnus-newsgroup-replied)
4409 ((memq number gnus-newsgroup-forwarded)
4410 gnus-forwarded-mark)
4411 ((memq number gnus-newsgroup-saved)
4413 ((memq number gnus-newsgroup-recent)
4415 ((memq number gnus-newsgroup-unseen)
4418 gnus-tmp-from (mail-header-from gnus-tmp-header)
4421 ((string-match "<[^>]+> *$" gnus-tmp-from)
4422 (setq beg-match (match-beginning 0))
4423 (or (and (string-match "^\".+\"" gnus-tmp-from)
4424 (substring gnus-tmp-from 1 (1- (match-end 0))))
4425 (substring gnus-tmp-from 0 beg-match)))
4426 ((string-match "(.+)" gnus-tmp-from)
4427 (substring gnus-tmp-from
4428 (1+ (match-beginning 0)) (1- (match-end 0))))
4430 gnus-tmp-thread-tree-header-string
4432 ((not gnus-show-threads) "")
4433 ((zerop gnus-tmp-level)
4435 (or gnus-sum-thread-tree-root subject)
4436 (or gnus-sum-thread-tree-single-indent subject)))
4438 (concat (apply 'concat
4439 (mapcar (lambda (item)
4441 gnus-sum-thread-tree-vertical
4442 gnus-sum-thread-tree-indent))
4443 (cdr (reverse tree-stack))))
4445 gnus-sum-thread-tree-leaf-with-other
4446 gnus-sum-thread-tree-single-leaf)))))
4447 (when (string= gnus-tmp-name "")
4448 (setq gnus-tmp-name gnus-tmp-from))
4449 (unless (numberp gnus-tmp-lines)
4450 (setq gnus-tmp-lines -1))
4451 (if (= gnus-tmp-lines -1)
4452 (setq gnus-tmp-lines "?")
4453 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
4454 (gnus-put-text-property
4456 (progn (eval gnus-summary-line-format-spec) (point))
4457 'gnus-number number)
4460 (gnus-run-hooks 'gnus-summary-update-hook)
4463 (setq gnus-tmp-prev-subject subject)))
4465 (when (nth 1 thread)
4466 (push (list (max 0 gnus-tmp-level)
4467 (copy-list tree-stack)
4470 (push (if (nth 1 thread) 1 0) tree-stack)
4471 (incf gnus-tmp-level)
4472 (setq threads (if thread-end nil (cdar thread)))
4474 (setq gnus-tmp-level 0)))))
4475 (gnus-message 7 "Generating summary...done"))
4477 (defun gnus-summary-prepare-unthreaded (headers)
4478 "Generate an unthreaded summary buffer based on HEADERS."
4479 (let (header number mark)
4484 ;; We may have to root out some bad articles...
4485 (when (memq (setq number (mail-header-number
4486 (setq header (pop headers))))
4487 gnus-newsgroup-limit)
4488 ;; Mark article as read when it has a low score.
4489 (when (and gnus-summary-mark-below
4490 (< (or (cdr (assq number gnus-newsgroup-scored))
4491 gnus-summary-default-score 0)
4492 gnus-summary-mark-below)
4493 (not (gnus-summary-article-ancient-p number)))
4494 (setq gnus-newsgroup-unreads
4495 (delq number gnus-newsgroup-unreads))
4496 (if gnus-newsgroup-auto-expire
4497 (push number gnus-newsgroup-expirable)
4498 (push (cons number gnus-low-score-mark)
4499 gnus-newsgroup-reads)))
4501 (setq mark (gnus-article-mark number))
4502 (push (gnus-data-make number mark (1+ (point)) header 0)
4503 gnus-newsgroup-data)
4504 (gnus-summary-insert-line
4506 mark (memq number gnus-newsgroup-replied)
4507 (memq number gnus-newsgroup-expirable)
4508 (mail-header-subject header) nil
4509 (cdr (assq number gnus-newsgroup-scored))
4510 (memq number gnus-newsgroup-processable))))))
4512 (defun gnus-summary-remove-list-identifiers ()
4513 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
4514 (let ((regexp (if (consp gnus-list-identifiers)
4515 (mapconcat 'identity gnus-list-identifiers " *\\|")
4516 gnus-list-identifiers))
4519 (dolist (header gnus-newsgroup-headers)
4520 (setq subject (mail-header-subject header)
4522 (while (string-match
4523 (concat "^\\(R[Ee]: +\\)*\\(" regexp " *\\)")
4526 (concat (substring subject 0 (match-beginning 2))
4527 (substring subject (match-end 0)))
4531 "^\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" subject))
4533 (concat (substring subject 0 (match-beginning 1))
4534 (substring subject (match-end 1)))))
4536 (mail-header-set-subject header subject))))))
4538 (defun gnus-fetch-headers (articles)
4539 "Fetch headers of ARTICLES."
4540 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
4541 (gnus-message 5 "Fetching headers for %s..." name)
4544 (setq gnus-headers-retrieved-by
4545 (gnus-retrieve-headers
4546 articles gnus-newsgroup-name
4547 ;; We might want to fetch old headers, but
4548 ;; not if there is only 1 article.
4550 (not (eq gnus-fetch-old-headers 'some))
4551 (not (numberp gnus-fetch-old-headers)))
4552 (> (length articles) 1))
4553 gnus-fetch-old-headers))))
4554 (gnus-get-newsgroup-headers-xover
4555 articles nil nil gnus-newsgroup-name t)
4556 (gnus-get-newsgroup-headers))
4557 (gnus-message 5 "Fetching headers for %s...done" name))))
4559 (defun gnus-select-newsgroup (group &optional read-all select-articles)
4560 "Select newsgroup GROUP.
4561 If READ-ALL is non-nil, all articles in the group are selected.
4562 If SELECT-ARTICLES, only select those articles from GROUP."
4563 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4564 ;;!!! Dirty hack; should be removed.
4565 (gnus-summary-ignore-duplicates
4566 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
4568 gnus-summary-ignore-duplicates))
4569 (info (nth 2 entry))
4570 articles fetched-articles cached)
4572 (unless (gnus-check-server
4573 (set (make-local-variable 'gnus-current-select-method)
4574 (gnus-find-method-for-group group)))
4575 (error "Couldn't open server"))
4577 (or (and entry (not (eq (car entry) t))) ; Either it's active...
4578 (gnus-activate-group group) ; Or we can activate it...
4579 (progn ; Or we bug out.
4580 (when (equal major-mode 'gnus-summary-mode)
4581 (kill-buffer (current-buffer)))
4582 (error "Couldn't activate group %s: %s"
4583 group (gnus-status-message group))))
4585 (unless (gnus-request-group group t)
4586 (when (equal major-mode 'gnus-summary-mode)
4587 (kill-buffer (current-buffer)))
4588 (error "Couldn't request group %s: %s"
4589 group (gnus-status-message group)))
4591 (setq gnus-newsgroup-name group
4592 gnus-newsgroup-unselected nil
4593 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
4595 (let ((display (gnus-group-find-parameter group 'display)))
4596 (setq gnus-newsgroup-display
4598 ((not (zerop (or (car-safe read-all) 0)))
4599 ;; The user entered the group with C-u SPC/RET, let's show
4605 (gnus-summary-display-make-predicate (mapcar 'identity display)))
4607 ;; The following is probably the "correct" solution, but
4608 ;; it makes Gnus fetch all headers and then limit the
4609 ;; articles (which is slow), so instead we hack the
4610 ;; select-articles parameter instead. -- Simon Josefsson
4613 ;; (gnus-byte-compile
4614 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
4616 (setq select-articles
4617 (gnus-uncompress-range
4618 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
4622 (cdr (gnus-active group)))))
4627 (gnus-summary-setup-default-charset)
4629 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4630 (when (gnus-virtual-group-p group)
4631 (setq cached gnus-newsgroup-cached))
4633 (setq gnus-newsgroup-unreads
4634 (gnus-set-difference
4635 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
4636 gnus-newsgroup-dormant))
4638 (setq gnus-newsgroup-processable nil)
4640 (gnus-update-read-articles group gnus-newsgroup-unreads)
4642 ;; Adjust and set lists of article marks.
4644 (gnus-adjust-marked-articles info))
4646 (if (setq articles select-articles)
4647 (setq gnus-newsgroup-unselected
4648 (gnus-sorted-intersection
4649 gnus-newsgroup-unreads
4650 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4651 (setq articles (gnus-articles-to-read group read-all)))
4655 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
4657 ((eq articles 0) nil)
4659 ;; Init the dependencies hash table.
4660 (setq gnus-newsgroup-dependencies
4661 (gnus-make-hashtable (length articles)))
4662 (gnus-set-global-variables)
4663 ;; Retrieve the headers and read them in.
4664 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
4666 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4668 (setq gnus-newsgroup-cached cached))
4670 ;; Suppress duplicates?
4671 (when gnus-suppress-duplicates
4672 (gnus-dup-suppress-articles))
4674 ;; Set the initial limit.
4675 (setq gnus-newsgroup-limit (copy-sequence articles))
4676 ;; Remove canceled articles from the list of unread articles.
4677 (setq fetched-articles
4678 (mapcar (lambda (headers) (mail-header-number headers))
4679 gnus-newsgroup-headers))
4680 (setq gnus-newsgroup-articles fetched-articles)
4681 (setq gnus-newsgroup-unreads
4682 (gnus-set-sorted-intersection
4683 gnus-newsgroup-unreads fetched-articles))
4685 ;; The `seen' marks are treated specially.
4686 (if (not gnus-newsgroup-seen)
4687 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
4688 (dolist (article gnus-newsgroup-articles)
4689 (unless (gnus-member-of-range article gnus-newsgroup-seen)
4690 (push article gnus-newsgroup-unseen)))
4691 (setq gnus-newsgroup-unseen (nreverse gnus-newsgroup-unseen)))
4693 ;; Removed marked articles that do not exist.
4694 (gnus-update-missing-marks
4695 (gnus-sorted-complement fetched-articles articles))
4696 ;; We might want to build some more threads first.
4697 (when (and gnus-fetch-old-headers
4698 (eq gnus-headers-retrieved-by 'nov))
4699 (if (eq gnus-fetch-old-headers 'invisible)
4700 (gnus-build-all-threads)
4701 (gnus-build-old-threads)))
4702 ;; Let the Gnus agent mark articles as read.
4704 (gnus-agent-get-undownloaded-list))
4705 ;; Remove list identifiers from subject
4706 (when gnus-list-identifiers
4707 (gnus-summary-remove-list-identifiers))
4708 ;; Check whether auto-expire is to be done in this group.
4709 (setq gnus-newsgroup-auto-expire
4710 (gnus-group-auto-expirable-p group))
4711 ;; Set up the article buffer now, if necessary.
4712 (unless gnus-single-article-buffer
4713 (gnus-article-setup-buffer))
4714 ;; First and last article in this newsgroup.
4715 (when gnus-newsgroup-headers
4716 (setq gnus-newsgroup-begin
4717 (mail-header-number (car gnus-newsgroup-headers))
4720 (gnus-last-element gnus-newsgroup-headers))))
4721 ;; GROUP is successfully selected.
4722 (or gnus-newsgroup-headers t)))))
4724 (defun gnus-summary-display-make-predicate (display)
4725 (require 'gnus-agent)
4726 (when (= (length display) 1)
4727 (setq display (car display)))
4728 (unless gnus-summary-display-cache
4729 (dolist (elem (append (list (cons 'read 'read)
4730 (cons 'unseen 'unseen))
4731 gnus-article-mark-lists))
4732 (push (cons (cdr elem)
4734 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
4735 gnus-summary-display-cache)))
4736 (let ((gnus-category-predicate-alist gnus-summary-display-cache))
4737 (gnus-get-predicate display)))
4739 ;; Uses the dynamically bound `number' variable.
4741 (defun gnus-article-marked-p (type &optional article)
4742 (let ((article (or article number)))
4745 (memq article gnus-newsgroup-marked))
4747 (memq article gnus-newsgroup-unsendable))
4748 ((eq type 'undownload)
4749 (memq article gnus-newsgroup-undownloaded))
4750 ((eq type 'download)
4751 (memq article gnus-newsgroup-downloadable))
4753 (memq article gnus-newsgroup-unreads))
4755 (memq article gnus-newsgroup-reads))
4757 (memq article gnus-newsgroup-dormant) )
4759 (memq article gnus-newsgroup-expirable))
4761 (memq article gnus-newsgroup-replied))
4763 (memq article gnus-newsgroup-killed))
4764 ((eq type 'bookmark)
4765 (assq article gnus-newsgroup-bookmarks))
4767 (assq article gnus-newsgroup-scored))
4769 (memq article gnus-newsgroup-saved))
4771 (memq article gnus-newsgroup-cached))
4773 (memq article gnus-newsgroup-forwarded))
4775 (not (memq article gnus-newsgroup-unseen)))
4777 (memq article gnus-newsgroup-recent))
4780 (defun gnus-articles-to-read (group &optional read-all)
4781 "Find out what articles the user wants to read."
4783 ;; Select all articles if `read-all' is non-nil, or if there
4784 ;; are no unread articles.
4786 (and (zerop (length gnus-newsgroup-marked))
4787 (zerop (length gnus-newsgroup-unreads)))
4788 (eq gnus-newsgroup-display 'gnus-not-ignore))
4789 ;; We want to select the headers for all the articles in
4790 ;; the group, so we select either all the active
4791 ;; articles in the group, or (if that's nil), the
4792 ;; articles in the cache.
4794 (gnus-uncompress-range (gnus-active group))
4795 (gnus-cache-articles-in-group group))
4796 ;; Select only the "normal" subset of articles.
4797 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
4798 (copy-sequence gnus-newsgroup-unreads))
4800 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
4801 (scored (length scored-list))
4802 (number (length articles))
4803 (marked (+ (length gnus-newsgroup-marked)
4804 (length gnus-newsgroup-dormant)))
4812 ((and (or (<= scored marked) (= scored number))
4813 (numberp gnus-large-newsgroup)
4814 (> number gnus-large-newsgroup))
4818 "How many articles from %s (default %d): "
4820 (gnus-group-decoded-name gnus-newsgroup-name)
4823 (if (string-match "^[ \t]*$" input) number input)))
4824 ((and (> scored marked) (< scored number)
4825 (> (- scored number) 20))
4828 (format "%s %s (%d scored, %d total): "
4829 "How many articles from"
4830 (gnus-group-decoded-name group)
4832 (if (string-match "^[ \t]*$" input)
4836 (message "Quit getting the articles to read")
4838 (setq select (if (stringp select) (string-to-number select) select))
4839 (if (or (null select) (zerop select))
4841 (if (and (not (zerop scored)) (<= (abs select) scored))
4843 (setq articles (sort scored-list '<))
4844 (setq number (length articles)))
4845 (setq articles (copy-sequence articles)))
4847 (when (< (abs select) number)
4849 ;; Select the N oldest articles.
4850 (setcdr (nthcdr (1- (abs select)) articles) nil)
4851 ;; Select the N most recent articles.
4852 (setq articles (nthcdr (- number select) articles))))
4853 (setq gnus-newsgroup-unselected
4854 (gnus-sorted-intersection
4855 gnus-newsgroup-unreads
4856 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4857 (when gnus-alter-articles-to-read-function
4858 (setq gnus-newsgroup-unreads
4860 (funcall gnus-alter-articles-to-read-function
4861 gnus-newsgroup-name gnus-newsgroup-unreads)
4865 (defun gnus-killed-articles (killed articles)
4868 (when (inline (gnus-member-of-range (car articles) killed))
4869 (push (car articles) out))
4870 (setq articles (cdr articles)))
4873 (defun gnus-uncompress-marks (marks)
4874 "Uncompress the mark ranges in MARKS."
4875 (let ((uncompressed '(score bookmark))
4878 (if (memq (caar marks) uncompressed)
4879 (push (car marks) out)
4880 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
4881 (setq marks (cdr marks)))
4884 (defun gnus-article-mark-to-type (mark)
4885 "Return the type of MARK."
4886 (or (cadr (assq mark gnus-article-special-mark-lists))
4889 (defun gnus-article-unpropagatable-p (mark)
4890 "Return whether MARK should be propagated to backend."
4891 (memq mark gnus-article-unpropagated-mark-lists))
4893 (defun gnus-adjust-marked-articles (info)
4894 "Set all article lists and remove all marks that are no longer valid."
4895 (let* ((marked-lists (gnus-info-marks info))
4896 (active (gnus-active (gnus-info-group info)))
4899 (types gnus-article-mark-lists)
4900 marks var articles article mark mark-type)
4902 (dolist (marks marked-lists)
4903 (setq mark (car marks)
4904 mark-type (gnus-article-mark-to-type mark)
4905 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
4907 ;; We set the variable according to the type of the marks list,
4908 ;; and then adjust the marks to a subset of the active articles.
4910 ;; Adjust "simple" lists.
4911 ((eq mark-type 'list)
4912 (set var (setq articles (gnus-uncompress-range (cdr marks))))
4913 (when (memq mark '(tick dormant expire reply save))
4915 (when (or (< (setq article (pop articles)) min) (> article max))
4916 (set var (delq article (symbol-value var)))))))
4918 ((eq mark-type 'tuple)
4919 (set var (setq articles (cdr marks)))
4920 (when (not (listp (cdr (symbol-value var))))
4921 (set var (list (symbol-value var))))
4922 (when (not (listp (cdr articles)))
4923 (setq articles (list articles)))
4925 (when (or (not (consp (setq article (pop articles))))
4926 (< (car article) min)
4927 (> (car article) max))
4928 (set var (delq article (symbol-value var))))))
4929 ;; Adjust ranges (sloppily).
4930 ((eq mark-type 'range)
4933 (setq articles (cdr marks))
4934 (while (and articles
4935 (or (and (consp (car articles))
4936 (> min (cdar articles)))
4937 (and (numberp (car articles))
4938 (> min (car articles)))))
4940 (set var articles))))))))
4942 (defun gnus-update-missing-marks (missing)
4943 "Go through the list of MISSING articles and remove them from the mark lists."
4946 ;; Go through all types.
4947 (dolist (elem gnus-article-mark-lists)
4948 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
4949 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
4950 (when (symbol-value var)
4951 ;; This list has articles. So we delete all missing
4952 ;; articles from it.
4955 (set var (delq (pop m) (symbol-value var))))))))))
4957 (defun gnus-update-marks ()
4958 "Enter the various lists of marked articles into the newsgroup info list."
4959 (let ((types gnus-article-mark-lists)
4960 (info (gnus-get-info gnus-newsgroup-name))
4961 type list newmarked symbol delta-marks)
4963 ;; Add all marks lists to the list of marks lists.
4964 (while (setq type (pop types))
4965 (setq list (symbol-value
4967 (intern (format "gnus-newsgroup-%s" (car type))))))
4970 ;; Get rid of the entries of the articles that have the
4972 (when (and (eq (cdr type) 'score)
4976 (prev (cons nil list))
4979 (if (or (not (consp (car arts)))
4980 (= (cdar arts) gnus-summary-default-score))
4981 (setcdr prev (cdr arts))
4983 (setq arts (cdr arts)))
4984 (setq list (cdr all)))))
4986 (when (eq (cdr type) 'seen)
4987 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
4989 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
4990 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
4992 (when (and (gnus-check-backend-function
4993 'request-set-mark gnus-newsgroup-name)
4994 (not (gnus-article-unpropagatable-p (cdr type))))
4995 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
4996 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
4997 (add (gnus-remove-from-range
4998 (gnus-copy-sequence list) old)))
5000 (push (list add 'add (list (cdr type))) delta-marks))
5002 (push (list del 'del (list (cdr type))) delta-marks))))
5005 (push (cons (cdr type) list) newmarked)))
5008 (unless (gnus-check-group gnus-newsgroup-name)
5009 (error "Can't open server for %s" gnus-newsgroup-name))
5010 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
5012 ;; Enter these new marks into the info of the group.
5014 (setcar (nthcdr 3 info) newmarked)
5015 ;; Add the marks lists to the end of the info.
5017 (setcdr (nthcdr 2 info) (list newmarked))))
5019 ;; Cut off the end of the info if there's nothing else there.
5023 (when (nthcdr (decf i) info)
5024 (setcdr (nthcdr i info) nil)))))))
5026 (defun gnus-set-mode-line (where)
5027 "Set the mode line of the article or summary buffers.
5028 If WHERE is `summary', the summary mode line format will be used."
5029 ;; Is this mode line one we keep updated?
5030 (when (and (memq where gnus-updated-mode-lines)
5032 (intern (format "gnus-%s-mode-line-format-spec" where))))
5035 ;; We evaluate this in the summary buffer since these
5036 ;; variables are buffer-local to that buffer.
5037 (set-buffer gnus-summary-buffer)
5038 ;; We bind all these variables that are used in the `eval' form
5040 (let* ((mformat (symbol-value
5042 (format "gnus-%s-mode-line-format-spec" where))))
5043 (gnus-tmp-group-name (gnus-group-decoded-name
5044 gnus-newsgroup-name))
5045 (gnus-tmp-article-number (or gnus-current-article 0))
5046 (gnus-tmp-unread gnus-newsgroup-unreads)
5047 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
5048 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
5049 (gnus-tmp-unread-and-unselected
5050 (cond ((and (zerop gnus-tmp-unread-and-unticked)
5051 (zerop gnus-tmp-unselected))
5053 ((zerop gnus-tmp-unselected)
5054 (format "{%d more}" gnus-tmp-unread-and-unticked))
5055 (t (format "{%d(+%d) more}"
5056 gnus-tmp-unread-and-unticked
5057 gnus-tmp-unselected))))
5059 (if (and gnus-current-headers
5060 (vectorp gnus-current-headers))
5061 (gnus-mode-string-quote
5062 (mail-header-subject gnus-current-headers))
5064 bufname-length max-len
5065 gnus-tmp-header) ;; passed as argument to any user-format-funcs
5066 (setq mode-string (eval mformat))
5067 (setq bufname-length (if (string-match "%b" mode-string)
5070 (if (eq where 'summary)
5072 (get-buffer gnus-article-buffer))))
5075 (setq max-len (max 4 (if gnus-mode-non-string-length
5077 gnus-mode-non-string-length
5079 (length mode-string))))
5080 ;; We might have to chop a bit of the string off...
5081 (when (> (length mode-string) max-len)
5083 (concat (truncate-string-to-width mode-string (- max-len 3))
5085 ;; Pad the mode string a bit.
5086 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
5087 ;; Update the mode line.
5088 (setq mode-line-buffer-identification
5089 (gnus-mode-line-buffer-identification (list mode-string)))
5090 (set-buffer-modified-p t))))
5092 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
5093 "Go through the HEADERS list and add all Xrefs to a hash table.
5094 The resulting hash table is returned, or nil if no Xrefs were found."
5095 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
5096 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
5097 (xref-hashtb (gnus-make-hashtable))
5098 start group entry number xrefs header)
5100 (setq header (pop headers))
5101 (when (and (setq xrefs (mail-header-xref header))
5102 (not (memq (setq number (mail-header-number header))
5105 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
5106 (setq start (match-end 0))
5107 (setq group (if prefix
5108 (concat prefix (substring xrefs (match-beginning 1)
5110 (substring xrefs (match-beginning 1) (match-end 1))))
5112 (string-to-int (substring xrefs (match-beginning 2)
5114 (if (setq entry (gnus-gethash group xref-hashtb))
5115 (setcdr entry (cons number (cdr entry)))
5116 (gnus-sethash group (cons number nil) xref-hashtb)))))
5117 (and start xref-hashtb)))
5119 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
5120 "Look through all the headers and mark the Xrefs as read."
5121 (let ((virtual (gnus-virtual-group-p from-newsgroup))
5122 name entry info xref-hashtb idlist method nth4)
5124 (set-buffer gnus-group-buffer)
5125 (when (setq xref-hashtb
5126 (gnus-create-xref-hashtb from-newsgroup headers unreads))
5129 (unless (string= from-newsgroup (setq name (symbol-name group)))
5130 (setq idlist (symbol-value group))
5131 ;; Dead groups are not updated.
5133 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
5135 (when (stringp (setq nth4 (gnus-info-method info)))
5136 (setq nth4 (gnus-server-to-method nth4))))
5137 ;; Only do the xrefs if the group has the same
5138 ;; select method as the group we have just read.
5139 (or (gnus-methods-equal-p
5140 nth4 (gnus-find-method-for-group from-newsgroup))
5142 (equal nth4 (setq method (gnus-find-method-for-group
5144 (and (equal (car nth4) (car method))
5145 (equal (nth 1 nth4) (nth 1 method))))
5146 gnus-use-cross-reference
5147 (or (not (eq gnus-use-cross-reference t))
5149 ;; Only do cross-references on subscribed
5150 ;; groups, if that is what is wanted.
5151 (<= (gnus-info-level info) gnus-level-subscribed))
5152 (gnus-group-make-articles-read name idlist))))
5155 (defun gnus-compute-read-articles (group articles)
5156 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5157 (info (nth 2 entry))
5158 (active (gnus-active group))
5161 ;; First peel off all invalid article numbers.
5163 (let ((ids articles)
5165 (while (setq id (pop ids))
5166 (when (and first (> id (cdr active)))
5167 ;; We'll end up in this situation in one particular
5168 ;; obscure situation. If you re-scan a group and get
5169 ;; a new article that is cross-posted to a different
5170 ;; group that has not been re-scanned, you might get
5171 ;; crossposted article that has a higher number than
5172 ;; Gnus believes possible. So we re-activate this
5173 ;; group as well. This might mean doing the
5174 ;; crossposting thingy will *increase* the number
5175 ;; of articles in some groups. Tsk, tsk.
5176 (setq active (or (gnus-activate-group group) active)))
5177 (when (or (> id (cdr active))
5178 (< id (car active)))
5179 (setq articles (delq id articles))))))
5180 ;; If the read list is nil, we init it.
5182 (null (gnus-info-read info))
5184 (setq ninfo (cons 1 (1- (car active))))
5185 (setq ninfo (gnus-info-read info)))
5186 ;; Then we add the read articles to the range.
5188 ninfo (setq articles (sort articles '<))))))
5190 (defun gnus-group-make-articles-read (group articles)
5191 "Update the info of GROUP to say that ARTICLES are read."
5193 (entry (gnus-gethash group gnus-newsrc-hashtb))
5194 (info (nth 2 entry))
5195 (active (gnus-active group))
5198 (setq range (gnus-compute-read-articles group articles))
5200 (set-buffer gnus-group-buffer)
5203 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
5204 (gnus-info-set-read ',info ',(gnus-info-read info))
5205 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
5206 (gnus-request-set-mark ,group (list (list ',range 'del '(read))))
5207 (gnus-group-update-group ,group t))))
5208 ;; Add the read articles to the range.
5209 (gnus-info-set-read info range)
5210 (gnus-request-set-mark group (list (list range 'add '(read))))
5211 ;; Then we have to re-compute how many unread
5212 ;; articles there are in this group.
5216 (setq num (- (1+ (cdr active)) (car active))))
5217 ((not (listp (cdr range)))
5218 (setq num (- (cdr active) (- (1+ (cdr range))
5222 (if (numberp (car range))
5224 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
5225 (setq range (cdr range)))
5226 (setq num (- (cdr active) num))))
5227 ;; Update the number of unread articles.
5229 ;; Update the group buffer.
5230 (gnus-group-update-group group t)))))
5232 (defvar gnus-newsgroup-none-id 0)
5234 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
5235 (let ((cur nntp-server-buffer)
5238 (save-excursion (set-buffer gnus-summary-buffer)
5239 gnus-newsgroup-dependencies)))
5241 (mail-parse-charset gnus-newsgroup-charset)
5242 (mail-parse-ignored-charsets
5243 (save-excursion (condition-case nil
5244 (set-buffer gnus-summary-buffer)
5246 gnus-newsgroup-ignored-charsets)))
5248 (set-buffer nntp-server-buffer)
5249 ;; Translate all TAB characters into SPACE characters.
5250 (subst-char-in-region (point-min) (point-max) ?\t ? t)
5251 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5252 (gnus-run-hooks 'gnus-parse-headers-hook)
5253 (let ((case-fold-search t)
5254 in-reply-to header p lines chars)
5255 (goto-char (point-min))
5256 ;; Search to the beginning of the next header. Error messages
5257 ;; do not begin with 2 or 3.
5258 (while (re-search-forward "^[23][0-9]+ " nil t)
5261 ;; This implementation of this function, with nine
5262 ;; search-forwards instead of the one re-search-forward and
5263 ;; a case (which basically was the old function) is actually
5264 ;; about twice as fast, even though it looks messier. You
5265 ;; can't have everything, I guess. Speed and elegance
5266 ;; doesn't always go hand in hand.
5275 (narrow-to-region (point)
5276 (or (and (search-forward "\n.\n" nil t)
5282 (if (search-forward "\nsubject:" nil t)
5283 (funcall gnus-decode-encoded-word-function
5284 (nnheader-header-value))
5289 (if (search-forward "\nfrom:" nil t)
5290 (funcall gnus-decode-encoded-word-function
5291 (nnheader-header-value))
5296 (if (search-forward "\ndate:" nil t)
5297 (nnheader-header-value) ""))
5301 (setq id (if (re-search-forward
5302 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
5303 ;; We do it this way to make sure the Message-ID
5304 ;; is (somewhat) syntactically valid.
5305 (buffer-substring (match-beginning 1)
5307 ;; If there was no message-id, we just fake one
5308 ;; to make subsequent routines simpler.
5309 (nnheader-generate-fake-message-id))))
5313 (if (search-forward "\nreferences:" nil t)
5317 (nnheader-header-value)
5322 (search-backward ">" end t)
5325 (search-backward "<" end t)
5327 ;; Get the references from the in-reply-to header if there
5328 ;; were no references and the in-reply-to header looks
5330 (if (and (search-forward "\nin-reply-to:" nil t)
5331 (setq in-reply-to (nnheader-header-value))
5332 (string-match "<[^>]+>" in-reply-to))
5334 (setq ref (substring in-reply-to (match-beginning 0)
5336 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
5337 (setq ref2 (substring in-reply-to (match-beginning 0)
5339 (when (> (length ref2) (length ref))
5346 (if (search-forward "\nchars: " nil t)
5347 (if (numberp (setq chars (ignore-errors (read cur))))
5353 (if (search-forward "\nlines: " nil t)
5354 (if (numberp (setq lines (ignore-errors (read cur))))
5360 (and (search-forward "\nxref:" nil t)
5361 (nnheader-header-value)))
5363 (when gnus-extra-headers
5364 (let ((extra gnus-extra-headers)
5368 (when (search-forward
5369 (concat "\n" (symbol-name (car extra)) ":") nil t)
5370 (push (cons (car extra) (nnheader-header-value))
5374 (when (equal id ref)
5377 (when gnus-alter-header-function
5378 (funcall gnus-alter-header-function header)
5379 (setq id (mail-header-id header)
5380 ref (gnus-parent-id (mail-header-references header))))
5383 (gnus-dependencies-add-header
5384 header dependencies force-new))
5385 (push header headers))
5386 (goto-char (point-max))
5388 (nreverse headers)))))
5390 ;; Goes through the xover lines and returns a list of vectors
5391 (defun gnus-get-newsgroup-headers-xover (sequence &optional
5392 force-new dependencies
5393 group also-fetch-heads)
5394 "Parse the news overview data in the server buffer.
5395 Return a list of headers that match SEQUENCE (see
5396 `nntp-retrieve-headers')."
5397 ;; Get the Xref when the users reads the articles since most/some
5398 ;; NNTP servers do not include Xrefs when using XOVER.
5399 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
5400 (let ((mail-parse-charset gnus-newsgroup-charset)
5401 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
5402 (cur nntp-server-buffer)
5403 (dependencies (or dependencies gnus-newsgroup-dependencies))
5405 ((eq gnus-read-all-available-headers t)
5407 ((stringp gnus-read-all-available-headers)
5408 (string-match gnus-read-all-available-headers group))
5411 number headers header)
5413 (set-buffer nntp-server-buffer)
5414 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5415 ;; Allow the user to mangle the headers before parsing them.
5416 (gnus-run-hooks 'gnus-parse-headers-hook)
5417 (goto-char (point-min))
5420 (while (and (or sequence allp)
5422 (setq number (read cur))
5424 (while (and sequence
5425 (< (car sequence) number))
5426 (setq sequence (cdr sequence))))
5429 (eq number (car sequence))))
5431 (setq sequence (cdr sequence))
5432 (setq header (inline
5433 (gnus-nov-parse-line
5434 number dependencies force-new)))))
5435 (push header headers))
5438 (gnus-error 4 "Strange nov line (%d)"
5439 (count-lines (point-min) (point)))))
5441 ;; A common bug in inn is that if you have posted an article and
5442 ;; then retrieves the active file, it will answer correctly --
5443 ;; the new article is included. However, a NOV entry for the
5444 ;; article may not have been generated yet, so this may fail.
5445 ;; We work around this problem by retrieving the last few
5446 ;; headers using HEAD.
5447 (if (or (not also-fetch-heads)
5449 ;; We (probably) got all the headers.
5451 (let ((gnus-nov-is-evil t))
5454 (when (eq (gnus-retrieve-headers sequence group) 'headers)
5455 (gnus-get-newsgroup-headers))))))))
5457 (defun gnus-article-get-xrefs ()
5458 "Fill in the Xref value in `gnus-current-headers', if necessary.
5459 This is meant to be called in `gnus-article-internal-prepare-hook'."
5460 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
5461 gnus-current-headers)))
5462 (or (not gnus-use-cross-reference)
5464 (and (mail-header-xref headers)
5465 (not (string= (mail-header-xref headers) "")))
5466 (let ((case-fold-search t)
5469 (nnheader-narrow-to-headers)
5470 (goto-char (point-min))
5471 (when (or (and (not (eobp))
5472 (eq (downcase (char-after)) ?x)
5473 (looking-at "Xref:"))
5474 (search-forward "\nXref:" nil t))
5475 (goto-char (1+ (match-end 0)))
5476 (setq xref (buffer-substring (point)
5477 (progn (end-of-line) (point))))
5478 (mail-header-set-xref headers xref)))))))
5480 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
5481 "Find article ID and insert the summary line for that article.
5482 OLD-HEADER can either be a header or a line number to insert
5483 the subject line on."
5484 (let* ((line (and (numberp old-header) old-header))
5485 (old-header (and (vectorp old-header) old-header))
5486 (header (cond ((and old-header use-old-header)
5489 (gnus-number-to-header id))
5490 (gnus-number-to-header id))
5492 (gnus-read-header id))))
5493 (number (and (numberp id) id))
5496 ;; Rebuild the thread that this article is part of and go to the
5497 ;; article we have fetched.
5498 (when (and (not gnus-show-threads)
5501 (setq d (gnus-data-find (mail-header-number old-header))))
5502 (goto-char (gnus-data-pos d))
5505 (- (gnus-point-at-bol)
5507 (1+ (gnus-point-at-eol))
5508 (gnus-delete-line))))))
5510 (mail-header-set-number header (mail-header-number old-header)))
5511 (setq gnus-newsgroup-sparse
5512 (delq (setq number (mail-header-number header))
5513 gnus-newsgroup-sparse))
5514 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
5515 (push number gnus-newsgroup-limit)
5516 (gnus-rebuild-thread (mail-header-id header) line)
5517 (gnus-summary-goto-subject number nil t))
5518 (when (and (numberp number)
5520 ;; We have to update the boundaries even if we can't fetch the
5521 ;; article if ID is a number -- so that the next `P' or `N'
5522 ;; command will fetch the previous (or next) article even
5523 ;; if the one we tried to fetch this time has been canceled.
5524 (when (> number gnus-newsgroup-end)
5525 (setq gnus-newsgroup-end number))
5526 (when (< number gnus-newsgroup-begin)
5527 (setq gnus-newsgroup-begin number))
5528 (setq gnus-newsgroup-unselected
5529 (delq number gnus-newsgroup-unselected)))
5530 ;; Report back a success?
5531 (and header (mail-header-number header))))
5533 ;;; Process/prefix in the summary buffer
5535 (defun gnus-summary-work-articles (n)
5536 "Return a list of articles to be worked upon.
5537 The prefix argument, the list of process marked articles, and the
5538 current article will be taken into consideration."
5540 (set-buffer gnus-summary-buffer)
5543 ;; A numerical prefix has been given.
5544 (setq n (prefix-numeric-value n))
5545 (let ((backward (< n 0))
5546 (n (abs (prefix-numeric-value n)))
5551 (push (setq article (gnus-summary-article-number))
5554 (gnus-summary-find-prev nil article)
5555 (gnus-summary-find-next nil article)))
5557 (nreverse articles)))
5558 ((and (gnus-region-active-p) (mark))
5559 (message "region active")
5560 ;; Work on the region between point and mark.
5561 (let ((max (max (point) (mark)))
5564 (goto-char (min (min (point) (mark))))
5567 (push (setq article (gnus-summary-article-number)) articles)
5568 (gnus-summary-find-next nil article)
5570 (nreverse articles))))
5571 (gnus-newsgroup-processable
5572 ;; There are process-marked articles present.
5573 ;; Save current state.
5574 (gnus-summary-save-process-mark)
5576 (reverse gnus-newsgroup-processable))
5578 ;; Just return the current article.
5579 (list (gnus-summary-article-number))))))
5581 (defmacro gnus-summary-iterate (arg &rest forms)
5582 "Iterate over the process/prefixed articles and do FORMS.
5583 ARG is the interactive prefix given to the command. FORMS will be
5584 executed with point over the summary line of the articles."
5585 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
5586 `(let ((,articles (gnus-summary-work-articles ,arg)))
5588 (gnus-summary-goto-subject (car ,articles))
5592 (put 'gnus-summary-iterate 'lisp-indent-function 1)
5593 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
5595 (defun gnus-summary-save-process-mark ()
5596 "Push the current set of process marked articles on the stack."
5598 (push (copy-sequence gnus-newsgroup-processable)
5599 gnus-newsgroup-process-stack))
5601 (defun gnus-summary-kill-process-mark ()
5602 "Push the current set of process marked articles on the stack and unmark."
5604 (gnus-summary-save-process-mark)
5605 (gnus-summary-unmark-all-processable))
5607 (defun gnus-summary-yank-process-mark ()
5608 "Pop the last process mark state off the stack and restore it."
5610 (unless gnus-newsgroup-process-stack
5611 (error "Empty mark stack"))
5612 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
5614 (defun gnus-summary-process-mark-set (set)
5615 "Make SET into the current process marked articles."
5616 (gnus-summary-unmark-all-processable)
5618 (gnus-summary-set-process-mark (pop set))))
5620 ;;; Searching and stuff
5622 (defun gnus-summary-search-group (&optional backward use-level)
5623 "Search for next unread newsgroup.
5624 If optional argument BACKWARD is non-nil, search backward instead."
5626 (set-buffer gnus-group-buffer)
5627 (when (gnus-group-search-forward
5628 backward nil (if use-level (gnus-group-group-level) nil))
5629 (gnus-group-group-name))))
5631 (defun gnus-summary-best-group (&optional exclude-group)
5632 "Find the name of the best unread group.
5633 If EXCLUDE-GROUP, do not go to this group."
5635 (set-buffer gnus-group-buffer)
5637 (gnus-group-best-unread-group exclude-group))))
5639 (defun gnus-summary-find-next (&optional unread article backward undownloaded)
5640 (if backward (gnus-summary-find-prev)
5641 (let* ((dummy (gnus-summary-article-intangible-p))
5642 (article (or article (gnus-summary-article-number)))
5643 (arts (gnus-data-find-list article))
5645 (when (and (not dummy)
5646 (or (not gnus-summary-check-current)
5648 (not (gnus-data-unread-p (car arts)))))
5649 (setq arts (cdr arts)))
5654 (when (or (and undownloaded
5655 (eq gnus-undownloaded-mark
5656 (gnus-data-mark (car arts))))
5657 (gnus-data-unread-p (car arts)))
5658 (setq result (car arts)
5660 (setq arts (cdr arts)))
5663 (goto-char (gnus-data-pos result))
5664 (gnus-data-number result)))))
5666 (defun gnus-summary-find-prev (&optional unread article)
5667 (let* ((eobp (eobp))
5668 (article (or article (gnus-summary-article-number)))
5669 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
5671 (when (and (not eobp)
5672 (or (not gnus-summary-check-current)
5674 (not (gnus-data-unread-p (car arts)))))
5675 (setq arts (cdr arts)))
5680 (when (gnus-data-unread-p (car arts))
5681 (setq result (car arts)
5683 (setq arts (cdr arts)))
5686 (goto-char (gnus-data-pos result))
5687 (gnus-data-number result))))
5689 (defun gnus-summary-find-subject (subject &optional unread backward article)
5690 (let* ((simp-subject (gnus-simplify-subject-fully subject))
5691 (article (or article (gnus-summary-article-number)))
5692 (articles (gnus-data-list backward))
5693 (arts (gnus-data-find-list article articles))
5695 (when (or (not gnus-summary-check-current)
5697 (not (gnus-data-unread-p (car arts))))
5698 (setq arts (cdr arts)))
5700 (and (or (not unread)
5701 (gnus-data-unread-p (car arts)))
5702 (vectorp (gnus-data-header (car arts)))
5704 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
5705 (setq result (car arts)
5707 (setq arts (cdr arts)))
5709 (goto-char (gnus-data-pos result))
5710 (gnus-data-number result))))
5712 (defun gnus-summary-search-forward (&optional unread subject backward)
5713 "Search forward for an article.
5714 If UNREAD, look for unread articles. If SUBJECT, look for
5715 articles with that subject. If BACKWARD, search backward instead."
5716 (cond (subject (gnus-summary-find-subject subject unread backward))
5717 (backward (gnus-summary-find-prev unread))
5718 (t (gnus-summary-find-next unread))))
5720 (defun gnus-recenter (&optional n)
5721 "Center point in window and redisplay frame.
5722 Also do horizontal recentering."
5724 (when (and gnus-auto-center-summary
5725 (not (eq gnus-auto-center-summary 'vertical)))
5726 (gnus-horizontal-recenter))
5729 (defun gnus-summary-recenter ()
5730 "Center point in the summary window.
5731 If `gnus-auto-center-summary' is nil, or the article buffer isn't
5732 displayed, no centering will be performed."
5733 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
5734 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
5736 (let* ((top (cond ((< (window-height) 4) 0)
5737 ((< (window-height) 7) 1)
5738 (t (if (numberp gnus-auto-center-summary)
5739 gnus-auto-center-summary
5741 (height (1- (window-height)))
5742 (bottom (save-excursion (goto-char (point-max))
5743 (forward-line (- height))
5745 (window (get-buffer-window (current-buffer))))
5746 ;; The user has to want it.
5747 (when gnus-auto-center-summary
5748 (when (get-buffer-window gnus-article-buffer)
5749 ;; Only do recentering when the article buffer is displayed,
5750 ;; Set the window start to either `bottom', which is the biggest
5751 ;; possible valid number, or the second line from the top,
5752 ;; whichever is the least.
5753 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
5754 (if (> bottom top-pos)
5755 ;; Keep the second line from the top visible
5756 (set-window-start window top-pos t)
5757 ;; Try to keep the bottom line visible; if it's partially
5758 ;; obscured, either scroll one more line to make it fully
5759 ;; visible, or revert to using TOP-POS.
5761 (goto-char (point-max))
5763 (let ((last-line-start (point)))
5765 (set-window-start window (point) t)
5766 (when (not (pos-visible-in-window-p last-line-start window))
5768 (set-window-start window (min (point) top-pos) t)))))))
5769 ;; Do horizontal recentering while we're at it.
5770 (when (and (get-buffer-window (current-buffer) t)
5771 (not (eq gnus-auto-center-summary 'vertical)))
5772 (let ((selected (selected-window)))
5773 (select-window (get-buffer-window (current-buffer) t))
5774 (gnus-summary-position-point)
5775 (gnus-horizontal-recenter)
5776 (select-window selected))))))
5778 (defun gnus-summary-jump-to-group (newsgroup)
5779 "Move point to NEWSGROUP in group mode buffer."
5780 ;; Keep update point of group mode buffer if visible.
5781 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
5782 (save-window-excursion
5783 ;; Take care of tree window mode.
5784 (when (get-buffer-window gnus-group-buffer)
5785 (pop-to-buffer gnus-group-buffer))
5786 (gnus-group-jump-to-group newsgroup))
5788 ;; Take care of tree window mode.
5789 (if (get-buffer-window gnus-group-buffer)
5790 (pop-to-buffer gnus-group-buffer)
5791 (set-buffer gnus-group-buffer))
5792 (gnus-group-jump-to-group newsgroup))))
5794 ;; This function returns a list of article numbers based on the
5795 ;; difference between the ranges of read articles in this group and
5796 ;; the range of active articles.
5797 (defun gnus-list-of-unread-articles (group)
5798 (let* ((read (gnus-info-read (gnus-get-info group)))
5799 (active (or (gnus-active group) (gnus-activate-group group)))
5802 ;; If none are read, then all are unread.
5804 (setq first (car active))
5805 ;; If the range of read articles is a single range, then the
5806 ;; first unread article is the article after the last read
5807 ;; article. Sounds logical, doesn't it?
5808 (if (and (not (listp (cdr read)))
5809 (or (< (car read) (car active))
5810 (progn (setq read (list read))
5812 (setq first (max (car active) (1+ (cdr read))))
5813 ;; `read' is a list of ranges.
5814 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
5817 (setq first (car active)))
5820 (while (< first nlast)
5822 (setq first (1+ first))))
5823 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
5824 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
5825 (setq read (cdr read)))))
5826 ;; And add the last unread articles.
5827 (while (<= first last)
5829 (setq first (1+ first)))
5830 ;; Return the list of unread articles.
5831 (delq 0 (nreverse unread))))
5833 (defun gnus-list-of-read-articles (group)
5834 "Return a list of unread, unticked and non-dormant articles."
5835 (let* ((info (gnus-get-info group))
5836 (marked (gnus-info-marks info))
5837 (active (gnus-active group)))
5839 (gnus-set-difference
5840 (gnus-sorted-complement
5841 (gnus-uncompress-range active)
5842 (gnus-list-of-unread-articles group))
5844 (gnus-uncompress-range (cdr (assq 'dormant marked)))
5845 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
5847 ;; Various summary commands
5849 (defun gnus-summary-select-article-buffer ()
5850 "Reconfigure windows to show article buffer."
5852 (if (not (gnus-buffer-live-p gnus-article-buffer))
5853 (error "There is no article buffer for this summary buffer")
5854 (gnus-configure-windows 'article)
5855 (select-window (get-buffer-window gnus-article-buffer))))
5857 (defun gnus-summary-universal-argument (arg)
5858 "Perform any operation on all articles that are process/prefixed."
5860 (let ((articles (gnus-summary-work-articles arg))
5867 (substitute-command-keys
5868 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
5870 (gnus-error 1 "Undefined key")
5873 (gnus-summary-goto-subject (setq article (pop articles)))
5874 (let (gnus-newsgroup-processable)
5875 (command-execute func))
5876 (gnus-summary-remove-process-mark article)))))
5877 (gnus-summary-position-point))
5879 (defun gnus-summary-toggle-truncation (&optional arg)
5880 "Toggle truncation of summary lines.
5881 With arg, turn line truncation on iff arg is positive."
5883 (setq truncate-lines
5884 (if (null arg) (not truncate-lines)
5885 (> (prefix-numeric-value arg) 0)))
5888 (defun gnus-summary-reselect-current-group (&optional all rescan)
5889 "Exit and then reselect the current newsgroup.
5890 The prefix argument ALL means to select all articles."
5892 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
5893 (error "Ephemeral groups can't be reselected"))
5894 (let ((current-subject (gnus-summary-article-number))
5895 (group gnus-newsgroup-name))
5896 (setq gnus-newsgroup-begin nil)
5898 ;; We have to adjust the point of group mode buffer because
5899 ;; point was moved to the next unread newsgroup by exiting.
5900 (gnus-summary-jump-to-group group)
5903 (gnus-group-get-new-news-this-group 1)))
5904 (gnus-group-read-group all t)
5905 (gnus-summary-goto-subject current-subject nil t)))
5907 (defun gnus-summary-rescan-group (&optional all)
5908 "Exit the newsgroup, ask for new articles, and select the newsgroup."
5910 (gnus-summary-reselect-current-group all t))
5912 (defun gnus-summary-update-info (&optional non-destructive)
5914 (let ((group gnus-newsgroup-name))
5916 (when gnus-newsgroup-kill-headers
5917 (setq gnus-newsgroup-killed
5918 (gnus-compress-sequence
5920 (gnus-set-sorted-intersection
5921 (gnus-uncompress-range gnus-newsgroup-killed)
5922 (setq gnus-newsgroup-unselected
5923 (sort gnus-newsgroup-unselected '<)))
5924 (setq gnus-newsgroup-unreads
5925 (sort gnus-newsgroup-unreads '<)))
5927 (unless (listp (cdr gnus-newsgroup-killed))
5928 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
5929 (let ((headers gnus-newsgroup-headers))
5930 ;; Set the new ranges of read articles.
5932 (set-buffer gnus-group-buffer)
5933 (gnus-undo-force-boundary))
5934 (gnus-update-read-articles
5935 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
5936 ;; Set the current article marks.
5937 (let ((gnus-newsgroup-scored
5938 (if (and (not gnus-save-score)
5939 (not non-destructive))
5941 gnus-newsgroup-scored)))
5943 (gnus-update-marks)))
5944 ;; Do the cross-ref thing.
5945 (when gnus-use-cross-reference
5946 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
5947 ;; Do not switch windows but change the buffer to work.
5948 (set-buffer gnus-group-buffer)
5949 (unless (gnus-ephemeral-group-p group)
5950 (gnus-group-update-group group)))))))
5952 (defun gnus-summary-save-newsrc (&optional force)
5953 "Save the current number of read/marked articles in the dribble buffer.
5954 The dribble buffer will then be saved.
5955 If FORCE (the prefix), also save the .newsrc file(s)."
5957 (gnus-summary-update-info t)
5959 (gnus-save-newsrc-file)
5960 (gnus-dribble-save)))
5962 (defun gnus-summary-exit (&optional temporary)
5963 "Exit reading current newsgroup, and then return to group selection mode.
5964 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
5966 (gnus-set-global-variables)
5967 (when (gnus-buffer-live-p gnus-article-buffer)
5969 (set-buffer gnus-article-buffer)
5970 (mm-destroy-parts gnus-article-mime-handles)
5971 ;; Set it to nil for safety reason.
5972 (setq gnus-article-mime-handle-alist nil)
5973 (setq gnus-article-mime-handles nil)))
5974 (gnus-kill-save-kill-buffer)
5975 (gnus-async-halt-prefetch)
5976 (let* ((group gnus-newsgroup-name)
5977 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
5980 (buf (current-buffer)))
5982 ;; Do adaptive scoring, and possibly save score files.
5983 (when gnus-newsgroup-adaptive
5984 (gnus-score-adaptive))
5985 (when gnus-use-scoring
5987 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
5988 ;; If we have several article buffers, we kill them at exit.
5989 (unless gnus-single-article-buffer
5990 (gnus-kill-buffer gnus-original-article-buffer)
5991 (setq gnus-article-current nil))
5992 (when gnus-use-cache
5993 (gnus-cache-possibly-remove-articles)
5994 (gnus-cache-save-buffers))
5995 (gnus-async-prefetch-remove-group group)
5996 (when gnus-suppress-duplicates
5997 (gnus-dup-enter-articles))
5998 (when gnus-use-trees
5999 (gnus-tree-close group))
6000 (when gnus-use-cache
6001 (gnus-cache-write-active))
6002 ;; Remove entries for this group.
6003 (nnmail-purge-split-history (gnus-group-real-name group))
6004 ;; Make all changes in this group permanent.
6006 (gnus-run-hooks 'gnus-exit-group-hook)
6007 (gnus-summary-update-info))
6008 (gnus-close-group group)
6009 ;; Make sure where we were, and go to next newsgroup.
6010 (set-buffer gnus-group-buffer)
6012 (gnus-group-jump-to-group group))
6013 (gnus-run-hooks 'gnus-summary-exit-hook)
6014 (unless (or quit-config
6015 ;; If this group has disappeared from the summary
6016 ;; buffer, don't skip forwards.
6017 (not (string= group (gnus-group-group-name))))
6018 (gnus-group-next-unread-group 1))
6019 (setq group-point (point))
6022 ;; If we have several article buffers, we kill them at exit.
6023 (unless gnus-single-article-buffer
6024 (gnus-kill-buffer gnus-article-buffer)
6025 (gnus-kill-buffer gnus-original-article-buffer)
6026 (setq gnus-article-current nil))
6028 (if (not gnus-kill-summary-on-exit)
6030 (gnus-deaden-summary)
6032 ;; We set all buffer-local variables to nil. It is unclear why
6033 ;; this is needed, but if we don't, buffer-local variables are
6034 ;; not garbage-collected, it seems. This would the lead to en
6035 ;; ever-growing Emacs.
6036 (gnus-summary-clear-local-variables)
6037 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6038 (gnus-summary-clear-local-variables))
6039 (when (get-buffer gnus-article-buffer)
6040 (bury-buffer gnus-article-buffer))
6041 ;; We clear the global counterparts of the buffer-local
6042 ;; variables as well, just to be on the safe side.
6043 (set-buffer gnus-group-buffer)
6044 (gnus-summary-clear-local-variables)
6045 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6046 (gnus-summary-clear-local-variables)))
6047 (setq gnus-current-select-method gnus-select-method)
6048 (pop-to-buffer gnus-group-buffer)
6049 (if (not quit-config)
6051 (goto-char group-point)
6052 (gnus-configure-windows 'group 'force))
6053 (gnus-handle-ephemeral-exit quit-config))
6054 ;; Return to group mode buffer.
6055 (when (eq mode 'gnus-summary-mode)
6056 (gnus-kill-buffer buf))
6057 ;; Clear the current group name.
6059 (setq gnus-newsgroup-name nil)))))
6061 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
6062 (defun gnus-summary-exit-no-update (&optional no-questions)
6063 "Quit reading current newsgroup without updating read article info."
6065 (let* ((group gnus-newsgroup-name)
6066 (quit-config (gnus-group-quit-config group)))
6067 (when (or no-questions
6069 (gnus-y-or-n-p "Discard changes to this group and exit? "))
6070 (gnus-async-halt-prefetch)
6072 (delq 'gnus-summary-expire-articles
6073 (copy-sequence gnus-summary-prepare-exit-hook)))
6074 (when (gnus-buffer-live-p gnus-article-buffer)
6076 (set-buffer gnus-article-buffer)
6077 (mm-destroy-parts gnus-article-mime-handles)
6078 ;; Set it to nil for safety reason.
6079 (setq gnus-article-mime-handle-alist nil)
6080 (setq gnus-article-mime-handles nil)))
6081 ;; If we have several article buffers, we kill them at exit.
6082 (unless gnus-single-article-buffer
6083 (gnus-kill-buffer gnus-article-buffer)
6084 (gnus-kill-buffer gnus-original-article-buffer)
6085 (setq gnus-article-current nil))
6086 (if (not gnus-kill-summary-on-exit)
6087 (gnus-deaden-summary)
6088 (gnus-close-group group)
6089 (gnus-summary-clear-local-variables)
6090 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6091 (gnus-summary-clear-local-variables))
6092 (set-buffer gnus-group-buffer)
6093 (gnus-summary-clear-local-variables)
6094 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6095 (gnus-summary-clear-local-variables))
6096 (when (get-buffer gnus-summary-buffer)
6097 (kill-buffer gnus-summary-buffer)))
6098 (unless gnus-single-article-buffer
6099 (setq gnus-article-current nil))
6100 (when gnus-use-trees
6101 (gnus-tree-close group))
6102 (gnus-async-prefetch-remove-group group)
6103 (when (get-buffer gnus-article-buffer)
6104 (bury-buffer gnus-article-buffer))
6105 ;; Return to the group buffer.
6106 (gnus-configure-windows 'group 'force)
6107 ;; Clear the current group name.
6108 (setq gnus-newsgroup-name nil)
6109 (when (equal (gnus-group-group-name) group)
6110 (gnus-group-next-unread-group 1))
6112 (gnus-handle-ephemeral-exit quit-config)))))
6114 (defun gnus-handle-ephemeral-exit (quit-config)
6115 "Handle movement when leaving an ephemeral group.
6116 The state which existed when entering the ephemeral is reset."
6117 (if (not (buffer-name (car quit-config)))
6118 (gnus-configure-windows 'group 'force)
6119 (set-buffer (car quit-config))
6120 (cond ((eq major-mode 'gnus-summary-mode)
6121 (gnus-set-global-variables))
6122 ((eq major-mode 'gnus-article-mode)
6124 ;; The `gnus-summary-buffer' variable may point
6125 ;; to the old summary buffer when using a single
6127 (unless (gnus-buffer-live-p gnus-summary-buffer)
6128 (set-buffer gnus-group-buffer))
6129 (set-buffer gnus-summary-buffer)
6130 (gnus-set-global-variables))))
6131 (if (or (eq (cdr quit-config) 'article)
6132 (eq (cdr quit-config) 'pick))
6134 ;; The current article may be from the ephemeral group
6135 ;; thus it is best that we reload this article
6136 (gnus-summary-show-article)
6137 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
6138 (gnus-configure-windows 'pick 'force)
6139 (gnus-configure-windows (cdr quit-config) 'force)))
6140 (gnus-configure-windows (cdr quit-config) 'force))
6141 (when (eq major-mode 'gnus-summary-mode)
6142 (gnus-summary-next-subject 1 nil t)
6143 (gnus-summary-recenter)
6144 (gnus-summary-position-point))))
6148 (defvar gnus-dead-summary-mode-map nil)
6150 (unless gnus-dead-summary-mode-map
6151 (setq gnus-dead-summary-mode-map (make-keymap))
6152 (suppress-keymap gnus-dead-summary-mode-map)
6153 (substitute-key-definition
6154 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
6155 (let ((keys '("\C-d" "\r" "\177" [delete])))
6157 (define-key gnus-dead-summary-mode-map
6158 (pop keys) 'gnus-summary-wake-up-the-dead))))
6160 (defvar gnus-dead-summary-mode nil
6161 "Minor mode for Gnus summary buffers.")
6163 (defun gnus-dead-summary-mode (&optional arg)
6164 "Minor mode for Gnus summary buffers."
6166 (when (eq major-mode 'gnus-summary-mode)
6167 (make-local-variable 'gnus-dead-summary-mode)
6168 (setq gnus-dead-summary-mode
6169 (if (null arg) (not gnus-dead-summary-mode)
6170 (> (prefix-numeric-value arg) 0)))
6171 (when gnus-dead-summary-mode
6172 (gnus-add-minor-mode
6173 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
6175 (defun gnus-deaden-summary ()
6176 "Make the current summary buffer into a dead summary buffer."
6177 ;; Kill any previous dead summary buffer.
6178 (when (and gnus-dead-summary
6179 (buffer-name gnus-dead-summary))
6181 (set-buffer gnus-dead-summary)
6182 (when gnus-dead-summary-mode
6183 (kill-buffer (current-buffer)))))
6184 ;; Make this the current dead summary.
6185 (setq gnus-dead-summary (current-buffer))
6186 (gnus-dead-summary-mode 1)
6187 (let ((name (buffer-name)))
6188 (when (string-match "Summary" name)
6190 (concat (substring name 0 (match-beginning 0)) "Dead "
6191 (substring name (match-beginning 0)))
6195 (defun gnus-kill-or-deaden-summary (buffer)
6196 "Kill or deaden the summary BUFFER."
6198 (when (and (buffer-name buffer)
6199 (not gnus-single-article-buffer))
6202 (gnus-kill-buffer gnus-article-buffer)
6203 (gnus-kill-buffer gnus-original-article-buffer)))
6204 (cond (gnus-kill-summary-on-exit
6205 (when (and gnus-use-trees
6206 (gnus-buffer-exists-p buffer))
6209 (gnus-tree-close gnus-newsgroup-name)))
6210 (gnus-kill-buffer buffer))
6211 ((gnus-buffer-exists-p buffer)
6214 (gnus-deaden-summary))))))
6216 (defun gnus-summary-wake-up-the-dead (&rest args)
6217 "Wake up the dead summary buffer."
6219 (gnus-dead-summary-mode -1)
6220 (let ((name (buffer-name)))
6221 (when (string-match "Dead " name)
6223 (concat (substring name 0 (match-beginning 0))
6224 (substring name (match-end 0)))
6226 (gnus-message 3 "This dead summary is now alive again"))
6228 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
6229 (defun gnus-summary-fetch-faq (&optional faq-dir)
6230 "Fetch the FAQ for the current group.
6231 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
6235 (when current-prefix-arg
6237 "Faq dir: " (and (listp gnus-group-faq-directory)
6238 (mapcar (lambda (file) (list file))
6239 gnus-group-faq-directory))))))
6240 (let (gnus-faq-buffer)
6241 (when (setq gnus-faq-buffer
6242 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
6243 (gnus-configure-windows 'summary-faq))))
6245 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6246 (defun gnus-summary-describe-group (&optional force)
6247 "Describe the current newsgroup."
6249 (gnus-group-describe-group force gnus-newsgroup-name))
6251 (defun gnus-summary-describe-briefly ()
6252 "Describe summary mode commands briefly."
6254 (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")))
6256 ;; Walking around group mode buffer from summary mode.
6258 (defun gnus-summary-next-group (&optional no-article target-group backward)
6259 "Exit current newsgroup and then select next unread newsgroup.
6260 If prefix argument NO-ARTICLE is non-nil, no article is selected
6261 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
6262 previous group instead."
6264 ;; Stop pre-fetching.
6265 (gnus-async-halt-prefetch)
6266 (let ((current-group gnus-newsgroup-name)
6267 (current-buffer (current-buffer))
6269 ;; First we semi-exit this group to update Xrefs and all variables.
6270 ;; We can't do a real exit, because the window conf must remain
6271 ;; the same in case the user is prompted for info, and we don't
6272 ;; want the window conf to change before that...
6273 (gnus-summary-exit t)
6274 (while (not entered)
6275 ;; Then we find what group we are supposed to enter.
6276 (set-buffer gnus-group-buffer)
6277 (gnus-group-jump-to-group current-group)
6280 (if (eq gnus-keep-same-level 'best)
6281 (gnus-summary-best-group gnus-newsgroup-name)
6282 (gnus-summary-search-group backward gnus-keep-same-level))))
6283 (if (not target-group)
6284 ;; There are no further groups, so we return to the group
6287 (gnus-message 5 "Returning to the group buffer")
6289 (when (gnus-buffer-live-p current-buffer)
6290 (set-buffer current-buffer)
6291 (gnus-summary-exit))
6292 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
6293 ;; We try to enter the target group.
6294 (gnus-group-jump-to-group target-group)
6295 (let ((unreads (gnus-group-group-unread)))
6296 (if (and (or (eq t unreads)
6297 (and unreads (not (zerop unreads))))
6298 (gnus-summary-read-group
6299 target-group nil no-article
6300 (and (buffer-name current-buffer) current-buffer)
6303 (setq current-group target-group
6304 target-group nil)))))))
6306 (defun gnus-summary-prev-group (&optional no-article)
6307 "Exit current newsgroup and then select previous unread newsgroup.
6308 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
6310 (gnus-summary-next-group no-article nil t))
6312 ;; Walking around summary lines.
6314 (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
6315 "Go to the first unread subject.
6316 If UNREAD is non-nil, go to the first unread article.
6317 Returns the article selected or nil if there are no unread articles."
6322 ((null gnus-newsgroup-data)
6323 (gnus-message 3 "No articles in the group")
6325 ;; Pick the first article.
6327 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
6328 (gnus-data-number (car gnus-newsgroup-data)))
6329 ;; No unread articles.
6330 ((null gnus-newsgroup-unreads)
6331 (gnus-message 3 "No more unread articles")
6333 ;; Find the first unread article.
6335 (let ((data gnus-newsgroup-data))
6337 (and (not (and undownloaded
6338 (eq gnus-undownloaded-mark
6339 (gnus-data-mark (car data)))))
6341 (memq (car data) gnus-newsgroup-unseen)))
6342 (not (gnus-data-unread-p (car data)))))
6343 (setq data (cdr data)))
6345 (goto-char (gnus-data-pos (car data)))
6346 (gnus-data-number (car data))))))
6347 (gnus-summary-position-point)))
6349 (defun gnus-summary-next-subject (n &optional unread dont-display)
6350 "Go to next N'th summary line.
6351 If N is negative, go to the previous N'th subject line.
6352 If UNREAD is non-nil, only unread articles are selected.
6353 The difference between N and the actual number of steps taken is
6356 (let ((backward (< n 0))
6360 (gnus-summary-find-prev unread)
6361 (gnus-summary-find-next unread)))
6362 (unless (zerop (setq n (1- n)))
6363 (gnus-summary-show-thread)))
6365 (gnus-message 7 "No more%s articles"
6366 (if unread " unread" "")))
6367 (unless dont-display
6368 (gnus-summary-recenter)
6369 (gnus-summary-position-point))
6372 (defun gnus-summary-next-unread-subject (n)
6373 "Go to next N'th unread summary line."
6375 (gnus-summary-next-subject n t))
6377 (defun gnus-summary-prev-subject (n &optional unread)
6378 "Go to previous N'th summary line.
6379 If optional argument UNREAD is non-nil, only unread article is selected."
6381 (gnus-summary-next-subject (- n) unread))
6383 (defun gnus-summary-prev-unread-subject (n)
6384 "Go to previous N'th unread summary line."
6386 (gnus-summary-next-subject (- n) t))
6388 (defun gnus-summary-goto-subject (article &optional force silent)
6389 "Go the subject line of ARTICLE.
6390 If FORCE, also allow jumping to articles not currently shown."
6391 (interactive "nArticle number: ")
6393 (data (gnus-data-find article)))
6394 ;; We read in the article if we have to.
6397 (gnus-summary-insert-subject
6399 (if (or (numberp force) (vectorp force)) force)
6401 (setq data (gnus-data-find article)))
6406 (gnus-message 3 "Can't find article %d" article))
6408 (let ((pt (gnus-data-pos data)))
6410 (gnus-summary-set-article-display-arrow pt))
6411 (gnus-summary-position-point)
6414 ;; Walking around summary lines with displaying articles.
6416 (defun gnus-summary-expand-window (&optional arg)
6417 "Make the summary buffer take up the entire Emacs frame.
6418 Given a prefix, will force an `article' buffer configuration."
6421 (gnus-configure-windows 'article 'force)
6422 (gnus-configure-windows 'summary 'force)))
6424 (defun gnus-summary-display-article (article &optional all-header)
6425 "Display ARTICLE in article buffer."
6426 (when (gnus-buffer-live-p gnus-article-buffer)
6427 (with-current-buffer gnus-article-buffer
6428 (mm-enable-multibyte-mule4)))
6429 (gnus-set-global-variables)
6430 (when (gnus-buffer-live-p gnus-article-buffer)
6431 (with-current-buffer gnus-article-buffer
6432 (setq gnus-article-charset gnus-newsgroup-charset)
6433 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
6434 (mm-enable-multibyte-mule4)))
6438 (if gnus-summary-display-article-function
6439 (funcall gnus-summary-display-article-function article all-header)
6440 (gnus-article-prepare article all-header))
6441 (gnus-run-hooks 'gnus-select-article-hook)
6442 (when (and gnus-current-article
6443 (not (zerop gnus-current-article)))
6444 (gnus-summary-goto-subject gnus-current-article))
6445 (gnus-summary-recenter)
6446 (when (and gnus-use-trees gnus-show-threads)
6447 (gnus-possibly-generate-tree article)
6448 (gnus-highlight-selected-tree article))
6449 ;; Successfully display article.
6450 (gnus-article-set-window-start
6451 (cdr (assq article gnus-newsgroup-bookmarks))))))
6453 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
6454 "Select the current article.
6455 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
6456 non-nil, the article will be re-fetched even if it already present in
6457 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
6459 ;; Make sure we are in the summary buffer to work around bbdb bug.
6460 (unless (eq major-mode 'gnus-summary-mode)
6461 (set-buffer gnus-summary-buffer))
6462 (let ((article (or article (gnus-summary-article-number)))
6463 (all-headers (not (not all-headers))) ;Must be t or nil.
6464 gnus-summary-display-article-function)
6466 (gnus-summary-article-pseudo-p article)
6467 (error "This is a pseudo-article"))
6469 (set-buffer gnus-summary-buffer)
6470 (if (or (and gnus-single-article-buffer
6471 (or (null gnus-current-article)
6472 (null gnus-article-current)
6473 (null (get-buffer gnus-article-buffer))
6474 (not (eq article (cdr gnus-article-current)))
6475 (not (equal (car gnus-article-current)
6476 gnus-newsgroup-name))))
6477 (and (not gnus-single-article-buffer)
6478 (or (null gnus-current-article)
6479 (not (eq gnus-current-article article))))
6481 ;; The requested article is different from the current article.
6483 (gnus-summary-display-article article all-headers)
6484 (when (gnus-buffer-live-p gnus-article-buffer)
6485 (with-current-buffer gnus-article-buffer
6486 (if (not gnus-article-decoded-p) ;; a local variable
6487 (mm-disable-multibyte-mule4))))
6488 (when (or all-headers gnus-show-all-headers)
6489 (gnus-article-show-all-headers))
6490 (gnus-article-set-window-start
6491 (cdr (assq article gnus-newsgroup-bookmarks)))
6493 (when (or all-headers gnus-show-all-headers)
6494 (gnus-article-show-all-headers))
6497 (defun gnus-summary-force-verify-and-decrypt ()
6499 (let ((mm-verify-option 'known)
6500 (mm-decrypt-option 'known))
6501 (gnus-summary-select-article nil 'force)))
6503 (defun gnus-summary-set-current-mark (&optional current-mark)
6504 "Obsolete function."
6507 (defun gnus-summary-next-article (&optional unread subject backward push)
6508 "Select the next article.
6509 If UNREAD, only unread articles are selected.
6510 If SUBJECT, only articles with SUBJECT are selected.
6511 If BACKWARD, the previous article is selected instead of the next."
6514 ;; Is there such an article?
6515 ((and (gnus-summary-search-forward unread subject backward)
6516 (or (gnus-summary-display-article (gnus-summary-article-number))
6517 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
6518 (gnus-summary-position-point))
6519 ;; If not, we try the first unread, if that is wanted.
6521 gnus-auto-select-same
6522 (gnus-summary-first-unread-article))
6523 (gnus-summary-position-point)
6524 (gnus-message 6 "Wrapped"))
6525 ;; Try to get next/previous article not displayed in this group.
6526 ((and gnus-auto-extend-newsgroup
6527 (not unread) (not subject))
6528 (gnus-summary-goto-article
6529 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
6530 nil (count-lines (point-min) (point))))
6531 ;; Go to next/previous group.
6533 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
6534 (gnus-summary-jump-to-group gnus-newsgroup-name))
6535 (let ((cmd last-command-char)
6538 (set-buffer gnus-group-buffer)
6541 (if (eq gnus-keep-same-level 'best)
6542 (gnus-summary-best-group gnus-newsgroup-name)
6543 (gnus-summary-search-group backward gnus-keep-same-level))))
6544 ;; For some reason, the group window gets selected. We change
6546 (select-window (get-buffer-window (current-buffer)))
6547 ;; Select next unread newsgroup automagically.
6549 ((or (not gnus-auto-select-next)
6551 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
6552 ((or (eq gnus-auto-select-next 'quietly)
6553 (and (eq gnus-auto-select-next 'slightly-quietly)
6555 (and (eq gnus-auto-select-next 'almost-quietly)
6556 (gnus-summary-last-article-p)))
6558 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
6560 (gnus-message 7 "No more%s articles (%s)..."
6561 (if unread " unread" "")
6562 (if group (concat "selecting " group)
6564 (gnus-summary-next-group nil group backward)))
6566 (when (gnus-key-press-event-p last-input-event)
6567 (gnus-summary-walk-group-buffer
6568 gnus-newsgroup-name cmd unread backward point))))))))
6570 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
6571 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
6572 (?\C-p (gnus-group-prev-unread-group 1))))
6573 (cursor-in-echo-area t)
6574 keve key group ended)
6576 (set-buffer gnus-group-buffer)
6579 (if (eq gnus-keep-same-level 'best)
6580 (gnus-summary-best-group gnus-newsgroup-name)
6581 (gnus-summary-search-group backward gnus-keep-same-level))))
6584 5 "No more%s articles%s" (if unread " unread" "")
6586 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
6587 (format " (Type %s for %s [%s])"
6588 (single-key-description cmd) group
6589 (car (gnus-gethash group gnus-newsrc-hashtb)))
6590 (format " (Type %s to exit %s)"
6591 (single-key-description cmd)
6592 gnus-newsgroup-name)))
6593 ;; Confirm auto selection.
6594 (setq key (car (setq keve (gnus-read-event-char))))
6597 ((assq key keystrokes)
6598 (let ((obuf (current-buffer)))
6599 (switch-to-buffer gnus-group-buffer)
6601 (gnus-group-jump-to-group group))
6602 (eval (cadr (assq key keystrokes)))
6603 (setq group (gnus-group-group-name))
6604 (switch-to-buffer obuf))
6608 (gnus-ephemeral-group-p gnus-newsgroup-name))
6610 (gnus-summary-next-group nil group backward)))
6612 (push (cdr keve) unread-command-events))))))
6614 (defun gnus-summary-next-unread-article ()
6615 "Select unread article after current one."
6617 (gnus-summary-next-article
6618 (or (not (eq gnus-summary-goto-unread 'never))
6619 (gnus-summary-last-article-p (gnus-summary-article-number)))
6620 (and gnus-auto-select-same
6621 (gnus-summary-article-subject))))
6623 (defun gnus-summary-prev-article (&optional unread subject)
6624 "Select the article after the current one.
6625 If UNREAD is non-nil, only unread articles are selected."
6627 (gnus-summary-next-article unread subject t))
6629 (defun gnus-summary-prev-unread-article ()
6630 "Select unread article before current one."
6632 (gnus-summary-prev-article
6633 (or (not (eq gnus-summary-goto-unread 'never))
6634 (gnus-summary-first-article-p (gnus-summary-article-number)))
6635 (and gnus-auto-select-same
6636 (gnus-summary-article-subject))))
6638 (defun gnus-summary-next-page (&optional lines circular)
6639 "Show next page of the selected article.
6640 If at the end of the current article, select the next article.
6641 LINES says how many lines should be scrolled up.
6643 If CIRCULAR is non-nil, go to the start of the article instead of
6644 selecting the next article when reaching the end of the current
6647 (setq gnus-summary-buffer (current-buffer))
6648 (gnus-set-global-variables)
6649 (let ((article (gnus-summary-article-number))
6650 (article-window (get-buffer-window gnus-article-buffer t))
6652 ;; If the buffer is empty, we have no article.
6654 (error "No article to select"))
6655 (gnus-configure-windows 'article)
6656 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
6657 (if (and (eq gnus-summary-goto-unread 'never)
6658 (not (gnus-summary-last-article-p article)))
6659 (gnus-summary-next-article)
6660 (gnus-summary-next-unread-article))
6661 (if (or (null gnus-current-article)
6662 (null gnus-article-current)
6663 (/= article (cdr gnus-article-current))
6664 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6665 ;; Selected subject is different from current article's.
6666 (gnus-summary-display-article article)
6667 (when article-window
6668 (gnus-eval-in-buffer-window gnus-article-buffer
6669 (setq endp (gnus-article-next-page lines)))
6672 (gnus-summary-beginning-of-article))
6674 (gnus-message 3 "End of message"))
6676 (if (and (eq gnus-summary-goto-unread 'never)
6677 (not (gnus-summary-last-article-p article)))
6678 (gnus-summary-next-article)
6679 (gnus-summary-next-unread-article))))))))
6680 (gnus-summary-recenter)
6681 (gnus-summary-position-point)))
6683 (defun gnus-summary-prev-page (&optional lines move)
6684 "Show previous page of selected article.
6685 Argument LINES specifies lines to be scrolled down.
6686 If MOVE, move to the previous unread article if point is at
6687 the beginning of the buffer."
6689 (let ((article (gnus-summary-article-number))
6690 (article-window (get-buffer-window gnus-article-buffer t))
6692 (gnus-configure-windows 'article)
6693 (if (or (null gnus-current-article)
6694 (null gnus-article-current)
6695 (/= article (cdr gnus-article-current))
6696 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6697 ;; Selected subject is different from current article's.
6698 (gnus-summary-display-article article)
6699 (gnus-summary-recenter)
6700 (when article-window
6701 (gnus-eval-in-buffer-window gnus-article-buffer
6702 (setq endp (gnus-article-prev-page lines)))
6703 (when (and move endp)
6705 (gnus-message 3 "Beginning of message"))
6707 (if (and (eq gnus-summary-goto-unread 'never)
6708 (not (gnus-summary-first-article-p article)))
6709 (gnus-summary-prev-article)
6710 (gnus-summary-prev-unread-article))))))))
6711 (gnus-summary-position-point))
6713 (defun gnus-summary-prev-page-or-article (&optional lines)
6714 "Show previous page of selected article.
6715 Argument LINES specifies lines to be scrolled down.
6716 If at the beginning of the article, go to the next article."
6718 (gnus-summary-prev-page lines t))
6720 (defun gnus-summary-scroll-up (lines)
6721 "Scroll up (or down) one line current article.
6722 Argument LINES specifies lines to be scrolled up (or down if negative)."
6724 (gnus-configure-windows 'article)
6725 (gnus-summary-show-thread)
6726 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
6727 (gnus-eval-in-buffer-window gnus-article-buffer
6729 (when (gnus-article-next-page lines)
6730 (gnus-message 3 "End of message")))
6732 (gnus-article-prev-page (- lines))))))
6733 (gnus-summary-recenter)
6734 (gnus-summary-position-point))
6736 (defun gnus-summary-scroll-down (lines)
6737 "Scroll down (or up) one line current article.
6738 Argument LINES specifies lines to be scrolled down (or up if negative)."
6740 (gnus-summary-scroll-up (- lines)))
6742 (defun gnus-summary-next-same-subject ()
6743 "Select next article which has the same subject as current one."
6745 (gnus-summary-next-article nil (gnus-summary-article-subject)))
6747 (defun gnus-summary-prev-same-subject ()
6748 "Select previous article which has the same subject as current one."
6750 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
6752 (defun gnus-summary-next-unread-same-subject ()
6753 "Select next unread article which has the same subject as current one."
6755 (gnus-summary-next-article t (gnus-summary-article-subject)))
6757 (defun gnus-summary-prev-unread-same-subject ()
6758 "Select previous unread article which has the same subject as current one."
6760 (gnus-summary-prev-article t (gnus-summary-article-subject)))
6762 (defun gnus-summary-first-unread-article ()
6763 "Select the first unread article.
6764 Return nil if there are no unread articles."
6767 (when (gnus-summary-first-subject t)
6768 (gnus-summary-show-thread)
6769 (gnus-summary-first-subject t)
6770 (gnus-summary-display-article (gnus-summary-article-number)))
6771 (gnus-summary-position-point)))
6773 (defun gnus-summary-first-unread-subject ()
6774 "Place the point on the subject line of the first unread article.
6775 Return nil if there are no unread articles."
6778 (when (gnus-summary-first-subject t)
6779 (gnus-summary-show-thread)
6780 (gnus-summary-first-subject t))
6781 (gnus-summary-position-point)))
6783 (defun gnus-summary-first-unseen-subject ()
6784 "Place the point on the subject line of the first unseen article.
6785 Return nil if there are no unseen articles."
6788 (when (gnus-summary-first-subject t t t)
6789 (gnus-summary-show-thread)
6790 (gnus-summary-first-subject t t t))
6791 (gnus-summary-position-point)))
6793 (defun gnus-summary-first-article ()
6794 "Select the first article.
6795 Return nil if there are no articles."
6798 (when (gnus-summary-first-subject)
6799 (gnus-summary-show-thread)
6800 (gnus-summary-first-subject)
6801 (gnus-summary-display-article (gnus-summary-article-number)))
6802 (gnus-summary-position-point)))
6804 (defun gnus-summary-best-unread-article ()
6805 "Select the unread article with the highest score."
6807 (let ((article (gnus-summary-best-unread-subject)))
6809 (gnus-summary-goto-article article)
6810 (error "No unread articles"))))
6812 (defun gnus-summary-best-unread-subject ()
6813 "Select the unread subject with the highest score."
6815 (let ((best -1000000)
6816 (data gnus-newsgroup-data)
6819 (and (gnus-data-unread-p (car data))
6821 (gnus-summary-article-score (gnus-data-number (car data))))
6824 article (gnus-data-number (car data))))
6825 (setq data (cdr data)))
6826 (gnus-summary-position-point)
6829 (defun gnus-summary-last-subject ()
6830 "Go to the last displayed subject line in the group."
6831 (let ((article (gnus-data-number (car (gnus-data-list t)))))
6833 (gnus-summary-goto-subject article))))
6835 (defun gnus-summary-goto-article (article &optional all-headers force)
6836 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
6837 If ALL-HEADERS is non-nil, no header lines are hidden.
6838 If FORCE, go to the article even if it isn't displayed. If FORCE
6839 is a number, it is the line the article is to be displayed on."
6843 "Article number or Message-ID: "
6844 (mapcar (lambda (number) (list (int-to-string number)))
6845 gnus-newsgroup-limit))
6849 (if (and (stringp article)
6850 (string-match "@" article))
6851 (gnus-summary-refer-article article)
6852 (when (stringp article)
6853 (setq article (string-to-number article)))
6854 (if (gnus-summary-goto-subject article force)
6855 (gnus-summary-display-article article all-headers)
6856 (gnus-message 4 "Couldn't go to article %s" article) nil))
6857 (gnus-summary-position-point)))
6859 (defun gnus-summary-goto-last-article ()
6860 "Go to the previously read article."
6863 (when gnus-last-article
6864 (gnus-summary-goto-article gnus-last-article nil t))
6865 (gnus-summary-position-point)))
6867 (defun gnus-summary-pop-article (number)
6868 "Pop one article off the history and go to the previous.
6869 NUMBER articles will be popped off."
6872 (setq gnus-newsgroup-history
6873 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
6875 (gnus-summary-goto-article (car to) nil t)
6876 (error "Article history empty")))
6877 (gnus-summary-position-point))
6879 ;; Summary commands and functions for limiting the summary buffer.
6881 (defun gnus-summary-limit-to-articles (n)
6882 "Limit the summary buffer to the next N articles.
6883 If not given a prefix, use the process marked articles instead."
6886 (let ((articles (gnus-summary-work-articles n)))
6887 (setq gnus-newsgroup-processable nil)
6888 (gnus-summary-limit articles))
6889 (gnus-summary-position-point)))
6891 (defun gnus-summary-pop-limit (&optional total)
6892 "Restore the previous limit.
6893 If given a prefix, remove all limits."
6896 (setq gnus-newsgroup-limits
6897 (list (mapcar (lambda (h) (mail-header-number h))
6898 gnus-newsgroup-headers))))
6899 (unless gnus-newsgroup-limits
6900 (error "No limit to pop"))
6902 (gnus-summary-limit nil 'pop)
6903 (gnus-summary-position-point)))
6905 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
6906 "Limit the summary buffer to articles that have subjects that match a regexp.
6907 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
6909 (list (read-string (if current-prefix-arg
6910 "Exclude subject (regexp): "
6911 "Limit to subject (regexp): "))
6912 nil current-prefix-arg))
6914 (setq header "subject"))
6915 (when (not (equal "" subject))
6917 (let ((articles (gnus-summary-find-matching
6918 (or header "subject") subject 'all nil nil
6921 (error "Found no matches for \"%s\"" subject))
6922 (gnus-summary-limit articles))
6923 (gnus-summary-position-point))))
6925 (defun gnus-summary-limit-to-author (from &optional not-matching)
6926 "Limit the summary buffer to articles that have authors that match a regexp.
6927 If NOT-MATCHING, excluding articles that have authors that match a regexp."
6929 (list (read-string (if current-prefix-arg
6930 "Exclude author (regexp): "
6931 "Limit to author (regexp): "))
6932 current-prefix-arg))
6933 (gnus-summary-limit-to-subject from "from" not-matching))
6935 (defun gnus-summary-limit-to-age (age &optional younger-p)
6936 "Limit the summary buffer to articles that are older than (or equal) AGE days.
6937 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
6938 articles that are younger than AGE days."
6940 (let ((younger current-prefix-arg)
6943 (while (not days-got)
6944 (setq days (if younger
6945 (read-string "Limit to articles within (in days): ")
6946 (read-string "Limit to articles older than (in days): ")))
6947 (when (> (length days) 0)
6948 (setq days (read days)))
6954 (setq younger (not younger))
6955 (setq days (* days -1)))))
6956 (message "Please enter a number.")
6958 (list days younger)))
6960 (let ((data gnus-newsgroup-data)
6961 (cutoff (days-to-time age))
6962 articles d date is-younger)
6963 (while (setq d (pop data))
6964 (when (and (vectorp (gnus-data-header d))
6965 (setq date (mail-header-date (gnus-data-header d))))
6966 (setq is-younger (time-less-p
6967 (time-since (condition-case ()
6974 (push (gnus-data-number d) articles))))
6975 (gnus-summary-limit (nreverse articles)))
6976 (gnus-summary-position-point)))
6978 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
6979 "Limit the summary buffer to articles that match an 'extra' header."
6983 (gnus-completing-read
6984 (symbol-name (car gnus-extra-headers))
6985 (if current-prefix-arg
6986 "Exclude extra header:"
6987 "Limit extra header:")
6989 (cons (symbol-name x) x))
6994 (read-string (format "%s header %s (regexp): "
6995 (if current-prefix-arg "Exclude" "Limit to")
6997 current-prefix-arg)))
6998 (when (not (equal "" regexp))
7000 (let ((articles (gnus-summary-find-matching
7001 (cons 'extra header) regexp 'all nil nil
7004 (error "Found no matches for \"%s\"" regexp))
7005 (gnus-summary-limit articles))
7006 (gnus-summary-position-point))))
7008 (defun gnus-summary-limit-to-display-predicate ()
7009 "Limit the summary buffer to the predicated in the `display' group parameter."
7011 (unless gnus-newsgroup-display
7012 (error "There is no `display' group parameter"))
7014 (dolist (number gnus-newsgroup-articles)
7015 (when (funcall gnus-newsgroup-display)
7016 (push number articles)))
7017 (gnus-summary-limit articles))
7018 (gnus-summary-position-point))
7020 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7022 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7024 (defun gnus-summary-limit-to-unread (&optional all)
7025 "Limit the summary buffer to articles that are not marked as read.
7026 If ALL is non-nil, limit strictly to unread articles."
7029 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
7030 (gnus-summary-limit-to-marks
7031 ;; Concat all the marks that say that an article is read and have
7033 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
7034 gnus-killed-mark gnus-kill-file-mark
7035 gnus-low-score-mark gnus-expirable-mark
7036 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
7037 gnus-duplicate-mark gnus-souped-mark)
7040 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
7041 (make-obsolete 'gnus-summary-delete-marked-with
7042 'gnus-summary-limit-exlude-marks)
7044 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
7045 "Exclude articles that are marked with MARKS (e.g. \"DK\").
7046 If REVERSE, limit the summary buffer to articles that are marked
7047 with MARKS. MARKS can either be a string of marks or a list of marks.
7048 Returns how many articles were removed."
7049 (interactive "sMarks: ")
7050 (gnus-summary-limit-to-marks marks t))
7052 (defun gnus-summary-limit-to-marks (marks &optional reverse)
7053 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
7054 If REVERSE (the prefix), limit the summary buffer to articles that are
7055 not marked with MARKS. MARKS can either be a string of marks or a
7057 Returns how many articles were removed."
7058 (interactive "sMarks: \nP")
7060 (let ((data gnus-newsgroup-data)
7061 (marks (if (listp marks) marks
7062 (append marks nil))) ; Transform to list.
7065 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
7066 (memq (gnus-data-mark (car data)) marks))
7067 (push (gnus-data-number (car data)) articles))
7068 (setq data (cdr data)))
7069 (gnus-summary-limit articles))
7070 (gnus-summary-position-point)))
7072 (defun gnus-summary-limit-to-score (score)
7073 "Limit to articles with score at or above SCORE."
7074 (interactive "NLimit to articles with score of at least: ")
7075 (let ((data gnus-newsgroup-data)
7078 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
7080 (push (gnus-data-number (car data)) articles))
7081 (setq data (cdr data)))
7083 (gnus-summary-limit articles)
7084 (gnus-summary-position-point))))
7086 (defun gnus-summary-limit-include-thread (id)
7087 "Display all the hidden articles that is in the thread with ID in it.
7088 When called interactively, ID is the Message-ID of the current
7090 (interactive (list (mail-header-id (gnus-summary-article-header))))
7091 (let ((articles (gnus-articles-in-thread
7092 (gnus-id-to-thread (gnus-root-id id)))))
7094 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7095 (gnus-summary-limit-include-matching-articles
7097 (regexp-quote (gnus-simplify-subject-re
7098 (mail-header-subject (gnus-id-to-header id)))))
7099 (gnus-summary-position-point))))
7101 (defun gnus-summary-limit-include-matching-articles (header regexp)
7102 "Display all the hidden articles that have HEADERs that match REGEXP."
7103 (interactive (list (read-string "Match on header: ")
7104 (read-string "Regexp: ")))
7105 (let ((articles (gnus-find-matching-articles header regexp)))
7107 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7108 (gnus-summary-position-point))))
7110 (defun gnus-summary-limit-include-dormant ()
7111 "Display all the hidden articles that are marked as dormant.
7112 Note that this command only works on a subset of the articles currently
7113 fetched for this group."
7115 (unless gnus-newsgroup-dormant
7116 (error "There are no dormant articles in this group"))
7118 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
7119 (gnus-summary-position-point)))
7121 (defun gnus-summary-limit-exclude-dormant ()
7122 "Hide all dormant articles."
7125 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
7126 (gnus-summary-position-point)))
7128 (defun gnus-summary-limit-exclude-childless-dormant ()
7129 "Hide all dormant articles that have no children."
7131 (let ((data (gnus-data-list t))
7132 articles d children)
7133 ;; Find all articles that are either not dormant or have
7135 (while (setq d (pop data))
7136 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
7138 (gnus-article-children (gnus-data-number d)))
7141 (when (memq (car children) articles)
7146 (push (gnus-data-number d) articles)))
7149 (gnus-summary-limit articles)
7150 (gnus-summary-position-point))))
7152 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
7153 "Mark all unread excluded articles as read.
7154 If ALL, mark even excluded ticked and dormants as read."
7156 (let ((articles (gnus-sorted-complement
7158 (mapcar (lambda (h) (mail-header-number h))
7159 gnus-newsgroup-headers)
7161 (sort gnus-newsgroup-limit '<)))
7163 (setq gnus-newsgroup-unreads
7164 (gnus-intersection gnus-newsgroup-unreads gnus-newsgroup-limit))
7166 (setq gnus-newsgroup-dormant nil
7167 gnus-newsgroup-marked nil
7168 gnus-newsgroup-reads
7170 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
7171 gnus-newsgroup-reads))
7172 (while (setq article (pop articles))
7173 (unless (or (memq article gnus-newsgroup-dormant)
7174 (memq article gnus-newsgroup-marked))
7175 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
7177 (defun gnus-summary-limit (articles &optional pop)
7179 ;; We pop the previous limit off the stack and use that.
7180 (setq articles (car gnus-newsgroup-limits)
7181 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
7182 ;; We use the new limit, so we push the old limit on the stack.
7183 (push gnus-newsgroup-limit gnus-newsgroup-limits))
7185 (setq gnus-newsgroup-limit articles)
7186 (let ((total (length gnus-newsgroup-data))
7187 (data (gnus-data-find-list (gnus-summary-article-number)))
7188 (gnus-summary-mark-below nil) ; Inhibit this.
7190 ;; This will do all the work of generating the new summary buffer
7191 ;; according to the new limit.
7192 (gnus-summary-prepare)
7193 ;; Hide any threads, possibly.
7194 (and gnus-show-threads
7195 gnus-thread-hide-subtree
7196 (gnus-summary-hide-all-threads))
7197 ;; Try to return to the article you were at, or one in the
7200 ;; We try to find some article after the current one.
7202 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
7205 (setq data (cdr data))))
7207 ;; If there is no data, that means that we were after the last
7208 ;; article. The same goes when we can't find any articles
7209 ;; after the current one.
7210 (goto-char (point-max))
7211 (gnus-summary-find-prev))
7212 (gnus-set-mode-line 'summary)
7213 ;; We return how many articles were removed from the summary
7214 ;; buffer as a result of the new limit.
7215 (- total (length gnus-newsgroup-data))))
7217 (defsubst gnus-invisible-cut-children (threads)
7220 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
7225 (defsubst gnus-cut-thread (thread)
7226 "Go forwards in the thread until we find an article that we want to display."
7227 (when (or (eq gnus-fetch-old-headers 'some)
7228 (eq gnus-fetch-old-headers 'invisible)
7229 (numberp gnus-fetch-old-headers)
7230 (eq gnus-build-sparse-threads 'some)
7231 (eq gnus-build-sparse-threads 'more))
7232 ;; Deal with old-fetched headers and sparse threads.
7236 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
7237 (gnus-summary-article-ancient-p
7238 (mail-header-number (car thread))))
7239 (if (or (<= (length (cdr thread)) 1)
7240 (eq gnus-fetch-old-headers 'invisible))
7241 (setq gnus-newsgroup-limit
7242 (delq (mail-header-number (car thread))
7243 gnus-newsgroup-limit)
7244 thread (cadr thread))
7245 (when (gnus-invisible-cut-children (cdr thread))
7246 (let ((th (cdr thread)))
7248 (if (memq (mail-header-number (caar th))
7249 gnus-newsgroup-limit)
7250 (setq thread (car th)
7252 (setq th (cdr th))))))))))
7255 (defun gnus-cut-threads (threads)
7256 "Cut off all uninteresting articles from the beginning of threads."
7257 (when (or (eq gnus-fetch-old-headers 'some)
7258 (eq gnus-fetch-old-headers 'invisible)
7259 (numberp gnus-fetch-old-headers)
7260 (eq gnus-build-sparse-threads 'some)
7261 (eq gnus-build-sparse-threads 'more))
7264 (setcar th (gnus-cut-thread (car th)))
7265 (setq th (cdr th)))))
7266 ;; Remove nixed out threads.
7269 (defun gnus-summary-initial-limit (&optional show-if-empty)
7270 "Figure out what the initial limit is supposed to be on group entry.
7271 This entails weeding out unwanted dormants, low-scored articles,
7272 fetch-old-headers verbiage, and so on."
7273 ;; Most groups have nothing to remove.
7274 (if (or gnus-inhibit-limiting
7275 (and (null gnus-newsgroup-dormant)
7276 (eq gnus-newsgroup-display 'gnus-not-ignore)
7277 (not (eq gnus-fetch-old-headers 'some))
7278 (not (numberp gnus-fetch-old-headers))
7279 (not (eq gnus-fetch-old-headers 'invisible))
7280 (null gnus-summary-expunge-below)
7281 (not (eq gnus-build-sparse-threads 'some))
7282 (not (eq gnus-build-sparse-threads 'more))
7283 (null gnus-thread-expunge-below)
7284 (not gnus-use-nocem)))
7286 (push gnus-newsgroup-limit gnus-newsgroup-limits)
7287 (setq gnus-newsgroup-limit nil)
7290 (unless (car (symbol-value node))
7291 ;; These threads have no parents -- they are roots.
7292 (let ((nodes (cdr (symbol-value node)))
7295 (if (and gnus-thread-expunge-below
7296 (< (gnus-thread-total-score (car nodes))
7297 gnus-thread-expunge-below))
7298 (gnus-expunge-thread (pop nodes))
7299 (setq thread (pop nodes))
7300 (gnus-summary-limit-children thread))))))
7301 gnus-newsgroup-dependencies)
7302 ;; If this limitation resulted in an empty group, we might
7303 ;; pop the previous limit and use it instead.
7304 (when (and (not gnus-newsgroup-limit)
7306 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
7307 gnus-newsgroup-limit))
7309 (defun gnus-summary-limit-children (thread)
7310 "Return 1 if this subthread is visible and 0 if it is not."
7311 ;; First we get the number of visible children to this thread. This
7312 ;; is done by recursing down the thread using this function, so this
7313 ;; will really go down to a leaf article first, before slowly
7314 ;; working its way up towards the root.
7318 (apply '+ (mapcar 'gnus-summary-limit-children
7321 (number (mail-header-number (car thread)))
7324 (not (memq number gnus-newsgroup-marked))
7326 ;; If this article is dormant and has absolutely no visible
7327 ;; children, then this article isn't visible.
7328 (and (memq number gnus-newsgroup-dormant)
7330 ;; If this is "fetch-old-headered" and there is no
7331 ;; visible children, then we don't want this article.
7332 (and (or (eq gnus-fetch-old-headers 'some)
7333 (numberp gnus-fetch-old-headers))
7334 (gnus-summary-article-ancient-p number)
7336 ;; If this is "fetch-old-headered" and `invisible', then
7337 ;; we don't want this article.
7338 (and (eq gnus-fetch-old-headers 'invisible)
7339 (gnus-summary-article-ancient-p number))
7340 ;; If this is a sparsely inserted article with no children,
7341 ;; we don't want it.
7342 (and (eq gnus-build-sparse-threads 'some)
7343 (gnus-summary-article-sparse-p number)
7345 ;; If we use expunging, and this article is really
7346 ;; low-scored, then we don't want this article.
7347 (when (and gnus-summary-expunge-below
7349 (or (cdr (assq number gnus-newsgroup-scored))
7350 gnus-summary-default-score))
7351 gnus-summary-expunge-below))
7352 ;; We increase the expunge-tally here, but that has
7353 ;; nothing to do with the limits, really.
7354 (incf gnus-newsgroup-expunged-tally)
7355 ;; We also mark as read here, if that's wanted.
7356 (when (and gnus-summary-mark-below
7357 (< score gnus-summary-mark-below))
7358 (setq gnus-newsgroup-unreads
7359 (delq number gnus-newsgroup-unreads))
7360 (if gnus-newsgroup-auto-expire
7361 (push number gnus-newsgroup-expirable)
7362 (push (cons number gnus-low-score-mark)
7363 gnus-newsgroup-reads)))
7365 ;; Do the `display' group parameter.
7366 (and gnus-newsgroup-display
7367 (not (funcall gnus-newsgroup-display)))
7368 ;; Check NoCeM things.
7369 (if (and gnus-use-nocem
7370 (gnus-nocem-unwanted-article-p
7371 (mail-header-id (car thread))))
7373 (setq gnus-newsgroup-unreads
7374 (delq number gnus-newsgroup-unreads))
7376 ;; Nope, invisible article.
7378 ;; Ok, this article is to be visible, so we add it to the limit
7380 (push number gnus-newsgroup-limit)
7383 (defun gnus-expunge-thread (thread)
7384 "Mark all articles in THREAD as read."
7385 (let* ((number (mail-header-number (car thread))))
7386 (incf gnus-newsgroup-expunged-tally)
7387 ;; We also mark as read here, if that's wanted.
7388 (setq gnus-newsgroup-unreads
7389 (delq number gnus-newsgroup-unreads))
7390 (if gnus-newsgroup-auto-expire
7391 (push number gnus-newsgroup-expirable)
7392 (push (cons number gnus-low-score-mark)
7393 gnus-newsgroup-reads)))
7394 ;; Go recursively through all subthreads.
7395 (mapcar 'gnus-expunge-thread (cdr thread)))
7397 ;; Summary article oriented commands
7399 (defun gnus-summary-refer-parent-article (n)
7400 "Refer parent article N times.
7401 If N is negative, go to ancestor -N instead.
7402 The difference between N and the number of articles fetched is returned."
7406 (when (not (natnump n))
7411 (setq header (gnus-summary-article-header))
7412 (if (and (eq (mail-header-number header)
7413 (cdr gnus-article-current))
7414 (equal gnus-newsgroup-name
7415 (car gnus-article-current)))
7416 ;; If we try to find the parent of the currently
7417 ;; displayed article, then we take a look at the actual
7418 ;; References header, since this is slightly more
7419 ;; reliable than the References field we got from the
7422 (set-buffer gnus-original-article-buffer)
7423 (nnheader-narrow-to-headers)
7424 (unless (setq ref (message-fetch-field "references"))
7425 (setq ref (message-fetch-field "in-reply-to")))
7428 ;; It's not the current article, so we take a bet on
7429 ;; the value we got from the server.
7430 (mail-header-references header)))
7432 (not (equal ref "")))
7433 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
7434 (gnus-message 1 "Couldn't find parent"))
7435 (gnus-message 1 "No references in article %d"
7436 (gnus-summary-article-number))
7439 (gnus-summary-position-point)
7442 (defun gnus-summary-refer-references ()
7443 "Fetch all articles mentioned in the References header.
7444 Return the number of articles fetched."
7446 (let ((ref (mail-header-references (gnus-summary-article-header)))
7447 (current (gnus-summary-article-number))
7451 (error "No References in the current article")
7452 ;; For each Message-ID in the References header...
7453 (while (string-match "<[^>]*>" ref)
7455 ;; ... fetch that article.
7456 (gnus-summary-refer-article
7457 (prog1 (match-string 0 ref)
7458 (setq ref (substring ref (match-end 0))))))
7459 (gnus-summary-goto-subject current)
7460 (gnus-summary-position-point)
7463 (defun gnus-summary-refer-thread (&optional limit)
7464 "Fetch all articles in the current thread.
7465 If LIMIT (the numerical prefix), fetch that many old headers instead
7466 of what's specified by the `gnus-refer-thread-limit' variable."
7468 (let ((id (mail-header-id (gnus-summary-article-header)))
7469 (limit (if limit (prefix-numeric-value limit)
7470 gnus-refer-thread-limit)))
7471 ;; We want to fetch LIMIT *old* headers, but we also have to
7472 ;; re-fetch all the headers in the current buffer, because many of
7473 ;; them may be undisplayed. So we adjust LIMIT.
7474 (when (numberp limit)
7475 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
7476 (unless (eq gnus-fetch-old-headers 'invisible)
7477 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
7478 ;; Retrieve the headers and read them in.
7479 (if (eq (gnus-retrieve-headers
7480 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
7482 (gnus-build-all-threads)
7483 (error "Can't fetch thread from backends that don't support NOV"))
7484 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
7485 (gnus-summary-limit-include-thread id)))
7487 (defun gnus-summary-refer-article (message-id)
7488 "Fetch an article specified by MESSAGE-ID."
7489 (interactive "sMessage-ID: ")
7490 (when (and (stringp message-id)
7491 (not (zerop (length message-id))))
7492 ;; Construct the correct Message-ID if necessary.
7493 ;; Suggested by tale@pawl.rpi.edu.
7494 (unless (string-match "^<" message-id)
7495 (setq message-id (concat "<" message-id)))
7496 (unless (string-match ">$" message-id)
7497 (setq message-id (concat message-id ">")))
7498 (let* ((header (gnus-id-to-header message-id))
7500 (gnus-summary-article-sparse-p
7501 (mail-header-number header))
7502 (memq (mail-header-number header)
7503 gnus-newsgroup-limit)))
7506 ;; If the article is present in the buffer we just go to it.
7508 (or (not (gnus-summary-article-sparse-p
7509 (mail-header-number header)))
7512 (gnus-summary-goto-article
7513 (mail-header-number header) nil t)
7515 (gnus-summary-update-article (mail-header-number header)))))
7517 ;; We fetch the article.
7519 (dolist (gnus-override-method (gnus-refer-article-methods))
7520 (gnus-check-server gnus-override-method)
7521 ;; Fetch the header, and display the article.
7522 (when (setq number (gnus-summary-insert-subject message-id))
7523 (gnus-summary-select-article nil nil nil number)
7525 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
7527 (defun gnus-refer-article-methods ()
7528 "Return a list of referrable methods."
7530 ;; No method, so we default to current and native.
7531 ((null gnus-refer-article-method)
7532 (list gnus-current-select-method gnus-select-method))
7534 ((eq 'current gnus-refer-article-method)
7535 (list gnus-current-select-method))
7536 ;; List of select methods.
7537 ((not (and (symbolp (car gnus-refer-article-method))
7538 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
7540 (dolist (method gnus-refer-article-method)
7541 (push (if (eq 'current method)
7542 gnus-current-select-method
7546 ;; One single select method.
7548 (list gnus-refer-article-method))))
7550 (defun gnus-summary-edit-parameters ()
7551 "Edit the group parameters of the current group."
7553 (gnus-group-edit-group gnus-newsgroup-name 'params))
7555 (defun gnus-summary-customize-parameters ()
7556 "Customize the group parameters of the current group."
7558 (gnus-group-customize gnus-newsgroup-name))
7560 (defun gnus-summary-enter-digest-group (&optional force)
7561 "Enter an nndoc group based on the current article.
7562 If FORCE, force a digest interpretation. If not, try
7563 to guess what the document format is."
7565 (let ((conf gnus-current-window-configuration))
7567 (gnus-summary-select-article))
7568 (setq gnus-current-window-configuration conf)
7569 (let* ((name (format "%s-%d"
7570 (gnus-group-prefixed-name
7571 gnus-newsgroup-name (list 'nndoc ""))
7573 (set-buffer gnus-summary-buffer)
7574 gnus-current-article)))
7575 (ogroup gnus-newsgroup-name)
7576 (params (append (gnus-info-params (gnus-get-info ogroup))
7577 (list (cons 'to-group ogroup))
7578 (list (cons 'save-article-group ogroup))))
7579 (case-fold-search t)
7580 (buf (current-buffer))
7583 (set-buffer gnus-original-article-buffer)
7584 ;; Have the digest group inherit the main mail address of
7585 ;; the parent article.
7586 (when (setq to-address (or (message-fetch-field "reply-to")
7587 (message-fetch-field "from")))
7588 (setq params (append
7589 (list (cons 'to-address
7590 (funcall gnus-decode-encoded-word-function
7592 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
7593 (insert-buffer-substring gnus-original-article-buffer)
7594 ;; Remove lines that may lead nndoc to misinterpret the
7597 (goto-char (point-min))
7598 (or (search-forward "\n\n" nil t) (point)))
7599 (goto-char (point-min))
7600 (delete-matching-lines "^Path:\\|^From ")
7603 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
7604 (gnus-newsgroup-ephemeral-ignored-charsets
7605 gnus-newsgroup-ignored-charsets))
7606 (gnus-group-read-ephemeral-group
7607 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
7609 ,(if force 'mbox 'guess))) t))
7610 ;; Make all postings to this group go to the parent group.
7611 (nconc (gnus-info-params (gnus-get-info name))
7613 ;; Couldn't select this doc group.
7614 (switch-to-buffer buf)
7615 (gnus-set-global-variables)
7616 (gnus-configure-windows 'summary)
7617 (gnus-message 3 "Article couldn't be entered?"))
7618 (kill-buffer dig)))))
7620 (defun gnus-summary-read-document (n)
7621 "Open a new group based on the current article(s).
7622 This will allow you to read digests and other similar
7623 documents as newsgroups.
7624 Obeys the standard process/prefix convention."
7626 (let* ((articles (gnus-summary-work-articles n))
7627 (ogroup gnus-newsgroup-name)
7628 (params (append (gnus-info-params (gnus-get-info ogroup))
7629 (list (cons 'to-group ogroup))))
7630 article group egroup groups vgroup)
7631 (while (setq article (pop articles))
7632 (setq group (format "%s-%d" gnus-newsgroup-name article))
7633 (gnus-summary-remove-process-mark article)
7634 (when (gnus-summary-display-article article)
7637 (insert-buffer-substring gnus-original-article-buffer)
7638 ;; Remove some headers that may lead nndoc to make
7640 (message-narrow-to-head)
7641 (goto-char (point-min))
7642 (delete-matching-lines "^\\(Path\\):\\|^From ")
7645 (gnus-group-read-ephemeral-group
7646 group `(nndoc ,group (nndoc-address ,(current-buffer))
7647 (nndoc-article-type guess))
7650 ;; Make all postings to this group go to the parent group.
7651 (nconc (gnus-info-params (gnus-get-info egroup))
7653 (push egroup groups))
7654 ;; Couldn't select this doc group.
7655 (gnus-error 3 "Article couldn't be entered"))))))
7656 ;; Now we have selected all the documents.
7659 (error "None of the articles could be interpreted as documents"))
7660 ((gnus-group-read-ephemeral-group
7661 (setq vgroup (format
7662 "nnvirtual:%s-%s" gnus-newsgroup-name
7663 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
7664 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
7666 (cons (current-buffer) 'summary)))
7668 (error "Couldn't select virtual nndoc group")))))
7670 (defun gnus-summary-isearch-article (&optional regexp-p)
7671 "Do incremental search forward on the current article.
7672 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
7674 (gnus-summary-select-article)
7675 (gnus-configure-windows 'article)
7676 (gnus-eval-in-buffer-window gnus-article-buffer
7679 (isearch-forward regexp-p))))
7681 (defun gnus-summary-search-article-forward (regexp &optional backward)
7682 "Search for an article containing REGEXP forward.
7683 If BACKWARD, search backward instead."
7686 (format "Search article %s (regexp%s): "
7687 (if current-prefix-arg "backward" "forward")
7688 (if gnus-last-search-regexp
7689 (concat ", default " gnus-last-search-regexp)
7691 current-prefix-arg))
7692 (if (string-equal regexp "")
7693 (setq regexp (or gnus-last-search-regexp ""))
7694 (setq gnus-last-search-regexp regexp)
7695 (setq gnus-article-before-search gnus-current-article))
7696 ;; Intentionally set gnus-last-article.
7697 (setq gnus-last-article gnus-article-before-search)
7698 (let ((gnus-last-article gnus-last-article))
7699 (if (gnus-summary-search-article regexp backward)
7700 (gnus-summary-show-thread)
7701 (error "Search failed: \"%s\"" regexp))))
7703 (defun gnus-summary-search-article-backward (regexp)
7704 "Search for an article containing REGEXP backward."
7707 (format "Search article backward (regexp%s): "
7708 (if gnus-last-search-regexp
7709 (concat ", default " gnus-last-search-regexp)
7711 (gnus-summary-search-article-forward regexp 'backward))
7713 (defun gnus-summary-search-article (regexp &optional backward)
7714 "Search for an article containing REGEXP.
7715 Optional argument BACKWARD means do search for backward.
7716 `gnus-select-article-hook' is not called during the search."
7717 ;; We have to require this here to make sure that the following
7718 ;; dynamic binding isn't shadowed by autoloading.
7719 (require 'gnus-async)
7721 (let ((gnus-select-article-hook nil) ;Disable hook.
7722 (gnus-article-prepare-hook nil)
7723 (gnus-mark-article-hook nil) ;Inhibit marking as read.
7724 (gnus-use-article-prefetch nil)
7725 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
7726 (gnus-use-trees nil) ;Inhibit updating tree buffer.
7727 (sum (current-buffer))
7728 (gnus-display-mime-function nil)
7731 (gnus-save-hidden-threads
7732 (gnus-summary-select-article)
7733 (set-buffer gnus-article-buffer)
7734 (goto-char (window-point (get-buffer-window (current-buffer))))
7738 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
7740 (re-search-backward regexp nil t)
7741 (re-search-forward regexp nil t))
7742 ;; We found the regexp.
7747 (get-buffer-window (current-buffer))
7751 (get-buffer-window (current-buffer))
7754 (setq point (point)))
7755 ;; We didn't find it, so we go to the next article.
7758 (while (eq found 'not)
7759 (if (not (if backward (gnus-summary-find-prev)
7760 (gnus-summary-find-next)))
7761 ;; No more articles.
7763 ;; Select the next article and adjust point.
7764 (unless (gnus-summary-article-sparse-p
7765 (gnus-summary-article-number))
7767 (gnus-summary-select-article)
7768 (set-buffer gnus-article-buffer)
7770 (goto-char (if backward (point-max) (point-min))))))))
7771 (gnus-message 7 ""))
7772 ;; Return whether we found the regexp.
7773 (when (eq found 'found)
7775 (gnus-summary-show-thread)
7776 (gnus-summary-goto-subject gnus-current-article)
7777 (gnus-summary-position-point)
7780 (defun gnus-find-matching-articles (header regexp)
7781 "Return a list of all articles that match REGEXP on HEADER.
7782 This search includes all articles in the current group that Gnus has
7783 fetched headers for, whether they are displayed or not."
7784 (let ((articles nil)
7785 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
7786 (case-fold-search t))
7787 (dolist (header gnus-newsgroup-headers)
7788 (when (string-match regexp (funcall func header))
7789 (push (mail-header-number header) articles)))
7790 (nreverse articles)))
7792 (defun gnus-summary-find-matching (header regexp &optional backward unread
7793 not-case-fold not-matching)
7794 "Return a list of all articles that match REGEXP on HEADER.
7795 The search stars on the current article and goes forwards unless
7796 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
7797 If UNREAD is non-nil, only unread articles will
7798 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
7799 in the comparisons. If NOT-MATCHING, return a list of all articles that
7800 not match REGEXP on HEADER."
7801 (let ((case-fold-search (not not-case-fold))
7804 (if (eq (car header) 'extra)
7807 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
7809 (error "%s is an invalid header" header))
7810 (unless (fboundp (intern (concat "mail-header-" header)))
7811 (error "%s is not a valid header" header))
7812 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
7813 (dolist (d (if (eq backward 'all)
7815 (gnus-data-find-list
7816 (gnus-summary-article-number)
7817 (gnus-data-list backward))))
7818 (when (and (or (not unread) ; We want all articles...
7819 (gnus-data-unread-p d)) ; Or just unreads.
7820 (vectorp (gnus-data-header d)) ; It's not a pseudo.
7824 (funcall func (gnus-data-header d))))
7825 (string-match regexp
7826 (funcall func (gnus-data-header d)))))
7827 (push (gnus-data-number d) articles))) ; Success!
7828 (nreverse articles)))
7830 (defun gnus-summary-execute-command (header regexp command &optional backward)
7831 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
7832 If HEADER is an empty string (or nil), the match is done on the entire
7833 article. If BACKWARD (the prefix) is non-nil, search backward instead."
7835 (list (let ((completion-ignore-case t))
7838 (mapcar (lambda (header) (list (format "%s" header)))
7840 '("Number" "Subject" "From" "Lines" "Date"
7841 "Message-ID" "Xref" "References" "Body")
7842 gnus-extra-headers))
7843 nil 'require-match))
7844 (read-string "Regexp: ")
7845 (read-key-sequence "Command: ")
7846 current-prefix-arg))
7847 (when (equal header "Body")
7849 ;; Hidden thread subtrees must be searched as well.
7850 (gnus-summary-show-all-threads)
7851 ;; We don't want to change current point nor window configuration.
7853 (save-window-excursion
7854 (gnus-message 6 "Executing %s..." (key-description command))
7855 ;; We'd like to execute COMMAND interactively so as to give arguments.
7856 (gnus-execute header regexp
7857 `(call-interactively ',(key-binding command))
7859 (gnus-message 6 "Executing %s...done" (key-description command)))))
7861 (defun gnus-summary-beginning-of-article ()
7862 "Scroll the article back to the beginning."
7864 (gnus-summary-select-article)
7865 (gnus-configure-windows 'article)
7866 (gnus-eval-in-buffer-window gnus-article-buffer
7868 (goto-char (point-min))
7869 (when gnus-page-broken
7870 (gnus-narrow-to-page))))
7872 (defun gnus-summary-end-of-article ()
7873 "Scroll to the end of the article."
7875 (gnus-summary-select-article)
7876 (gnus-configure-windows 'article)
7877 (gnus-eval-in-buffer-window gnus-article-buffer
7879 (goto-char (point-max))
7881 (when gnus-page-broken
7882 (gnus-narrow-to-page))))
7884 (defun gnus-summary-print-truncate-and-quote (string &optional len)
7885 "Truncate to LEN and quote all \"(\"'s in STRING."
7886 (gnus-replace-in-string (if (and len (> (length string) len))
7887 (substring string 0 len)
7891 (defun gnus-summary-print-article (&optional filename n)
7892 "Generate and print a PostScript image of the N next (mail) articles.
7894 If N is negative, print the N previous articles. If N is nil and articles
7895 have been marked with the process mark, print these instead.
7897 If the optional first argument FILENAME is nil, send the image to the
7898 printer. If FILENAME is a string, save the PostScript image in a file with
7899 that name. If FILENAME is a number, prompt the user for the name of the file
7901 (interactive (list (ps-print-preprint current-prefix-arg)))
7902 (dolist (article (gnus-summary-work-articles n))
7903 (gnus-summary-select-article nil nil 'pseudo article)
7904 (gnus-eval-in-buffer-window gnus-article-buffer
7905 (let ((buffer (generate-new-buffer " *print*")))
7908 (copy-to-buffer buffer (point-min) (point-max))
7910 (gnus-article-delete-invisible-text)
7911 (when (gnus-visual-p 'article-highlight 'highlight)
7912 ;; Copy-to-buffer doesn't copy overlay. So redo
7914 (let ((gnus-article-buffer buffer))
7915 (gnus-article-highlight-citation t)
7916 (gnus-article-highlight-signature)))
7917 (let ((ps-left-header
7920 (gnus-summary-print-truncate-and-quote
7921 (mail-header-subject gnus-current-headers)
7924 (gnus-summary-print-truncate-and-quote
7925 (mail-header-from gnus-current-headers)
7929 "/pagenumberstring load"
7931 (mail-header-date gnus-current-headers) ")"))))
7932 (gnus-run-hooks 'gnus-ps-print-hook)
7935 (ps-spool-buffer-with-faces)
7936 (ps-spool-buffer)))))
7937 (kill-buffer buffer))))
7938 (gnus-summary-remove-process-mark article))
7939 (ps-despool filename))
7941 (defun gnus-summary-show-article (&optional arg)
7942 "Force redisplaying of the current article.
7943 If ARG (the prefix) is a number, show the article with the charset
7944 defined in `gnus-summary-show-article-charset-alist', or the charset
7946 If ARG (the prefix) is non-nil and not a number, show the raw article
7947 without any article massaging functions being run. Normally, the key strokes
7952 (gnus-summary-show-article t)
7953 (let ((gnus-newsgroup-charset
7954 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
7955 (mm-read-coding-system
7958 (set-buffer gnus-article-buffer)
7959 (let ((coding-systems
7960 (detect-coding-region (point) (point-max))))
7961 (or (car-safe coding-systems)
7962 coding-systems))))))
7963 (gnus-newsgroup-ignored-charsets 'gnus-all))
7964 (gnus-summary-select-article nil 'force)
7965 (let ((deps gnus-newsgroup-dependencies)
7968 (set-buffer gnus-original-article-buffer)
7970 (message-narrow-to-head)
7971 (setq head (buffer-string))
7972 (goto-char (point-min))
7973 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
7974 (goto-char (point-max))
7976 (setq lines (1- (count-lines (point) (point-max))))))
7978 (insert (format "211 %d Article retrieved.\n"
7979 (cdr gnus-article-current)))
7981 (if lines (insert (format "Lines: %d\n" lines)))
7983 (let ((nntp-server-buffer (current-buffer)))
7984 (setq header (car (gnus-get-newsgroup-headers deps t))))))
7985 (gnus-data-set-header
7986 (gnus-data-find (cdr gnus-article-current))
7988 (gnus-summary-update-article-line
7989 (cdr gnus-article-current) header)
7990 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
7991 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
7993 ;; Select the article the normal way.
7994 (gnus-summary-select-article nil 'force))
7996 ;; We have to require this here to make sure that the following
7997 ;; dynamic binding isn't shadowed by autoloading.
7998 (require 'gnus-async)
8000 ;; Bind the article treatment functions to nil.
8001 (let ((gnus-have-all-headers t)
8002 gnus-article-prepare-hook
8003 gnus-article-decode-hook
8004 gnus-display-mime-function
8006 ;; Destroy any MIME parts.
8007 (when (gnus-buffer-live-p gnus-article-buffer)
8009 (set-buffer gnus-article-buffer)
8010 (mm-destroy-parts gnus-article-mime-handles)
8011 ;; Set it to nil for safety reason.
8012 (setq gnus-article-mime-handle-alist nil)
8013 (setq gnus-article-mime-handles nil)))
8014 (gnus-summary-select-article nil 'force))))
8015 (gnus-summary-goto-subject gnus-current-article)
8016 (gnus-summary-position-point))
8018 (defun gnus-summary-show-raw-article ()
8019 "Show the raw article without any article massaging functions being run."
8021 (gnus-summary-show-article t))
8023 (defun gnus-summary-verbose-headers (&optional arg)
8024 "Toggle permanent full header display.
8025 If ARG is a positive number, turn header display on.
8026 If ARG is a negative number, turn header display off."
8028 (setq gnus-show-all-headers
8029 (cond ((or (not (numberp arg))
8031 (not gnus-show-all-headers))
8034 (gnus-summary-show-article))
8036 (defun gnus-summary-toggle-header (&optional arg)
8037 "Show the headers if they are hidden, or hide them if they are shown.
8038 If ARG is a positive number, show the entire header.
8039 If ARG is a negative number, hide the unwanted header lines."
8042 (set-buffer gnus-article-buffer)
8044 (let* ((buffer-read-only nil)
8045 (inhibit-point-motion-hooks t)
8051 (article-narrow-to-head)
8052 (gnus-article-hidden-text-p 'headers))))
8053 (goto-char (point-min))
8054 (when (search-forward "\n\n" nil t)
8055 (delete-region (point-min) (1- (point))))
8056 (goto-char (point-min))
8058 (set-buffer gnus-original-article-buffer)
8059 (goto-char (point-min))
8060 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
8061 (insert-buffer-substring gnus-original-article-buffer 1 e)
8063 (narrow-to-region (point-min) (point))
8064 (article-decode-encoded-words)
8066 (let ((gnus-treat-hide-headers nil)
8067 (gnus-treat-hide-boring-headers nil))
8068 (setq gnus-article-wash-types
8069 (delq 'headers gnus-article-wash-types))
8070 (gnus-treat-article 'head))
8071 (gnus-treat-article 'head)))
8072 (gnus-set-mode-line 'article)))))
8074 (defun gnus-summary-show-all-headers ()
8075 "Make all header lines visible."
8077 (gnus-summary-toggle-header 1))
8079 (defun gnus-summary-caesar-message (&optional arg)
8080 "Caesar rotate the current article by 13.
8081 The numerical prefix specifies how many places to rotate each letter
8084 (gnus-summary-select-article)
8085 (let ((mail-header-separator ""))
8086 (gnus-eval-in-buffer-window gnus-article-buffer
8089 (let ((start (window-start))
8091 (message-caesar-buffer-body arg)
8092 (set-window-start (get-buffer-window (current-buffer)) start))))))
8094 (defun gnus-summary-stop-page-breaking ()
8095 "Stop page breaking in the current article."
8097 (gnus-summary-select-article)
8098 (gnus-eval-in-buffer-window gnus-article-buffer
8100 (when (gnus-visual-p 'page-marker)
8101 (let ((buffer-read-only nil))
8102 (gnus-remove-text-with-property 'gnus-prev)
8103 (gnus-remove-text-with-property 'gnus-next))
8104 (setq gnus-page-broken nil))))
8106 (defun gnus-summary-move-article (&optional n to-newsgroup
8107 select-method action)
8108 "Move the current article to a different newsgroup.
8109 If N is a positive number, move the N next articles.
8110 If N is a negative number, move the N previous articles.
8111 If N is nil and any articles have been marked with the process mark,
8112 move those articles instead.
8113 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8114 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
8115 re-spool using this method.
8117 For this function to work, both the current newsgroup and the
8118 newsgroup that you want to move to have to support the `request-move'
8119 and `request-accept' functions.
8121 ACTION can be either `move' (the default), `crosspost' or `copy'."
8124 (setq action 'move))
8125 ;; Check whether the source group supports the required functions.
8126 (cond ((and (eq action 'move)
8127 (not (gnus-check-backend-function
8128 'request-move-article gnus-newsgroup-name)))
8129 (error "The current group does not support article moving"))
8130 ((and (eq action 'crosspost)
8131 (not (gnus-check-backend-function
8132 'request-replace-article gnus-newsgroup-name)))
8133 (error "The current group does not support article editing")))
8134 (let ((articles (gnus-summary-work-articles n))
8135 (prefix (if (gnus-check-backend-function
8136 'request-move-article gnus-newsgroup-name)
8137 (gnus-group-real-prefix gnus-newsgroup-name)
8139 (names '((move "Move" "Moving")
8140 (copy "Copy" "Copying")
8141 (crosspost "Crosspost" "Crossposting")))
8142 (copy-buf (save-excursion
8143 (nnheader-set-temp-buffer " *copy article*")))
8144 art-group to-method new-xref article to-groups)
8145 (unless (assq action names)
8146 (error "Unknown action %s" action))
8147 ;; We have to select an article to give
8148 ;; `gnus-read-move-group-name' an opportunity to suggest an
8149 ;; appropriate default.
8150 (unless (gnus-buffer-live-p gnus-original-article-buffer)
8151 (gnus-summary-select-article nil nil nil (car articles)))
8152 ;; Read the newsgroup name.
8153 (when (and (not to-newsgroup)
8154 (not select-method))
8156 (gnus-read-move-group-name
8157 (cadr (assq action names))
8158 (symbol-value (intern (format "gnus-current-%s-group" action)))
8160 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
8161 (setq to-method (or select-method
8162 (gnus-server-to-method
8163 (gnus-group-method to-newsgroup))))
8164 ;; Check the method we are to move this article to...
8165 (unless (gnus-check-backend-function
8166 'request-accept-article (car to-method))
8167 (error "%s does not support article copying" (car to-method)))
8168 (unless (gnus-check-server to-method)
8169 (error "Can't open server %s" (car to-method)))
8170 (gnus-message 6 "%s to %s: %s..."
8171 (caddr (assq action names))
8172 (or (car select-method) to-newsgroup) articles)
8174 (setq article (pop articles))
8178 ;; Move the article.
8180 ;; Remove this article from future suppression.
8181 (gnus-dup-unsuppress-article article)
8182 (gnus-request-move-article
8183 article ; Article to move
8184 gnus-newsgroup-name ; From newsgroup
8185 (nth 1 (gnus-find-method-for-group
8186 gnus-newsgroup-name)) ; Server
8187 (list 'gnus-request-accept-article
8188 to-newsgroup (list 'quote select-method)
8189 (not articles) t) ; Accept form
8190 (not articles))) ; Only save nov last time
8191 ;; Copy the article.
8194 (set-buffer copy-buf)
8195 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
8196 (gnus-request-accept-article
8197 to-newsgroup select-method (not articles) t))))
8198 ;; Crosspost the article.
8199 ((eq action 'crosspost)
8200 (let ((xref (message-tokenize-header
8201 (mail-header-xref (gnus-summary-article-header article))
8203 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
8204 ":" (number-to-string article)))
8206 (setq xref (list (system-name))))
8209 (mapconcat 'identity
8210 (delete "Xref:" (delete new-xref xref))
8214 (set-buffer copy-buf)
8215 ;; First put the article in the destination group.
8216 (gnus-request-article-this-buffer article gnus-newsgroup-name)
8217 (when (consp (setq art-group
8218 (gnus-request-accept-article
8219 to-newsgroup select-method (not articles))))
8220 (setq new-xref (concat new-xref " " (car art-group)
8222 (number-to-string (cdr art-group))))
8223 ;; Now we have the new Xrefs header, so we insert
8224 ;; it and replace the new article.
8225 (nnheader-replace-header "Xref" new-xref)
8226 (gnus-request-replace-article
8227 (cdr art-group) to-newsgroup (current-buffer))
8231 (gnus-message 1 "Couldn't %s article %s: %s"
8232 (cadr (assq action names)) article
8233 (nnheader-get-report (car to-method))))
8234 ((eq art-group 'junk)
8235 (when (eq action 'move)
8236 (gnus-summary-mark-article article gnus-canceled-mark)
8237 (gnus-message 4 "Deleted article %s" article)))
8239 (let* ((pto-group (gnus-group-prefixed-name
8240 (car art-group) to-method))
8242 (gnus-gethash pto-group gnus-newsrc-hashtb))
8243 (info (nth 2 entry))
8244 (to-group (gnus-info-group info))
8246 ;; Update the group that has been moved to.
8248 (memq action '(move copy)))
8249 (unless (member to-group to-groups)
8250 (push to-group to-groups))
8252 (unless (memq article gnus-newsgroup-unreads)
8253 (push 'read to-marks)
8255 info (gnus-add-to-range (gnus-info-read info)
8256 (list (cdr art-group)))))
8258 ;; See whether the article is to be put in the cache.
8259 (let ((marks gnus-article-mark-lists)
8260 (to-article (cdr art-group)))
8262 ;; Enter the article into the cache in the new group,
8263 ;; if that is required.
8264 (when gnus-use-cache
8265 (gnus-cache-possibly-enter-article
8267 (memq article gnus-newsgroup-marked)
8268 (memq article gnus-newsgroup-dormant)
8269 (memq article gnus-newsgroup-unreads)))
8271 (when gnus-preserve-marks
8272 ;; Copy any marks over to the new group.
8273 (when (and (equal to-group gnus-newsgroup-name)
8274 (not (memq article gnus-newsgroup-unreads)))
8275 ;; Mark this article as read in this group.
8276 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
8277 (setcdr (gnus-active to-group) to-article)
8278 (setcdr gnus-newsgroup-active to-article))
8281 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
8282 (when (memq article (symbol-value
8283 (intern (format "gnus-newsgroup-%s"
8285 (push (cdar marks) to-marks)
8286 ;; If the other group is the same as this group,
8287 ;; then we have to add the mark to the list.
8288 (when (equal to-group gnus-newsgroup-name)
8289 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
8292 (intern (format "gnus-newsgroup-%s"
8294 ;; Copy the marks to other group.
8295 (gnus-add-marked-articles
8296 to-group (cdar marks) (list to-article) info)))
8297 (setq marks (cdr marks)))
8299 (gnus-request-set-mark to-group (list (list (list to-article)
8304 (concat "(gnus-group-set-info '"
8305 (gnus-prin1-to-string (gnus-get-info to-group))
8308 ;; Update the Xref header in this article to point to
8309 ;; the new crossposted article we have just created.
8310 (when (eq action 'crosspost)
8312 (set-buffer copy-buf)
8313 (gnus-request-article-this-buffer article gnus-newsgroup-name)
8314 (nnheader-replace-header "Xref" new-xref)
8315 (gnus-request-replace-article
8316 article gnus-newsgroup-name (current-buffer)))))
8318 ;;;!!!Why is this necessary?
8319 (set-buffer gnus-summary-buffer)
8321 (gnus-summary-goto-subject article)
8322 (when (eq action 'move)
8323 (gnus-summary-mark-article article gnus-canceled-mark))))
8324 (gnus-summary-remove-process-mark article))
8325 ;; Re-activate all groups that have been moved to.
8327 (set-buffer gnus-group-buffer)
8328 (let ((gnus-group-marked to-groups))
8329 (gnus-group-get-new-news-this-group nil t)))
8331 (gnus-kill-buffer copy-buf)
8332 (gnus-summary-position-point)
8333 (gnus-set-mode-line 'summary)))
8335 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
8336 "Move the current article to a different newsgroup.
8337 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8338 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
8339 re-spool using this method."
8341 (gnus-summary-move-article n to-newsgroup select-method 'copy))
8343 (defun gnus-summary-crosspost-article (&optional n)
8344 "Crosspost the current article to some other group."
8346 (gnus-summary-move-article n nil nil 'crosspost))
8348 (defcustom gnus-summary-respool-default-method nil
8349 "Default method type for respooling an article.
8350 If nil, use to the current newsgroup method."
8352 :group 'gnus-summary-mail)
8354 (defun gnus-summary-respool-article (&optional n method)
8355 "Respool the current article.
8356 The article will be squeezed through the mail spooling process again,
8357 which means that it will be put in some mail newsgroup or other
8358 depending on `nnmail-split-methods'.
8359 If N is a positive number, respool the N next articles.
8360 If N is a negative number, respool the N previous articles.
8361 If N is nil and any articles have been marked with the process mark,
8362 respool those articles instead.
8364 Respooling can be done both from mail groups and \"real\" newsgroups.
8365 In the former case, the articles in question will be moved from the
8366 current group into whatever groups they are destined to. In the
8367 latter case, they will be copied into the relevant groups."
8369 (list current-prefix-arg
8370 (let* ((methods (gnus-methods-using 'respool))
8372 (symbol-name (or gnus-summary-respool-default-method
8373 (car (gnus-find-method-for-group
8374 gnus-newsgroup-name)))))
8376 (gnus-completing-read
8377 methname "What backend do you want to use when respooling?"
8378 methods nil t nil 'gnus-mail-method-history))
8381 ((zerop (length (setq ms (gnus-servers-using-backend
8383 (list (intern method) ""))
8387 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
8388 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
8391 (error "No method given for respooling"))
8392 (if (assoc (symbol-name
8393 (car (gnus-find-method-for-group gnus-newsgroup-name)))
8394 (gnus-methods-using 'respool))
8395 (gnus-summary-move-article n nil method)
8396 (gnus-summary-copy-article n nil method)))
8398 (defun gnus-summary-import-article (file &optional edit)
8399 "Import an arbitrary file into a mail newsgroup."
8400 (interactive "fImport file: \nP")
8401 (let ((group gnus-newsgroup-name)
8402 (now (current-time))
8403 atts lines group-art)
8404 (unless (gnus-check-backend-function 'request-accept-article group)
8405 (error "%s does not support article importing" group))
8406 (or (file-readable-p file)
8407 (not (file-regular-p file))
8408 (error "Can't read %s" file))
8410 (set-buffer (gnus-get-buffer-create " *import file*"))
8412 (nnheader-insert-file-contents file)
8413 (goto-char (point-min))
8414 (if (nnheader-article-p)
8416 (goto-char (point-min))
8417 (search-forward "\n\n" nil t)
8418 (narrow-to-region (point-min) (1- (point)))
8419 (goto-char (point-min))
8420 (unless (re-search-forward "^date:" nil t)
8421 (goto-char (point-max))
8422 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
8423 ;; This doesn't look like an article, so we fudge some headers.
8424 (setq atts (file-attributes file)
8425 lines (count-lines (point-min) (point-max)))
8426 (insert "From: " (read-string "From: ") "\n"
8427 "Subject: " (read-string "Subject: ") "\n"
8428 "Date: " (message-make-date (nth 5 atts)) "\n"
8429 "Message-ID: " (message-make-message-id) "\n"
8430 "Lines: " (int-to-string lines) "\n"
8431 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
8432 (setq group-art (gnus-request-accept-article group nil t))
8433 (kill-buffer (current-buffer)))
8434 (setq gnus-newsgroup-active (gnus-activate-group group))
8436 (gnus-summary-goto-article (cdr group-art) nil t)
8438 (gnus-summary-edit-article))))
8440 (defun gnus-summary-create-article ()
8441 "Create an article in a mail newsgroup."
8443 (let ((group gnus-newsgroup-name)
8444 (now (current-time))
8446 (unless (gnus-check-backend-function 'request-accept-article group)
8447 (error "%s does not support article importing" group))
8449 (set-buffer (gnus-get-buffer-create " *import file*"))
8451 (goto-char (point-min))
8452 ;; This doesn't look like an article, so we fudge some headers.
8453 (insert "From: " (read-string "From: ") "\n"
8454 "Subject: " (read-string "Subject: ") "\n"
8455 "Date: " (message-make-date now) "\n"
8456 "Message-ID: " (message-make-message-id) "\n")
8457 (setq group-art (gnus-request-accept-article group nil t))
8458 (kill-buffer (current-buffer)))
8459 (setq gnus-newsgroup-active (gnus-activate-group group))
8461 (gnus-summary-goto-article (cdr group-art) nil t)
8462 (gnus-summary-edit-article)))
8464 (defun gnus-summary-article-posted-p ()
8465 "Say whether the current (mail) article is available from news as well.
8466 This will be the case if the article has both been mailed and posted."
8468 (let ((id (mail-header-references (gnus-summary-article-header)))
8469 (gnus-override-method (car (gnus-refer-article-methods))))
8470 (if (gnus-request-head id "")
8471 (gnus-message 2 "The current message was found on %s"
8472 gnus-override-method)
8473 (gnus-message 2 "The current message couldn't be found on %s"
8474 gnus-override-method)
8477 (defun gnus-summary-expire-articles (&optional now)
8478 "Expire all articles that are marked as expirable in the current group."
8480 (when (gnus-check-backend-function
8481 'request-expire-articles gnus-newsgroup-name)
8482 ;; This backend supports expiry.
8483 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
8484 (expirable (if total
8486 ;; We need to update the info for
8487 ;; this group for `gnus-list-of-read-articles'
8488 ;; to give us the right answer.
8489 (gnus-run-hooks 'gnus-exit-group-hook)
8490 (gnus-summary-update-info)
8491 (gnus-list-of-read-articles gnus-newsgroup-name))
8492 (setq gnus-newsgroup-expirable
8493 (sort gnus-newsgroup-expirable '<))))
8494 (expiry-wait (if now 'immediate
8495 (gnus-group-find-parameter
8496 gnus-newsgroup-name 'expiry-wait)))
8497 (nnmail-expiry-target
8498 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
8499 nnmail-expiry-target))
8502 ;; There are expirable articles in this group, so we run them
8503 ;; through the expiry process.
8504 (gnus-message 6 "Expiring articles...")
8505 (unless (gnus-check-group gnus-newsgroup-name)
8506 (error "Can't open server for %s" gnus-newsgroup-name))
8507 ;; The list of articles that weren't expired is returned.
8510 (let ((nnmail-expiry-wait-function nil)
8511 (nnmail-expiry-wait expiry-wait))
8512 (setq es (gnus-request-expire-articles
8513 expirable gnus-newsgroup-name)))
8514 (setq es (gnus-request-expire-articles
8515 expirable gnus-newsgroup-name)))
8517 (setq gnus-newsgroup-expirable es))
8518 ;; We go through the old list of expirable, and mark all
8519 ;; really expired articles as nonexistent.
8520 (unless (eq es expirable) ;If nothing was expired, we don't mark.
8521 (let ((gnus-use-cache nil))
8523 (unless (memq (car expirable) es)
8524 (when (gnus-data-find (car expirable))
8525 (gnus-summary-mark-article
8526 (car expirable) gnus-canceled-mark)))
8527 (setq expirable (cdr expirable))))))
8528 (gnus-message 6 "Expiring articles...done")))))
8530 (defun gnus-summary-expire-articles-now ()
8531 "Expunge all expirable articles in the current group.
8532 This means that *all* articles that are marked as expirable will be
8533 deleted forever, right now."
8535 (or gnus-expert-user
8537 "Are you really, really, really sure you want to delete all these messages? ")
8539 (gnus-summary-expire-articles t))
8541 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
8542 (defun gnus-summary-delete-article (&optional n)
8543 "Delete the N next (mail) articles.
8544 This command actually deletes articles. This is not a marking
8545 command. The article will disappear forever from your life, never to
8547 If N is negative, delete backwards.
8548 If N is nil and articles have been marked with the process mark,
8549 delete these instead."
8551 (unless (gnus-check-backend-function 'request-expire-articles
8552 gnus-newsgroup-name)
8553 (error "The current newsgroup does not support article deletion"))
8554 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
8555 (error "Couldn't open server"))
8556 ;; Compute the list of articles to delete.
8557 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
8559 (if (and gnus-novice-user
8560 (not (gnus-yes-or-no-p
8561 (format "Do you really want to delete %s forever? "
8562 (if (> (length articles) 1)
8563 (format "these %s articles" (length articles))
8566 ;; Delete the articles.
8567 (setq not-deleted (gnus-request-expire-articles
8568 articles gnus-newsgroup-name 'force))
8570 (gnus-summary-remove-process-mark (car articles))
8571 ;; The backend might not have been able to delete the article
8573 (unless (memq (car articles) not-deleted)
8574 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
8575 (setq articles (cdr articles)))
8577 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
8578 (gnus-summary-position-point)
8579 (gnus-set-mode-line 'summary)
8582 (defun gnus-summary-edit-article (&optional arg)
8583 "Edit the current article.
8584 This will have permanent effect only in mail groups.
8585 If ARG is nil, edit the decoded articles.
8586 If ARG is 1, edit the raw articles.
8587 If ARG is 2, edit the raw articles even in read-only groups.
8588 If ARG is 3, edit the articles with the current handles.
8589 Otherwise, allow editing of articles even in read-only
8592 (let (force raw current-handles)
8595 ((eq arg 1) (setq raw t))
8596 ((eq arg 2) (setq raw t
8598 ((eq arg 3) (setq current-handles
8599 (and (gnus-buffer-live-p gnus-article-buffer)
8600 (with-current-buffer gnus-article-buffer
8602 gnus-article-mime-handles
8603 (setq gnus-article-mime-handles nil))))))
8605 (if (and raw (not force) (equal gnus-newsgroup-name "nndraft:drafts"))
8606 (error "Can't edit the raw article in group nndraft:drafts"))
8608 (set-buffer gnus-summary-buffer)
8609 (let ((mail-parse-charset gnus-newsgroup-charset)
8610 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
8611 (gnus-set-global-variables)
8612 (when (and (not force)
8613 (gnus-group-read-only-p))
8614 (error "The current newsgroup does not support article editing"))
8615 (gnus-summary-show-article t)
8616 (when (and (not raw) (gnus-buffer-live-p gnus-article-buffer))
8617 (with-current-buffer gnus-article-buffer
8618 (mm-enable-multibyte-mule4)))
8619 (if (equal gnus-newsgroup-name "nndraft:drafts")
8621 (gnus-article-edit-article
8624 (let ((mbl mml-buffer-list))
8625 (setq mml-buffer-list nil)
8626 (mime-to-mml ,'current-handles)
8627 (let ((mbl1 mml-buffer-list))
8628 (setq mml-buffer-list mbl)
8629 (set (make-local-variable 'mml-buffer-list) mbl1))
8630 (make-local-hook 'kill-buffer-hook)
8631 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))))
8632 `(lambda (no-highlight)
8633 (let ((mail-parse-charset ',gnus-newsgroup-charset)
8634 (message-options message-options)
8635 (message-options-set-recipient)
8636 (mail-parse-ignored-charsets
8637 ',gnus-newsgroup-ignored-charsets))
8638 ,(if (not raw) '(progn
8640 (mml-destroy-buffers)
8641 (remove-hook 'kill-buffer-hook
8642 'mml-destroy-buffers t)
8643 (kill-local-variable 'mml-buffer-list)))
8644 (gnus-summary-edit-article-done
8645 ,(or (mail-header-references gnus-current-headers) "")
8646 ,(gnus-group-read-only-p)
8647 ,gnus-summary-buffer no-highlight))))))))
8649 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
8651 (defun gnus-summary-edit-article-done (&optional references read-only buffer
8653 "Make edits to the current article permanent."
8656 ;; The buffer restriction contains the entire article if it exists.
8657 (when (article-goto-body)
8658 (let ((lines (count-lines (point) (point-max)))
8659 (length (- (point-max) (point)))
8660 (case-fold-search t)
8661 (body (copy-marker (point))))
8662 (goto-char (point-min))
8663 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
8664 (delete-region (match-beginning 1) (match-end 1))
8665 (insert (number-to-string length)))
8666 (goto-char (point-min))
8667 (when (re-search-forward
8668 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
8669 (delete-region (match-beginning 1) (match-end 1))
8670 (insert (number-to-string length)))
8671 (goto-char (point-min))
8672 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
8673 (delete-region (match-beginning 1) (match-end 1))
8674 (insert (number-to-string lines))))))
8675 ;; Replace the article.
8676 (let ((buf (current-buffer)))
8678 (insert-buffer-substring buf)
8680 (if (and (not read-only)
8681 (not (gnus-request-replace-article
8682 (cdr gnus-article-current) (car gnus-article-current)
8683 (current-buffer) t)))
8684 (error "Couldn't replace article")
8685 ;; Update the summary buffer.
8687 (equal (message-tokenize-header references " ")
8688 (message-tokenize-header
8689 (or (message-fetch-field "references") "") " ")))
8690 ;; We only have to update this line.
8693 (message-narrow-to-head)
8694 (let ((head (buffer-string))
8697 (insert (format "211 %d Article retrieved.\n"
8698 (cdr gnus-article-current)))
8701 (let ((nntp-server-buffer (current-buffer)))
8702 (setq header (car (gnus-get-newsgroup-headers
8704 (set-buffer gnus-summary-buffer)
8705 gnus-newsgroup-dependencies)
8708 (set-buffer gnus-summary-buffer)
8709 (gnus-data-set-header
8710 (gnus-data-find (cdr gnus-article-current))
8712 (gnus-summary-update-article-line
8713 (cdr gnus-article-current) header)
8714 (if (gnus-summary-goto-subject
8715 (cdr gnus-article-current) nil t)
8716 (gnus-summary-update-secondary-mark
8717 (cdr gnus-article-current))))))))
8719 (set-buffer (or buffer gnus-summary-buffer))
8720 (gnus-summary-update-article (cdr gnus-article-current))
8721 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
8722 (gnus-summary-update-secondary-mark
8723 (cdr gnus-article-current))))
8724 ;; Prettify the article buffer again.
8725 (unless no-highlight
8727 (set-buffer gnus-article-buffer)
8728 ;;;!!! Fix this -- article should be rehighlighted.
8729 ;;;(gnus-run-hooks 'gnus-article-display-hook)
8730 (set-buffer gnus-original-article-buffer)
8731 (gnus-request-article
8732 (cdr gnus-article-current)
8733 (car gnus-article-current) (current-buffer))))
8734 ;; Prettify the summary buffer line.
8735 (when (gnus-visual-p 'summary-highlight 'highlight)
8736 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
8738 (defun gnus-summary-edit-wash (key)
8739 "Perform editing command KEY in the article buffer."
8743 (message "%s" (concat (this-command-keys) "- "))
8746 (gnus-summary-edit-article)
8747 (execute-kbd-macro (concat (this-command-keys) key))
8748 (gnus-article-edit-done))
8751 (defun gnus-summary-toggle-smiley (&optional arg)
8752 "Toggle the display of smilies as small graphical icons."
8755 (set-buffer gnus-article-buffer)
8756 (gnus-smiley-display arg)))
8760 (defun gnus-summary-respool-query (&optional silent trace)
8761 "Query where the respool algorithm would put this article."
8763 (let (gnus-mark-article-hook)
8764 (gnus-summary-select-article)
8766 (set-buffer gnus-original-article-buffer)
8768 (message-narrow-to-head)
8769 (let ((groups (nnmail-article-group 'identity trace)))
8772 (message "This message would go to %s"
8773 (mapconcat 'car groups ", "))
8774 (message "This message would go to no groups"))
8777 (defun gnus-summary-respool-trace ()
8778 "Trace where the respool algorithm would put this article.
8779 Display a buffer showing all fancy splitting patterns which matched."
8781 (gnus-summary-respool-query nil t))
8783 ;; Summary marking commands.
8785 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
8786 "Mark articles which has the same subject as read, and then select the next.
8787 If UNMARK is positive, remove any kind of mark.
8788 If UNMARK is negative, tick articles."
8791 (setq unmark (prefix-numeric-value unmark)))
8793 (gnus-summary-mark-same-subject
8794 (gnus-summary-article-subject) unmark)))
8795 ;; Select next unread article. If auto-select-same mode, should
8796 ;; select the first unread article.
8797 (gnus-summary-next-article t (and gnus-auto-select-same
8798 (gnus-summary-article-subject)))
8799 (gnus-message 7 "%d article%s marked as %s"
8800 count (if (= count 1) " is" "s are")
8801 (if unmark "unread" "read"))))
8803 (defun gnus-summary-kill-same-subject (&optional unmark)
8804 "Mark articles which has the same subject as read.
8805 If UNMARK is positive, remove any kind of mark.
8806 If UNMARK is negative, tick articles."
8809 (setq unmark (prefix-numeric-value unmark)))
8811 (gnus-summary-mark-same-subject
8812 (gnus-summary-article-subject) unmark)))
8813 ;; If marked as read, go to next unread subject.
8815 ;; Go to next unread subject.
8816 (gnus-summary-next-subject 1 t))
8817 (gnus-message 7 "%d articles are marked as %s"
8818 count (if unmark "unread" "read"))))
8820 (defun gnus-summary-mark-same-subject (subject &optional unmark)
8821 "Mark articles with same SUBJECT as read, and return marked number.
8822 If optional argument UNMARK is positive, remove any kinds of marks.
8823 If optional argument UNMARK is negative, mark articles as unread instead."
8827 ((null unmark) ; Mark as read.
8830 (gnus-summary-mark-article-as-read gnus-killed-mark)
8831 (gnus-summary-show-thread) t)
8832 (gnus-summary-find-subject subject))
8833 (setq count (1+ count))))
8834 ((> unmark 0) ; Tick.
8837 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
8838 (gnus-summary-show-thread) t)
8839 (gnus-summary-find-subject subject))
8840 (setq count (1+ count))))
8841 (t ; Mark as unread.
8844 (gnus-summary-mark-article-as-unread gnus-unread-mark)
8845 (gnus-summary-show-thread) t)
8846 (gnus-summary-find-subject subject))
8847 (setq count (1+ count)))))
8848 (gnus-set-mode-line 'summary)
8849 ;; Return the number of marked articles.
8852 (defun gnus-summary-mark-as-processable (n &optional unmark)
8853 "Set the process mark on the next N articles.
8854 If N is negative, mark backward instead. If UNMARK is non-nil, remove
8855 the process mark instead. The difference between N and the actual
8856 number of articles marked is returned."
8858 (if (and (null n) (gnus-region-active-p))
8859 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
8860 (setq n (prefix-numeric-value n))
8861 (let ((backward (< n 0))
8866 (gnus-summary-remove-process-mark
8867 (gnus-summary-article-number))
8868 (gnus-summary-set-process-mark (gnus-summary-article-number)))
8869 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
8872 (gnus-message 7 "No more articles"))
8873 (gnus-summary-recenter)
8874 (gnus-summary-position-point)
8877 (defun gnus-summary-unmark-as-processable (n)
8878 "Remove the process mark from the next N articles.
8879 If N is negative, unmark backward instead. The difference between N and
8880 the actual number of articles unmarked is returned."
8882 (gnus-summary-mark-as-processable n t))
8884 (defun gnus-summary-unmark-all-processable ()
8885 "Remove the process mark from all articles."
8888 (while gnus-newsgroup-processable
8889 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
8890 (gnus-summary-position-point))
8892 (defun gnus-summary-add-mark (article type)
8893 "Mark ARTICLE with a mark of TYPE."
8894 (let ((vtype (car (assq type gnus-article-mark-lists)))
8897 (error "No such mark type: %s" type)
8898 (setq var (intern (format "gnus-newsgroup-%s" type)))
8899 (set var (cons article (symbol-value var)))
8900 (if (memq type '(processable cached replied forwarded recent saved))
8901 (gnus-summary-update-secondary-mark article)
8902 ;;; !!! This is bogus. We should find out what primary
8903 ;;; !!! mark we want to set.
8904 (gnus-summary-update-mark gnus-del-mark 'unread)))))
8906 (defun gnus-summary-mark-as-expirable (n)
8907 "Mark N articles forward as expirable.
8908 If N is negative, mark backward instead. The difference between N and
8909 the actual number of articles marked is returned."
8911 (gnus-summary-mark-forward n gnus-expirable-mark))
8913 (defun gnus-summary-mark-article-as-replied (article)
8914 "Mark ARTICLE as replied to and update the summary line.
8915 ARTICLE can also be a list of articles."
8916 (interactive (list (gnus-summary-article-number)))
8917 (let ((articles (if (listp article) article (list article))))
8918 (dolist (article articles)
8919 (push article gnus-newsgroup-replied)
8920 (let ((buffer-read-only nil))
8921 (when (gnus-summary-goto-subject article nil t)
8922 (gnus-summary-update-secondary-mark article))))))
8924 (defun gnus-summary-mark-article-as-forwarded (article)
8925 "Mark ARTICLE as forwarded and update the summary line.
8926 ARTICLE can also be a list of articles."
8927 (let ((articles (if (listp article) article (list article))))
8928 (dolist (article articles)
8929 (push article gnus-newsgroup-forwarded)
8930 (let ((buffer-read-only nil))
8931 (when (gnus-summary-goto-subject article nil t)
8932 (gnus-summary-update-secondary-mark article))))))
8934 (defun gnus-summary-set-bookmark (article)
8935 "Set a bookmark in current article."
8936 (interactive (list (gnus-summary-article-number)))
8937 (when (or (not (get-buffer gnus-article-buffer))
8938 (not gnus-current-article)
8939 (not gnus-article-current)
8940 (not (equal gnus-newsgroup-name (car gnus-article-current))))
8941 (error "No current article selected"))
8942 ;; Remove old bookmark, if one exists.
8943 (let ((old (assq article gnus-newsgroup-bookmarks)))
8945 (setq gnus-newsgroup-bookmarks
8946 (delq old gnus-newsgroup-bookmarks))))
8947 ;; Set the new bookmark, which is on the form
8948 ;; (article-number . line-number-in-body).
8952 (set-buffer gnus-article-buffer)
8956 (goto-char (point-min))
8957 (search-forward "\n\n" nil t)
8960 gnus-newsgroup-bookmarks)
8961 (gnus-message 6 "A bookmark has been added to the current article."))
8963 (defun gnus-summary-remove-bookmark (article)
8964 "Remove the bookmark from the current article."
8965 (interactive (list (gnus-summary-article-number)))
8966 ;; Remove old bookmark, if one exists.
8967 (let ((old (assq article gnus-newsgroup-bookmarks)))
8970 (setq gnus-newsgroup-bookmarks
8971 (delq old gnus-newsgroup-bookmarks))
8972 (gnus-message 6 "Removed bookmark."))
8973 (gnus-message 6 "No bookmark in current article."))))
8975 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8976 (defun gnus-summary-mark-as-dormant (n)
8977 "Mark N articles forward as dormant.
8978 If N is negative, mark backward instead. The difference between N and
8979 the actual number of articles marked is returned."
8981 (gnus-summary-mark-forward n gnus-dormant-mark))
8983 (defun gnus-summary-set-process-mark (article)
8984 "Set the process mark on ARTICLE and update the summary line."
8985 (setq gnus-newsgroup-processable
8987 (delq article gnus-newsgroup-processable)))
8988 (when (gnus-summary-goto-subject article)
8989 (gnus-summary-show-thread)
8990 (gnus-summary-goto-subject article)
8991 (gnus-summary-update-secondary-mark article)))
8993 (defun gnus-summary-remove-process-mark (article)
8994 "Remove the process mark from ARTICLE and update the summary line."
8995 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
8996 (when (gnus-summary-goto-subject article)
8997 (gnus-summary-show-thread)
8998 (gnus-summary-goto-subject article)
8999 (gnus-summary-update-secondary-mark article)))
9001 (defun gnus-summary-set-saved-mark (article)
9002 "Set the process mark on ARTICLE and update the summary line."
9003 (push article gnus-newsgroup-saved)
9004 (when (gnus-summary-goto-subject article)
9005 (gnus-summary-update-secondary-mark article)))
9007 (defun gnus-summary-mark-forward (n &optional mark no-expire)
9008 "Mark N articles as read forwards.
9009 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
9010 The difference between N and the actual number of articles marked is
9012 Iff NO-EXPIRE, auto-expiry will be inhibited."
9014 (gnus-summary-show-thread)
9015 (let ((backward (< n 0))
9016 (gnus-summary-goto-unread
9017 (and gnus-summary-goto-unread
9018 (not (eq gnus-summary-goto-unread 'never))
9019 (not (memq mark (list gnus-unread-mark
9020 gnus-ticked-mark gnus-dormant-mark)))))
9022 (mark (or mark gnus-del-mark)))
9024 (gnus-summary-mark-article nil mark no-expire)
9025 (zerop (gnus-summary-next-subject
9027 (and gnus-summary-goto-unread
9028 (not (eq gnus-summary-goto-unread 'never)))
9032 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
9033 (gnus-summary-recenter)
9034 (gnus-summary-position-point)
9035 (gnus-set-mode-line 'summary)
9038 (defun gnus-summary-mark-article-as-read (mark)
9039 "Mark the current article quickly as read with MARK."
9040 (let ((article (gnus-summary-article-number)))
9041 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9042 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9043 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9044 (push (cons article mark) gnus-newsgroup-reads)
9045 ;; Possibly remove from cache, if that is used.
9046 (when gnus-use-cache
9047 (gnus-cache-enter-remove-article article))
9048 ;; Allow the backend to change the mark.
9049 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9050 ;; Check for auto-expiry.
9051 (when (and gnus-newsgroup-auto-expire
9052 (memq mark gnus-auto-expirable-marks))
9053 (setq mark gnus-expirable-mark)
9054 ;; Let the backend know about the mark change.
9055 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9056 (push article gnus-newsgroup-expirable))
9057 ;; Set the mark in the buffer.
9058 (gnus-summary-update-mark mark 'unread)
9061 (defun gnus-summary-mark-article-as-unread (mark)
9062 "Mark the current article quickly as unread with MARK."
9063 (let* ((article (gnus-summary-article-number))
9064 (old-mark (gnus-summary-article-mark article)))
9065 ;; Allow the backend to change the mark.
9066 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9067 (if (eq mark old-mark)
9071 (gnus-error 1 "Can't mark negative article numbers")
9073 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9074 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9075 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
9076 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
9077 (cond ((= mark gnus-ticked-mark)
9078 (push article gnus-newsgroup-marked))
9079 ((= mark gnus-dormant-mark)
9080 (push article gnus-newsgroup-dormant))
9082 (push article gnus-newsgroup-unreads)))
9083 (gnus-pull article gnus-newsgroup-reads)
9085 ;; See whether the article is to be put in the cache.
9087 (vectorp (gnus-summary-article-header article))
9089 (gnus-cache-possibly-enter-article
9090 gnus-newsgroup-name article
9091 (= mark gnus-ticked-mark)
9092 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9095 (gnus-summary-update-mark mark 'unread)
9098 (defun gnus-summary-mark-article (&optional article mark no-expire)
9099 "Mark ARTICLE with MARK. MARK can be any character.
9100 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
9101 `??' (dormant) and `?E' (expirable).
9102 If MARK is nil, then the default character `?r' is used.
9103 If ARTICLE is nil, then the article on the current line will be
9105 Iff NO-EXPIRE, auto-expiry will be inhibited."
9106 ;; The mark might be a string.
9107 (when (stringp mark)
9108 (setq mark (aref mark 0)))
9109 ;; If no mark is given, then we check auto-expiring.
9111 (setq mark gnus-del-mark))
9112 (when (and (not no-expire)
9113 gnus-newsgroup-auto-expire
9114 (memq mark gnus-auto-expirable-marks))
9115 (setq mark gnus-expirable-mark))
9116 (let ((article (or article (gnus-summary-article-number)))
9117 (old-mark (gnus-summary-article-mark article)))
9118 ;; Allow the backend to change the mark.
9119 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9120 (if (eq mark old-mark)
9123 (error "No article on current line"))
9124 (if (not (if (or (= mark gnus-unread-mark)
9125 (= mark gnus-ticked-mark)
9126 (= mark gnus-dormant-mark))
9127 (gnus-mark-article-as-unread article mark)
9128 (gnus-mark-article-as-read article mark)))
9130 ;; See whether the article is to be put in the cache.
9132 (not (= mark gnus-canceled-mark))
9133 (vectorp (gnus-summary-article-header article))
9135 (gnus-cache-possibly-enter-article
9136 gnus-newsgroup-name article
9137 (= mark gnus-ticked-mark)
9138 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9140 (when (gnus-summary-goto-subject article nil t)
9141 (let ((buffer-read-only nil))
9142 (gnus-summary-show-thread)
9144 (gnus-summary-update-mark mark 'unread)
9147 (defun gnus-summary-update-secondary-mark (article)
9148 "Update the secondary (read, process, cache) mark."
9149 (gnus-summary-update-mark
9150 (cond ((memq article gnus-newsgroup-processable)
9152 ((memq article gnus-newsgroup-cached)
9154 ((memq article gnus-newsgroup-replied)
9156 ((memq article gnus-newsgroup-forwarded)
9157 gnus-forwarded-mark)
9158 ((memq article gnus-newsgroup-saved)
9160 ((memq article gnus-newsgroup-recent)
9162 ((memq article gnus-newsgroup-unseen)
9166 (when (gnus-visual-p 'summary-highlight 'highlight)
9167 (gnus-run-hooks 'gnus-summary-update-hook))
9170 (defun gnus-summary-update-mark (mark type)
9171 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
9172 (buffer-read-only nil))
9173 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
9175 (when (looking-at "\r")
9177 (when (<= (+ forward (point)) (point-max))
9178 ;; Go to the right position on the line.
9179 (goto-char (+ forward (point)))
9180 ;; Replace the old mark with the new mark.
9181 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
9182 ;; Optionally update the marks by some user rule.
9183 (when (eq type 'unread)
9185 (gnus-data-find (gnus-summary-article-number)) mark)
9186 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
9188 (defun gnus-mark-article-as-read (article &optional mark)
9189 "Enter ARTICLE in the pertinent lists and remove it from others."
9190 ;; Make the article expirable.
9191 (let ((mark (or mark gnus-del-mark)))
9192 (if (= mark gnus-expirable-mark)
9193 (push article gnus-newsgroup-expirable)
9194 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
9195 ;; Remove from unread and marked lists.
9196 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9197 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9198 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9199 (push (cons article mark) gnus-newsgroup-reads)
9200 ;; Possibly remove from cache, if that is used.
9201 (when gnus-use-cache
9202 (gnus-cache-enter-remove-article article))
9205 (defun gnus-mark-article-as-unread (article &optional mark)
9206 "Enter ARTICLE in the pertinent lists and remove it from others."
9207 (let ((mark (or mark gnus-ticked-mark)))
9210 (gnus-error 1 "Can't mark negative article numbers")
9212 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
9213 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
9214 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
9215 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9217 ;; Unsuppress duplicates?
9218 (when gnus-suppress-duplicates
9219 (gnus-dup-unsuppress-article article))
9221 (cond ((= mark gnus-ticked-mark)
9222 (push article gnus-newsgroup-marked))
9223 ((= mark gnus-dormant-mark)
9224 (push article gnus-newsgroup-dormant))
9226 (push article gnus-newsgroup-unreads)))
9227 (gnus-pull article gnus-newsgroup-reads)
9230 (defalias 'gnus-summary-mark-as-unread-forward
9231 'gnus-summary-tick-article-forward)
9232 (make-obsolete 'gnus-summary-mark-as-unread-forward
9233 'gnus-summary-tick-article-forward)
9234 (defun gnus-summary-tick-article-forward (n)
9235 "Tick N articles forwards.
9236 If N is negative, tick backwards instead.
9237 The difference between N and the number of articles ticked is returned."
9239 (gnus-summary-mark-forward n gnus-ticked-mark))
9241 (defalias 'gnus-summary-mark-as-unread-backward
9242 'gnus-summary-tick-article-backward)
9243 (make-obsolete 'gnus-summary-mark-as-unread-backward
9244 'gnus-summary-tick-article-backward)
9245 (defun gnus-summary-tick-article-backward (n)
9246 "Tick N articles backwards.
9247 The difference between N and the number of articles ticked is returned."
9249 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
9251 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9252 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9253 (defun gnus-summary-tick-article (&optional article clear-mark)
9254 "Mark current article as unread.
9255 Optional 1st argument ARTICLE specifies article number to be marked as unread.
9256 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
9258 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
9261 (defun gnus-summary-mark-as-read-forward (n)
9262 "Mark N articles as read forwards.
9263 If N is negative, mark backwards instead.
9264 The difference between N and the actual number of articles marked is
9267 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
9269 (defun gnus-summary-mark-as-read-backward (n)
9270 "Mark the N articles as read backwards.
9271 The difference between N and the actual number of articles marked is
9274 (gnus-summary-mark-forward
9275 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
9277 (defun gnus-summary-mark-as-read (&optional article mark)
9278 "Mark current article as read.
9279 ARTICLE specifies the article to be marked as read.
9280 MARK specifies a string to be inserted at the beginning of the line."
9281 (gnus-summary-mark-article article mark))
9283 (defun gnus-summary-clear-mark-forward (n)
9284 "Clear marks from N articles forward.
9285 If N is negative, clear backward instead.
9286 The difference between N and the number of marks cleared is returned."
9288 (gnus-summary-mark-forward n gnus-unread-mark))
9290 (defun gnus-summary-clear-mark-backward (n)
9291 "Clear marks from N articles backward.
9292 The difference between N and the number of marks cleared is returned."
9294 (gnus-summary-mark-forward (- n) gnus-unread-mark))
9296 (defun gnus-summary-mark-unread-as-read ()
9297 "Intended to be used by `gnus-summary-mark-article-hook'."
9298 (when (memq gnus-current-article gnus-newsgroup-unreads)
9299 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
9301 (defun gnus-summary-mark-read-and-unread-as-read ()
9302 "Intended to be used by `gnus-summary-mark-article-hook'."
9303 (let ((mark (gnus-summary-article-mark)))
9304 (when (or (gnus-unread-mark-p mark)
9305 (gnus-read-mark-p mark))
9306 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
9308 (defun gnus-summary-mark-unread-as-ticked ()
9309 "Intended to be used by `gnus-summary-mark-article-hook'."
9310 (when (memq gnus-current-article gnus-newsgroup-unreads)
9311 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
9313 (defun gnus-summary-mark-region-as-read (point mark all)
9314 "Mark all unread articles between point and mark as read.
9315 If given a prefix, mark all articles between point and mark as read,
9316 even ticked and dormant ones."
9317 (interactive "r\nP")
9326 (memq (setq article (gnus-summary-article-number))
9327 gnus-newsgroup-unreads))
9328 (gnus-summary-mark-article article gnus-del-mark))
9330 (gnus-summary-find-next))))))
9332 (defun gnus-summary-mark-below (score mark)
9333 "Mark articles with score less than SCORE with MARK."
9334 (interactive "P\ncMark: ")
9335 (setq score (if score
9336 (prefix-numeric-value score)
9337 (or gnus-summary-default-score 0)))
9339 (set-buffer gnus-summary-buffer)
9340 (goto-char (point-min))
9343 (and (< (gnus-summary-article-score) score)
9344 (gnus-summary-mark-article nil mark))
9345 (gnus-summary-find-next)))))
9347 (defun gnus-summary-kill-below (&optional score)
9348 "Mark articles with score below SCORE as read."
9350 (gnus-summary-mark-below score gnus-killed-mark))
9352 (defun gnus-summary-clear-above (&optional score)
9353 "Clear all marks from articles with score above SCORE."
9355 (gnus-summary-mark-above score gnus-unread-mark))
9357 (defun gnus-summary-tick-above (&optional score)
9358 "Tick all articles with score above SCORE."
9360 (gnus-summary-mark-above score gnus-ticked-mark))
9362 (defun gnus-summary-mark-above (score mark)
9363 "Mark articles with score over SCORE with MARK."
9364 (interactive "P\ncMark: ")
9365 (setq score (if score
9366 (prefix-numeric-value score)
9367 (or gnus-summary-default-score 0)))
9369 (set-buffer gnus-summary-buffer)
9370 (goto-char (point-min))
9372 (when (> (gnus-summary-article-score) score)
9373 (gnus-summary-mark-article nil mark))
9375 (gnus-summary-find-next)))))
9377 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9378 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
9379 (defun gnus-summary-limit-include-expunged (&optional no-error)
9380 "Display all the hidden articles that were expunged for low scores."
9382 (let ((buffer-read-only nil))
9383 (let ((scored gnus-newsgroup-scored)
9386 (unless (gnus-summary-article-header (caar scored))
9387 (and (setq h (gnus-number-to-header (caar scored)))
9388 (< (cdar scored) gnus-summary-expunge-below)
9390 (setq scored (cdr scored)))
9392 (when (not no-error)
9393 (error "No expunged articles hidden"))
9394 (goto-char (point-min))
9395 (push gnus-newsgroup-limit gnus-newsgroup-limits)
9396 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
9397 (mapcar (lambda (x) (push (mail-header-number x)
9398 gnus-newsgroup-limit))
9400 (gnus-summary-prepare-unthreaded (nreverse headers))
9401 (goto-char (point-min))
9402 (gnus-summary-position-point)
9405 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
9406 "Mark all unread articles in this newsgroup as read.
9407 If prefix argument ALL is non-nil, ticked and dormant articles will
9408 also be marked as read.
9409 If QUIETLY is non-nil, no questions will be asked.
9410 If TO-HERE is non-nil, it should be a point in the buffer. All
9411 articles before (after, if REVERSE is set) this point will be marked as read.
9412 Note that this function will only catch up the unread article
9413 in the current summary buffer limitation.
9414 The number of articles marked as read is returned."
9419 (not gnus-interactive-catchup) ;Without confirmation?
9423 "Mark absolutely all articles as read? "
9424 "Mark all unread articles as read? ")))
9426 (not gnus-newsgroup-adaptive)
9427 (not gnus-newsgroup-auto-expire)
9428 (not gnus-suppress-duplicates)
9429 (or (not gnus-use-cache)
9430 (eq gnus-use-cache 'passive)))
9433 (setq gnus-newsgroup-marked nil
9434 gnus-newsgroup-dormant nil))
9435 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
9436 ;; We actually mark all articles as canceled, which we
9437 ;; have to do when using auto-expiry or adaptive scoring.
9438 (gnus-summary-show-all-threads)
9439 (if (and to-here reverse)
9443 (gnus-summary-mark-article-as-read gnus-catchup-mark)
9444 (gnus-summary-find-next (not all) nil nil t))))
9445 (when (gnus-summary-first-subject (not all) t)
9447 (if to-here (< (point) to-here) t)
9448 (gnus-summary-mark-article-as-read gnus-catchup-mark)
9449 (gnus-summary-find-next (not all) nil nil t)))))
9450 (gnus-set-mode-line 'summary))
9452 (gnus-summary-position-point)))
9454 (defun gnus-summary-catchup-to-here (&optional all)
9455 "Mark all unticked articles before the current one as read.
9456 If ALL is non-nil, also mark ticked and dormant articles as read."
9459 (gnus-save-hidden-threads
9460 (let ((beg (point)))
9461 ;; We check that there are unread articles.
9462 (when (or all (gnus-summary-find-prev))
9463 (gnus-summary-catchup all t beg)))))
9464 (gnus-summary-position-point))
9466 (defun gnus-summary-catchup-from-here (&optional all)
9467 "Mark all unticked articles after the current one as read.
9468 If ALL is non-nil, also mark ticked and dormant articles as read."
9471 (gnus-save-hidden-threads
9472 (let ((beg (point)))
9473 ;; We check that there are unread articles.
9474 (when (or all (gnus-summary-find-next))
9475 (gnus-summary-catchup all t beg nil t)))))
9477 (gnus-summary-position-point))
9478 (defun gnus-summary-catchup-all (&optional quietly)
9479 "Mark all articles in this newsgroup as read."
9481 (gnus-summary-catchup t quietly))
9483 (defun gnus-summary-catchup-and-exit (&optional all quietly)
9484 "Mark all unread articles in this group as read, then exit.
9485 If prefix argument ALL is non-nil, all articles are marked as read.
9486 If QUIETLY is non-nil, no questions will be asked."
9488 (when (gnus-summary-catchup all quietly nil 'fast)
9489 ;; Select next newsgroup or exit.
9490 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
9491 (eq gnus-auto-select-next 'quietly))
9492 (gnus-summary-next-group nil)
9493 (gnus-summary-exit))))
9495 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
9496 "Mark all articles in this newsgroup as read, and then exit."
9498 (gnus-summary-catchup-and-exit t quietly))
9500 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
9501 "Mark all articles in this group as read and select the next group.
9502 If given a prefix, mark all articles, unread as well as ticked, as
9506 (gnus-summary-catchup all))
9507 (gnus-summary-next-group))
9513 (defmacro gnus-with-article (article &rest forms)
9514 "Select ARTICLE and perform FORMS in the original article buffer.
9515 Then replace the article with the result."
9517 ;; We don't want the article to be marked as read.
9518 (let (gnus-mark-article-hook)
9519 (gnus-summary-select-article t t nil ,article))
9520 (set-buffer gnus-original-article-buffer)
9522 (if (not (gnus-check-backend-function
9523 'request-replace-article (car gnus-article-current)))
9524 (gnus-message 5 "Read-only group; not replacing")
9525 (unless (gnus-request-replace-article
9526 ,article (car gnus-article-current)
9528 (error "Couldn't replace article")))
9529 ;; The cache and backlog have to be flushed somewhat.
9530 (when gnus-keep-backlog
9531 (gnus-backlog-remove-article
9532 (car gnus-article-current) (cdr gnus-article-current)))
9533 (when gnus-use-cache
9534 (gnus-cache-update-article
9535 (car gnus-article-current) (cdr gnus-article-current)))))
9537 (put 'gnus-with-article 'lisp-indent-function 1)
9538 (put 'gnus-with-article 'edebug-form-spec '(form body))
9540 ;; Thread-based commands.
9542 (defun gnus-summary-articles-in-thread (&optional article)
9543 "Return a list of all articles in the current thread.
9544 If ARTICLE is non-nil, return all articles in the thread that starts
9546 (let* ((article (or article (gnus-summary-article-number)))
9547 (data (gnus-data-find-list article))
9548 (top-level (gnus-data-level (car data)))
9550 (cond ((null gnus-thread-operation-ignore-subject)
9551 (gnus-simplify-subject-re
9552 (mail-header-subject (gnus-data-header (car data)))))
9553 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
9554 (gnus-simplify-subject-fuzzy
9555 (mail-header-subject (gnus-data-header (car data)))))
9557 (end-point (save-excursion
9558 (if (gnus-summary-go-to-next-thread)
9559 (point) (point-max))))
9562 (< (gnus-data-pos (car data)) end-point))
9563 (when (or (not top-subject)
9564 (string= top-subject
9565 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
9566 (gnus-simplify-subject-fuzzy
9567 (mail-header-subject
9568 (gnus-data-header (car data))))
9569 (gnus-simplify-subject-re
9570 (mail-header-subject
9571 (gnus-data-header (car data)))))))
9572 (push (gnus-data-number (car data)) articles))
9573 (unless (and (setq data (cdr data))
9574 (> (gnus-data-level (car data)) top-level))
9576 ;; Return the list of articles.
9577 (nreverse articles)))
9579 (defun gnus-summary-rethread-current ()
9580 "Rethread the thread the current article is part of."
9582 (let* ((gnus-show-threads t)
9583 (article (gnus-summary-article-number))
9584 (id (mail-header-id (gnus-summary-article-header)))
9585 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
9587 (error "No article on the current line"))
9588 (gnus-rebuild-thread id)
9589 (gnus-summary-goto-subject article)))
9591 (defun gnus-summary-reparent-thread ()
9592 "Make the current article child of the marked (or previous) article.
9594 Note that the re-threading will only work if `gnus-thread-ignore-subject'
9595 is non-nil or the Subject: of both articles are the same."
9597 (unless (not (gnus-group-read-only-p))
9598 (error "The current newsgroup does not support article editing"))
9599 (unless (<= (length gnus-newsgroup-processable) 1)
9600 (error "No more than one article may be marked"))
9601 (save-window-excursion
9602 (let ((gnus-article-buffer " *reparent*")
9603 (current-article (gnus-summary-article-number))
9604 ;; First grab the marked article, otherwise one line up.
9605 (parent-article (if (not (null gnus-newsgroup-processable))
9606 (car gnus-newsgroup-processable)
9608 (if (eq (forward-line -1) 0)
9609 (gnus-summary-article-number)
9610 (error "Beginning of summary buffer"))))))
9611 (unless (not (eq current-article parent-article))
9612 (error "An article may not be self-referential"))
9613 (let ((message-id (mail-header-id
9614 (gnus-summary-article-header parent-article))))
9615 (unless (and message-id (not (equal message-id "")))
9616 (error "No message-id in desired parent"))
9617 (gnus-with-article current-article
9619 (goto-char (point-min))
9620 (message-narrow-to-head)
9621 (if (re-search-forward "^References: " nil t)
9623 (re-search-forward "^[^ \t]" nil t)
9626 (insert " " message-id))
9627 (insert "References: " message-id "\n"))))
9628 (set-buffer gnus-summary-buffer)
9629 (gnus-summary-unmark-all-processable)
9630 (gnus-summary-update-article current-article)
9631 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9632 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
9633 (gnus-summary-rethread-current)
9634 (gnus-message 3 "Article %d is now the child of article %d"
9635 current-article parent-article)))))
9637 (defun gnus-summary-toggle-threads (&optional arg)
9638 "Toggle showing conversation threads.
9639 If ARG is positive number, turn showing conversation threads on."
9641 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
9642 (setq gnus-show-threads
9643 (if (null arg) (not gnus-show-threads)
9644 (> (prefix-numeric-value arg) 0)))
9645 (gnus-summary-prepare)
9646 (gnus-summary-goto-subject current)
9647 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
9648 (gnus-summary-position-point)))
9650 (defun gnus-summary-show-all-threads ()
9654 (let ((buffer-read-only nil))
9655 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
9656 (gnus-summary-position-point))
9658 (defun gnus-summary-show-thread ()
9659 "Show thread subtrees.
9660 Returns nil if no thread was there to be shown."
9662 (let ((buffer-read-only nil)
9664 ;; first goto end then to beg, to have point at beg after let
9665 (end (progn (end-of-line) (point)))
9666 (beg (progn (beginning-of-line) (point))))
9668 ;; Any hidden lines here?
9669 (search-forward "\r" end t)
9670 (subst-char-in-region beg end ?\^M ?\n t)
9672 (gnus-summary-position-point))))
9674 (defun gnus-summary-hide-all-threads ()
9675 "Hide all thread subtrees."
9678 (goto-char (point-min))
9679 (gnus-summary-hide-thread)
9680 (while (zerop (gnus-summary-next-thread 1 t))
9681 (gnus-summary-hide-thread)))
9682 (gnus-summary-position-point))
9684 (defun gnus-summary-hide-thread ()
9685 "Hide thread subtrees.
9686 Returns nil if no threads were there to be hidden."
9688 (let ((buffer-read-only nil)
9690 (article (gnus-summary-article-number)))
9692 ;; Go forward until either the buffer ends or the subthread
9694 (when (and (not (eobp))
9695 (or (zerop (gnus-summary-next-thread 1 t))
9696 (goto-char (point-max))))
9698 (if (and (> (point) start)
9699 (search-backward "\n" start t))
9701 (subst-char-in-region start (point) ?\n ?\^M)
9702 (gnus-summary-goto-subject article))
9706 (defun gnus-summary-go-to-next-thread (&optional previous)
9707 "Go to the same level (or less) next thread.
9708 If PREVIOUS is non-nil, go to previous thread instead.
9709 Return the article number moved to, or nil if moving was impossible."
9710 (let ((level (gnus-summary-thread-level))
9711 (way (if previous -1 1))
9714 (while (and (not (eobp))
9715 (< level (gnus-summary-thread-level)))
9723 (gnus-summary-article-number)
9726 (defun gnus-summary-next-thread (n &optional silent)
9727 "Go to the same level next N'th thread.
9728 If N is negative, search backward instead.
9729 Returns the difference between N and the number of skips actually
9732 If SILENT, don't output messages."
9734 (let ((backward (< n 0))
9737 (gnus-summary-go-to-next-thread backward))
9740 (gnus-summary-position-point))
9741 (when (and (not silent) (/= 0 n))
9742 (gnus-message 7 "No more threads"))
9745 (defun gnus-summary-prev-thread (n)
9746 "Go to the same level previous N'th thread.
9747 Returns the difference between N and the number of skips actually
9750 (gnus-summary-next-thread (- n)))
9752 (defun gnus-summary-go-down-thread ()
9753 "Go down one level in the current thread."
9754 (let ((children (gnus-summary-article-children)))
9756 (gnus-summary-goto-subject (car children)))))
9758 (defun gnus-summary-go-up-thread ()
9759 "Go up one level in the current thread."
9760 (let ((parent (gnus-summary-article-parent)))
9762 (gnus-summary-goto-subject parent))))
9764 (defun gnus-summary-down-thread (n)
9765 "Go down thread N steps.
9766 If N is negative, go up instead.
9767 Returns the difference between N and how many steps down that were
9773 (if up (gnus-summary-go-up-thread)
9774 (gnus-summary-go-down-thread)))
9776 (gnus-summary-position-point)
9778 (gnus-message 7 "Can't go further"))
9781 (defun gnus-summary-up-thread (n)
9782 "Go up thread N steps.
9783 If N is negative, go down instead.
9784 Returns the difference between N and how many steps down that were
9787 (gnus-summary-down-thread (- n)))
9789 (defun gnus-summary-top-thread ()
9790 "Go to the top of the thread."
9792 (while (gnus-summary-go-up-thread))
9793 (gnus-summary-article-number))
9795 (defun gnus-summary-kill-thread (&optional unmark)
9796 "Mark articles under current thread as read.
9797 If the prefix argument is positive, remove any kinds of marks.
9798 If the prefix argument is negative, tick articles instead."
9801 (setq unmark (prefix-numeric-value unmark)))
9802 (let ((articles (gnus-summary-articles-in-thread)))
9804 ;; Expand the thread.
9805 (gnus-summary-show-thread)
9806 ;; Mark all the articles.
9808 (gnus-summary-goto-subject (car articles))
9809 (cond ((null unmark)
9810 (gnus-summary-mark-article-as-read gnus-killed-mark))
9812 (gnus-summary-mark-article-as-unread gnus-unread-mark))
9814 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
9815 (setq articles (cdr articles))))
9816 ;; Hide killed subtrees.
9818 gnus-thread-hide-killed
9819 (gnus-summary-hide-thread))
9820 ;; If marked as read, go to next unread subject.
9822 ;; Go to next unread subject.
9823 (gnus-summary-next-subject 1 t)))
9824 (gnus-set-mode-line 'summary))
9826 ;; Summary sorting commands
9828 (defun gnus-summary-sort-by-number (&optional reverse)
9829 "Sort the summary buffer by article number.
9830 Argument REVERSE means reverse order."
9832 (gnus-summary-sort 'number reverse))
9834 (defun gnus-summary-sort-by-author (&optional reverse)
9835 "Sort the summary buffer by author name alphabetically.
9836 If `case-fold-search' is non-nil, case of letters is ignored.
9837 Argument REVERSE means reverse order."
9839 (gnus-summary-sort 'author reverse))
9841 (defun gnus-summary-sort-by-subject (&optional reverse)
9842 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
9843 If `case-fold-search' is non-nil, case of letters is ignored.
9844 Argument REVERSE means reverse order."
9846 (gnus-summary-sort 'subject reverse))
9848 (defun gnus-summary-sort-by-date (&optional reverse)
9849 "Sort the summary buffer by date.
9850 Argument REVERSE means reverse order."
9852 (gnus-summary-sort 'date reverse))
9854 (defun gnus-summary-sort-by-score (&optional reverse)
9855 "Sort the summary buffer by score.
9856 Argument REVERSE means reverse order."
9858 (gnus-summary-sort 'score reverse))
9860 (defun gnus-summary-sort-by-lines (&optional reverse)
9861 "Sort the summary buffer by the number of lines.
9862 Argument REVERSE means reverse order."
9864 (gnus-summary-sort 'lines reverse))
9866 (defun gnus-summary-sort-by-chars (&optional reverse)
9867 "Sort the summary buffer by article length.
9868 Argument REVERSE means reverse order."
9870 (gnus-summary-sort 'chars reverse))
9872 (defun gnus-summary-sort-by-original (&optional reverse)
9873 "Sort the summary buffer using the default sorting method.
9874 Argument REVERSE means reverse order."
9876 (let* ((buffer-read-only)
9877 (gnus-summary-prepare-hook nil))
9878 ;; We do the sorting by regenerating the threads.
9879 (gnus-summary-prepare)
9880 ;; Hide subthreads if needed.
9881 (when (and gnus-show-threads gnus-thread-hide-subtree)
9882 (gnus-summary-hide-all-threads))))
9884 (defun gnus-summary-sort (predicate reverse)
9885 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
9886 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
9887 (article (intern (format "gnus-article-sort-by-%s" predicate)))
9888 (gnus-thread-sort-functions
9893 (gnus-sort-gathered-threads-function
9894 gnus-thread-sort-functions)
9895 (gnus-article-sort-functions
9901 (gnus-summary-prepare-hook nil))
9902 ;; We do the sorting by regenerating the threads.
9903 (gnus-summary-prepare)
9904 ;; Hide subthreads if needed.
9905 (when (and gnus-show-threads gnus-thread-hide-subtree)
9906 (gnus-summary-hide-all-threads))))
9908 ;; Summary saving commands.
9910 (defun gnus-summary-save-article (&optional n not-saved)
9911 "Save the current article using the default saver function.
9912 If N is a positive number, save the N next articles.
9913 If N is a negative number, save the N previous articles.
9914 If N is nil and any articles have been marked with the process mark,
9915 save those articles instead.
9916 The variable `gnus-default-article-saver' specifies the saver function."
9918 (let* ((articles (gnus-summary-work-articles n))
9919 (save-buffer (save-excursion
9920 (nnheader-set-temp-buffer " *Gnus Save*")))
9921 (num (length articles))
9923 (dolist (article articles)
9924 (setq header (gnus-summary-article-header article))
9925 (if (not (vectorp header))
9926 ;; This is a pseudo-article.
9927 (if (assq 'name header)
9928 (gnus-copy-file (cdr (assq 'name header)))
9929 (gnus-message 1 "Article %d is unsaveable" article))
9930 ;; This is a real article.
9931 (save-window-excursion
9932 (let ((gnus-display-mime-function nil)
9933 (gnus-article-prepare-hook nil))
9934 (gnus-summary-select-article t nil nil article)))
9936 (set-buffer save-buffer)
9938 (insert-buffer-substring gnus-original-article-buffer))
9939 (setq file (gnus-article-save save-buffer file num))
9940 (gnus-summary-remove-process-mark article)
9942 (gnus-summary-set-saved-mark article))))
9943 (gnus-kill-buffer save-buffer)
9944 (gnus-summary-position-point)
9945 (gnus-set-mode-line 'summary)
9948 (defun gnus-summary-pipe-output (&optional arg)
9949 "Pipe the current article to a subprocess.
9950 If N is a positive number, pipe the N next articles.
9951 If N is a negative number, pipe the N previous articles.
9952 If N is nil and any articles have been marked with the process mark,
9953 pipe those articles instead."
9956 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
9957 (gnus-summary-save-article arg t))
9958 (let ((buffer (get-buffer "*Shell Command Output*")))
9960 (with-current-buffer buffer (> (point-max) (point-min))))
9961 (gnus-configure-windows 'pipe))))
9963 (defun gnus-summary-save-article-mail (&optional arg)
9964 "Append the current article to an mail file.
9965 If N is a positive number, save the N next articles.
9966 If N is a negative number, save the N previous articles.
9967 If N is nil and any articles have been marked with the process mark,
9968 save those articles instead."
9971 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
9972 (gnus-summary-save-article arg)))
9974 (defun gnus-summary-save-article-rmail (&optional arg)
9975 "Append the current article to an rmail file.
9976 If N is a positive number, save the N next articles.
9977 If N is a negative number, save the N previous articles.
9978 If N is nil and any articles have been marked with the process mark,
9979 save those articles instead."
9982 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
9983 (gnus-summary-save-article arg)))
9985 (defun gnus-summary-save-article-file (&optional arg)
9986 "Append the current article to a file.
9987 If N is a positive number, save the N next articles.
9988 If N is a negative number, save the N previous articles.
9989 If N is nil and any articles have been marked with the process mark,
9990 save those articles instead."
9993 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
9994 (gnus-summary-save-article arg)))
9996 (defun gnus-summary-write-article-file (&optional arg)
9997 "Write the current article to a file, deleting the previous file.
9998 If N is a positive number, save the N next articles.
9999 If N is a negative number, save the N previous articles.
10000 If N is nil and any articles have been marked with the process mark,
10001 save those articles instead."
10003 (require 'gnus-art)
10004 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
10005 (gnus-summary-save-article arg)))
10007 (defun gnus-summary-save-article-body-file (&optional arg)
10008 "Append the current article body to a file.
10009 If N is a positive number, save the N next articles.
10010 If N is a negative number, save the N previous articles.
10011 If N is nil and any articles have been marked with the process mark,
10012 save those articles instead."
10014 (require 'gnus-art)
10015 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
10016 (gnus-summary-save-article arg)))
10018 (defun gnus-summary-muttprint (&optional arg)
10019 "Print the current article using Muttprint.
10020 If N is a positive number, save the N next articles.
10021 If N is a negative number, save the N previous articles.
10022 If N is nil and any articles have been marked with the process mark,
10023 save those articles instead."
10025 (require 'gnus-art)
10026 (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint))
10027 (gnus-summary-save-article arg t)))
10029 (defun gnus-summary-pipe-message (program)
10030 "Pipe the current article through PROGRAM."
10031 (interactive "sProgram: ")
10032 (gnus-summary-select-article)
10033 (let ((mail-header-separator ""))
10034 (gnus-eval-in-buffer-window gnus-article-buffer
10037 (let ((start (window-start))
10039 (message-pipe-buffer-body program)
10040 (set-window-start (get-buffer-window (current-buffer)) start))))))
10042 (defun gnus-get-split-value (methods)
10043 "Return a value based on the split METHODS."
10044 (let (split-name method result match)
10047 (set-buffer gnus-original-article-buffer)
10049 (nnheader-narrow-to-headers)
10050 (while (and methods (not split-name))
10051 (goto-char (point-min))
10052 (setq method (pop methods))
10053 (setq match (car method))
10056 ;; Regular expression.
10058 (re-search-forward match nil t)))
10059 ((gnus-functionp match)
10063 (setq result (funcall match gnus-newsgroup-name))))
10068 (setq result (eval match)))))
10069 (setq split-name (cdr method))
10070 (cond ((stringp result)
10071 (push (expand-file-name
10072 result gnus-article-save-directory)
10075 (setq split-name (append result split-name)))))))))
10076 (nreverse split-name)))
10078 (defun gnus-valid-move-group-p (group)
10079 (and (boundp group)
10080 (symbol-name group)
10081 (symbol-value group)
10082 (gnus-get-function (gnus-find-method-for-group
10083 (symbol-name group)) 'request-accept-article t)))
10085 (defun gnus-read-move-group-name (prompt default articles prefix)
10086 "Read a group name."
10087 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
10088 (minibuffer-confirm-incomplete nil) ; XEmacs
10090 (format "%s %s to:"
10092 (if (> (length articles) 1)
10093 (format "these %d articles" (length articles))
10098 (gnus-completing-read default prom
10100 'gnus-valid-move-group-p
10102 'gnus-group-history))
10103 ((= 1 (length split-name))
10104 (gnus-completing-read (car split-name) prom
10106 'gnus-valid-move-group-p
10108 'gnus-group-history))
10110 (gnus-completing-read nil prom
10111 (mapcar (lambda (el) (list el))
10112 (nreverse split-name))
10114 'gnus-group-history))))
10115 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
10117 (if (or (string= to-newsgroup "")
10118 (string= to-newsgroup prefix))
10119 (setq to-newsgroup default))
10120 (unless to-newsgroup
10121 (error "No group name entered"))
10122 (or (gnus-active to-newsgroup)
10123 (gnus-activate-group to-newsgroup nil nil to-method)
10124 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
10126 (or (and (gnus-request-create-group to-newsgroup to-method)
10127 (gnus-activate-group
10128 to-newsgroup nil nil to-method)
10129 (gnus-subscribe-group to-newsgroup))
10130 (error "Couldn't create group %s" to-newsgroup)))
10131 (error "No such group: %s" to-newsgroup)))
10134 (defun gnus-summary-save-parts (type dir n &optional reverse)
10135 "Save parts matching TYPE to DIR.
10136 If REVERSE, save parts that do not match TYPE."
10138 (list (read-string "Save parts of type: "
10139 (or (car gnus-summary-save-parts-type-history)
10140 gnus-summary-save-parts-default-mime)
10141 'gnus-summary-save-parts-type-history)
10142 (setq gnus-summary-save-parts-last-directory
10143 (read-file-name "Save to directory: "
10144 gnus-summary-save-parts-last-directory
10146 current-prefix-arg))
10147 (gnus-summary-iterate n
10148 (let ((gnus-display-mime-function nil)
10149 (gnus-inhibit-treatment t))
10150 (gnus-summary-select-article))
10152 (set-buffer gnus-article-buffer)
10153 (let ((handles (or gnus-article-mime-handles
10154 (mm-dissect-buffer) (mm-uu-dissect))))
10156 (gnus-summary-save-parts-1 type dir handles reverse)
10157 (unless gnus-article-mime-handles ;; Don't destroy this case.
10158 (mm-destroy-parts handles)))))))
10160 (defun gnus-summary-save-parts-1 (type dir handle reverse)
10161 (if (stringp (car handle))
10162 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
10165 (not (string-match type (mm-handle-media-type handle)))
10166 (string-match type (mm-handle-media-type handle)))
10167 (let ((file (expand-file-name
10168 (file-name-nondirectory
10170 (mail-content-type-get
10171 (mm-handle-disposition handle) 'filename)
10172 (concat gnus-newsgroup-name
10173 "." (number-to-string
10174 (cdr gnus-article-current)))))
10176 (unless (file-exists-p file)
10177 (mm-save-part-to-file handle file))))))
10179 ;; Summary extract commands
10181 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
10182 (let ((buffer-read-only nil)
10183 (article (gnus-summary-article-number))
10185 (unless (gnus-summary-goto-subject article)
10186 (error "No such article: %d" article))
10187 (gnus-summary-position-point)
10188 ;; If all commands are to be bunched up on one line, we collect
10190 (unless gnus-view-pseudos-separately
10191 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
10194 (setq action (cdr (assq 'action (car ps))))
10195 (setq files (list (cdr (assq 'name (car ps)))))
10196 (while (and ps (cdr ps)
10197 (string= (or action "1")
10198 (or (cdr (assq 'action (cadr ps))) "2")))
10199 (push (cdr (assq 'name (cadr ps))) files)
10200 (setcdr ps (cddr ps)))
10202 (when (not (string-match "%s" action))
10205 (when (assq 'execute (car ps))
10206 (setcdr (assq 'execute (car ps))
10207 (funcall (if (string-match "%s" action)
10216 (setq ps (cdr ps)))))
10217 (if (and gnus-view-pseudos (not not-view))
10219 (when (assq 'execute (car pslist))
10220 (gnus-execute-command (cdr (assq 'execute (car pslist)))
10221 (eq gnus-view-pseudos 'not-confirm)))
10222 (setq pslist (cdr pslist)))
10225 (setq after-article (or (cdr (assq 'article (car pslist)))
10226 (gnus-summary-article-number)))
10227 (gnus-summary-goto-subject after-article)
10230 (insert " " (file-name-nondirectory
10231 (cdr (assq 'name (car pslist))))
10232 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
10234 (forward-line -1) ; back to `b'
10235 (gnus-add-text-properties
10236 b (1- e) (list 'gnus-number gnus-reffed-article-number
10237 gnus-mouse-face-prop gnus-mouse-face))
10239 after-article gnus-reffed-article-number
10240 gnus-unread-mark b (car pslist) 0 (- e b))
10241 (push gnus-reffed-article-number gnus-newsgroup-unreads)
10242 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
10243 (setq pslist (cdr pslist)))))))
10245 (defun gnus-pseudos< (p1 p2)
10246 (let ((c1 (cdr (assq 'action p1)))
10247 (c2 (cdr (assq 'action p2))))
10248 (and c1 c2 (string< c1 c2))))
10250 (defun gnus-request-pseudo-article (props)
10251 (cond ((assq 'execute props)
10252 (gnus-execute-command (cdr (assq 'execute props)))))
10253 (let ((gnus-current-article (gnus-summary-article-number)))
10254 (gnus-run-hooks 'gnus-mark-article-hook)))
10256 (defun gnus-execute-command (command &optional automatic)
10258 (gnus-article-setup-buffer)
10259 (set-buffer gnus-article-buffer)
10260 (setq buffer-read-only nil)
10261 (let ((command (if automatic command
10262 (read-string "Command: " (cons command 0)))))
10264 (insert "$ " command "\n\n")
10265 (if gnus-view-pseudo-asynchronously
10266 (start-process "gnus-execute" (current-buffer) shell-file-name
10267 shell-command-switch command)
10268 (call-process shell-file-name nil t nil
10269 shell-command-switch command)))))
10271 ;; Summary kill commands.
10273 (defun gnus-summary-edit-global-kill (article)
10274 "Edit the \"global\" kill file."
10275 (interactive (list (gnus-summary-article-number)))
10276 (gnus-group-edit-global-kill article))
10278 (defun gnus-summary-edit-local-kill ()
10279 "Edit a local kill file applied to the current newsgroup."
10281 (setq gnus-current-headers (gnus-summary-article-header))
10282 (gnus-group-edit-local-kill
10283 (gnus-summary-article-number) gnus-newsgroup-name))
10285 ;;; Header reading.
10287 (defun gnus-read-header (id &optional header)
10288 "Read the headers of article ID and enter them into the Gnus system."
10289 (let ((group gnus-newsgroup-name)
10290 (gnus-override-method
10292 gnus-override-method
10293 (and (gnus-news-group-p gnus-newsgroup-name)
10294 (car (gnus-refer-article-methods)))))
10296 ;; First we check to see whether the header in question is already
10299 ;; This is a Message-ID.
10300 (setq header (or header (gnus-id-to-header id)))
10301 ;; This is an article number.
10302 (setq header (or header (gnus-summary-article-header id))))
10304 (not (gnus-summary-article-sparse-p (mail-header-number header))))
10305 ;; We have found the header.
10307 ;; If this is a sparse article, we have to nix out its
10308 ;; previous entry in the thread hashtb.
10310 (gnus-summary-article-sparse-p (mail-header-number header)))
10311 (let* ((parent (gnus-parent-id (mail-header-references header)))
10312 (thread (and parent (gnus-id-to-thread parent))))
10314 (delq (assq header thread) thread))))
10315 ;; We have to really fetch the header to this article.
10317 (set-buffer nntp-server-buffer)
10318 (when (setq where (gnus-request-head id group))
10319 (nnheader-fold-continuation-lines)
10320 (goto-char (point-max))
10322 (goto-char (point-min))
10326 ((cdr where) (cdr where))
10327 (header (mail-header-number header))
10328 (t gnus-reffed-article-number))
10330 (insert " Article retrieved.\n"))
10331 (if (or (not where)
10332 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
10333 () ; Malformed head.
10334 (unless (gnus-summary-article-sparse-p (mail-header-number header))
10335 (when (and (stringp id)
10336 (not (string= (gnus-group-real-name group)
10338 ;; If we fetched by Message-ID and the article came
10339 ;; from a different group, we fudge some bogus article
10340 ;; numbers for this article.
10341 (mail-header-set-number header gnus-reffed-article-number))
10343 (set-buffer gnus-summary-buffer)
10344 (decf gnus-reffed-article-number)
10345 (gnus-remove-header (mail-header-number header))
10346 (push header gnus-newsgroup-headers)
10347 (setq gnus-current-headers header)
10348 (push (mail-header-number header) gnus-newsgroup-limit)))
10351 (defun gnus-remove-header (number)
10352 "Remove header NUMBER from `gnus-newsgroup-headers'."
10353 (if (and gnus-newsgroup-headers
10354 (= number (mail-header-number (car gnus-newsgroup-headers))))
10355 (pop gnus-newsgroup-headers)
10356 (let ((headers gnus-newsgroup-headers))
10357 (while (and (cdr headers)
10358 (not (= number (mail-header-number (cadr headers)))))
10360 (when (cdr headers)
10361 (setcdr headers (cddr headers))))))
10364 ;;; summary highlights
10367 (defun gnus-highlight-selected-summary ()
10368 "Highlight selected article in summary buffer."
10369 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
10370 (when gnus-summary-selected-face
10372 (let* ((beg (progn (beginning-of-line) (point)))
10373 (end (progn (end-of-line) (point)))
10374 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
10375 (from (if (get-text-property beg gnus-mouse-face-prop)
10377 (or (next-single-property-change
10378 beg gnus-mouse-face-prop nil end)
10383 (or (next-single-property-change
10384 from gnus-mouse-face-prop nil end)
10386 ;; If no mouse-face prop on line we will have to = from = end,
10387 ;; so we highlight the entire line instead.
10388 (when (= (+ to 2) from)
10391 (if gnus-newsgroup-selected-overlay
10392 ;; Move old overlay.
10394 gnus-newsgroup-selected-overlay from to (current-buffer))
10395 ;; Create new overlay.
10397 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
10398 'face gnus-summary-selected-face))))))
10400 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
10401 (defun gnus-summary-highlight-line ()
10402 "Highlight current line according to `gnus-summary-highlight'."
10403 (let* ((list gnus-summary-highlight)
10405 (end (progn (end-of-line) (point)))
10406 ;; now find out where the line starts and leave point there.
10407 (beg (progn (beginning-of-line) (point)))
10408 (article (gnus-summary-article-number))
10409 (score (or (cdr (assq (or article gnus-current-article)
10410 gnus-newsgroup-scored))
10411 gnus-summary-default-score 0))
10412 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
10413 (inhibit-read-only t))
10414 ;; Eval the cars of the lists until we find a match.
10415 (let ((default gnus-summary-default-score)
10416 (default-high gnus-summary-default-high-score)
10417 (default-low gnus-summary-default-low-score))
10419 (not (eval (caar list))))
10420 (setq list (cdr list))))
10421 (let ((face (cdar list)))
10422 (unless (eq face (get-text-property beg 'face))
10423 (gnus-put-text-property-excluding-characters-with-faces
10425 (setq face (if (boundp face) (symbol-value face) face)))
10426 (when gnus-summary-highlight-line-function
10427 (funcall gnus-summary-highlight-line-function article face))))
10430 (defun gnus-update-read-articles (group unread &optional compute)
10431 "Update the list of read articles in GROUP."
10432 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
10433 (entry (gnus-gethash group gnus-newsrc-hashtb))
10434 (info (nth 2 entry))
10436 (unread (sort (copy-sequence unread) '<))
10438 (if (or (not info) (not active))
10439 ;; There is no info on this group if it was, in fact,
10440 ;; killed. Gnus stores no information on killed groups, so
10441 ;; there's nothing to be done.
10442 ;; One could store the information somewhere temporarily,
10443 ;; perhaps... Hmmm...
10445 ;; Remove any negative articles numbers.
10446 (while (and unread (< (car unread) 0))
10447 (setq unread (cdr unread)))
10448 ;; Remove any expired article numbers
10449 (while (and unread (< (car unread) (car active)))
10450 (setq unread (cdr unread)))
10451 ;; Compute the ranges of read articles by looking at the list of
10452 ;; unread articles.
10454 (when (/= (car unread) prev)
10455 (push (if (= prev (1- (car unread))) prev
10456 (cons prev (1- (car unread))))
10458 (setq prev (1+ (car unread)))
10459 (setq unread (cdr unread)))
10460 (when (<= prev (cdr active))
10461 (push (cons prev (cdr active)) read))
10462 (setq read (if (> (length read) 1) (nreverse read) read))
10467 ;; Propagate the read marks to the backend.
10468 (when (gnus-check-backend-function 'request-set-mark group)
10469 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
10470 (add (gnus-remove-from-range read (gnus-info-read info))))
10472 (unless (gnus-check-group group)
10473 (error "Can't open server for %s" group))
10474 (gnus-request-set-mark
10475 group (delq nil (list (if add (list add 'add '(read)))
10476 (if del (list del 'del '(read))))))
10478 `(gnus-request-set-mark
10481 (if del (list del 'add '(read)))
10482 (if add (list add 'del '(read))))))))))
10483 (set-buffer gnus-group-buffer)
10484 (gnus-undo-register
10486 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
10487 (gnus-info-set-read ',info ',(gnus-info-read info))
10488 (gnus-get-unread-articles-in-group ',info
10489 (gnus-active ,group))
10490 (gnus-group-update-group ,group t)
10492 ;; Enter this list into the group info.
10493 (gnus-info-set-read info read)
10494 ;; Set the number of unread articles in gnus-newsrc-hashtb.
10495 (gnus-get-unread-articles-in-group info (gnus-active group))
10498 (defun gnus-offer-save-summaries ()
10499 "Offer to save all active summary buffers."
10501 ;; Go through all buffers and find all summaries.
10502 (dolist (buffer (buffer-list))
10503 (when (and (setq buffer (buffer-name buffer))
10504 (string-match "Summary" buffer)
10506 (set-buffer buffer)
10507 ;; We check that this is, indeed, a summary buffer.
10508 (and (eq major-mode 'gnus-summary-mode)
10509 ;; Also make sure this isn't bogus.
10510 gnus-newsgroup-prepared
10511 ;; Also make sure that this isn't a
10512 ;; dead summary buffer.
10513 (not gnus-dead-summary-mode))))
10514 (push buffer buffers)))
10515 ;; Go through all these summary buffers and offer to save them.
10519 "Update summary buffer %s? "
10521 (switch-to-buffer buf)
10522 (gnus-summary-exit))
10525 (defun gnus-summary-setup-default-charset ()
10526 "Setup newsgroup default charset."
10527 (if (equal gnus-newsgroup-name "nndraft:drafts")
10528 (setq gnus-newsgroup-charset nil)
10529 (let* ((ignored-charsets
10530 (or gnus-newsgroup-ephemeral-ignored-charsets
10532 (and gnus-newsgroup-name
10533 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
10534 gnus-newsgroup-ignored-charsets))))
10535 (setq gnus-newsgroup-charset
10536 (or gnus-newsgroup-ephemeral-charset
10537 (and gnus-newsgroup-name
10538 (gnus-parameter-charset gnus-newsgroup-name))
10539 gnus-default-charset))
10540 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
10541 ignored-charsets))))
10547 (defun gnus-summary-display-buttonized (&optional show-all-parts)
10548 "Display the current article buffer fully MIME-buttonized.
10549 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
10550 treated as multipart/mixed."
10552 (require 'gnus-art)
10553 (let ((gnus-unbuttonized-mime-types nil)
10554 (gnus-mime-display-multipart-as-mixed show-all-parts))
10555 (gnus-summary-show-article)))
10557 (defun gnus-summary-repair-multipart (article)
10558 "Add a Content-Type header to a multipart article without one."
10559 (interactive (list (gnus-summary-article-number)))
10560 (gnus-with-article article
10561 (message-narrow-to-head)
10562 (message-remove-header "Mime-Version")
10563 (goto-char (point-max))
10564 (insert "Mime-Version: 1.0\n")
10566 (when (search-forward "\n--" nil t)
10567 (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
10568 (message-narrow-to-head)
10569 (message-remove-header "Content-Type")
10570 (goto-char (point-max))
10571 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
10574 (let (gnus-mark-article-hook)
10575 (gnus-summary-select-article t t nil article)))
10577 (defun gnus-summary-toggle-display-buttonized ()
10578 "Toggle the buttonizing of the article buffer."
10580 (require 'gnus-art)
10581 (if (setq gnus-inhibit-mime-unbuttonizing
10582 (not gnus-inhibit-mime-unbuttonizing))
10583 (let ((gnus-unbuttonized-mime-types nil))
10584 (gnus-summary-show-article))
10585 (gnus-summary-show-article)))
10588 ;;; Generic summary marking commands
10591 (defvar gnus-summary-marking-alist
10592 '((read gnus-del-mark "d")
10593 (unread gnus-unread-mark "u")
10594 (ticked gnus-ticked-mark "!")
10595 (dormant gnus-dormant-mark "?")
10596 (expirable gnus-expirable-mark "e"))
10597 "An alist of names/marks/keystrokes.")
10599 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
10600 (defvar gnus-summary-mark-map)
10602 (defun gnus-summary-make-all-marking-commands ()
10603 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
10604 (dolist (elem gnus-summary-marking-alist)
10605 (apply 'gnus-summary-make-marking-command elem)))
10607 (defun gnus-summary-make-marking-command (name mark keystroke)
10608 (let ((map (make-sparse-keymap)))
10609 (define-key gnus-summary-generic-mark-map keystroke map)
10610 (dolist (lway `((next "next" next nil "n")
10611 (next-unread "next unread" next t "N")
10612 (prev "previous" prev nil "p")
10613 (prev-unread "previous unread" prev t "P")
10614 (nomove "" nil nil ,keystroke)))
10615 (let ((func (gnus-summary-make-marking-command-1
10616 mark (car lway) lway name)))
10617 (setq func (eval func))
10618 (define-key map (nth 4 lway) func)))))
10620 (defun gnus-summary-make-marking-command-1 (mark way lway name)
10622 (format "gnus-summary-put-mark-as-%s%s"
10623 name (if (eq way 'nomove)
10625 (concat "-" (symbol-name way)))))
10628 "Mark the current article as %s%s.
10629 If N, the prefix, then repeat N times.
10630 If N is negative, move in reverse order.
10631 The difference between N and the actual number of articles marked is
10635 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
10637 (defun gnus-summary-generic-mark (n mark move unread)
10638 "Mark N articles with MARK."
10639 (unless (eq major-mode 'gnus-summary-mode)
10640 (error "This command can only be used in the summary buffer"))
10641 (gnus-summary-show-thread)
10644 ((eq move 'next) 1)
10645 ((eq move 'prev) -1)
10647 (if (zerop nummove)
10651 nummove (* -1 nummove))))
10652 (while (and (> n 0)
10653 (gnus-summary-mark-article nil mark)
10654 (zerop (gnus-summary-next-subject nummove unread t)))
10657 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
10658 (gnus-summary-recenter)
10659 (gnus-summary-position-point)
10660 (gnus-set-mode-line 'summary)
10663 (defun gnus-summary-insert-articles (articles)
10664 (when (setq articles
10665 (gnus-set-difference articles
10666 (mapcar (lambda (h) (mail-header-number h))
10667 gnus-newsgroup-headers)))
10668 (setq gnus-newsgroup-headers
10670 gnus-newsgroup-headers
10671 (gnus-fetch-headers articles)
10672 'gnus-article-sort-by-number))
10673 ;; Suppress duplicates?
10674 (when gnus-suppress-duplicates
10675 (gnus-dup-suppress-articles))
10677 ;; We might want to build some more threads first.
10678 (when (and gnus-fetch-old-headers
10679 (eq gnus-headers-retrieved-by 'nov))
10680 (if (eq gnus-fetch-old-headers 'invisible)
10681 (gnus-build-all-threads)
10682 (gnus-build-old-threads)))
10683 ;; Let the Gnus agent mark articles as read.
10685 (gnus-agent-get-undownloaded-list))
10686 ;; Remove list identifiers from subject
10687 (when gnus-list-identifiers
10688 (gnus-summary-remove-list-identifiers))
10689 ;; First and last article in this newsgroup.
10690 (when gnus-newsgroup-headers
10691 (setq gnus-newsgroup-begin
10692 (mail-header-number (car gnus-newsgroup-headers))
10694 (mail-header-number
10695 (gnus-last-element gnus-newsgroup-headers))))
10696 (when gnus-use-scoring
10697 (gnus-possibly-score-headers))))
10699 (defun gnus-summary-insert-old-articles (&optional all)
10700 "Insert all old articles in this group.
10701 If ALL is non-nil, already read articles become readable.
10702 If ALL is a number, fetch this number of articles."
10705 (let ((old (mapcar 'car gnus-newsgroup-data))
10706 (i (car gnus-newsgroup-active))
10708 (while (<= i (cdr gnus-newsgroup-active))
10709 (or (memq i old) (push i older))
10711 (setq len (length older))
10716 (setq older (subseq older 0 all))))
10719 (if (and (numberp gnus-large-newsgroup)
10720 (> len gnus-large-newsgroup))
10724 "How many articles from %s (default %d): "
10726 (gnus-group-decoded-name gnus-newsgroup-name) 35)
10728 (unless (string-match "^[ \t]*$" input)
10729 (setq all (string-to-number input))
10731 (setq older (subseq older 0 all))))))))
10733 (message "No old news.")
10734 (gnus-summary-insert-articles older)
10735 (gnus-summary-limit (gnus-union older old))))
10736 (gnus-summary-position-point)))
10738 (defun gnus-summary-insert-new-articles ()
10739 "Insert all new articles in this group."
10742 (let ((old (mapcar 'car gnus-newsgroup-data))
10743 (old-active gnus-newsgroup-active)
10744 (nnmail-fetched-sources (list t))
10746 (setq gnus-newsgroup-active
10747 (gnus-activate-group gnus-newsgroup-name 'scan))
10748 (setq i (1+ (cdr old-active)))
10749 (while (<= i (cdr gnus-newsgroup-active))
10753 (message "No gnus is bad news.")
10754 (setq new (nreverse new))
10755 (gnus-summary-insert-articles new)
10756 (setq gnus-newsgroup-unreads
10757 (append gnus-newsgroup-unreads new))
10758 (gnus-summary-limit (gnus-union old new))))
10759 (gnus-summary-position-point)))
10761 (gnus-summary-make-all-marking-commands)
10763 (gnus-ems-redefine)
10765 (provide 'gnus-sum)
10767 (run-hooks 'gnus-sum-load-hook)
10769 ;;; gnus-sum.el ends here