1 ;;; gnus-sum.el --- summary mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
29 (eval-when-compile (require 'cl))
40 ;; (require 'gnus-art)
42 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
43 (autoload 'gnus-cache-write-active "gnus-cache")
44 (autoload 'gnus-mailing-list-insinuate "gnus-ml" nil t)
45 (autoload 'turn-on-gnus-mailing-list-mode "gnus-ml" nil t)
46 (autoload 'mm-uu-dissect "mm-uu")
48 (defcustom gnus-kill-summary-on-exit t
49 "*If non-nil, kill the summary buffer when you exit from it.
50 If nil, the summary will become a \"*Dead Summary*\" buffer, and
51 it will be killed sometime later."
52 :group 'gnus-summary-exit
55 (defcustom gnus-fetch-old-headers nil
56 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
57 If an unread article in the group refers to an older, already read (or
58 just marked as read) article, the old article will not normally be
59 displayed in the Summary buffer. If this variable is non-nil, Gnus
60 will attempt to grab the headers to the old articles, and thereby
61 build complete threads. If it has the value `some', only enough
62 headers to connect otherwise loose threads will be displayed. This
63 variable can also be a number. In that case, no more than that number
64 of old headers will be fetched. If it has the value `invisible', all
65 old headers will be fetched, but none will be displayed.
67 The server has to support NOV for any of this to work."
69 :type '(choice (const :tag "off" nil)
72 (sexp :menu-tag "other" t)))
74 (defcustom gnus-refer-thread-limit 200
75 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
76 If t, fetch all the available old headers."
79 (sexp :menu-tag "other" t)))
81 (defcustom gnus-summary-make-false-root 'adopt
82 "*nil means that Gnus won't gather loose threads.
83 If the root of a thread has expired or been read in a previous
84 session, the information necessary to build a complete thread has been
85 lost. Instead of having many small sub-threads from this original thread
86 scattered all over the summary buffer, Gnus can gather them.
88 If non-nil, Gnus will try to gather all loose sub-threads from an
89 original thread into one large thread.
91 If this variable is non-nil, it should be one of `none', `adopt',
94 If this variable is `none', Gnus will not make a false root, but just
95 present the sub-threads after another.
96 If this variable is `dummy', Gnus will create a dummy root that will
97 have all the sub-threads as children.
98 If this variable is `adopt', Gnus will make one of the \"children\"
99 the parent and mark all the step-children as such.
100 If this variable is `empty', the \"children\" are printed with empty
101 subject fields. (Or rather, they will be printed with a string
102 given by the `gnus-summary-same-subject' variable.)"
104 :type '(choice (const :tag "off" nil)
110 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
111 "*A regexp to match subjects to be excluded from loose thread gathering.
112 As loose thread gathering is done on subjects only, that means that
113 there can be many false gatherings performed. By rooting out certain
114 common subjects, gathering might become saner."
118 (defcustom gnus-summary-gather-subject-limit nil
119 "*Maximum length of subject comparisons when gathering loose threads.
120 Use nil to compare full subjects. Setting this variable to a low
121 number will help gather threads that have been corrupted by
122 newsreaders chopping off subject lines, but it might also mean that
123 unrelated articles that have subject that happen to begin with the
124 same few characters will be incorrectly gathered.
126 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
129 :type '(choice (const :tag "off" nil)
131 (sexp :menu-tag "on" t)))
133 (defcustom gnus-simplify-subject-functions nil
134 "List of functions taking a string argument that simplify subjects.
135 The functions are applied recursively.
137 Useful functions to put in this list include: `gnus-simplify-subject-re',
138 `gnus-simplify-subject-fuzzy' and `gnus-simplify-whitespace'."
140 :type '(repeat function))
142 (defcustom gnus-simplify-ignored-prefixes nil
143 "*Regexp, matches for which are removed from subject lines when simplifying fuzzily."
145 :type '(choice (const :tag "off" nil)
148 (defcustom gnus-build-sparse-threads nil
149 "*If non-nil, fill in the gaps in threads.
150 If `some', only fill in the gaps that are needed to tie loose threads
151 together. If `more', fill in all leaf nodes that Gnus can find. If
152 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
154 :type '(choice (const :tag "off" nil)
157 (sexp :menu-tag "all" t)))
159 (defcustom gnus-summary-thread-gathering-function
160 'gnus-gather-threads-by-subject
161 "*Function used for gathering loose threads.
162 There are two pre-defined functions: `gnus-gather-threads-by-subject',
163 which only takes Subjects into consideration; and
164 `gnus-gather-threads-by-references', which compared the References
165 headers of the articles to find matches."
167 :type '(radio (function-item gnus-gather-threads-by-subject)
168 (function-item gnus-gather-threads-by-references)
169 (function :tag "other")))
171 (defcustom gnus-summary-same-subject ""
172 "*String indicating that the current article has the same subject as the previous.
173 This variable will only be used if the value of
174 `gnus-summary-make-false-root' is `empty'."
175 :group 'gnus-summary-format
178 (defcustom gnus-summary-goto-unread t
179 "*If t, many commands will go to the next unread article.
180 This applies to marking commands as well as other commands that
181 \"naturally\" select the next article, like, for instance, `SPC' at
182 the end of an article.
184 If nil, the marking commands do NOT go to the next unread article
185 (they go to the next article instead). If `never', commands that
186 usually go to the next unread article, will go to the next article,
187 whether it is read or not."
188 :group 'gnus-summary-marks
189 :link '(custom-manual "(gnus)Setting Marks")
190 :type '(choice (const :tag "off" nil)
192 (sexp :menu-tag "on" t)))
194 (defcustom gnus-summary-default-score 0
195 "*Default article score level.
196 All scores generated by the score files will be added to this score.
197 If this variable is nil, scoring will be disabled."
198 :group 'gnus-score-default
199 :type '(choice (const :tag "disable")
202 (defcustom gnus-summary-default-high-score 0
203 "*Default threshold for a high scored article.
204 An article will be highlighted as high scored if its score is greater
206 :group 'gnus-score-default
209 (defcustom gnus-summary-default-low-score 0
210 "*Default threshold for a low scored article.
211 An article will be highlighted as low scored if its score is smaller
213 :group 'gnus-score-default
216 (defcustom gnus-summary-zcore-fuzz 0
217 "*Fuzziness factor for the zcore in the summary buffer.
218 Articles with scores closer than this to `gnus-summary-default-score'
220 :group 'gnus-summary-format
223 (defcustom gnus-simplify-subject-fuzzy-regexp nil
224 "*Strings to be removed when doing fuzzy matches.
225 This can either be a regular expression or list of regular expressions
226 that will be removed from subject strings if fuzzy subject
227 simplification is selected."
229 :type '(repeat regexp))
231 (defcustom gnus-show-threads t
232 "*If non-nil, display threads in summary mode."
236 (defcustom gnus-thread-hide-subtree nil
237 "*If non-nil, hide all threads initially.
238 If threads are hidden, you have to run the command
239 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
240 to expose hidden threads."
244 (defcustom gnus-thread-hide-killed t
245 "*If non-nil, hide killed threads automatically."
249 (defcustom gnus-thread-ignore-subject t
250 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
251 If nil, articles that have different subjects from their parents will
252 start separate threads."
256 (defcustom gnus-thread-operation-ignore-subject t
257 "*If non-nil, subjects will be ignored when doing thread commands.
258 This affects commands like `gnus-summary-kill-thread' and
259 `gnus-summary-lower-thread'.
261 If this variable is nil, articles in the same thread with different
262 subjects will not be included in the operation in question. If this
263 variable is `fuzzy', only articles that have subjects that are fuzzily
264 equal will be included."
266 :type '(choice (const :tag "off" nil)
270 (defcustom gnus-thread-indent-level 4
271 "*Number that says how much each sub-thread should be indented."
275 (defcustom gnus-auto-extend-newsgroup t
276 "*If non-nil, extend newsgroup forward and backward when requested."
277 :group 'gnus-summary-choose
280 (defcustom gnus-auto-select-first t
281 "*If nil, don't select the first unread article when entering a group.
282 If this variable is `best', select the highest-scored unread article
283 in the group. If t, select the first unread article.
285 This variable can also be a function to place point on a likely
286 subject line. Useful values include `gnus-summary-first-unread-subject',
287 `gnus-summary-first-unread-article' and
288 `gnus-summary-best-unread-article'.
290 If you want to prevent automatic selection of the first unread article
291 in some newsgroups, set the variable to nil in
292 `gnus-select-group-hook'."
293 :group 'gnus-group-select
294 :type '(choice (const :tag "none" nil)
296 (sexp :menu-tag "first" t)
297 (function-item gnus-summary-first-unread-subject)
298 (function-item gnus-summary-first-unread-article)
299 (function-item gnus-summary-best-unread-article)))
301 (defcustom gnus-auto-select-next t
302 "*If non-nil, offer to go to the next group from the end of the previous.
303 If the value is t and the next newsgroup is empty, Gnus will exit
304 summary mode and go back to group mode. If the value is neither nil
305 nor t, Gnus will select the following unread newsgroup. In
306 particular, if the value is the symbol `quietly', the next unread
307 newsgroup will be selected without any confirmation, and if it is
308 `almost-quietly', the next group will be selected without any
309 confirmation if you are located on the last article in the group.
310 Finally, if this variable is `slightly-quietly', the `Z n' command
311 will go to the next group without confirmation."
312 :group 'gnus-summary-maneuvering
313 :type '(choice (const :tag "off" nil)
315 (const almost-quietly)
316 (const slightly-quietly)
317 (sexp :menu-tag "on" t)))
319 (defcustom gnus-auto-select-same nil
320 "*If non-nil, select the next article with the same subject.
321 If there are no more articles with the same subject, go to
322 the first unread article."
323 :group 'gnus-summary-maneuvering
326 (defcustom gnus-summary-check-current nil
327 "*If non-nil, consider the current article when moving.
328 The \"unread\" movement commands will stay on the same line if the
329 current article is unread."
330 :group 'gnus-summary-maneuvering
333 (defcustom gnus-auto-center-summary t
334 "*If non-nil, always center the current summary buffer.
335 In particular, if `vertical' do only vertical recentering. If non-nil
336 and non-`vertical', do both horizontal and vertical recentering."
337 :group 'gnus-summary-maneuvering
338 :type '(choice (const :tag "none" nil)
340 (integer :tag "height")
341 (sexp :menu-tag "both" t)))
343 (defcustom gnus-show-all-headers nil
344 "*If non-nil, don't hide any headers."
345 :group 'gnus-article-hiding
346 :group 'gnus-article-headers
349 (defcustom gnus-summary-ignore-duplicates nil
350 "*If non-nil, ignore articles with identical Message-ID headers."
354 (defcustom gnus-single-article-buffer t
355 "*If non-nil, display all articles in the same buffer.
356 If nil, each group will get its own article buffer."
357 :group 'gnus-article-various
360 (defcustom gnus-break-pages t
361 "*If non-nil, do page breaking on articles.
362 The page delimiter is specified by the `gnus-page-delimiter'
364 :group 'gnus-article-various
367 (defcustom gnus-move-split-methods nil
368 "*Variable used to suggest where articles are to be moved to.
369 It uses the same syntax as the `gnus-split-methods' variable.
370 However, whereas `gnus-split-methods' specifies file names as targets,
371 this variable specifies group names."
372 :group 'gnus-summary-mail
373 :type '(repeat (choice (list :value (fun) function)
374 (cons :value ("" "") regexp (repeat string))
377 (defcustom gnus-unread-mark ? ;Whitespace
378 "*Mark used for unread articles."
379 :group 'gnus-summary-marks
382 (defcustom gnus-ticked-mark ?!
383 "*Mark used for ticked articles."
384 :group 'gnus-summary-marks
387 (defcustom gnus-dormant-mark ??
388 "*Mark used for dormant articles."
389 :group 'gnus-summary-marks
392 (defcustom gnus-del-mark ?r
393 "*Mark used for del'd articles."
394 :group 'gnus-summary-marks
397 (defcustom gnus-read-mark ?R
398 "*Mark used for read articles."
399 :group 'gnus-summary-marks
402 (defcustom gnus-expirable-mark ?E
403 "*Mark used for expirable articles."
404 :group 'gnus-summary-marks
407 (defcustom gnus-killed-mark ?K
408 "*Mark used for killed articles."
409 :group 'gnus-summary-marks
412 (defcustom gnus-souped-mark ?F
413 "*Mark used for souped articles."
414 :group 'gnus-summary-marks
417 (defcustom gnus-kill-file-mark ?X
418 "*Mark used for articles killed by kill files."
419 :group 'gnus-summary-marks
422 (defcustom gnus-low-score-mark ?Y
423 "*Mark used for articles with a low score."
424 :group 'gnus-summary-marks
427 (defcustom gnus-catchup-mark ?C
428 "*Mark used for articles that are caught up."
429 :group 'gnus-summary-marks
432 (defcustom gnus-replied-mark ?A
433 "*Mark used for articles that have been replied to."
434 :group 'gnus-summary-marks
437 (defcustom gnus-forwarded-mark ?F
438 "*Mark used for articles that have been forwarded."
439 :group 'gnus-summary-marks
442 (defcustom gnus-recent-mark ?N
443 "*Mark used for articles that are recent."
444 :group 'gnus-summary-marks
447 (defcustom gnus-cached-mark ?*
448 "*Mark used for articles that are in the cache."
449 :group 'gnus-summary-marks
452 (defcustom gnus-saved-mark ?S
453 "*Mark used for articles that have been saved."
454 :group 'gnus-summary-marks
457 (defcustom gnus-unseen-mark ?.
458 "*Mark used for articles that haven't been seen."
459 :group 'gnus-summary-marks
462 (defcustom gnus-no-mark ? ;Whitespace
463 "*Mark used for articles that have no other secondary mark."
464 :group 'gnus-summary-marks
467 (defcustom gnus-ancient-mark ?O
468 "*Mark used for ancient articles."
469 :group 'gnus-summary-marks
472 (defcustom gnus-sparse-mark ?Q
473 "*Mark used for sparsely reffed articles."
474 :group 'gnus-summary-marks
477 (defcustom gnus-canceled-mark ?G
478 "*Mark used for canceled articles."
479 :group 'gnus-summary-marks
482 (defcustom gnus-duplicate-mark ?M
483 "*Mark used for duplicate articles."
484 :group 'gnus-summary-marks
487 (defcustom gnus-undownloaded-mark ?@
488 "*Mark used for articles that weren't downloaded."
489 :group 'gnus-summary-marks
492 (defcustom gnus-downloadable-mark ?%
493 "*Mark used for articles that are to be downloaded."
494 :group 'gnus-summary-marks
497 (defcustom gnus-unsendable-mark ?=
498 "*Mark used for articles that won't be sent."
499 :group 'gnus-summary-marks
502 (defcustom gnus-score-over-mark ?+
503 "*Score mark used for articles with high scores."
504 :group 'gnus-summary-marks
507 (defcustom gnus-score-below-mark ?-
508 "*Score mark used for articles with low scores."
509 :group 'gnus-summary-marks
512 (defcustom gnus-empty-thread-mark ? ;Whitespace
513 "*There is no thread under the article."
514 :group 'gnus-summary-marks
517 (defcustom gnus-not-empty-thread-mark ?=
518 "*There is a thread under the article."
519 :group 'gnus-summary-marks
522 (defcustom gnus-view-pseudo-asynchronously nil
523 "*If non-nil, Gnus will view pseudo-articles asynchronously."
524 :group 'gnus-extract-view
527 (defcustom gnus-auto-expirable-marks
528 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
529 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
530 gnus-souped-mark gnus-duplicate-mark)
531 "*The list of marks converted into expiration if a group is auto-expirable."
534 :type '(repeat character))
536 (defcustom gnus-inhibit-user-auto-expire t
537 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
542 (defcustom gnus-view-pseudos nil
543 "*If `automatic', pseudo-articles will be viewed automatically.
544 If `not-confirm', pseudos will be viewed automatically, and the user
545 will not be asked to confirm the command."
546 :group 'gnus-extract-view
547 :type '(choice (const :tag "off" nil)
549 (const not-confirm)))
551 (defcustom gnus-view-pseudos-separately t
552 "*If non-nil, one pseudo-article will be created for each file to be viewed.
553 If nil, all files that use the same viewing command will be given as a
554 list of parameters to that command."
555 :group 'gnus-extract-view
558 (defcustom gnus-insert-pseudo-articles t
559 "*If non-nil, insert pseudo-articles when decoding articles."
560 :group 'gnus-extract-view
563 (defcustom gnus-summary-dummy-line-format
565 "*The format specification for the dummy roots in the summary buffer.
566 It works along the same lines as a normal formatting string,
567 with some simple extensions.
570 :group 'gnus-threading
573 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
574 "*The format specification for the summary mode line.
575 It works along the same lines as a normal formatting string,
576 with some simple extensions:
579 %p Unprefixed group name
580 %A Current article number
581 %z Current article score
583 %U Number of unread articles in the group
584 %e Number of unselected articles in the group
585 %Z A string with unread/unselected article counts
586 %g Shortish group name
587 %S Subject of the current article
589 %s Current score file name
590 %d Number of dormant articles
591 %r Number of articles that have been marked as read in this session
592 %E Number of articles expunged by the score files"
593 :group 'gnus-summary-format
596 (defcustom gnus-list-identifiers nil
597 "Regexp that matches list identifiers to be removed from subject.
598 This can also be a list of regexps."
600 :group 'gnus-summary-format
601 :group 'gnus-article-hiding
602 :type '(choice (const :tag "none" nil)
604 (repeat :value (".*") regexp)))
606 (defcustom gnus-summary-mark-below 0
607 "*Mark all articles with a score below this variable as read.
608 This variable is local to each summary buffer and usually set by the
610 :group 'gnus-score-default
613 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
614 "*List of functions used for sorting articles in the summary buffer.
616 Each function takes two articles and returns non-nil if the first
617 article should be sorted before the other. If you use more than one
618 function, the primary sort function should be the last. You should
619 probably always include `gnus-article-sort-by-number' in the list of
620 sorting functions -- preferably first. Also note that sorting by date
621 is often much slower than sorting by number, and the sorting order is
622 very similar. (Sorting by date means sorting by the time the message
623 was sent, sorting by number means sorting by arrival time.)
625 Ready-made functions include `gnus-article-sort-by-number',
626 `gnus-article-sort-by-author', `gnus-article-sort-by-subject',
627 `gnus-article-sort-by-date' and `gnus-article-sort-by-score'.
629 When threading is turned on, the variable `gnus-thread-sort-functions'
630 controls how articles are sorted."
631 :group 'gnus-summary-sort
632 :type '(repeat (choice (function-item gnus-article-sort-by-number)
633 (function-item gnus-article-sort-by-author)
634 (function-item gnus-article-sort-by-subject)
635 (function-item gnus-article-sort-by-date)
636 (function-item gnus-article-sort-by-score)
637 (function :tag "other"))))
639 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
640 "*List of functions used for sorting threads in the summary buffer.
641 By default, threads are sorted by article number.
643 Each function takes two threads and returns non-nil if the first
644 thread should be sorted before the other. If you use more than one
645 function, the primary sort function should be the last. You should
646 probably always include `gnus-thread-sort-by-number' in the list of
647 sorting functions -- preferably first. Also note that sorting by date
648 is often much slower than sorting by number, and the sorting order is
649 very similar. (Sorting by date means sorting by the time the message
650 was sent, sorting by number means sorting by arrival time.)
652 Ready-made functions include `gnus-thread-sort-by-number',
653 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
654 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
655 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').
657 When threading is turned off, the variable
658 `gnus-article-sort-functions' controls how articles are sorted."
659 :group 'gnus-summary-sort
660 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
661 (function-item gnus-thread-sort-by-author)
662 (function-item gnus-thread-sort-by-subject)
663 (function-item gnus-thread-sort-by-date)
664 (function-item gnus-thread-sort-by-score)
665 (function-item gnus-thread-sort-by-total-score)
666 (function :tag "other"))))
668 (defcustom gnus-thread-score-function '+
669 "*Function used for calculating the total score of a thread.
671 The function is called with the scores of the article and each
672 subthread and should then return the score of the thread.
674 Some functions you can use are `+', `max', or `min'."
675 :group 'gnus-summary-sort
678 (defcustom gnus-summary-expunge-below nil
679 "All articles that have a score less than this variable will be expunged.
680 This variable is local to the summary buffers."
681 :group 'gnus-score-default
682 :type '(choice (const :tag "off" nil)
685 (defcustom gnus-thread-expunge-below nil
686 "All threads that have a total score less than this variable will be expunged.
687 See `gnus-thread-score-function' for en explanation of what a
690 This variable is local to the summary buffers."
691 :group 'gnus-threading
692 :group 'gnus-score-default
693 :type '(choice (const :tag "off" nil)
696 (defcustom gnus-summary-mode-hook nil
697 "*A hook for Gnus summary mode.
698 This hook is run before any variables are set in the summary buffer."
699 :options '(turn-on-gnus-mailing-list-mode gnus-pick-mode)
700 :group 'gnus-summary-various
703 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
704 (when (featurep 'xemacs)
705 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
706 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
707 (add-hook 'gnus-summary-mode-hook
708 'gnus-xmas-switch-horizontal-scrollbar-off))
710 (defcustom gnus-summary-menu-hook nil
711 "*Hook run after the creation of the summary mode menu."
712 :group 'gnus-summary-visual
715 (defcustom gnus-summary-exit-hook nil
716 "*A hook called on exit from the summary buffer.
717 It will be called with point in the group buffer."
718 :group 'gnus-summary-exit
721 (defcustom gnus-summary-prepare-hook nil
722 "*A hook called after the summary buffer has been generated.
723 If you want to modify the summary buffer, you can use this hook."
724 :group 'gnus-summary-various
727 (defcustom gnus-summary-prepared-hook nil
728 "*A hook called as the last thing after the summary buffer has been generated."
729 :group 'gnus-summary-various
732 (defcustom gnus-summary-generate-hook nil
733 "*A hook run just before generating the summary buffer.
734 This hook is commonly used to customize threading variables and the
736 :group 'gnus-summary-various
739 (defcustom gnus-select-group-hook nil
740 "*A hook called when a newsgroup is selected.
742 If you'd like to simplify subjects like the
743 `gnus-summary-next-same-subject' command does, you can use the
746 (setq gnus-select-group-hook
749 (mapcar (lambda (header)
750 (mail-header-set-subject
752 (gnus-simplify-subject
753 (mail-header-subject header) 're-only)))
754 gnus-newsgroup-headers))))"
755 :group 'gnus-group-select
758 (defcustom gnus-select-article-hook nil
759 "*A hook called when an article is selected."
760 :group 'gnus-summary-choose
763 (defcustom gnus-visual-mark-article-hook
764 (list 'gnus-highlight-selected-summary)
765 "*Hook run after selecting an article in the summary buffer.
766 It is meant to be used for highlighting the article in some way. It
767 is not run if `gnus-visual' is nil."
768 :group 'gnus-summary-visual
771 (defcustom gnus-parse-headers-hook nil
772 "*A hook called before parsing the headers."
776 (defcustom gnus-exit-group-hook nil
777 "*A hook called when exiting summary mode.
778 This hook is not called from the non-updating exit commands like `Q'."
782 (defcustom gnus-summary-update-hook
783 (list 'gnus-summary-highlight-line)
784 "*A hook called when a summary line is changed.
785 The hook will not be called if `gnus-visual' is nil.
787 The default function `gnus-summary-highlight-line' will
788 highlight the line according to the `gnus-summary-highlight'
790 :group 'gnus-summary-visual
793 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
794 "*A hook called when an article is selected for the first time.
795 The hook is intended to mark an article as read (or unread)
796 automatically when it is selected."
797 :group 'gnus-summary-choose
800 (defcustom gnus-group-no-more-groups-hook nil
801 "*A hook run when returning to group mode having no more (unread) groups."
802 :group 'gnus-group-select
805 (defcustom gnus-ps-print-hook nil
806 "*A hook run before ps-printing something from Gnus."
810 (defcustom gnus-summary-display-arrow
811 (and (fboundp 'display-graphic-p)
813 "*If non-nil, display an arrow highlighting the current article."
818 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
819 "Face used for highlighting the current article in the summary buffer."
820 :group 'gnus-summary-visual
823 (defcustom gnus-summary-highlight
824 '(((= mark gnus-canceled-mark)
825 . gnus-summary-cancelled-face)
826 ((and (> score default-high)
827 (or (= mark gnus-dormant-mark)
828 (= mark gnus-ticked-mark)))
829 . gnus-summary-high-ticked-face)
830 ((and (< score default-low)
831 (or (= mark gnus-dormant-mark)
832 (= mark gnus-ticked-mark)))
833 . gnus-summary-low-ticked-face)
834 ((or (= mark gnus-dormant-mark)
835 (= mark gnus-ticked-mark))
836 . gnus-summary-normal-ticked-face)
837 ((and (> score default-high) (= mark gnus-ancient-mark))
838 . gnus-summary-high-ancient-face)
839 ((and (< score default-low) (= mark gnus-ancient-mark))
840 . gnus-summary-low-ancient-face)
841 ((= mark gnus-ancient-mark)
842 . gnus-summary-normal-ancient-face)
843 ((and (> score default-high) (= mark gnus-unread-mark))
844 . gnus-summary-high-unread-face)
845 ((and (< score default-low) (= mark gnus-unread-mark))
846 . gnus-summary-low-unread-face)
847 ((= mark gnus-unread-mark)
848 . gnus-summary-normal-unread-face)
849 ((and (> score default-high) (memq mark (list gnus-downloadable-mark
850 gnus-undownloaded-mark)))
851 . gnus-summary-high-unread-face)
852 ((and (< score default-low) (memq mark (list gnus-downloadable-mark
853 gnus-undownloaded-mark)))
854 . gnus-summary-low-unread-face)
855 ((and (memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
856 (memq article gnus-newsgroup-unreads))
857 . gnus-summary-normal-unread-face)
858 ((memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
859 . gnus-summary-normal-read-face)
860 ((> score default-high)
861 . gnus-summary-high-read-face)
862 ((< score default-low)
863 . gnus-summary-low-read-face)
865 . gnus-summary-normal-read-face))
866 "*Controls the highlighting of summary buffer lines.
868 A list of (FORM . FACE) pairs. When deciding how a a particular
869 summary line should be displayed, each form is evaluated. The content
870 of the face field after the first true form is used. You can change
871 how those summary lines are displayed, by editing the face field.
873 You can use the following variables in the FORM field.
875 score: The article's score
876 default: The default article score.
877 default-high: The default score for high scored articles.
878 default-low: The default score for low scored articles.
879 below: The score below which articles are automatically marked as read.
880 mark: The articles mark."
881 :group 'gnus-summary-visual
882 :type '(repeat (cons (sexp :tag "Form" nil)
885 (defcustom gnus-alter-header-function nil
886 "Function called to allow alteration of article header structures.
887 The function is called with one parameter, the article header vector,
888 which it may alter in any way.")
890 (defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string
891 "Variable that says which function should be used to decode a string with encoded words.")
893 (defcustom gnus-extra-headers nil
894 "*Extra headers to parse."
897 :type '(repeat symbol))
899 (defcustom gnus-ignored-from-addresses
900 (and user-mail-address (regexp-quote user-mail-address))
901 "*Regexp of From headers that may be suppressed in favor of To headers."
906 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
907 "List of charsets that should be ignored.
908 When these charsets are used in the \"charset\" parameter, the
909 default charset will be used instead."
911 :type '(repeat symbol)
912 :group 'gnus-charset)
914 (gnus-define-group-parameter
918 "Return the ignored charsets of GROUP."
919 :variable gnus-group-ignored-charsets-alist
921 '(("alt\\.chinese\\.text" iso-8859-1))
923 "Alist of regexps (to match group names) and charsets that should be ignored.
924 When these charsets are used in the \"charset\" parameter, the
925 default charset will be used instead."
926 :variable-group gnus-charset
927 :variable-type '(repeat (cons (regexp :tag "Group")
929 :parameter-type '(choice :tag "Ignored charsets"
932 :parameter-document "\
933 List of charsets that should be ignored.
935 When these charsets are used in the \"charset\" parameter, the
936 default charset will be used instead.")
938 (defcustom gnus-group-highlight-words-alist nil
939 "Alist of group regexps and highlight regexps.
940 This variable uses the same syntax as `gnus-emphasis-alist'."
942 :type '(repeat (cons (regexp :tag "Group")
943 (repeat (list (regexp :tag "Highlight regexp")
944 (number :tag "Group for entire word" 0)
945 (number :tag "Group for displayed part" 0)
947 gnus-emphasis-highlight-words)))))
948 :group 'gnus-summary-visual)
950 (defcustom gnus-summary-show-article-charset-alist
952 "Alist of number and charset.
953 The article will be shown with the charset corresponding to the
955 For example: ((1 . cn-gb-2312) (2 . big5))."
957 :type '(repeat (cons (number :tag "Argument" 1)
958 (symbol :tag "Charset")))
959 :group 'gnus-charset)
961 (defcustom gnus-preserve-marks t
962 "Whether marks are preserved when moving, copying and respooling messages."
965 :group 'gnus-summary-marks)
967 (defcustom gnus-alter-articles-to-read-function nil
968 "Function to be called to alter the list of articles to be selected."
969 :type '(choice (const nil) function)
970 :group 'gnus-summary)
972 (defcustom gnus-orphan-score nil
973 "*All orphans get this score added. Set in the score file."
974 :group 'gnus-score-default
975 :type '(choice (const nil)
978 (defcustom gnus-summary-save-parts-default-mime "image/.*"
979 "*A regexp to match MIME parts when saving multiple parts of a message
980 with gnus-summary-save-parts (X m). This regexp will be used by default
981 when prompting the user for which type of files to save."
986 (defcustom gnus-summary-save-parts-default-mime "image/.*"
987 "*A regexp to match MIME parts when saving multiple parts of a message
988 with gnus-summary-save-parts (X m). This regexp will be used by default
989 when prompting the user for which type of files to save."
993 (defcustom gnus-read-all-available-headers nil
994 "Whether Gnus should parse all headers made available to it.
995 This is mostly relevant for slow backends where the user may
996 wish to widen the summary buffer to include all headers
997 that were fetched. Say, for nnultimate groups."
999 :type '(choice boolean regexp))
1001 ;;; Internal variables
1003 (defvar gnus-summary-display-cache nil)
1004 (defvar gnus-article-mime-handles nil)
1005 (defvar gnus-article-decoded-p nil)
1006 (defvar gnus-article-charset nil)
1007 (defvar gnus-article-ignored-charsets nil)
1008 (defvar gnus-scores-exclude-files nil)
1009 (defvar gnus-page-broken nil)
1010 (defvar gnus-inhibit-mime-unbuttonizing nil)
1012 (defvar gnus-original-article nil)
1013 (defvar gnus-article-internal-prepare-hook nil)
1014 (defvar gnus-newsgroup-process-stack nil)
1016 (defvar gnus-thread-indent-array nil)
1017 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1018 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1019 "Function called to sort the articles within a thread after it has been gathered together.")
1021 (defvar gnus-summary-save-parts-type-history nil)
1022 (defvar gnus-summary-save-parts-last-directory nil)
1024 (defvar gnus-summary-save-parts-type-history nil)
1025 (defvar gnus-summary-save-parts-last-directory nil)
1027 ;; Avoid highlighting in kill files.
1028 (defvar gnus-summary-inhibit-highlight nil)
1029 (defvar gnus-newsgroup-selected-overlay nil)
1030 (defvar gnus-inhibit-limiting nil)
1031 (defvar gnus-newsgroup-adaptive-score-file nil)
1032 (defvar gnus-current-score-file nil)
1033 (defvar gnus-current-move-group nil)
1034 (defvar gnus-current-copy-group nil)
1035 (defvar gnus-current-crosspost-group nil)
1036 (defvar gnus-newsgroup-display nil)
1038 (defvar gnus-newsgroup-dependencies nil)
1039 (defvar gnus-newsgroup-adaptive nil)
1040 (defvar gnus-summary-display-article-function nil)
1041 (defvar gnus-summary-highlight-line-function nil
1042 "Function called after highlighting a summary line.")
1044 (defvar gnus-summary-line-format-alist
1045 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1046 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1047 (?s gnus-tmp-subject-or-nil ?s)
1048 (?n gnus-tmp-name ?s)
1049 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1051 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1053 (?F gnus-tmp-from ?s)
1054 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1055 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1056 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1057 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1058 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1059 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1060 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1061 (?L gnus-tmp-lines ?s)
1062 (?I gnus-tmp-indentation ?s)
1063 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1064 (?R gnus-tmp-replied ?c)
1065 (?\[ gnus-tmp-opening-bracket ?c)
1066 (?\] gnus-tmp-closing-bracket ?c)
1067 (?\> (make-string gnus-tmp-level ? ) ?s)
1068 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1069 (?i gnus-tmp-score ?d)
1070 (?z gnus-tmp-score-char ?c)
1071 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1072 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1073 (?U gnus-tmp-unread ?c)
1074 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header) ?s)
1075 (?t (gnus-summary-number-of-articles-in-thread
1076 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1078 (?e (gnus-summary-number-of-articles-in-thread
1079 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1081 (?u gnus-tmp-user-defined ?s)
1082 (?P (gnus-pick-line-number) ?d)
1083 (?B gnus-tmp-thread-tree-header-string ?s))
1084 "An alist of format specifications that can appear in summary lines.
1085 These are paired with what variables they correspond with, along with
1086 the type of the variable (string, integer, character, etc).")
1088 (defvar gnus-summary-dummy-line-format-alist
1089 `((?S gnus-tmp-subject ?s)
1090 (?N gnus-tmp-number ?d)
1091 (?u gnus-tmp-user-defined ?s)))
1093 (defvar gnus-summary-mode-line-format-alist
1094 `((?G gnus-tmp-group-name ?s)
1095 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1096 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1097 (?A gnus-tmp-article-number ?d)
1098 (?Z gnus-tmp-unread-and-unselected ?s)
1099 (?V gnus-version ?s)
1100 (?U gnus-tmp-unread-and-unticked ?d)
1101 (?S gnus-tmp-subject ?s)
1102 (?e gnus-tmp-unselected ?d)
1103 (?u gnus-tmp-user-defined ?s)
1104 (?d (length gnus-newsgroup-dormant) ?d)
1105 (?t (length gnus-newsgroup-marked) ?d)
1106 (?r (length gnus-newsgroup-reads) ?d)
1107 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1108 (?E gnus-newsgroup-expunged-tally ?d)
1109 (?s (gnus-current-score-file-nondirectory) ?s)))
1111 (defvar gnus-last-search-regexp nil
1112 "Default regexp for article search command.")
1114 (defvar gnus-last-shell-command nil
1115 "Default shell command on article.")
1117 (defvar gnus-newsgroup-begin nil)
1118 (defvar gnus-newsgroup-end nil)
1119 (defvar gnus-newsgroup-last-rmail nil)
1120 (defvar gnus-newsgroup-last-mail nil)
1121 (defvar gnus-newsgroup-last-folder nil)
1122 (defvar gnus-newsgroup-last-file nil)
1123 (defvar gnus-newsgroup-auto-expire nil)
1124 (defvar gnus-newsgroup-active nil)
1126 (defvar gnus-newsgroup-data nil)
1127 (defvar gnus-newsgroup-data-reverse nil)
1128 (defvar gnus-newsgroup-limit nil)
1129 (defvar gnus-newsgroup-limits nil)
1131 (defvar gnus-newsgroup-unreads nil
1132 "List of unread articles in the current newsgroup.")
1134 (defvar gnus-newsgroup-unselected nil
1135 "List of unselected unread articles in the current newsgroup.")
1137 (defvar gnus-newsgroup-reads nil
1138 "Alist of read articles and article marks in the current newsgroup.")
1140 (defvar gnus-newsgroup-expunged-tally nil)
1142 (defvar gnus-newsgroup-marked nil
1143 "List of ticked articles in the current newsgroup (a subset of unread art).")
1145 (defvar gnus-newsgroup-killed nil
1146 "List of ranges of articles that have been through the scoring process.")
1148 (defvar gnus-newsgroup-cached nil
1149 "List of articles that come from the article cache.")
1151 (defvar gnus-newsgroup-saved nil
1152 "List of articles that have been saved.")
1154 (defvar gnus-newsgroup-kill-headers nil)
1156 (defvar gnus-newsgroup-replied nil
1157 "List of articles that have been replied to in the current newsgroup.")
1159 (defvar gnus-newsgroup-forwarded nil
1160 "List of articles that have been forwarded in the current newsgroup.")
1162 (defvar gnus-newsgroup-recent nil
1163 "List of articles that have are recent in the current newsgroup.")
1165 (defvar gnus-newsgroup-expirable nil
1166 "List of articles in the current newsgroup that can be expired.")
1168 (defvar gnus-newsgroup-processable nil
1169 "List of articles in the current newsgroup that can be processed.")
1171 (defvar gnus-newsgroup-downloadable nil
1172 "List of articles in the current newsgroup that can be processed.")
1174 (defvar gnus-newsgroup-undownloaded nil
1175 "List of articles in the current newsgroup that haven't been downloaded..")
1177 (defvar gnus-newsgroup-unsendable nil
1178 "List of articles in the current newsgroup that won't be sent.")
1180 (defvar gnus-newsgroup-bookmarks nil
1181 "List of articles in the current newsgroup that have bookmarks.")
1183 (defvar gnus-newsgroup-dormant nil
1184 "List of dormant articles in the current newsgroup.")
1186 (defvar gnus-newsgroup-unseen nil
1187 "List of unseen articles in the current newsgroup.")
1189 (defvar gnus-newsgroup-seen nil
1190 "Range of seen articles in the current newsgroup.")
1192 (defvar gnus-newsgroup-articles nil
1193 "List of articles in the current newsgroup.")
1195 (defvar gnus-newsgroup-scored nil
1196 "List of scored articles in the current newsgroup.")
1198 (defvar gnus-newsgroup-headers nil
1199 "List of article headers in the current newsgroup.")
1201 (defvar gnus-newsgroup-threads nil)
1203 (defvar gnus-newsgroup-prepared nil
1204 "Whether the current group has been prepared properly.")
1206 (defvar gnus-newsgroup-ancient nil
1207 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1209 (defvar gnus-newsgroup-sparse nil)
1211 (defvar gnus-current-article nil)
1212 (defvar gnus-article-current nil)
1213 (defvar gnus-current-headers nil)
1214 (defvar gnus-have-all-headers nil)
1215 (defvar gnus-last-article nil)
1216 (defvar gnus-newsgroup-history nil)
1217 (defvar gnus-newsgroup-charset nil)
1218 (defvar gnus-newsgroup-ephemeral-charset nil)
1219 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1221 (defvar gnus-article-before-search nil)
1223 (defconst gnus-summary-local-variables
1224 '(gnus-newsgroup-name
1225 gnus-newsgroup-begin gnus-newsgroup-end
1226 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1227 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1228 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1229 gnus-newsgroup-unselected gnus-newsgroup-marked
1230 gnus-newsgroup-reads gnus-newsgroup-saved
1231 gnus-newsgroup-replied gnus-newsgroup-forwarded
1232 gnus-newsgroup-recent
1233 gnus-newsgroup-expirable
1234 gnus-newsgroup-processable gnus-newsgroup-killed
1235 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1236 gnus-newsgroup-unsendable gnus-newsgroup-unseen
1237 gnus-newsgroup-seen gnus-newsgroup-articles
1238 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1239 gnus-newsgroup-headers gnus-newsgroup-threads
1240 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1241 gnus-current-article gnus-current-headers gnus-have-all-headers
1242 gnus-last-article gnus-article-internal-prepare-hook
1243 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1244 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1245 gnus-thread-expunge-below
1246 gnus-score-alist gnus-current-score-file
1247 (gnus-summary-expunge-below . global)
1248 (gnus-summary-mark-below . global)
1249 (gnus-orphan-score . global)
1250 gnus-newsgroup-active gnus-scores-exclude-files
1251 gnus-newsgroup-history gnus-newsgroup-ancient
1252 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1253 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1254 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1255 (gnus-newsgroup-expunged-tally . 0)
1256 gnus-cache-removable-articles gnus-newsgroup-cached
1257 gnus-newsgroup-data gnus-newsgroup-data-reverse
1258 gnus-newsgroup-limit gnus-newsgroup-limits
1259 gnus-newsgroup-charset gnus-newsgroup-display)
1260 "Variables that are buffer-local to the summary buffers.")
1262 (defvar gnus-newsgroup-variables nil
1263 "Variables that have separate values in the newsgroups.")
1265 ;; Byte-compiler warning.
1266 (eval-when-compile (defvar gnus-article-mode-map))
1270 (defvar gnus-decode-encoded-word-methods
1271 '(mail-decode-encoded-word-string)
1272 "List of methods used to decode encoded words.
1274 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item is
1275 FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1276 (REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
1277 whose names match REGEXP.
1280 ((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
1281 mail-decode-encoded-word-string
1282 (\"chinese\" . rfc1843-decode-string))")
1284 (defvar gnus-decode-encoded-word-methods-cache nil)
1286 (defun gnus-multi-decode-encoded-word-string (string)
1287 "Apply the functions from `gnus-encoded-word-methods' that match."
1288 (unless (and gnus-decode-encoded-word-methods-cache
1289 (eq gnus-newsgroup-name
1290 (car gnus-decode-encoded-word-methods-cache)))
1291 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
1294 (nconc gnus-decode-encoded-word-methods-cache (list x))
1295 (if (and gnus-newsgroup-name
1296 (string-match (car x) gnus-newsgroup-name))
1297 (nconc gnus-decode-encoded-word-methods-cache
1299 gnus-decode-encoded-word-methods))
1300 (let ((xlist gnus-decode-encoded-word-methods-cache))
1303 (setq string (funcall (pop xlist) string))))
1306 ;; Subject simplification.
1308 (defun gnus-simplify-whitespace (str)
1309 "Remove excessive whitespace from STR."
1312 (while (string-match "[ \t][ \t]+" mystr)
1313 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1315 (substring mystr (match-end 0)))))
1317 (when (string-match "^[ \t]+" mystr)
1318 (setq mystr (substring mystr (match-end 0))))
1320 (when (string-match "[ \t]+$" mystr)
1321 (setq mystr (substring mystr 0 (match-beginning 0))))
1324 (defsubst gnus-simplify-subject-re (subject)
1325 "Remove \"Re:\" from subject lines."
1326 (if (string-match message-subject-re-regexp subject)
1327 (substring subject (match-end 0))
1330 (defun gnus-simplify-subject (subject &optional re-only)
1331 "Remove `Re:' and words in parentheses.
1332 If RE-ONLY is non-nil, strip leading `Re:'s only."
1333 (let ((case-fold-search t)) ;Ignore case.
1334 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1335 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1336 (setq subject (substring subject (match-end 0))))
1337 ;; Remove uninteresting prefixes.
1338 (when (and (not re-only)
1339 gnus-simplify-ignored-prefixes
1340 (string-match gnus-simplify-ignored-prefixes subject))
1341 (setq subject (substring subject (match-end 0))))
1342 ;; Remove words in parentheses from end.
1344 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1345 (setq subject (substring subject 0 (match-beginning 0)))))
1346 ;; Return subject string.
1349 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1351 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1352 (goto-char (point-min))
1353 (while (re-search-forward regexp nil t)
1354 (replace-match (or newtext ""))))
1356 (defun gnus-simplify-buffer-fuzzy ()
1357 "Simplify string in the buffer fuzzily.
1358 The string in the accessible portion of the current buffer is simplified.
1359 It is assumed to be a single-line subject.
1360 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1361 matter is removed. Additional things can be deleted by setting
1362 `gnus-simplify-subject-fuzzy-regexp'."
1363 (let ((case-fold-search t)
1365 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1367 (while (not (eq modified-tick (buffer-modified-tick)))
1368 (setq modified-tick (buffer-modified-tick))
1370 ((listp gnus-simplify-subject-fuzzy-regexp)
1371 (mapcar 'gnus-simplify-buffer-fuzzy-step
1372 gnus-simplify-subject-fuzzy-regexp))
1373 (gnus-simplify-subject-fuzzy-regexp
1374 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1375 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1376 (gnus-simplify-buffer-fuzzy-step
1377 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1378 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1380 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1381 (gnus-simplify-buffer-fuzzy-step " +" " ")
1382 (gnus-simplify-buffer-fuzzy-step " $")
1383 (gnus-simplify-buffer-fuzzy-step "^ +")))
1385 (defun gnus-simplify-subject-fuzzy (subject)
1386 "Simplify a subject string fuzzily.
1387 See `gnus-simplify-buffer-fuzzy' for details."
1389 (gnus-set-work-buffer)
1390 (let ((case-fold-search t))
1391 ;; Remove uninteresting prefixes.
1392 (when (and gnus-simplify-ignored-prefixes
1393 (string-match gnus-simplify-ignored-prefixes subject))
1394 (setq subject (substring subject (match-end 0))))
1396 (inline (gnus-simplify-buffer-fuzzy))
1399 (defsubst gnus-simplify-subject-fully (subject)
1400 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1402 (gnus-simplify-subject-functions
1403 (gnus-map-function gnus-simplify-subject-functions subject))
1404 ((null gnus-summary-gather-subject-limit)
1405 (gnus-simplify-subject-re subject))
1406 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1407 (gnus-simplify-subject-fuzzy subject))
1408 ((numberp gnus-summary-gather-subject-limit)
1409 (gnus-limit-string (gnus-simplify-subject-re subject)
1410 gnus-summary-gather-subject-limit))
1414 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1415 "Check whether two subjects are equal.
1416 If optional argument simple-first is t, first argument is already
1419 ((null simple-first)
1420 (equal (gnus-simplify-subject-fully s1)
1421 (gnus-simplify-subject-fully s2)))
1424 (gnus-simplify-subject-fully s2)))))
1426 (defun gnus-summary-bubble-group ()
1427 "Increase the score of the current group.
1428 This is a handy function to add to `gnus-summary-exit-hook' to
1429 increase the score of each group you read."
1430 (gnus-group-add-score gnus-newsgroup-name))
1434 ;;; Gnus summary mode
1437 (put 'gnus-summary-mode 'mode-class 'special)
1439 (defvar gnus-article-commands-menu)
1442 ;; Non-orthogonal keys
1444 (gnus-define-keys gnus-summary-mode-map
1445 " " gnus-summary-next-page
1446 "\177" gnus-summary-prev-page
1447 [delete] gnus-summary-prev-page
1448 [backspace] gnus-summary-prev-page
1449 "\r" gnus-summary-scroll-up
1450 "\M-\r" gnus-summary-scroll-down
1451 "n" gnus-summary-next-unread-article
1452 "p" gnus-summary-prev-unread-article
1453 "N" gnus-summary-next-article
1454 "P" gnus-summary-prev-article
1455 "\M-\C-n" gnus-summary-next-same-subject
1456 "\M-\C-p" gnus-summary-prev-same-subject
1457 "\M-n" gnus-summary-next-unread-subject
1458 "\M-p" gnus-summary-prev-unread-subject
1459 "." gnus-summary-first-unread-article
1460 "," gnus-summary-best-unread-article
1461 "\M-s" gnus-summary-search-article-forward
1462 "\M-r" gnus-summary-search-article-backward
1463 "<" gnus-summary-beginning-of-article
1464 ">" gnus-summary-end-of-article
1465 "j" gnus-summary-goto-article
1466 "^" gnus-summary-refer-parent-article
1467 "\M-^" gnus-summary-refer-article
1468 "u" gnus-summary-tick-article-forward
1469 "!" gnus-summary-tick-article-forward
1470 "U" gnus-summary-tick-article-backward
1471 "d" gnus-summary-mark-as-read-forward
1472 "D" gnus-summary-mark-as-read-backward
1473 "E" gnus-summary-mark-as-expirable
1474 "\M-u" gnus-summary-clear-mark-forward
1475 "\M-U" gnus-summary-clear-mark-backward
1476 "k" gnus-summary-kill-same-subject-and-select
1477 "\C-k" gnus-summary-kill-same-subject
1478 "\M-\C-k" gnus-summary-kill-thread
1479 "\M-\C-l" gnus-summary-lower-thread
1480 "e" gnus-summary-edit-article
1481 "#" gnus-summary-mark-as-processable
1482 "\M-#" gnus-summary-unmark-as-processable
1483 "\M-\C-t" gnus-summary-toggle-threads
1484 "\M-\C-s" gnus-summary-show-thread
1485 "\M-\C-h" gnus-summary-hide-thread
1486 "\M-\C-f" gnus-summary-next-thread
1487 "\M-\C-b" gnus-summary-prev-thread
1488 [(meta down)] gnus-summary-next-thread
1489 [(meta up)] gnus-summary-prev-thread
1490 "\M-\C-u" gnus-summary-up-thread
1491 "\M-\C-d" gnus-summary-down-thread
1492 "&" gnus-summary-execute-command
1493 "c" gnus-summary-catchup-and-exit
1494 "\C-w" gnus-summary-mark-region-as-read
1495 "\C-t" gnus-summary-toggle-truncation
1496 "?" gnus-summary-mark-as-dormant
1497 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1498 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1499 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1500 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1501 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1502 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1503 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1504 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1505 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1506 "=" gnus-summary-expand-window
1507 "\C-x\C-s" gnus-summary-reselect-current-group
1508 "\M-g" gnus-summary-rescan-group
1509 "w" gnus-summary-stop-page-breaking
1510 "\C-c\C-r" gnus-summary-caesar-message
1511 "f" gnus-summary-followup
1512 "F" gnus-summary-followup-with-original
1513 "C" gnus-summary-cancel-article
1514 "r" gnus-summary-reply
1515 "R" gnus-summary-reply-with-original
1516 "\C-c\C-f" gnus-summary-mail-forward
1517 "o" gnus-summary-save-article
1518 "\C-o" gnus-summary-save-article-mail
1519 "|" gnus-summary-pipe-output
1520 "\M-k" gnus-summary-edit-local-kill
1521 "\M-K" gnus-summary-edit-global-kill
1523 "\C-c\C-d" gnus-summary-describe-group
1524 "q" gnus-summary-exit
1525 "Q" gnus-summary-exit-no-update
1526 "\C-c\C-i" gnus-info-find-node
1527 gnus-mouse-2 gnus-mouse-pick-article
1528 "m" gnus-summary-mail-other-window
1529 "a" gnus-summary-post-news
1530 "x" gnus-summary-limit-to-unread
1531 "s" gnus-summary-isearch-article
1532 "t" gnus-summary-toggle-header
1533 "g" gnus-summary-show-article
1534 "l" gnus-summary-goto-last-article
1535 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1536 "\C-d" gnus-summary-enter-digest-group
1537 "\M-\C-d" gnus-summary-read-document
1538 "\M-\C-e" gnus-summary-edit-parameters
1539 "\M-\C-a" gnus-summary-customize-parameters
1541 "*" gnus-cache-enter-article
1542 "\M-*" gnus-cache-remove-article
1543 "\M-&" gnus-summary-universal-argument
1544 "\C-l" gnus-recenter
1545 "I" gnus-summary-increase-score
1546 "L" gnus-summary-lower-score
1547 "\M-i" gnus-symbolic-argument
1548 "h" gnus-summary-select-article-buffer
1550 "b" gnus-article-view-part
1551 "\M-t" gnus-summary-toggle-display-buttonized
1553 "V" gnus-summary-score-map
1554 "X" gnus-uu-extract-map
1555 "S" gnus-summary-send-map)
1557 ;; Sort of orthogonal keymap
1558 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1559 "t" gnus-summary-tick-article-forward
1560 "!" gnus-summary-tick-article-forward
1561 "d" gnus-summary-mark-as-read-forward
1562 "r" gnus-summary-mark-as-read-forward
1563 "c" gnus-summary-clear-mark-forward
1564 " " gnus-summary-clear-mark-forward
1565 "e" gnus-summary-mark-as-expirable
1566 "x" gnus-summary-mark-as-expirable
1567 "?" gnus-summary-mark-as-dormant
1568 "b" gnus-summary-set-bookmark
1569 "B" gnus-summary-remove-bookmark
1570 "#" gnus-summary-mark-as-processable
1571 "\M-#" gnus-summary-unmark-as-processable
1572 "S" gnus-summary-limit-include-expunged
1573 "C" gnus-summary-catchup
1574 "H" gnus-summary-catchup-to-here
1575 "h" gnus-summary-catchup-from-here
1576 "\C-c" gnus-summary-catchup-all
1577 "k" gnus-summary-kill-same-subject-and-select
1578 "K" gnus-summary-kill-same-subject
1579 "P" gnus-uu-mark-map)
1581 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1582 "c" gnus-summary-clear-above
1583 "u" gnus-summary-tick-above
1584 "m" gnus-summary-mark-above
1585 "k" gnus-summary-kill-below)
1587 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1588 "/" gnus-summary-limit-to-subject
1589 "n" gnus-summary-limit-to-articles
1590 "w" gnus-summary-pop-limit
1591 "s" gnus-summary-limit-to-subject
1592 "a" gnus-summary-limit-to-author
1593 "u" gnus-summary-limit-to-unread
1594 "m" gnus-summary-limit-to-marks
1595 "M" gnus-summary-limit-exclude-marks
1596 "v" gnus-summary-limit-to-score
1597 "*" gnus-summary-limit-include-cached
1598 "D" gnus-summary-limit-include-dormant
1599 "T" gnus-summary-limit-include-thread
1600 "d" gnus-summary-limit-exclude-dormant
1601 "t" gnus-summary-limit-to-age
1602 "x" gnus-summary-limit-to-extra
1603 "p" gnus-summary-limit-to-display-predicate
1604 "E" gnus-summary-limit-include-expunged
1605 "c" gnus-summary-limit-exclude-childless-dormant
1606 "C" gnus-summary-limit-mark-excluded-as-read
1607 "o" gnus-summary-insert-old-articles
1608 "N" gnus-summary-insert-new-articles)
1610 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1611 "n" gnus-summary-next-unread-article
1612 "p" gnus-summary-prev-unread-article
1613 "N" gnus-summary-next-article
1614 "P" gnus-summary-prev-article
1615 "\C-n" gnus-summary-next-same-subject
1616 "\C-p" gnus-summary-prev-same-subject
1617 "\M-n" gnus-summary-next-unread-subject
1618 "\M-p" gnus-summary-prev-unread-subject
1619 "f" gnus-summary-first-unread-article
1620 "b" gnus-summary-best-unread-article
1621 "j" gnus-summary-goto-article
1622 "g" gnus-summary-goto-subject
1623 "l" gnus-summary-goto-last-article
1624 "o" gnus-summary-pop-article)
1626 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1627 "k" gnus-summary-kill-thread
1628 "l" gnus-summary-lower-thread
1629 "i" gnus-summary-raise-thread
1630 "T" gnus-summary-toggle-threads
1631 "t" gnus-summary-rethread-current
1632 "^" gnus-summary-reparent-thread
1633 "s" gnus-summary-show-thread
1634 "S" gnus-summary-show-all-threads
1635 "h" gnus-summary-hide-thread
1636 "H" gnus-summary-hide-all-threads
1637 "n" gnus-summary-next-thread
1638 "p" gnus-summary-prev-thread
1639 "u" gnus-summary-up-thread
1640 "o" gnus-summary-top-thread
1641 "d" gnus-summary-down-thread
1642 "#" gnus-uu-mark-thread
1643 "\M-#" gnus-uu-unmark-thread)
1645 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1646 "g" gnus-summary-prepare
1647 "c" gnus-summary-insert-cached-articles)
1649 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1650 "c" gnus-summary-catchup-and-exit
1651 "C" gnus-summary-catchup-all-and-exit
1652 "E" gnus-summary-exit-no-update
1653 "Q" gnus-summary-exit
1654 "Z" gnus-summary-exit
1655 "n" gnus-summary-catchup-and-goto-next-group
1656 "R" gnus-summary-reselect-current-group
1657 "G" gnus-summary-rescan-group
1658 "N" gnus-summary-next-group
1659 "s" gnus-summary-save-newsrc
1660 "P" gnus-summary-prev-group)
1662 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1663 " " gnus-summary-next-page
1664 "n" gnus-summary-next-page
1665 "\177" gnus-summary-prev-page
1666 [delete] gnus-summary-prev-page
1667 "p" gnus-summary-prev-page
1668 "\r" gnus-summary-scroll-up
1669 "\M-\r" gnus-summary-scroll-down
1670 "<" gnus-summary-beginning-of-article
1671 ">" gnus-summary-end-of-article
1672 "b" gnus-summary-beginning-of-article
1673 "e" gnus-summary-end-of-article
1674 "^" gnus-summary-refer-parent-article
1675 "r" gnus-summary-refer-parent-article
1676 "D" gnus-summary-enter-digest-group
1677 "R" gnus-summary-refer-references
1678 "T" gnus-summary-refer-thread
1679 "g" gnus-summary-show-article
1680 "s" gnus-summary-isearch-article
1681 "P" gnus-summary-print-article
1682 "M" gnus-mailing-list-insinuate
1683 "t" gnus-article-babel)
1685 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1686 "b" gnus-article-add-buttons
1687 "B" gnus-article-add-buttons-to-head
1688 "o" gnus-article-treat-overstrike
1689 "e" gnus-article-emphasize
1690 "w" gnus-article-fill-cited-article
1691 "Q" gnus-article-fill-long-lines
1692 "C" gnus-article-capitalize-sentences
1693 "c" gnus-article-remove-cr
1694 "q" gnus-article-de-quoted-unreadable
1695 "6" gnus-article-de-base64-unreadable
1696 "Z" gnus-article-decode-HZ
1697 "h" gnus-article-wash-html
1698 "s" gnus-summary-force-verify-and-decrypt
1699 "f" gnus-article-display-x-face
1700 "l" gnus-summary-stop-page-breaking
1701 "r" gnus-summary-caesar-message
1702 "t" gnus-summary-toggle-header
1703 "g" gnus-summary-toggle-smiley
1704 "v" gnus-summary-verbose-headers
1705 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
1706 "p" gnus-article-verify-x-pgp-sig
1707 "d" gnus-article-treat-dumbquotes)
1709 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1710 "a" gnus-article-hide
1711 "h" gnus-article-hide-headers
1712 "b" gnus-article-hide-boring-headers
1713 "s" gnus-article-hide-signature
1714 "c" gnus-article-hide-citation
1715 "C" gnus-article-hide-citation-in-followups
1716 "l" gnus-article-hide-list-identifiers
1717 "p" gnus-article-hide-pgp
1718 "B" gnus-article-strip-banner
1719 "P" gnus-article-hide-pem
1720 "\C-c" gnus-article-hide-citation-maybe)
1722 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1723 "a" gnus-article-highlight
1724 "h" gnus-article-highlight-headers
1725 "c" gnus-article-highlight-citation
1726 "s" gnus-article-highlight-signature)
1728 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
1729 "w" gnus-article-decode-mime-words
1730 "c" gnus-article-decode-charset
1731 "v" gnus-mime-view-all-parts
1732 "b" gnus-article-view-part)
1734 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1735 "z" gnus-article-date-ut
1736 "u" gnus-article-date-ut
1737 "l" gnus-article-date-local
1738 "p" gnus-article-date-english
1739 "e" gnus-article-date-lapsed
1740 "o" gnus-article-date-original
1741 "i" gnus-article-date-iso8601
1742 "s" gnus-article-date-user)
1744 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1745 "t" gnus-article-remove-trailing-blank-lines
1746 "l" gnus-article-strip-leading-blank-lines
1747 "m" gnus-article-strip-multiple-blank-lines
1748 "a" gnus-article-strip-blank-lines
1749 "A" gnus-article-strip-all-blank-lines
1750 "s" gnus-article-strip-leading-space
1751 "e" gnus-article-strip-trailing-space
1752 "w" gnus-article-remove-leading-whitespace)
1754 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1756 "f" gnus-summary-fetch-faq
1757 "d" gnus-summary-describe-group
1758 "h" gnus-summary-describe-briefly
1759 "i" gnus-info-find-node)
1761 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1762 "e" gnus-summary-expire-articles
1763 "\M-\C-e" gnus-summary-expire-articles-now
1764 "\177" gnus-summary-delete-article
1765 [delete] gnus-summary-delete-article
1766 [backspace] gnus-summary-delete-article
1767 "m" gnus-summary-move-article
1768 "r" gnus-summary-respool-article
1769 "w" gnus-summary-edit-article
1770 "c" gnus-summary-copy-article
1771 "B" gnus-summary-crosspost-article
1772 "q" gnus-summary-respool-query
1773 "t" gnus-summary-respool-trace
1774 "i" gnus-summary-import-article
1775 "I" gnus-summary-create-article
1776 "p" gnus-summary-article-posted-p)
1778 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1779 "o" gnus-summary-save-article
1780 "m" gnus-summary-save-article-mail
1781 "F" gnus-summary-write-article-file
1782 "r" gnus-summary-save-article-rmail
1783 "f" gnus-summary-save-article-file
1784 "b" gnus-summary-save-article-body-file
1785 "h" gnus-summary-save-article-folder
1786 "v" gnus-summary-save-article-vm
1787 "p" gnus-summary-pipe-output
1788 "s" gnus-soup-add-article)
1790 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
1791 "b" gnus-summary-display-buttonized
1792 "m" gnus-summary-repair-multipart
1793 "v" gnus-article-view-part
1794 "o" gnus-article-save-part
1795 "c" gnus-article-copy-part
1796 "C" gnus-article-view-part-as-charset
1797 "e" gnus-article-externalize-part
1798 "E" gnus-article-encrypt-body
1799 "i" gnus-article-inline-part
1800 "|" gnus-article-pipe-part))
1802 (defvar gnus-article-post-menu nil)
1804 (defun gnus-summary-make-menu-bar ()
1805 (gnus-turn-off-edit-menu 'summary)
1807 (unless (boundp 'gnus-summary-misc-menu)
1810 gnus-summary-kill-menu gnus-summary-mode-map ""
1815 ["Customize" gnus-score-customize t])
1816 (gnus-make-score-map 'increase)
1817 (gnus-make-score-map 'lower)
1819 ["Kill below" gnus-summary-kill-below t]
1820 ["Mark above" gnus-summary-mark-above t]
1821 ["Tick above" gnus-summary-tick-above t]
1822 ["Clear above" gnus-summary-clear-above t])
1823 ["Current score" gnus-summary-current-score t]
1824 ["Set score" gnus-summary-set-score t]
1825 ["Switch current score file..." gnus-score-change-score-file t]
1826 ["Set mark below..." gnus-score-set-mark-below t]
1827 ["Set expunge below..." gnus-score-set-expunge-below t]
1828 ["Edit current score file" gnus-score-edit-current-scores t]
1829 ["Edit score file" gnus-score-edit-file t]
1830 ["Trace score" gnus-score-find-trace t]
1831 ["Find words" gnus-score-find-favourite-words t]
1832 ["Rescore buffer" gnus-summary-rescore t]
1833 ["Increase score..." gnus-summary-increase-score t]
1834 ["Lower score..." gnus-summary-lower-score t]))))
1836 ;; Define both the Article menu in the summary buffer and the equivalent
1837 ;; Commands menu in the article buffer here for consistency.
1840 ["All" gnus-article-hide t]
1841 ["Headers" gnus-article-hide-headers t]
1842 ["Signature" gnus-article-hide-signature t]
1843 ["Citation" gnus-article-hide-citation t]
1844 ["List identifiers" gnus-article-hide-list-identifiers t]
1845 ["PGP" gnus-article-hide-pgp t]
1846 ["Banner" gnus-article-strip-banner t]
1847 ["Boring headers" gnus-article-hide-boring-headers t])
1849 ["All" gnus-article-highlight t]
1850 ["Headers" gnus-article-highlight-headers t]
1851 ["Signature" gnus-article-highlight-signature t]
1852 ["Citation" gnus-article-highlight-citation t])
1854 ["Words" gnus-article-decode-mime-words t]
1855 ["Charset" gnus-article-decode-charset t]
1856 ["QP" gnus-article-de-quoted-unreadable t]
1857 ["Base64" gnus-article-de-base64-unreadable t]
1858 ["View all" gnus-mime-view-all-parts t]
1859 ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t]
1860 ["Encrypt body" gnus-article-encrypt-body t])
1862 ["Local" gnus-article-date-local t]
1863 ["ISO8601" gnus-article-date-iso8601 t]
1864 ["UT" gnus-article-date-ut t]
1865 ["Original" gnus-article-date-original t]
1866 ["Lapsed" gnus-article-date-lapsed t]
1867 ["User-defined" gnus-article-date-user t])
1870 ["Leading" gnus-article-strip-leading-blank-lines t]
1871 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1872 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1873 ["All of the above" gnus-article-strip-blank-lines t]
1874 ["All" gnus-article-strip-all-blank-lines t]
1875 ["Leading space" gnus-article-strip-leading-space t]
1876 ["Trailing space" gnus-article-strip-trailing-space t]
1877 ["Leading space in headers"
1878 gnus-article-remove-leading-whitespace t])
1879 ["Overstrike" gnus-article-treat-overstrike t]
1880 ["Dumb quotes" gnus-article-treat-dumbquotes t]
1881 ["Emphasis" gnus-article-emphasize t]
1882 ["Word wrap" gnus-article-fill-cited-article t]
1883 ["Fill long lines" gnus-article-fill-long-lines t]
1884 ["Capitalize sentences" gnus-article-capitalize-sentences t]
1885 ["CR" gnus-article-remove-cr t]
1886 ["Show X-Face" gnus-article-display-x-face t]
1887 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
1888 ["Base64" gnus-article-de-base64-unreadable t]
1889 ["Rot 13" gnus-summary-caesar-message
1890 ,@(if (featurep 'xemacs) '(t)
1891 '(:help "\"Caesar rotate\" article by 13"))]
1892 ["Unix pipe" gnus-summary-pipe-message t]
1893 ["Add buttons" gnus-article-add-buttons t]
1894 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1895 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1896 ["Verbose header" gnus-summary-verbose-headers t]
1897 ["Toggle header" gnus-summary-toggle-header t]
1898 ["Toggle smiley" gnus-summary-toggle-smiley t]
1899 ["Html" gnus-article-wash-html t]
1900 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
1901 ["HZ" gnus-article-decode-HZ t])
1903 ["Save in default format" gnus-summary-save-article
1904 ,@(if (featurep 'xemacs) '(t)
1905 '(:help "Save article using default method"))]
1906 ["Save in file" gnus-summary-save-article-file
1907 ,@(if (featurep 'xemacs) '(t)
1908 '(:help "Save article in file"))]
1909 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1910 ["Save in MH folder" gnus-summary-save-article-folder t]
1911 ["Save in VM folder" gnus-summary-save-article-vm t]
1912 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1913 ["Save body in file" gnus-summary-save-article-body-file t]
1914 ["Pipe through a filter" gnus-summary-pipe-output t]
1915 ["Add to SOUP packet" gnus-soup-add-article t]
1916 ["Print" gnus-summary-print-article t])
1918 ["Respool article..." gnus-summary-respool-article t]
1919 ["Move article..." gnus-summary-move-article
1920 (gnus-check-backend-function
1921 'request-move-article gnus-newsgroup-name)]
1922 ["Copy article..." gnus-summary-copy-article t]
1923 ["Crosspost article..." gnus-summary-crosspost-article
1924 (gnus-check-backend-function
1925 'request-replace-article gnus-newsgroup-name)]
1926 ["Import file..." gnus-summary-import-article t]
1927 ["Create article..." gnus-summary-create-article t]
1928 ["Check if posted" gnus-summary-article-posted-p t]
1929 ["Edit article" gnus-summary-edit-article
1930 (not (gnus-group-read-only-p))]
1931 ["Delete article" gnus-summary-delete-article
1932 (gnus-check-backend-function
1933 'request-expire-articles gnus-newsgroup-name)]
1934 ["Query respool" gnus-summary-respool-query t]
1935 ["Trace respool" gnus-summary-respool-trace t]
1936 ["Delete expirable articles" gnus-summary-expire-articles-now
1937 (gnus-check-backend-function
1938 'request-expire-articles gnus-newsgroup-name)])
1940 ["Uudecode" gnus-uu-decode-uu
1941 ,@(if (featurep 'xemacs) '(t)
1942 '(:help "Decode uuencoded article(s)"))]
1943 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1944 ["Unshar" gnus-uu-decode-unshar t]
1945 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1946 ["Save" gnus-uu-decode-save t]
1947 ["Binhex" gnus-uu-decode-binhex t]
1948 ["Postscript" gnus-uu-decode-postscript t])
1950 ["Enter article" gnus-cache-enter-article t]
1951 ["Remove article" gnus-cache-remove-article t])
1952 ["Translate" gnus-article-babel t]
1953 ["Select article buffer" gnus-summary-select-article-buffer t]
1954 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1955 ["Isearch article..." gnus-summary-isearch-article t]
1956 ["Beginning of the article" gnus-summary-beginning-of-article t]
1957 ["End of the article" gnus-summary-end-of-article t]
1958 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1959 ["Fetch referenced articles" gnus-summary-refer-references t]
1960 ["Fetch current thread" gnus-summary-refer-thread t]
1961 ["Fetch article with id..." gnus-summary-refer-article t]
1962 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
1963 ["Redisplay" gnus-summary-show-article t]
1964 ["Raw article" gnus-summary-show-raw-article t])))
1966 gnus-summary-article-menu gnus-summary-mode-map ""
1967 (cons "Article" innards))
1969 (if (not (keymapp gnus-summary-article-menu))
1971 gnus-article-commands-menu gnus-article-mode-map ""
1972 (cons "Commands" innards))
1973 ;; in Emacs, don't share menu.
1974 (setq gnus-article-commands-menu
1975 (copy-keymap gnus-summary-article-menu))
1976 (define-key gnus-article-mode-map [menu-bar commands]
1977 (cons "Commands" gnus-article-commands-menu))))
1980 gnus-summary-thread-menu gnus-summary-mode-map ""
1982 ["Toggle threading" gnus-summary-toggle-threads t]
1983 ["Hide threads" gnus-summary-hide-all-threads t]
1984 ["Show threads" gnus-summary-show-all-threads t]
1985 ["Hide thread" gnus-summary-hide-thread t]
1986 ["Show thread" gnus-summary-show-thread t]
1987 ["Go to next thread" gnus-summary-next-thread t]
1988 ["Go to previous thread" gnus-summary-prev-thread t]
1989 ["Go down thread" gnus-summary-down-thread t]
1990 ["Go up thread" gnus-summary-up-thread t]
1991 ["Top of thread" gnus-summary-top-thread t]
1992 ["Mark thread as read" gnus-summary-kill-thread t]
1993 ["Lower thread score" gnus-summary-lower-thread t]
1994 ["Raise thread score" gnus-summary-raise-thread t]
1995 ["Rethread current" gnus-summary-rethread-current t]))
1998 gnus-summary-post-menu gnus-summary-mode-map ""
2000 ["Post an article" gnus-summary-post-news
2001 ,@(if (featurep 'xemacs) '(t)
2002 '(:help "Post an article"))]
2003 ["Followup" gnus-summary-followup
2004 ,@(if (featurep 'xemacs) '(t)
2005 '(:help "Post followup to this article"))]
2006 ["Followup and yank" gnus-summary-followup-with-original
2007 ,@(if (featurep 'xemacs) '(t)
2008 '(:help "Post followup to this article, quoting its contents"))]
2009 ["Supersede article" gnus-summary-supersede-article t]
2010 ["Cancel article" gnus-summary-cancel-article
2011 ,@(if (featurep 'xemacs) '(t)
2012 '(:help "Cancel an article you posted"))]
2013 ["Reply" gnus-summary-reply t]
2014 ["Reply and yank" gnus-summary-reply-with-original t]
2015 ["Wide reply" gnus-summary-wide-reply t]
2016 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2017 ,@(if (featurep 'xemacs) '(t)
2018 '(:help "Mail a reply, quoting this article"))]
2019 ["Mail forward" gnus-summary-mail-forward t]
2020 ["Post forward" gnus-summary-post-forward t]
2021 ["Digest and mail" gnus-uu-digest-mail-forward t]
2022 ["Digest and post" gnus-uu-digest-post-forward t]
2023 ["Resend message" gnus-summary-resend-message t]
2024 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2025 ["Send a mail" gnus-summary-mail-other-window t]
2026 ["Uuencode and post" gnus-uu-post-news
2027 ,@(if (featurep 'xemacs) '(t)
2028 '(:help "Post a uuencoded article"))]
2029 ["Followup via news" gnus-summary-followup-to-mail t]
2030 ["Followup via news and yank"
2031 gnus-summary-followup-to-mail-with-original t]
2033 ;;["Send" gnus-summary-send-draft t]
2034 ;;["Send bounced" gnus-resend-bounced-mail t])
2038 ((not (keymapp gnus-summary-post-menu))
2039 (setq gnus-article-post-menu gnus-summary-post-menu))
2040 ((not gnus-article-post-menu)
2041 ;; Don't share post menu.
2042 (setq gnus-article-post-menu
2043 (copy-keymap gnus-summary-post-menu))))
2044 (define-key gnus-article-mode-map [menu-bar post]
2045 (cons "Post" gnus-article-post-menu))
2048 gnus-summary-misc-menu gnus-summary-mode-map ""
2051 ["Mark as read" gnus-summary-mark-as-read-forward t]
2052 ["Mark same subject and select"
2053 gnus-summary-kill-same-subject-and-select t]
2054 ["Mark same subject" gnus-summary-kill-same-subject t]
2055 ["Catchup" gnus-summary-catchup
2056 ,@(if (featurep 'xemacs) '(t)
2057 '(:help "Mark unread articles in this group as read"))]
2058 ["Catchup all" gnus-summary-catchup-all t]
2059 ["Catchup to here" gnus-summary-catchup-to-here t]
2060 ["Catchup from here" gnus-summary-catchup-from-here t]
2061 ["Catchup region" gnus-summary-mark-region-as-read t]
2062 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2064 ["Tick" gnus-summary-tick-article-forward t]
2065 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2066 ["Remove marks" gnus-summary-clear-mark-forward t]
2067 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2068 ["Set bookmark" gnus-summary-set-bookmark t]
2069 ["Remove bookmark" gnus-summary-remove-bookmark t])
2071 ["Marks..." gnus-summary-limit-to-marks t]
2072 ["Subject..." gnus-summary-limit-to-subject t]
2073 ["Author..." gnus-summary-limit-to-author t]
2074 ["Age..." gnus-summary-limit-to-age t]
2075 ["Extra..." gnus-summary-limit-to-extra t]
2076 ["Score" gnus-summary-limit-to-score t]
2077 ["Score" gnus-summary-limit-to-display-predicate t]
2078 ["Unread" gnus-summary-limit-to-unread t]
2079 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2080 ["Articles" gnus-summary-limit-to-articles t]
2081 ["Pop limit" gnus-summary-pop-limit t]
2082 ["Show dormant" gnus-summary-limit-include-dormant t]
2083 ["Hide childless dormant"
2084 gnus-summary-limit-exclude-childless-dormant t]
2085 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2086 ["Hide marked" gnus-summary-limit-exclude-marks t]
2087 ["Show expunged" gnus-summary-limit-include-expunged t])
2089 ["Set mark" gnus-summary-mark-as-processable t]
2090 ["Remove mark" gnus-summary-unmark-as-processable t]
2091 ["Remove all marks" gnus-summary-unmark-all-processable t]
2092 ["Mark above" gnus-uu-mark-over t]
2093 ["Mark series" gnus-uu-mark-series t]
2094 ["Mark region" gnus-uu-mark-region t]
2095 ["Unmark region" gnus-uu-unmark-region t]
2096 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2097 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2098 ["Mark all" gnus-uu-mark-all t]
2099 ["Mark buffer" gnus-uu-mark-buffer t]
2100 ["Mark sparse" gnus-uu-mark-sparse t]
2101 ["Mark thread" gnus-uu-mark-thread t]
2102 ["Unmark thread" gnus-uu-unmark-thread t]
2103 ("Process Mark Sets"
2104 ["Kill" gnus-summary-kill-process-mark t]
2105 ["Yank" gnus-summary-yank-process-mark
2106 gnus-newsgroup-process-stack]
2107 ["Save" gnus-summary-save-process-mark t]))
2109 ["Page forward" gnus-summary-next-page
2110 ,@(if (featurep 'xemacs) '(t)
2111 '(:help "Show next page of article"))]
2112 ["Page backward" gnus-summary-prev-page
2113 ,@(if (featurep 'xemacs) '(t)
2114 '(:help "Show previous page of article"))]
2115 ["Line forward" gnus-summary-scroll-up t])
2117 ["Next unread article" gnus-summary-next-unread-article t]
2118 ["Previous unread article" gnus-summary-prev-unread-article t]
2119 ["Next article" gnus-summary-next-article t]
2120 ["Previous article" gnus-summary-prev-article t]
2121 ["Next unread subject" gnus-summary-next-unread-subject t]
2122 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2123 ["Next article same subject" gnus-summary-next-same-subject t]
2124 ["Previous article same subject" gnus-summary-prev-same-subject t]
2125 ["First unread article" gnus-summary-first-unread-article t]
2126 ["Best unread article" gnus-summary-best-unread-article t]
2127 ["Go to subject number..." gnus-summary-goto-subject t]
2128 ["Go to article number..." gnus-summary-goto-article t]
2129 ["Go to the last article" gnus-summary-goto-last-article t]
2130 ["Pop article off history" gnus-summary-pop-article t])
2132 ["Sort by number" gnus-summary-sort-by-number t]
2133 ["Sort by author" gnus-summary-sort-by-author t]
2134 ["Sort by subject" gnus-summary-sort-by-subject t]
2135 ["Sort by date" gnus-summary-sort-by-date t]
2136 ["Sort by score" gnus-summary-sort-by-score t]
2137 ["Sort by lines" gnus-summary-sort-by-lines t]
2138 ["Sort by characters" gnus-summary-sort-by-chars t]
2139 ["Original sort" gnus-summary-sort-by-original t])
2141 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2142 ["Describe group" gnus-summary-describe-group t]
2143 ["Read manual" gnus-info-find-node t])
2145 ["Pick and read" gnus-pick-mode t]
2146 ["Binary" gnus-binary-mode t])
2148 ["Regenerate" gnus-summary-prepare t]
2149 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2150 ["Toggle threading" gnus-summary-toggle-threads t])
2151 ["See old articles" gnus-summary-insert-old-articles t]
2152 ["See new articles" gnus-summary-insert-new-articles t]
2153 ["Filter articles..." gnus-summary-execute-command t]
2154 ["Run command on subjects..." gnus-summary-universal-argument t]
2155 ["Search articles forward..." gnus-summary-search-article-forward t]
2156 ["Search articles backward..." gnus-summary-search-article-backward t]
2157 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2158 ["Expand window" gnus-summary-expand-window t]
2159 ["Expire expirable articles" gnus-summary-expire-articles
2160 (gnus-check-backend-function
2161 'request-expire-articles gnus-newsgroup-name)]
2162 ["Edit local kill file" gnus-summary-edit-local-kill t]
2163 ["Edit main kill file" gnus-summary-edit-global-kill t]
2164 ["Edit group parameters" gnus-summary-edit-parameters t]
2165 ["Customize group parameters" gnus-summary-customize-parameters t]
2166 ["Send a bug report" gnus-bug t]
2168 ["Catchup and exit" gnus-summary-catchup-and-exit
2169 ,@(if (featurep 'xemacs) '(t)
2170 '(:help "Mark unread articles in this group as read, then exit"))]
2171 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2172 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2173 ["Exit group" gnus-summary-exit
2174 ,@(if (featurep 'xemacs) '(t)
2175 '(:help "Exit current group, return to group selection mode"))]
2176 ["Exit group without updating" gnus-summary-exit-no-update t]
2177 ["Exit and goto next group" gnus-summary-next-group t]
2178 ["Exit and goto prev group" gnus-summary-prev-group t]
2179 ["Reselect group" gnus-summary-reselect-current-group t]
2180 ["Rescan group" gnus-summary-rescan-group t]
2181 ["Update dribble" gnus-summary-save-newsrc t])))
2183 (gnus-run-hooks 'gnus-summary-menu-hook)))
2185 (defvar gnus-summary-tool-bar-map nil)
2187 ;; Emacs 21 tool bar. Should be no-op otherwise.
2188 (defun gnus-summary-make-tool-bar ()
2189 (if (and (fboundp 'tool-bar-add-item-from-menu)
2190 (default-value 'tool-bar-mode)
2191 (not gnus-summary-tool-bar-map))
2192 (setq gnus-summary-tool-bar-map
2193 (let ((tool-bar-map (make-sparse-keymap))
2194 (load-path (mm-image-load-path)))
2195 (tool-bar-add-item-from-menu
2196 'gnus-summary-prev-unread "prev-ur" gnus-summary-mode-map)
2197 (tool-bar-add-item-from-menu
2198 'gnus-summary-next-unread "next-ur" gnus-summary-mode-map)
2199 (tool-bar-add-item-from-menu
2200 'gnus-summary-post-news "post" gnus-summary-mode-map)
2201 (tool-bar-add-item-from-menu
2202 'gnus-summary-followup-with-original "fuwo" gnus-summary-mode-map)
2203 (tool-bar-add-item-from-menu
2204 'gnus-summary-followup "followup" gnus-summary-mode-map)
2205 (tool-bar-add-item-from-menu
2206 'gnus-summary-reply-with-original "reply-wo" gnus-summary-mode-map)
2207 (tool-bar-add-item-from-menu
2208 'gnus-summary-reply "reply" gnus-summary-mode-map)
2209 (tool-bar-add-item-from-menu
2210 'gnus-summary-caesar-message "rot13" gnus-summary-mode-map)
2211 (tool-bar-add-item-from-menu
2212 'gnus-uu-decode-uu "uu-decode" gnus-summary-mode-map)
2213 (tool-bar-add-item-from-menu
2214 'gnus-summary-save-article-file "save-aif" gnus-summary-mode-map)
2215 (tool-bar-add-item-from-menu
2216 'gnus-summary-save-article "save-art" gnus-summary-mode-map)
2217 (tool-bar-add-item-from-menu
2218 'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2219 (tool-bar-add-item-from-menu
2220 'gnus-summary-catchup "catchup" gnus-summary-mode-map)
2221 (tool-bar-add-item-from-menu
2222 'gnus-summary-catchup-and-exit "cu-exit" gnus-summary-mode-map)
2223 (tool-bar-add-item-from-menu
2224 'gnus-summary-exit "exit-summ" gnus-summary-mode-map)
2226 (if gnus-summary-tool-bar-map
2227 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
2229 (defun gnus-score-set-default (var value)
2230 "A version of set that updates the GNU Emacs menu-bar."
2232 ;; It is the message that forces the active status to be updated.
2235 (defun gnus-make-score-map (type)
2236 "Make a summary score map of type TYPE."
2239 (let ((headers '(("author" "from" string)
2240 ("subject" "subject" string)
2241 ("article body" "body" string)
2242 ("article head" "head" string)
2243 ("xref" "xref" string)
2244 ("extra header" "extra" string)
2245 ("lines" "lines" number)
2246 ("followups to author" "followup" string)))
2247 (types '((number ("less than" <)
2250 (string ("substring" s)
2254 (perms '(("temporary" (current-time-string))
2262 (if (eq type 'lower)
2267 (setq header (car headers))
2273 (let ((ts (cdr (assoc (nth 2 header) types)))
2289 'gnus-summary-score-entry
2291 (if (or (string= (nth 1 header)
2293 (string= (nth 1 header)
2296 (list 'gnus-summary-header
2298 (list 'quote (nth 1 (car ts)))
2299 (list 'gnus-score-delta-default
2306 (list (nreverse outp))))
2309 (list (nreverse outt))))
2311 (setq headers (cdr headers)))
2312 (list (nreverse outh))))))))
2316 (defun gnus-summary-mode (&optional group)
2317 "Major mode for reading articles.
2319 All normal editing commands are switched off.
2320 \\<gnus-summary-mode-map>
2321 Each line in this buffer represents one article. To read an
2322 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2323 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2326 You can also post articles and send mail from this buffer. To
2327 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2328 of an article, type `\\[gnus-summary-reply]'.
2330 There are approx. one gazillion commands you can execute in this
2331 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2333 The following commands are available:
2335 \\{gnus-summary-mode-map}"
2337 (kill-all-local-variables)
2338 (when (gnus-visual-p 'summary-menu 'menu)
2339 (gnus-summary-make-menu-bar)
2340 (gnus-summary-make-tool-bar))
2341 (gnus-summary-make-local-variables)
2342 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2343 (gnus-summary-make-local-variables))
2344 (gnus-make-thread-indent-array)
2345 (gnus-simplify-mode-line)
2346 (setq major-mode 'gnus-summary-mode)
2347 (setq mode-name "Summary")
2348 (make-local-variable 'minor-mode-alist)
2349 (use-local-map gnus-summary-mode-map)
2350 (buffer-disable-undo)
2351 (setq buffer-read-only t) ;Disable modification
2352 (setq truncate-lines t)
2353 (setq selective-display t)
2354 (setq selective-display-ellipses t) ;Display `...'
2355 (gnus-summary-set-display-table)
2356 (gnus-set-default-directory)
2357 (setq gnus-newsgroup-name group)
2358 (make-local-variable 'gnus-summary-line-format)
2359 (make-local-variable 'gnus-summary-line-format-spec)
2360 (make-local-variable 'gnus-summary-dummy-line-format)
2361 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2362 (make-local-variable 'gnus-summary-mark-positions)
2363 (make-local-hook 'pre-command-hook)
2364 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2365 (gnus-run-hooks 'gnus-summary-mode-hook)
2366 (turn-on-gnus-mailing-list-mode)
2367 (mm-enable-multibyte-mule4)
2368 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2369 (gnus-update-summary-mark-positions))
2371 (defun gnus-summary-make-local-variables ()
2372 "Make all the local summary buffer variables."
2374 (dolist (local gnus-summary-local-variables)
2377 (if (eq (cdr local) 'global)
2378 ;; Copy the global value of the variable.
2379 (setq global (symbol-value (car local)))
2380 ;; Use the value from the list.
2381 (setq global (eval (cdr local))))
2382 (set (make-local-variable (car local)) global))
2383 ;; Simple nil-valued local variable.
2384 (set (make-local-variable local) nil)))))
2386 (defun gnus-summary-clear-local-variables ()
2387 (let ((locals gnus-summary-local-variables))
2389 (if (consp (car locals))
2390 (and (vectorp (caar locals))
2391 (set (caar locals) nil))
2392 (and (vectorp (car locals))
2393 (set (car locals) nil)))
2394 (setq locals (cdr locals)))))
2396 ;; Summary data functions.
2398 (defmacro gnus-data-number (data)
2401 (defmacro gnus-data-set-number (data number)
2402 `(setcar ,data ,number))
2404 (defmacro gnus-data-mark (data)
2407 (defmacro gnus-data-set-mark (data mark)
2408 `(setcar (nthcdr 1 ,data) ,mark))
2410 (defmacro gnus-data-pos (data)
2413 (defmacro gnus-data-set-pos (data pos)
2414 `(setcar (nthcdr 2 ,data) ,pos))
2416 (defmacro gnus-data-header (data)
2419 (defmacro gnus-data-set-header (data header)
2420 `(setf (nth 3 ,data) ,header))
2422 (defmacro gnus-data-level (data)
2425 (defmacro gnus-data-unread-p (data)
2426 `(= (nth 1 ,data) gnus-unread-mark))
2428 (defmacro gnus-data-read-p (data)
2429 `(/= (nth 1 ,data) gnus-unread-mark))
2431 (defmacro gnus-data-pseudo-p (data)
2432 `(consp (nth 3 ,data)))
2434 (defmacro gnus-data-find (number)
2435 `(assq ,number gnus-newsgroup-data))
2437 (defmacro gnus-data-find-list (number &optional data)
2438 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2439 (memq (assq ,number bdata)
2442 (defmacro gnus-data-make (number mark pos header level)
2443 `(list ,number ,mark ,pos ,header ,level))
2445 (defun gnus-data-enter (after-article number mark pos header level offset)
2446 (let ((data (gnus-data-find-list after-article)))
2448 (error "No such article: %d" after-article))
2449 (setcdr data (cons (gnus-data-make number mark pos header level)
2451 (setq gnus-newsgroup-data-reverse nil)
2452 (gnus-data-update-list (cddr data) offset)))
2454 (defun gnus-data-enter-list (after-article list &optional offset)
2456 (let ((data (and after-article (gnus-data-find-list after-article)))
2460 (let ((odata gnus-newsgroup-data))
2461 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2463 (gnus-data-update-list odata offset)))
2464 ;; Find the last element in the list to be spliced into the main
2467 (setq list (cdr list)))
2470 (setcdr list gnus-newsgroup-data)
2471 (setq gnus-newsgroup-data ilist)
2473 (gnus-data-update-list (cdr list) offset)))
2474 (setcdr list (cdr data))
2477 (gnus-data-update-list (cdr list) offset))))
2478 (setq gnus-newsgroup-data-reverse nil))))
2480 (defun gnus-data-remove (article &optional offset)
2481 (let ((data gnus-newsgroup-data))
2482 (if (= (gnus-data-number (car data)) article)
2484 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2485 gnus-newsgroup-data-reverse nil)
2487 (gnus-data-update-list gnus-newsgroup-data offset)))
2489 (when (= (gnus-data-number (cadr data)) article)
2490 (setcdr data (cddr data))
2492 (gnus-data-update-list (cdr data) offset))
2494 gnus-newsgroup-data-reverse nil))
2495 (setq data (cdr data))))))
2497 (defmacro gnus-data-list (backward)
2499 (or gnus-newsgroup-data-reverse
2500 (setq gnus-newsgroup-data-reverse
2501 (reverse gnus-newsgroup-data)))
2502 gnus-newsgroup-data))
2504 (defun gnus-data-update-list (data offset)
2505 "Add OFFSET to the POS of all data entries in DATA."
2506 (setq gnus-newsgroup-data-reverse nil)
2508 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2509 (setq data (cdr data))))
2511 (defun gnus-summary-article-pseudo-p (article)
2512 "Say whether this article is a pseudo article or not."
2513 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2515 (defmacro gnus-summary-article-sparse-p (article)
2516 "Say whether this article is a sparse article or not."
2517 `(memq ,article gnus-newsgroup-sparse))
2519 (defmacro gnus-summary-article-ancient-p (article)
2520 "Say whether this article is a sparse article or not."
2521 `(memq ,article gnus-newsgroup-ancient))
2523 (defun gnus-article-parent-p (number)
2524 "Say whether this article is a parent or not."
2525 (let ((data (gnus-data-find-list number)))
2526 (and (cdr data) ; There has to be an article after...
2527 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2528 (gnus-data-level (nth 1 data))))))
2530 (defun gnus-article-children (number)
2531 "Return a list of all children to NUMBER."
2532 (let* ((data (gnus-data-find-list number))
2533 (level (gnus-data-level (car data)))
2535 (setq data (cdr data))
2537 (= (gnus-data-level (car data)) (1+ level)))
2538 (push (gnus-data-number (car data)) children)
2539 (setq data (cdr data)))
2542 (defmacro gnus-summary-skip-intangible ()
2543 "If the current article is intangible, then jump to a different article."
2544 '(let ((to (get-text-property (point) 'gnus-intangible)))
2545 (and to (gnus-summary-goto-subject to))))
2547 (defmacro gnus-summary-article-intangible-p ()
2548 "Say whether this article is intangible or not."
2549 '(get-text-property (point) 'gnus-intangible))
2551 (defun gnus-article-read-p (article)
2552 "Say whether ARTICLE is read or not."
2553 (not (or (memq article gnus-newsgroup-marked)
2554 (memq article gnus-newsgroup-unreads)
2555 (memq article gnus-newsgroup-unselected)
2556 (memq article gnus-newsgroup-dormant))))
2558 ;; Some summary mode macros.
2560 (defmacro gnus-summary-article-number ()
2561 "The article number of the article on the current line.
2562 If there isn's an article number here, then we return the current
2565 (gnus-summary-skip-intangible)
2566 (or (get-text-property (point) 'gnus-number)
2567 (gnus-summary-last-subject))))
2569 (defmacro gnus-summary-article-header (&optional number)
2570 "Return the header of article NUMBER."
2571 `(gnus-data-header (gnus-data-find
2572 ,(or number '(gnus-summary-article-number)))))
2574 (defmacro gnus-summary-thread-level (&optional number)
2575 "Return the level of thread that starts with article NUMBER."
2576 `(if (and (eq gnus-summary-make-false-root 'dummy)
2577 (get-text-property (point) 'gnus-intangible))
2579 (gnus-data-level (gnus-data-find
2580 ,(or number '(gnus-summary-article-number))))))
2582 (defmacro gnus-summary-article-mark (&optional number)
2583 "Return the mark of article NUMBER."
2584 `(gnus-data-mark (gnus-data-find
2585 ,(or number '(gnus-summary-article-number)))))
2587 (defmacro gnus-summary-article-pos (&optional number)
2588 "Return the position of the line of article NUMBER."
2589 `(gnus-data-pos (gnus-data-find
2590 ,(or number '(gnus-summary-article-number)))))
2592 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2593 (defmacro gnus-summary-article-subject (&optional number)
2594 "Return current subject string or nil if nothing."
2597 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2598 '(gnus-data-header (assq (gnus-summary-article-number)
2599 gnus-newsgroup-data)))))
2602 (mail-header-subject headers))))
2604 (defmacro gnus-summary-article-score (&optional number)
2605 "Return current article score."
2606 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2607 gnus-newsgroup-scored))
2608 gnus-summary-default-score 0))
2610 (defun gnus-summary-article-children (&optional number)
2611 "Return a list of article numbers that are children of article NUMBER."
2612 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2613 (level (gnus-data-level (car data)))
2615 (while (and (setq data (cdr data))
2616 (> (setq l (gnus-data-level (car data))) level))
2617 (and (= (1+ level) l)
2618 (push (gnus-data-number (car data))
2620 (nreverse children)))
2622 (defun gnus-summary-article-parent (&optional number)
2623 "Return the article number of the parent of article NUMBER."
2624 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2625 (gnus-data-list t)))
2626 (level (gnus-data-level (car data))))
2628 () ; This is a root.
2629 ;; We search until we find an article with a level less than
2630 ;; this one. That function has to be the parent.
2631 (while (and (setq data (cdr data))
2632 (not (< (gnus-data-level (car data)) level))))
2633 (and data (gnus-data-number (car data))))))
2635 (defun gnus-unread-mark-p (mark)
2636 "Say whether MARK is the unread mark."
2637 (= mark gnus-unread-mark))
2639 (defun gnus-read-mark-p (mark)
2640 "Say whether MARK is one of the marks that mark as read.
2641 This is all marks except unread, ticked, dormant, and expirable."
2642 (not (or (= mark gnus-unread-mark)
2643 (= mark gnus-ticked-mark)
2644 (= mark gnus-dormant-mark)
2645 (= mark gnus-expirable-mark))))
2647 (defmacro gnus-article-mark (number)
2648 "Return the MARK of article NUMBER.
2649 This macro should only be used when computing the mark the \"first\"
2650 time; i.e., when generating the summary lines. After that,
2651 `gnus-summary-article-mark' should be used to examine the
2654 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2655 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2656 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2657 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2658 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2659 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2660 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2661 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2662 gnus-ancient-mark))))
2664 ;; Saving hidden threads.
2666 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2667 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2669 (defmacro gnus-save-hidden-threads (&rest forms)
2670 "Save hidden threads, eval FORMS, and restore the hidden threads."
2671 (let ((config (make-symbol "config")))
2672 `(let ((,config (gnus-hidden-threads-configuration)))
2676 (gnus-restore-hidden-threads-configuration ,config)))))
2678 (defun gnus-data-compute-positions ()
2679 "Compute the positions of all articles."
2680 (setq gnus-newsgroup-data-reverse nil)
2681 (let ((data gnus-newsgroup-data))
2683 (gnus-save-hidden-threads
2684 (gnus-summary-show-all-threads)
2685 (goto-char (point-min))
2687 (while (get-text-property (point) 'gnus-intangible)
2689 (gnus-data-set-pos (car data) (+ (point) 3))
2690 (setq data (cdr data))
2691 (forward-line 1))))))
2693 (defun gnus-hidden-threads-configuration ()
2694 "Return the current hidden threads configuration."
2697 (goto-char (point-min))
2698 (while (search-forward "\r" nil t)
2699 (push (1- (point)) config))
2702 (defun gnus-restore-hidden-threads-configuration (config)
2703 "Restore hidden threads configuration from CONFIG."
2705 (let (point buffer-read-only)
2706 (while (setq point (pop config))
2707 (when (and (< point (point-max))
2709 (eq (char-after) ?\n))
2710 (subst-char-in-region point (1+ point) ?\n ?\r))))))
2712 ;; Various summary mode internalish functions.
2714 (defun gnus-mouse-pick-article (e)
2717 (gnus-summary-next-page nil t))
2719 (defun gnus-summary-set-display-table ()
2720 "Change the display table.
2721 Odd characters have a tendency to mess
2722 up nicely formatted displays - we make all possible glyphs
2723 display only a single character."
2725 ;; We start from the standard display table, if any.
2726 (let ((table (or (copy-sequence standard-display-table)
2727 (make-display-table)))
2729 ;; Nix out all the control chars...
2730 (while (>= (setq i (1- i)) 0)
2731 (aset table i [??]))
2732 ;; ... but not newline and cr, of course. (cr is necessary for the
2733 ;; selective display).
2734 (aset table ?\n nil)
2735 (aset table ?\r nil)
2736 ;; We keep TAB as well.
2737 (aset table ?\t nil)
2738 ;; We nix out any glyphs over 126 that are not set already.
2740 (while (>= (setq i (1- i)) 127)
2741 ;; Only modify if the entry is nil.
2742 (unless (aref table i)
2743 (aset table i [??]))))
2744 (setq buffer-display-table table)))
2746 (defun gnus-summary-set-article-display-arrow (pos)
2747 "Update the overlay arrow to point to line at position POS."
2748 (when (and gnus-summary-display-arrow
2749 (boundp 'overlay-arrow-position)
2750 (boundp 'overlay-arrow-string))
2754 (unless overlay-arrow-position
2755 (setq overlay-arrow-position (make-marker)))
2756 (setq overlay-arrow-string "=>"
2757 overlay-arrow-position (set-marker overlay-arrow-position
2759 (current-buffer))))))
2761 (defun gnus-summary-buffer-name (group)
2762 "Return the summary buffer name of GROUP."
2763 (concat "*Summary " group "*"))
2765 (defun gnus-summary-setup-buffer (group)
2766 "Initialize summary buffer."
2767 (let ((buffer (gnus-summary-buffer-name group)))
2768 (if (get-buffer buffer)
2771 (setq gnus-summary-buffer (current-buffer))
2772 (not gnus-newsgroup-prepared))
2773 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2774 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
2775 (gnus-summary-mode group)
2777 (gnus-carpal-setup-buffer 'summary))
2778 (unless gnus-single-article-buffer
2779 (make-local-variable 'gnus-article-buffer)
2780 (make-local-variable 'gnus-article-current)
2781 (make-local-variable 'gnus-original-article-buffer))
2782 (setq gnus-newsgroup-name group)
2783 ;; Set any local variables in the group parameters.
2784 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2787 (defun gnus-set-global-variables ()
2788 "Set the global equivalents of the buffer-local variables.
2789 They are set to the latest values they had. These reflect the summary
2790 buffer that was in action when the last article was fetched."
2791 (when (eq major-mode 'gnus-summary-mode)
2792 (setq gnus-summary-buffer (current-buffer))
2793 (let ((name gnus-newsgroup-name)
2794 (marked gnus-newsgroup-marked)
2795 (unread gnus-newsgroup-unreads)
2796 (headers gnus-current-headers)
2797 (data gnus-newsgroup-data)
2798 (summary gnus-summary-buffer)
2799 (article-buffer gnus-article-buffer)
2800 (original gnus-original-article-buffer)
2801 (gac gnus-article-current)
2802 (reffed gnus-reffed-article-number)
2803 (score-file gnus-current-score-file)
2804 (default-charset gnus-newsgroup-charset)
2806 (let ((locals gnus-newsgroup-variables))
2808 (if (consp (car locals))
2809 (push (eval (caar locals)) vlist)
2810 (push (eval (car locals)) vlist))
2811 (setq locals (cdr locals)))
2812 (setq vlist (nreverse vlist)))
2814 (set-buffer gnus-group-buffer)
2815 (setq gnus-newsgroup-name name
2816 gnus-newsgroup-marked marked
2817 gnus-newsgroup-unreads unread
2818 gnus-current-headers headers
2819 gnus-newsgroup-data data
2820 gnus-article-current gac
2821 gnus-summary-buffer summary
2822 gnus-article-buffer article-buffer
2823 gnus-original-article-buffer original
2824 gnus-reffed-article-number reffed
2825 gnus-current-score-file score-file
2826 gnus-newsgroup-charset default-charset)
2827 (let ((locals gnus-newsgroup-variables))
2829 (if (consp (car locals))
2830 (set (caar locals) (pop vlist))
2831 (set (car locals) (pop vlist)))
2832 (setq locals (cdr locals))))
2833 ;; The article buffer also has local variables.
2834 (when (gnus-buffer-live-p gnus-article-buffer)
2835 (set-buffer gnus-article-buffer)
2836 (setq gnus-summary-buffer summary))))))
2838 (defun gnus-summary-article-unread-p (article)
2839 "Say whether ARTICLE is unread or not."
2840 (memq article gnus-newsgroup-unreads))
2842 (defun gnus-summary-first-article-p (&optional article)
2843 "Return whether ARTICLE is the first article in the buffer."
2844 (if (not (setq article (or article (gnus-summary-article-number))))
2846 (eq article (caar gnus-newsgroup-data))))
2848 (defun gnus-summary-last-article-p (&optional article)
2849 "Return whether ARTICLE is the last article in the buffer."
2850 (if (not (setq article (or article (gnus-summary-article-number))))
2851 ;; All non-existent numbers are the last article. :-)
2853 (not (cdr (gnus-data-find-list article)))))
2855 (defun gnus-make-thread-indent-array ()
2857 (unless (and gnus-thread-indent-array
2858 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2859 (setq gnus-thread-indent-array (make-vector 201 "")
2860 gnus-thread-indent-array-level gnus-thread-indent-level)
2862 (aset gnus-thread-indent-array n
2863 (make-string (* n gnus-thread-indent-level) ? ))
2866 (defun gnus-update-summary-mark-positions ()
2867 "Compute where the summary marks are to go."
2869 (when (gnus-buffer-exists-p gnus-summary-buffer)
2870 (set-buffer gnus-summary-buffer))
2871 (let ((gnus-replied-mark 129)
2872 (gnus-score-below-mark 130)
2873 (gnus-score-over-mark 130)
2874 (gnus-download-mark 131)
2875 (spec gnus-summary-line-format-spec)
2878 (gnus-set-work-buffer)
2879 (let ((gnus-summary-line-format-spec spec)
2880 (gnus-newsgroup-downloadable '((0 . t))))
2881 (gnus-summary-insert-line
2882 [0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil]
2883 0 nil 128 t nil "" nil 1)
2884 (goto-char (point-min))
2885 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2887 (goto-char (point-min))
2888 (push (cons 'replied (and (search-forward "\201" nil t)
2891 (goto-char (point-min))
2892 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2894 (goto-char (point-min))
2895 (push (cons 'download
2896 (and (search-forward "\203" nil t) (- (point) 2)))
2898 (setq gnus-summary-mark-positions pos))))
2900 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2901 "Insert a dummy root in the summary buffer."
2903 (gnus-add-text-properties
2904 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2905 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2907 (defun gnus-summary-from-or-to-or-newsgroups (header)
2908 (let ((to (cdr (assq 'To (mail-header-extra header))))
2909 (newsgroups (cdr (assq 'Newsgroups (mail-header-extra header))))
2910 (mail-parse-charset gnus-newsgroup-charset)
2911 (mail-parse-ignored-charsets
2912 (save-excursion (set-buffer gnus-summary-buffer)
2913 gnus-newsgroup-ignored-charsets)))
2916 gnus-ignored-from-addresses
2917 (string-match gnus-ignored-from-addresses
2918 (mail-header-from header)))
2920 (or (car (funcall gnus-extract-address-components
2922 gnus-decode-encoded-word-function to)))
2923 (funcall gnus-decode-encoded-word-function to))))
2925 gnus-ignored-from-addresses
2926 (string-match gnus-ignored-from-addresses
2927 (mail-header-from header)))
2928 (concat "=> " newsgroups))
2930 (or (car (funcall gnus-extract-address-components
2931 (mail-header-from header)))
2932 (mail-header-from header))))))
2934 (defun gnus-summary-insert-line (gnus-tmp-header
2935 gnus-tmp-level gnus-tmp-current
2936 gnus-tmp-unread gnus-tmp-replied
2937 gnus-tmp-expirable gnus-tmp-subject-or-nil
2938 &optional gnus-tmp-dummy gnus-tmp-score
2940 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2941 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2942 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2943 (gnus-tmp-score-char
2944 (if (or (null gnus-summary-default-score)
2945 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2946 gnus-summary-zcore-fuzz))
2948 (if (< gnus-tmp-score gnus-summary-default-score)
2949 gnus-score-below-mark gnus-score-over-mark)))
2950 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2952 (cond (gnus-tmp-process gnus-process-mark)
2953 ((memq gnus-tmp-current gnus-newsgroup-cached)
2955 (gnus-tmp-replied gnus-replied-mark)
2956 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
2957 gnus-forwarded-mark)
2958 ((memq gnus-tmp-current gnus-newsgroup-saved)
2960 ((memq gnus-tmp-number gnus-newsgroup-recent)
2962 ((memq gnus-tmp-number gnus-newsgroup-unseen)
2965 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2968 ((string-match "<[^>]+> *$" gnus-tmp-from)
2969 (let ((beg (match-beginning 0)))
2970 (or (and (string-match "^\".+\"" gnus-tmp-from)
2971 (substring gnus-tmp-from 1 (1- (match-end 0))))
2972 (substring gnus-tmp-from 0 beg))))
2973 ((string-match "(.+)" gnus-tmp-from)
2974 (substring gnus-tmp-from
2975 (1+ (match-beginning 0)) (1- (match-end 0))))
2977 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2978 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2979 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
2980 (buffer-read-only nil))
2981 (when (string= gnus-tmp-name "")
2982 (setq gnus-tmp-name gnus-tmp-from))
2983 (unless (numberp gnus-tmp-lines)
2984 (setq gnus-tmp-lines -1))
2985 (if (= gnus-tmp-lines -1)
2986 (setq gnus-tmp-lines "?")
2987 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
2988 (gnus-put-text-property
2990 (progn (eval gnus-summary-line-format-spec) (point))
2991 'gnus-number gnus-tmp-number)
2992 (when (gnus-visual-p 'summary-highlight 'highlight)
2994 (gnus-run-hooks 'gnus-summary-update-hook)
2997 (defun gnus-summary-update-line (&optional dont-update)
2998 "Update summary line after change."
2999 (when (and gnus-summary-default-score
3000 (not gnus-summary-inhibit-highlight))
3001 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3002 (article (gnus-summary-article-number))
3003 (score (gnus-summary-article-score article)))
3005 (if (and gnus-summary-mark-below
3006 (< (gnus-summary-article-score)
3007 gnus-summary-mark-below))
3008 ;; This article has a low score, so we mark it as read.
3009 (when (memq article gnus-newsgroup-unreads)
3010 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3011 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3012 ;; This article was previously marked as read on account
3013 ;; of a low score, but now it has risen, so we mark it as
3015 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3016 (gnus-summary-update-mark
3017 (if (or (null gnus-summary-default-score)
3018 (<= (abs (- score gnus-summary-default-score))
3019 gnus-summary-zcore-fuzz))
3021 (if (< score gnus-summary-default-score)
3022 gnus-score-below-mark gnus-score-over-mark))
3024 ;; Do visual highlighting.
3025 (when (gnus-visual-p 'summary-highlight 'highlight)
3026 (gnus-run-hooks 'gnus-summary-update-hook)))))
3028 (defvar gnus-tmp-new-adopts nil)
3030 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3031 "Return the number of articles in THREAD.
3032 This may be 0 in some cases -- if none of the articles in
3033 the thread are to be displayed."
3035 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3037 ((not (listp thread))
3039 ((and (consp thread) (cdr thread))
3042 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3045 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3048 (when (and level (zerop level) gnus-tmp-new-adopts)
3051 'gnus-summary-number-of-articles-in-thread
3052 gnus-tmp-new-adopts))))
3054 (if (> number 1) gnus-not-empty-thread-mark
3055 gnus-empty-thread-mark)
3058 (defun gnus-summary-set-local-parameters (group)
3059 "Go through the local params of GROUP and set all variable specs in that list."
3060 (let ((params (gnus-group-find-parameter group))
3061 (vars '(quit-config)) ; Ignore quit-config.
3064 (setq elem (car params)
3065 params (cdr params))
3066 (and (consp elem) ; Has to be a cons.
3067 (consp (cdr elem)) ; The cdr has to be a list.
3068 (symbolp (car elem)) ; Has to be a symbol in there.
3069 (not (memq (car elem) vars))
3070 (ignore-errors ; So we set it.
3071 (push (car elem) vars)
3072 (make-local-variable (car elem))
3073 (set (car elem) (eval (nth 1 elem))))))))
3075 (defun gnus-summary-read-group (group &optional show-all no-article
3076 kill-buffer no-display backward
3078 "Start reading news in newsgroup GROUP.
3079 If SHOW-ALL is non-nil, already read articles are also listed.
3080 If NO-ARTICLE is non-nil, no article is selected initially.
3081 If NO-DISPLAY, don't generate a summary buffer."
3085 (let ((gnus-auto-select-next nil))
3086 (or (gnus-summary-read-group-1
3087 group show-all no-article
3088 kill-buffer no-display
3091 select-articles nil)))))
3092 (eq gnus-auto-select-next 'quietly))
3093 (set-buffer gnus-group-buffer)
3094 ;; The entry function called above goes to the next
3095 ;; group automatically, so we go two groups back
3096 ;; if we are searching for the previous group.
3098 (gnus-group-prev-unread-group 2))
3099 (if (not (equal group (gnus-group-group-name)))
3100 (setq group (gnus-group-group-name))
3104 (defun gnus-summary-read-group-1 (group show-all no-article
3105 kill-buffer no-display
3106 &optional select-articles)
3107 ;; Killed foreign groups can't be entered.
3108 ;; (when (and (not (gnus-group-native-p group))
3109 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3110 ;; (error "Dead non-native groups can't be entered"))
3111 (gnus-message 5 "Retrieving newsgroup: %s..."
3112 (gnus-group-decoded-name group))
3113 (let* ((new-group (gnus-summary-setup-buffer group))
3114 (quit-config (gnus-group-quit-config group))
3115 (did-select (and new-group (gnus-select-newsgroup
3116 group show-all select-articles))))
3118 ;; This summary buffer exists already, so we just select it.
3120 (gnus-set-global-variables)
3122 (gnus-kill-or-deaden-summary kill-buffer))
3123 (gnus-configure-windows 'summary 'force)
3124 (gnus-set-mode-line 'summary)
3125 (gnus-summary-position-point)
3128 ;; We couldn't select this group.
3130 (when (and (eq major-mode 'gnus-summary-mode)
3131 (not (equal (current-buffer) kill-buffer)))
3132 (kill-buffer (current-buffer))
3133 (if (not quit-config)
3135 ;; Update the info -- marks might need to be removed,
3137 (gnus-summary-update-info)
3138 (set-buffer gnus-group-buffer)
3139 (gnus-group-jump-to-group group)
3140 (gnus-group-next-unread-group 1))
3141 (gnus-handle-ephemeral-exit quit-config)))
3142 (let ((grpinfo (gnus-get-info group)))
3143 (if (null (gnus-info-read grpinfo))
3144 (gnus-message 3 "Group %s contains no messages"
3145 (gnus-group-decoded-name group))
3146 (gnus-message 3 "Can't select group")))
3148 ;; The user did a `C-g' while prompting for number of articles,
3149 ;; so we exit this group.
3150 ((eq did-select 'quit)
3151 (and (eq major-mode 'gnus-summary-mode)
3152 (not (equal (current-buffer) kill-buffer))
3153 (kill-buffer (current-buffer)))
3155 (gnus-kill-or-deaden-summary kill-buffer))
3156 (if (not quit-config)
3158 (set-buffer gnus-group-buffer)
3159 (gnus-group-jump-to-group group)
3160 (gnus-group-next-unread-group 1)
3161 (gnus-configure-windows 'group 'force))
3162 (gnus-handle-ephemeral-exit quit-config))
3163 ;; Finally signal the quit.
3165 ;; The group was successfully selected.
3167 (gnus-set-global-variables)
3168 ;; Save the active value in effect when the group was entered.
3169 (setq gnus-newsgroup-active
3171 (gnus-active gnus-newsgroup-name)))
3172 ;; You can change the summary buffer in some way with this hook.
3173 (gnus-run-hooks 'gnus-select-group-hook)
3174 (gnus-update-format-specifications
3175 nil 'summary 'summary-mode 'summary-dummy)
3176 (gnus-update-summary-mark-positions)
3177 ;; Do score processing.
3178 (when gnus-use-scoring
3179 (gnus-possibly-score-headers))
3180 ;; Check whether to fill in the gaps in the threads.
3181 (when gnus-build-sparse-threads
3182 (gnus-build-sparse-threads))
3183 ;; Find the initial limit.
3184 (if gnus-show-threads
3186 (let ((gnus-newsgroup-dormant nil))
3187 (gnus-summary-initial-limit show-all))
3188 (gnus-summary-initial-limit show-all))
3189 ;; When untreaded, all articles are always shown.
3190 (setq gnus-newsgroup-limit
3192 (lambda (header) (mail-header-number header))
3193 gnus-newsgroup-headers)))
3194 ;; Generate the summary buffer.
3196 (gnus-summary-prepare))
3197 (when gnus-use-trees
3198 (gnus-tree-open group)
3199 (setq gnus-summary-highlight-line-function
3200 'gnus-tree-highlight-article))
3201 ;; If the summary buffer is empty, but there are some low-scored
3202 ;; articles or some excluded dormants, we include these in the
3204 (when (and (zerop (buffer-size))
3206 (cond (gnus-newsgroup-dormant
3207 (gnus-summary-limit-include-dormant))
3208 ((and gnus-newsgroup-scored show-all)
3209 (gnus-summary-limit-include-expunged t))))
3210 ;; Function `gnus-apply-kill-file' must be called in this hook.
3211 (gnus-run-hooks 'gnus-apply-kill-hook)
3212 (if (and (zerop (buffer-size))
3215 ;; This newsgroup is empty.
3216 (gnus-summary-catchup-and-exit nil t)
3217 (gnus-message 6 "No unread news")
3219 (gnus-kill-or-deaden-summary kill-buffer))
3220 ;; Return nil from this function.
3222 ;; Hide conversation thread subtrees. We cannot do this in
3223 ;; gnus-summary-prepare-hook since kill processing may not
3224 ;; work with hidden articles.
3225 (and gnus-show-threads
3226 gnus-thread-hide-subtree
3227 (gnus-summary-hide-all-threads))
3229 (gnus-kill-or-deaden-summary kill-buffer))
3230 ;; Show first unread article if requested.
3231 (if (and (not no-article)
3233 gnus-newsgroup-unreads
3234 gnus-auto-select-first)
3236 (gnus-configure-windows 'summary)
3238 ((eq gnus-auto-select-first 'best)
3239 (gnus-summary-best-unread-article))
3240 ((eq gnus-auto-select-first t)
3241 (gnus-summary-first-unread-article))
3242 ((gnus-functionp gnus-auto-select-first)
3243 (funcall gnus-auto-select-first))))
3244 ;; Don't select any articles, just move point to the first
3245 ;; article in the group.
3246 (goto-char (point-min))
3247 (gnus-summary-position-point)
3248 (gnus-configure-windows 'summary 'force)
3249 (gnus-set-mode-line 'summary))
3250 (when (get-buffer-window gnus-group-buffer t)
3251 ;; Gotta use windows, because recenter does weird stuff if
3252 ;; the current buffer ain't the displayed window.
3253 (let ((owin (selected-window)))
3254 (select-window (get-buffer-window gnus-group-buffer t))
3255 (when (gnus-group-goto-group group)
3257 (select-window owin)))
3258 ;; Mark this buffer as "prepared".
3259 (setq gnus-newsgroup-prepared t)
3260 (gnus-run-hooks 'gnus-summary-prepared-hook)
3263 (defun gnus-summary-prepare ()
3264 "Generate the summary buffer."
3266 (let ((buffer-read-only nil))
3268 (setq gnus-newsgroup-data nil
3269 gnus-newsgroup-data-reverse nil)
3270 (gnus-run-hooks 'gnus-summary-generate-hook)
3271 ;; Generate the buffer, either with threads or without.
3272 (when gnus-newsgroup-headers
3273 (gnus-summary-prepare-threads
3274 (if gnus-show-threads
3275 (gnus-sort-gathered-threads
3276 (funcall gnus-summary-thread-gathering-function
3278 (gnus-cut-threads (gnus-make-threads)))))
3279 ;; Unthreaded display.
3280 (gnus-sort-articles gnus-newsgroup-headers))))
3281 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3282 ;; Call hooks for modifying summary buffer.
3283 (goto-char (point-min))
3284 (gnus-run-hooks 'gnus-summary-prepare-hook)))
3286 (defsubst gnus-general-simplify-subject (subject)
3287 "Simply subject by the same rules as gnus-gather-threads-by-subject."
3290 ;; Truncate the subject.
3291 (gnus-simplify-subject-functions
3292 (gnus-map-function gnus-simplify-subject-functions subject))
3293 ((numberp gnus-summary-gather-subject-limit)
3294 (setq subject (gnus-simplify-subject-re subject))
3295 (if (> (length subject) gnus-summary-gather-subject-limit)
3296 (substring subject 0 gnus-summary-gather-subject-limit)
3298 ;; Fuzzily simplify it.
3299 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3300 (gnus-simplify-subject-fuzzy subject))
3301 ;; Just remove the leading "Re:".
3303 (gnus-simplify-subject-re subject))))
3305 (if (and gnus-summary-gather-exclude-subject
3306 (string-match gnus-summary-gather-exclude-subject subject))
3307 nil ; This article shouldn't be gathered
3310 (defun gnus-summary-simplify-subject-query ()
3311 "Query where the respool algorithm would put this article."
3313 (gnus-summary-select-article)
3314 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
3316 (defun gnus-gather-threads-by-subject (threads)
3317 "Gather threads by looking at Subject headers."
3318 (if (not gnus-summary-make-false-root)
3320 (let ((hashtb (gnus-make-hashtable 1024))
3323 subject hthread whole-subject)
3325 (setq subject (gnus-general-simplify-subject
3326 (setq whole-subject (mail-header-subject
3329 (if (setq hthread (gnus-gethash subject hashtb))
3331 ;; We enter a dummy root into the thread, if we
3332 ;; haven't done that already.
3333 (unless (stringp (caar hthread))
3334 (setcar hthread (list whole-subject (car hthread))))
3335 ;; We add this new gathered thread to this gathered
3337 (setcdr (car hthread)
3338 (nconc (cdar hthread) (list (car threads))))
3339 ;; Remove it from the list of threads.
3340 (setcdr prev (cdr threads))
3341 (setq threads prev))
3342 ;; Enter this thread into the hash table.
3343 (gnus-sethash subject threads hashtb)))
3345 (setq threads (cdr threads)))
3348 (defun gnus-gather-threads-by-references (threads)
3349 "Gather threads by looking at References headers."
3350 (let ((idhashtb (gnus-make-hashtable 1024))
3351 (thhashtb (gnus-make-hashtable 1024))
3354 ids references id gthread gid entered ref)
3356 (when (setq references (mail-header-references (caar threads)))
3357 (setq id (mail-header-id (caar threads))
3358 ids (gnus-split-references references)
3360 (while (setq ref (pop ids))
3361 (setq ids (delete ref ids))
3362 (if (not (setq gid (gnus-gethash ref idhashtb)))
3364 (gnus-sethash ref id idhashtb)
3365 (gnus-sethash id threads thhashtb))
3366 (setq gthread (gnus-gethash gid thhashtb))
3368 ;; We enter a dummy root into the thread, if we
3369 ;; haven't done that already.
3370 (unless (stringp (caar gthread))
3371 (setcar gthread (list (mail-header-subject (caar gthread))
3373 ;; We add this new gathered thread to this gathered
3375 (setcdr (car gthread)
3376 (nconc (cdar gthread) (list (car threads)))))
3377 ;; Add it into the thread hash table.
3378 (gnus-sethash id gthread thhashtb)
3380 ;; Remove it from the list of threads.
3381 (setcdr prev (cdr threads))
3382 (setq threads prev))))
3384 (setq threads (cdr threads)))
3387 (defun gnus-sort-gathered-threads (threads)
3388 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
3389 (let ((result threads))
3391 (when (stringp (caar threads))
3392 (setcdr (car threads)
3393 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3394 (setq threads (cdr threads)))
3397 (defun gnus-thread-loop-p (root thread)
3398 "Say whether ROOT is in THREAD."
3399 (let ((stack (list thread))
3402 (while (setq thread (pop stack))
3403 (setq th (cdr thread))
3405 (not (eq (caar th) root)))
3408 ;; We have found a loop.
3410 (setcdr thread (delq (car th) (cdr thread)))
3411 (if (boundp (setq ref-dep (intern "none"
3412 gnus-newsgroup-dependencies)))
3413 (setcdr (symbol-value ref-dep)
3414 (nconc (cdr (symbol-value ref-dep))
3416 (set ref-dep (list nil (car th))))
3419 ;; Push all the subthreads onto the stack.
3420 (push (cdr thread) stack)))
3423 (defun gnus-make-threads ()
3424 "Go through the dependency hashtb and find the roots. Return all threads."
3426 (while (catch 'infloop
3429 ;; Deal with self-referencing References loops.
3430 (when (and (car (symbol-value refs))
3437 (car (symbol-value refs)) thread))
3438 (cdr (symbol-value refs)))))))
3441 (unless (car (symbol-value refs))
3442 ;; These threads do not refer back to any other articles,
3443 ;; so they're roots.
3444 (setq threads (append (cdr (symbol-value refs)) threads))))
3445 gnus-newsgroup-dependencies)))
3448 ;; Build the thread tree.
3449 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3450 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3452 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3453 if it was already present.
3455 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3456 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3457 Message-IDs will be renamed be renamed to a unique Message-ID before
3460 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3461 (let* ((id (mail-header-id header))
3462 (id-dep (and id (intern id dependencies)))
3463 ref ref-dep ref-header)
3464 ;; Enter this `header' in the `dependencies' table.
3468 ;; The first two cases do the normal part: enter a new `header'
3469 ;; in the `dependencies' table.
3470 ((not (boundp id-dep))
3471 (set id-dep (list header)))
3472 ((null (car (symbol-value id-dep)))
3473 (setcar (symbol-value id-dep) header))
3475 ;; From here the `header' was already present in the
3476 ;; `dependencies' table.
3478 ;; Overrides an existing entry;
3479 ;; just set the header part of the entry.
3480 (setcar (symbol-value id-dep) header))
3482 ;; Renames the existing `header' to a unique Message-ID.
3483 ((not gnus-summary-ignore-duplicates)
3484 ;; An article with this Message-ID has already been seen.
3485 ;; We rename the Message-ID.
3486 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3488 (mail-header-set-id header id))
3490 ;; The last case ignores an existing entry, except it adds any
3491 ;; additional Xrefs (in case the two articles came from different
3493 ;; Also sets `header' to `nil' meaning that the `dependencies'
3494 ;; table was *not* modified.
3496 (mail-header-set-xref
3497 (car (symbol-value id-dep))
3498 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3500 (or (mail-header-xref header) "")))
3504 ;; First check if that we are not creating a References loop.
3505 (setq ref (gnus-parent-id (mail-header-references header)))
3507 (setq ref-dep (intern-soft ref dependencies))
3509 (setq ref-header (car (symbol-value ref-dep))))
3510 (if (string= id ref)
3511 ;; Yuk! This is a reference loop. Make the article be a
3514 (mail-header-set-references (car (symbol-value id-dep)) "none")
3516 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3517 (setq ref (gnus-parent-id (mail-header-references header)))
3518 (setq ref-dep (intern (or ref "none") dependencies))
3519 (if (boundp ref-dep)
3520 (setcdr (symbol-value ref-dep)
3521 (nconc (cdr (symbol-value ref-dep))
3522 (list (symbol-value id-dep))))
3523 (set ref-dep (list nil (symbol-value id-dep)))))
3526 (defun gnus-build-sparse-threads ()
3527 (let ((headers gnus-newsgroup-headers)
3528 (mail-parse-charset gnus-newsgroup-charset)
3529 (gnus-summary-ignore-duplicates t)
3530 header references generation relations
3531 subject child end new-child date)
3532 ;; First we create an alist of generations/relations, where
3533 ;; generations is how much we trust the relation, and the relation
3535 (gnus-message 7 "Making sparse threads...")
3537 (nnheader-set-temp-buffer " *gnus sparse threads*")
3538 (while (setq header (pop headers))
3539 (when (and (setq references (mail-header-references header))
3540 (not (string= references "")))
3542 (setq child (mail-header-id header)
3543 subject (mail-header-subject header)
3544 date (mail-header-date header)
3546 (while (search-backward ">" nil t)
3547 (setq end (1+ (point)))
3548 (when (search-backward "<" nil t)
3549 (setq new-child (buffer-substring (point) end))
3550 (push (list (incf generation)
3551 child (setq child new-child)
3555 (push (list (1+ generation) child nil subject) relations))
3557 (kill-buffer (current-buffer)))
3558 ;; Sort over trustworthiness.
3561 (when (gnus-dependencies-add-header
3562 (make-full-mail-header
3563 gnus-reffed-article-number
3564 (nth 3 relation) "" (or (nth 4 relation) "")
3566 (or (nth 2 relation) "") 0 0 "")
3567 gnus-newsgroup-dependencies nil)
3568 (push gnus-reffed-article-number gnus-newsgroup-limit)
3569 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3570 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3571 gnus-newsgroup-reads)
3572 (decf gnus-reffed-article-number)))
3573 (sort relations 'car-less-than-car))
3574 (gnus-message 7 "Making sparse threads...done")))
3576 (defun gnus-build-old-threads ()
3577 ;; Look at all the articles that refer back to old articles, and
3578 ;; fetch the headers for the articles that aren't there. This will
3579 ;; build complete threads - if the roots haven't been expired by the
3581 (let ((mail-parse-charset gnus-newsgroup-charset)
3585 (when (not (car (symbol-value refs)))
3586 (setq heads (cdr (symbol-value refs)))
3588 (if (memq (mail-header-number (caar heads))
3589 gnus-newsgroup-dormant)
3590 (setq heads (cdr heads))
3591 (setq id (symbol-name refs))
3592 (while (and (setq id (gnus-build-get-header id))
3593 (not (car (gnus-id-to-thread id)))))
3594 (setq heads nil)))))
3595 gnus-newsgroup-dependencies)))
3597 ;; This function has to be called with point after the article number
3598 ;; on the beginning of the line.
3599 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3600 (let ((eol (gnus-point-at-eol))
3601 (buffer (current-buffer))
3604 ;; overview: [num subject from date id refs chars lines misc]
3607 (narrow-to-region (point) eol)
3612 (make-full-mail-header
3614 (funcall gnus-decode-encoded-word-function
3615 (nnheader-nov-field)) ; subject
3616 (funcall gnus-decode-encoded-word-function
3617 (nnheader-nov-field)) ; from
3618 (nnheader-nov-field) ; date
3619 (nnheader-nov-read-message-id) ; id
3620 (nnheader-nov-field) ; refs
3621 (nnheader-nov-read-integer) ; chars
3622 (nnheader-nov-read-integer) ; lines
3624 (if (looking-at "Xref: ")
3625 (goto-char (match-end 0)))
3626 (nnheader-nov-field)) ; Xref
3627 (nnheader-nov-parse-extra)))) ; extra
3631 (when gnus-alter-header-function
3632 (funcall gnus-alter-header-function header))
3633 (gnus-dependencies-add-header header dependencies force-new)))
3635 (defun gnus-build-get-header (id)
3636 "Look through the buffer of NOV lines and find the header to ID.
3637 Enter this line into the dependencies hash table, and return
3638 the id of the parent article (if any)."
3639 (let ((deps gnus-newsgroup-dependencies)
3643 (set-buffer nntp-server-buffer)
3644 (let ((case-fold-search nil))
3645 (goto-char (point-min))
3646 (while (and (not found)
3647 (search-forward id nil t))
3649 (setq found (looking-at
3650 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3651 (regexp-quote id))))
3652 (or found (beginning-of-line 2)))
3656 (setq header (gnus-nov-parse-line
3657 (read (current-buffer)) deps))
3658 (gnus-parent-id (mail-header-references header))))))
3660 (let ((number (mail-header-number header)))
3661 (push number gnus-newsgroup-limit)
3662 (push header gnus-newsgroup-headers)
3663 (if (memq number gnus-newsgroup-unselected)
3665 (push number gnus-newsgroup-unreads)
3666 (setq gnus-newsgroup-unselected
3667 (delq number gnus-newsgroup-unselected)))
3668 (push number gnus-newsgroup-ancient)))))))
3670 (defun gnus-build-all-threads ()
3671 "Read all the headers."
3672 (let ((gnus-summary-ignore-duplicates t)
3673 (mail-parse-charset gnus-newsgroup-charset)
3674 (dependencies gnus-newsgroup-dependencies)
3677 (set-buffer nntp-server-buffer)
3678 (let ((case-fold-search nil))
3679 (goto-char (point-min))
3682 (setq article (read (current-buffer))
3683 header (gnus-nov-parse-line article dependencies)))
3686 (set-buffer gnus-summary-buffer)
3687 (push header gnus-newsgroup-headers)
3688 (if (memq (setq article (mail-header-number header))
3689 gnus-newsgroup-unselected)
3691 (push article gnus-newsgroup-unreads)
3692 (setq gnus-newsgroup-unselected
3693 (delq article gnus-newsgroup-unselected)))
3694 (push article gnus-newsgroup-ancient)))
3695 (forward-line 1)))))))
3697 (defun gnus-summary-update-article-line (article header)
3698 "Update the line for ARTICLE using HEADERS."
3699 (let* ((id (mail-header-id header))
3700 (thread (gnus-id-to-thread id)))
3702 (error "Article in no thread"))
3703 ;; Update the thread.
3704 (setcar thread header)
3705 (gnus-summary-goto-subject article)
3706 (let* ((datal (gnus-data-find-list article))
3708 (length (when (cdr datal)
3709 (- (gnus-data-pos data)
3710 (gnus-data-pos (cadr datal)))))
3711 (buffer-read-only nil)
3712 (level (gnus-summary-thread-level)))
3714 (gnus-summary-insert-line
3715 header level nil (gnus-article-mark article)
3716 (memq article gnus-newsgroup-replied)
3717 (memq article gnus-newsgroup-expirable)
3718 ;; Only insert the Subject string when it's different
3719 ;; from the previous Subject string.
3724 (mail-header-subject
3727 (gnus-data-find-list
3729 (gnus-data-list t)))))
3730 ;; Error on the side of excessive subjects.
3732 (mail-header-subject header)))
3734 (mail-header-subject header))
3735 nil (cdr (assq article gnus-newsgroup-scored))
3736 (memq article gnus-newsgroup-processable))
3738 (gnus-data-update-list
3739 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3741 (defun gnus-summary-update-article (article &optional iheader)
3742 "Update ARTICLE in the summary buffer."
3743 (set-buffer gnus-summary-buffer)
3744 (let* ((header (gnus-summary-article-header article))
3745 (id (mail-header-id header))
3746 (data (gnus-data-find article))
3747 (thread (gnus-id-to-thread id))
3748 (references (mail-header-references header))
3752 (when (and references
3753 (not (equal "" references)))
3756 (buffer-read-only nil)
3762 (delq thread parent)))
3763 (if (gnus-summary-insert-subject id header)
3764 ;; Set the (possibly) new article number in the data structure.
3765 (gnus-data-set-number data (gnus-id-to-article id))
3769 (defun gnus-rebuild-thread (id &optional line)
3770 "Rebuild the thread containing ID.
3771 If LINE, insert the rebuilt thread starting on line LINE."
3772 (let ((buffer-read-only nil)
3773 old-pos current thread data)
3774 (if (not gnus-show-threads)
3775 (setq thread (list (car (gnus-id-to-thread id))))
3776 ;; Get the thread this article is part of.
3777 (setq thread (gnus-remove-thread id)))
3778 (setq old-pos (gnus-point-at-bol))
3779 (setq current (save-excursion
3780 (and (re-search-backward "[\r\n]" nil t)
3781 (gnus-summary-article-number))))
3782 ;; If this is a gathered thread, we have to go some re-gathering.
3783 (when (stringp (car thread))
3784 (let ((subject (car thread))
3786 (setq thread (cdr thread))
3788 (unless (memq (setq thr (gnus-id-to-thread
3790 (mail-header-id (caar thread)))))
3793 (setq thread (cdr thread)))
3794 ;; We now have all (unique) roots.
3795 (if (= (length roots) 1)
3796 ;; All the loose roots are now one solid root.
3797 (setq thread (car roots))
3798 (setq thread (cons subject (gnus-sort-threads roots))))))
3800 ;; We then insert this thread into the summary buffer.
3802 (goto-char (point-min))
3803 (forward-line (1- line)))
3804 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3805 (if gnus-show-threads
3806 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3807 (gnus-summary-prepare-unthreaded thread))
3808 (setq data (nreverse gnus-newsgroup-data))
3809 (setq threads gnus-newsgroup-threads))
3810 ;; We splice the new data into the data structure.
3811 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
3812 ;;!!! then we want to insert at the beginning of the buffer.
3813 ;;!!! That happens to be true with Gnus now, but that may
3814 ;;!!! change in the future. Perhaps.
3815 (gnus-data-enter-list
3816 (if line nil current) data (- (point) old-pos))
3817 (setq gnus-newsgroup-threads
3818 (nconc threads gnus-newsgroup-threads))
3819 (gnus-data-compute-positions))))
3821 (defun gnus-number-to-header (number)
3822 "Return the header for article NUMBER."
3823 (let ((headers gnus-newsgroup-headers))
3825 (not (= number (mail-header-number (car headers)))))
3830 (defun gnus-parent-headers (in-headers &optional generation)
3831 "Return the headers of the GENERATIONeth parent of HEADERS."
3833 (setq generation 1))
3835 (headers in-headers)
3838 (not (zerop generation))
3839 (setq references (mail-header-references headers)))
3840 (setq headers (if (and references
3841 (setq parent (gnus-parent-id references)))
3842 (car (gnus-id-to-thread parent))
3845 (and (not (eq headers in-headers))
3848 (defun gnus-id-to-thread (id)
3849 "Return the (sub-)thread where ID appears."
3850 (gnus-gethash id gnus-newsgroup-dependencies))
3852 (defun gnus-id-to-article (id)
3853 "Return the article number of ID."
3854 (let ((thread (gnus-id-to-thread id)))
3857 (mail-header-number (car thread)))))
3859 (defun gnus-id-to-header (id)
3860 "Return the article headers of ID."
3861 (car (gnus-id-to-thread id)))
3863 (defun gnus-article-displayed-root-p (article)
3864 "Say whether ARTICLE is a root(ish) article."
3865 (let ((level (gnus-summary-thread-level article))
3866 (refs (mail-header-references (gnus-summary-article-header article)))
3872 ((null (gnus-parent-id refs)) t)
3874 (null (setq particle (gnus-id-to-article
3875 (gnus-parent-id refs))))
3876 (null (gnus-summary-thread-level particle)))))))
3878 (defun gnus-root-id (id)
3879 "Return the id of the root of the thread where ID appears."
3881 (while (and id (setq prev (car (gnus-id-to-thread id))))
3883 id (gnus-parent-id (mail-header-references prev))))
3886 (defun gnus-articles-in-thread (thread)
3887 "Return the list of articles in THREAD."
3888 (cons (mail-header-number (car thread))
3889 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
3891 (defun gnus-remove-thread (id &optional dont-remove)
3892 "Remove the thread that has ID in it."
3893 (let (headers thread last-id)
3894 ;; First go up in this thread until we find the root.
3895 (setq last-id (gnus-root-id id)
3896 headers (message-flatten-list (gnus-id-to-thread last-id)))
3897 ;; We have now found the real root of this thread. It might have
3898 ;; been gathered into some loose thread, so we have to search
3899 ;; through the threads to find the thread we wanted.
3900 (let ((threads gnus-newsgroup-threads)
3903 (setq sub (car threads))
3904 (if (stringp (car sub))
3905 ;; This is a gathered thread, so we look at the roots
3906 ;; below it to find whether this article is in this
3909 (setq sub (cdr sub))
3911 (when (member (caar sub) headers)
3912 (setq thread (car threads)
3915 (setq sub (cdr sub))))
3916 ;; It's an ordinary thread, so we check it.
3917 (when (eq (car sub) (car headers))
3920 (setq threads (cdr threads)))
3921 ;; If this article is in no thread, then it's a root.
3924 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
3925 (setq thread (gnus-id-to-thread last-id)))
3928 thread ; We return this thread.
3930 (if (stringp (car thread))
3932 ;; If we use dummy roots, then we have to remove the
3933 ;; dummy root as well.
3934 (when (eq gnus-summary-make-false-root 'dummy)
3935 ;; We go to the dummy root by going to
3936 ;; the first sub-"thread", and then one line up.
3937 (gnus-summary-goto-article
3938 (mail-header-number (caadr thread)))
3941 (gnus-data-compute-positions))
3942 (setq thread (cdr thread))
3944 (gnus-remove-thread-1 (car thread))
3945 (setq thread (cdr thread))))
3946 (gnus-remove-thread-1 thread))))))))
3948 (defun gnus-remove-thread-1 (thread)
3949 "Remove the thread THREAD recursively."
3950 (let ((number (mail-header-number (pop thread)))
3952 (setq thread (reverse thread))
3954 (gnus-remove-thread-1 (pop thread)))
3955 (when (setq d (gnus-data-find number))
3956 (goto-char (gnus-data-pos d))
3957 (gnus-summary-show-thread)
3960 (- (gnus-point-at-bol)
3962 (1+ (gnus-point-at-eol))
3963 (gnus-delete-line)))))))
3965 (defun gnus-sort-threads-1 (threads func)
3966 (sort (mapcar (lambda (thread)
3969 (gnus-sort-threads-1 (cdr thread) func))))
3972 (defun gnus-sort-threads (threads)
3974 (if (not gnus-thread-sort-functions)
3976 (gnus-message 8 "Sorting threads...")
3978 (gnus-sort-threads-1
3980 (gnus-make-sort-function gnus-thread-sort-functions))
3981 (gnus-message 8 "Sorting threads...done"))))
3983 (defun gnus-sort-articles (articles)
3985 (when gnus-article-sort-functions
3986 (gnus-message 7 "Sorting articles...")
3988 (setq gnus-newsgroup-headers
3989 (sort articles (gnus-make-sort-function
3990 gnus-article-sort-functions)))
3991 (gnus-message 7 "Sorting articles...done"))))
3993 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3994 (defmacro gnus-thread-header (thread)
3995 "Return header of first article in THREAD.
3996 Note that THREAD must never, ever be anything else than a variable -
3997 using some other form will lead to serious barfage."
3998 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
3999 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4000 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4003 (defsubst gnus-article-sort-by-number (h1 h2)
4004 "Sort articles by article number."
4005 (< (mail-header-number h1)
4006 (mail-header-number h2)))
4008 (defun gnus-thread-sort-by-number (h1 h2)
4009 "Sort threads by root article number."
4010 (gnus-article-sort-by-number
4011 (gnus-thread-header h1) (gnus-thread-header h2)))
4013 (defsubst gnus-article-sort-by-lines (h1 h2)
4014 "Sort articles by article Lines header."
4015 (< (mail-header-lines h1)
4016 (mail-header-lines h2)))
4018 (defun gnus-thread-sort-by-lines (h1 h2)
4019 "Sort threads by root article Lines header."
4020 (gnus-article-sort-by-lines
4021 (gnus-thread-header h1) (gnus-thread-header h2)))
4023 (defsubst gnus-article-sort-by-chars (h1 h2)
4024 "Sort articles by octet length."
4025 (< (mail-header-chars h1)
4026 (mail-header-chars h2)))
4028 (defun gnus-thread-sort-by-chars (h1 h2)
4029 "Sort threads by root article octet length."
4030 (gnus-article-sort-by-chars
4031 (gnus-thread-header h1) (gnus-thread-header h2)))
4033 (defsubst gnus-article-sort-by-author (h1 h2)
4034 "Sort articles by root author."
4036 (let ((extract (funcall
4037 gnus-extract-address-components
4038 (mail-header-from h1))))
4039 (or (car extract) (cadr extract) ""))
4040 (let ((extract (funcall
4041 gnus-extract-address-components
4042 (mail-header-from h2))))
4043 (or (car extract) (cadr extract) ""))))
4045 (defun gnus-thread-sort-by-author (h1 h2)
4046 "Sort threads by root author."
4047 (gnus-article-sort-by-author
4048 (gnus-thread-header h1) (gnus-thread-header h2)))
4050 (defsubst gnus-article-sort-by-subject (h1 h2)
4051 "Sort articles by root subject."
4053 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4054 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4056 (defun gnus-thread-sort-by-subject (h1 h2)
4057 "Sort threads by root subject."
4058 (gnus-article-sort-by-subject
4059 (gnus-thread-header h1) (gnus-thread-header h2)))
4061 (defsubst gnus-article-sort-by-date (h1 h2)
4062 "Sort articles by root article date."
4064 (gnus-date-get-time (mail-header-date h1))
4065 (gnus-date-get-time (mail-header-date h2))))
4067 (defun gnus-thread-sort-by-date (h1 h2)
4068 "Sort threads by root article date."
4069 (gnus-article-sort-by-date
4070 (gnus-thread-header h1) (gnus-thread-header h2)))
4072 (defsubst gnus-article-sort-by-score (h1 h2)
4073 "Sort articles by root article score.
4074 Unscored articles will be counted as having a score of zero."
4075 (> (or (cdr (assq (mail-header-number h1)
4076 gnus-newsgroup-scored))
4077 gnus-summary-default-score 0)
4078 (or (cdr (assq (mail-header-number h2)
4079 gnus-newsgroup-scored))
4080 gnus-summary-default-score 0)))
4082 (defun gnus-thread-sort-by-score (h1 h2)
4083 "Sort threads by root article score."
4084 (gnus-article-sort-by-score
4085 (gnus-thread-header h1) (gnus-thread-header h2)))
4087 (defun gnus-thread-sort-by-total-score (h1 h2)
4088 "Sort threads by the sum of all scores in the thread.
4089 Unscored articles will be counted as having a score of zero."
4090 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4092 (defun gnus-thread-total-score (thread)
4093 ;; This function find the total score of THREAD.
4094 (cond ((null thread)
4097 (if (stringp (car thread))
4098 (apply gnus-thread-score-function 0
4099 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4100 (gnus-thread-total-score-1 thread)))
4102 (gnus-thread-total-score-1 (list thread)))))
4104 (defun gnus-thread-total-score-1 (root)
4105 ;; This function find the total score of the thread below ROOT.
4106 (setq root (car root))
4107 (apply gnus-thread-score-function
4109 (mapcar 'gnus-thread-total-score
4110 (cdr (gnus-id-to-thread (mail-header-id root))))
4111 (when (> (mail-header-number root) 0)
4112 (list (or (cdr (assq (mail-header-number root)
4113 gnus-newsgroup-scored))
4114 gnus-summary-default-score 0))))
4115 (list gnus-summary-default-score)
4118 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
4119 (defvar gnus-tmp-prev-subject nil)
4120 (defvar gnus-tmp-false-parent nil)
4121 (defvar gnus-tmp-root-expunged nil)
4122 (defvar gnus-tmp-dummy-line nil)
4124 (eval-when-compile (defvar gnus-tmp-header))
4125 (defun gnus-extra-header (type &optional header)
4126 "Return the extra header of TYPE."
4127 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
4130 (defvar gnus-tmp-thread-tree-header-string "")
4132 (defvar gnus-sum-thread-tree-root "> "
4133 "With %B spec, used for the root of a thread.
4134 If nil, use subject instead.")
4135 (defvar gnus-sum-thread-tree-single-indent ""
4136 "With %B spec, used for a thread with just one message.
4137 If nil, use subject instead.")
4138 (defvar gnus-sum-thread-tree-vertical "| "
4139 "With %B spec, used for drawing a vertical line.")
4140 (defvar gnus-sum-thread-tree-indent " "
4141 "With %B spec, used for indenting.")
4142 (defvar gnus-sum-thread-tree-leaf-with-other "+-> "
4143 "With %B spec, used for a leaf with brothers.")
4144 (defvar gnus-sum-thread-tree-single-leaf "\\-> "
4145 "With %B spec, used for a leaf without brothers.")
4147 (defun gnus-summary-prepare-threads (threads)
4148 "Prepare summary buffer from THREADS and indentation LEVEL.
4149 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
4150 or a straight list of headers."
4151 (gnus-message 7 "Generating summary...")
4153 (setq gnus-newsgroup-threads threads)
4156 (let ((gnus-tmp-level 0)
4157 (default-score (or gnus-summary-default-score 0))
4158 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
4159 thread number subject stack state gnus-tmp-gathered beg-match
4160 new-roots gnus-tmp-new-adopts thread-end
4161 gnus-tmp-header gnus-tmp-unread
4162 gnus-tmp-replied gnus-tmp-subject-or-nil
4163 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
4164 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
4165 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
4168 (setq gnus-tmp-prev-subject nil)
4170 (if (vectorp (car threads))
4171 ;; If this is a straight (sic) list of headers, then a
4172 ;; threaded summary display isn't required, so we just create
4173 ;; an unthreaded one.
4174 (gnus-summary-prepare-unthreaded threads)
4176 ;; Do the threaded display.
4178 (while (or threads stack gnus-tmp-new-adopts new-roots)
4180 (if (and (= gnus-tmp-level 0)
4183 (not gnus-tmp-false-parent)
4184 (or gnus-tmp-new-adopts new-roots))
4185 (if gnus-tmp-new-adopts
4186 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
4187 thread (list (car gnus-tmp-new-adopts))
4188 gnus-tmp-header (caar thread)
4189 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
4191 (setq thread (list (car new-roots))
4192 gnus-tmp-header (caar thread)
4193 new-roots (cdr new-roots))))
4196 ;; If there are some threads, we do them before the
4197 ;; threads on the stack.
4198 (setq thread threads
4199 gnus-tmp-header (caar thread))
4200 ;; There were no current threads, so we pop something off
4202 (setq state (car stack)
4203 gnus-tmp-level (car state)
4204 tree-stack (cadr state)
4205 thread (caddr state)
4207 gnus-tmp-header (caar thread))))
4209 (setq gnus-tmp-false-parent nil)
4210 (setq gnus-tmp-root-expunged nil)
4211 (setq thread-end nil)
4213 (if (stringp gnus-tmp-header)
4214 ;; The header is a dummy root.
4216 ((eq gnus-summary-make-false-root 'adopt)
4217 ;; We let the first article adopt the rest.
4218 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
4220 (setq gnus-tmp-gathered
4222 (lambda (h) (mail-header-number (car h)))
4225 (setq thread (cons (list (caar thread)
4228 (setq gnus-tmp-level -1
4229 gnus-tmp-false-parent t))
4230 ((eq gnus-summary-make-false-root 'empty)
4231 ;; We print adopted articles with empty subject fields.
4232 (setq gnus-tmp-gathered
4234 (lambda (h) (mail-header-number (car h)))
4237 (setq gnus-tmp-level -1))
4238 ((eq gnus-summary-make-false-root 'dummy)
4239 ;; We remember that we probably want to output a dummy
4241 (setq gnus-tmp-dummy-line gnus-tmp-header)
4242 (setq gnus-tmp-prev-subject gnus-tmp-header))
4244 ;; We do not make a root for the gathered
4245 ;; sub-threads at all.
4246 (setq gnus-tmp-level -1)))
4248 (setq number (mail-header-number gnus-tmp-header)
4249 subject (mail-header-subject gnus-tmp-header))
4252 ;; If the thread has changed subject, we might want to make
4253 ;; this subthread into a root.
4254 ((and (null gnus-thread-ignore-subject)
4255 (not (zerop gnus-tmp-level))
4256 gnus-tmp-prev-subject
4258 (gnus-subject-equal gnus-tmp-prev-subject subject))))
4259 (setq new-roots (nconc new-roots (list (car thread)))
4261 gnus-tmp-header nil))
4262 ;; If the article lies outside the current limit,
4263 ;; then we do not display it.
4264 ((not (memq number gnus-newsgroup-limit))
4265 (setq gnus-tmp-gathered
4267 (lambda (h) (mail-header-number (car h)))
4270 (setq gnus-tmp-new-adopts (if (cdar thread)
4271 (append gnus-tmp-new-adopts
4273 gnus-tmp-new-adopts)
4275 gnus-tmp-header nil)
4276 (when (zerop gnus-tmp-level)
4277 (setq gnus-tmp-root-expunged t)))
4278 ;; Perhaps this article is to be marked as read?
4279 ((and gnus-summary-mark-below
4280 (< (or (cdr (assq number gnus-newsgroup-scored))
4282 gnus-summary-mark-below)
4283 ;; Don't touch sparse articles.
4284 (not (gnus-summary-article-sparse-p number))
4285 (not (gnus-summary-article-ancient-p number)))
4286 (setq gnus-newsgroup-unreads
4287 (delq number gnus-newsgroup-unreads))
4288 (if gnus-newsgroup-auto-expire
4289 (push number gnus-newsgroup-expirable)
4290 (push (cons number gnus-low-score-mark)
4291 gnus-newsgroup-reads))))
4293 (when gnus-tmp-header
4294 ;; We may have an old dummy line to output before this
4296 (when (and gnus-tmp-dummy-line
4299 (mail-header-subject gnus-tmp-header)))
4300 (gnus-summary-insert-dummy-line
4301 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
4302 (setq gnus-tmp-dummy-line nil))
4304 ;; Compute the mark.
4305 (setq gnus-tmp-unread (gnus-article-mark number))
4307 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
4308 gnus-tmp-header gnus-tmp-level)
4309 gnus-newsgroup-data)
4311 ;; Actually insert the line.
4313 gnus-tmp-subject-or-nil
4315 ((and gnus-thread-ignore-subject
4316 gnus-tmp-prev-subject
4317 (not (inline (gnus-subject-equal
4318 gnus-tmp-prev-subject subject))))
4320 ((zerop gnus-tmp-level)
4321 (if (and (eq gnus-summary-make-false-root 'empty)
4322 (memq number gnus-tmp-gathered)
4323 gnus-tmp-prev-subject
4324 (inline (gnus-subject-equal
4325 gnus-tmp-prev-subject subject)))
4326 gnus-summary-same-subject
4328 (t gnus-summary-same-subject)))
4329 (if (and (eq gnus-summary-make-false-root 'adopt)
4330 (= gnus-tmp-level 1)
4331 (memq number gnus-tmp-gathered))
4332 (setq gnus-tmp-opening-bracket ?\<
4333 gnus-tmp-closing-bracket ?\>)
4334 (setq gnus-tmp-opening-bracket ?\[
4335 gnus-tmp-closing-bracket ?\]))
4337 gnus-tmp-indentation
4338 (aref gnus-thread-indent-array gnus-tmp-level)
4339 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4340 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4341 gnus-summary-default-score 0)
4343 (if (or (null gnus-summary-default-score)
4344 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
4345 gnus-summary-zcore-fuzz))
4347 (if (< gnus-tmp-score gnus-summary-default-score)
4348 gnus-score-below-mark gnus-score-over-mark))
4350 (cond ((memq number gnus-newsgroup-processable)
4352 ((memq number gnus-newsgroup-cached)
4354 ((memq number gnus-newsgroup-replied)
4356 ((memq number gnus-newsgroup-forwarded)
4357 gnus-forwarded-mark)
4358 ((memq number gnus-newsgroup-saved)
4360 ((memq number gnus-newsgroup-recent)
4362 ((memq number gnus-newsgroup-unseen)
4365 gnus-tmp-from (mail-header-from gnus-tmp-header)
4368 ((string-match "<[^>]+> *$" gnus-tmp-from)
4369 (setq beg-match (match-beginning 0))
4370 (or (and (string-match "^\".+\"" gnus-tmp-from)
4371 (substring gnus-tmp-from 1 (1- (match-end 0))))
4372 (substring gnus-tmp-from 0 beg-match)))
4373 ((string-match "(.+)" gnus-tmp-from)
4374 (substring gnus-tmp-from
4375 (1+ (match-beginning 0)) (1- (match-end 0))))
4377 gnus-tmp-thread-tree-header-string
4379 ((not gnus-show-threads) "")
4380 ((zerop gnus-tmp-level)
4382 (or gnus-sum-thread-tree-root subject)
4383 (or gnus-sum-thread-tree-single-indent subject)))
4385 (concat (apply 'concat
4386 (mapcar (lambda (item)
4388 gnus-sum-thread-tree-vertical
4389 gnus-sum-thread-tree-indent))
4390 (cdr (reverse tree-stack))))
4392 gnus-sum-thread-tree-leaf-with-other
4393 gnus-sum-thread-tree-single-leaf)))))
4394 (when (string= gnus-tmp-name "")
4395 (setq gnus-tmp-name gnus-tmp-from))
4396 (unless (numberp gnus-tmp-lines)
4397 (setq gnus-tmp-lines -1))
4398 (if (= gnus-tmp-lines -1)
4399 (setq gnus-tmp-lines "?")
4400 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
4401 (gnus-put-text-property
4403 (progn (eval gnus-summary-line-format-spec) (point))
4404 'gnus-number number)
4407 (gnus-run-hooks 'gnus-summary-update-hook)
4410 (setq gnus-tmp-prev-subject subject)))
4412 (when (nth 1 thread)
4413 (push (list (max 0 gnus-tmp-level)
4414 (copy-list tree-stack)
4417 (push (if (nth 1 thread) 1 0) tree-stack)
4418 (incf gnus-tmp-level)
4419 (setq threads (if thread-end nil (cdar thread)))
4421 (setq gnus-tmp-level 0)))))
4422 (gnus-message 7 "Generating summary...done"))
4424 (defun gnus-summary-prepare-unthreaded (headers)
4425 "Generate an unthreaded summary buffer based on HEADERS."
4426 (let (header number mark)
4431 ;; We may have to root out some bad articles...
4432 (when (memq (setq number (mail-header-number
4433 (setq header (pop headers))))
4434 gnus-newsgroup-limit)
4435 ;; Mark article as read when it has a low score.
4436 (when (and gnus-summary-mark-below
4437 (< (or (cdr (assq number gnus-newsgroup-scored))
4438 gnus-summary-default-score 0)
4439 gnus-summary-mark-below)
4440 (not (gnus-summary-article-ancient-p number)))
4441 (setq gnus-newsgroup-unreads
4442 (delq number gnus-newsgroup-unreads))
4443 (if gnus-newsgroup-auto-expire
4444 (push number gnus-newsgroup-expirable)
4445 (push (cons number gnus-low-score-mark)
4446 gnus-newsgroup-reads)))
4448 (setq mark (gnus-article-mark number))
4449 (push (gnus-data-make number mark (1+ (point)) header 0)
4450 gnus-newsgroup-data)
4451 (gnus-summary-insert-line
4453 mark (memq number gnus-newsgroup-replied)
4454 (memq number gnus-newsgroup-expirable)
4455 (mail-header-subject header) nil
4456 (cdr (assq number gnus-newsgroup-scored))
4457 (memq number gnus-newsgroup-processable))))))
4459 (defun gnus-summary-remove-list-identifiers ()
4460 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
4461 (let ((regexp (if (consp gnus-list-identifiers)
4462 (mapconcat 'identity gnus-list-identifiers " *\\|")
4463 gnus-list-identifiers))
4466 (dolist (header gnus-newsgroup-headers)
4467 (setq subject (mail-header-subject header)
4469 (while (string-match
4470 (concat "^\\(R[Ee]: +\\)*\\(" regexp " *\\)")
4473 (concat (substring subject 0 (match-beginning 2))
4474 (substring subject (match-end 0)))
4478 "^\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" subject))
4480 (concat (substring subject 0 (match-beginning 1))
4481 (substring subject (match-end 1)))))
4483 (mail-header-set-subject header subject))))))
4485 (defun gnus-fetch-headers (articles)
4486 "Fetch headers of ARTICLES."
4487 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
4488 (gnus-message 5 "Fetching headers for %s..." name)
4491 (setq gnus-headers-retrieved-by
4492 (gnus-retrieve-headers
4493 articles gnus-newsgroup-name
4494 ;; We might want to fetch old headers, but
4495 ;; not if there is only 1 article.
4497 (not (eq gnus-fetch-old-headers 'some))
4498 (not (numberp gnus-fetch-old-headers)))
4499 (> (length articles) 1))
4500 gnus-fetch-old-headers))))
4501 (gnus-get-newsgroup-headers-xover
4502 articles nil nil gnus-newsgroup-name t)
4503 (gnus-get-newsgroup-headers))
4504 (gnus-message 5 "Fetching headers for %s...done" name))))
4506 (defun gnus-select-newsgroup (group &optional read-all select-articles)
4507 "Select newsgroup GROUP.
4508 If READ-ALL is non-nil, all articles in the group are selected.
4509 If SELECT-ARTICLES, only select those articles from GROUP."
4510 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4511 ;;!!! Dirty hack; should be removed.
4512 (gnus-summary-ignore-duplicates
4513 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
4515 gnus-summary-ignore-duplicates))
4516 (info (nth 2 entry))
4517 articles fetched-articles cached)
4519 (unless (gnus-check-server
4520 (set (make-local-variable 'gnus-current-select-method)
4521 (gnus-find-method-for-group group)))
4522 (error "Couldn't open server"))
4524 (or (and entry (not (eq (car entry) t))) ; Either it's active...
4525 (gnus-activate-group group) ; Or we can activate it...
4526 (progn ; Or we bug out.
4527 (when (equal major-mode 'gnus-summary-mode)
4528 (kill-buffer (current-buffer)))
4529 (error "Couldn't activate group %s: %s"
4530 group (gnus-status-message group))))
4532 (unless (gnus-request-group group t)
4533 (when (equal major-mode 'gnus-summary-mode)
4534 (kill-buffer (current-buffer)))
4535 (error "Couldn't request group %s: %s"
4536 group (gnus-status-message group)))
4538 (setq gnus-newsgroup-name group
4539 gnus-newsgroup-unselected nil
4540 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
4542 (let ((display (gnus-group-find-parameter group 'display)))
4543 (setq gnus-newsgroup-display
4548 (gnus-summary-display-make-predicate (mapcar 'identity display)))
4552 (gnus-summary-setup-default-charset)
4554 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4555 (when (gnus-virtual-group-p group)
4556 (setq cached gnus-newsgroup-cached))
4558 (setq gnus-newsgroup-unreads
4559 (gnus-set-difference
4560 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
4561 gnus-newsgroup-dormant))
4563 (setq gnus-newsgroup-processable nil)
4565 (gnus-update-read-articles group gnus-newsgroup-unreads)
4567 ;; Adjust and set lists of article marks.
4569 (gnus-adjust-marked-articles info))
4571 (if (setq articles select-articles)
4572 (setq gnus-newsgroup-unselected
4573 (gnus-sorted-intersection
4574 gnus-newsgroup-unreads
4575 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4576 (setq articles (gnus-articles-to-read group read-all)))
4580 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
4582 ((eq articles 0) nil)
4584 ;; Init the dependencies hash table.
4585 (setq gnus-newsgroup-dependencies
4586 (gnus-make-hashtable (length articles)))
4587 (gnus-set-global-variables)
4588 ;; Retrieve the headers and read them in.
4589 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
4591 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4593 (setq gnus-newsgroup-cached cached))
4595 ;; Suppress duplicates?
4596 (when gnus-suppress-duplicates
4597 (gnus-dup-suppress-articles))
4599 ;; Set the initial limit.
4600 (setq gnus-newsgroup-limit (copy-sequence articles))
4601 ;; Remove canceled articles from the list of unread articles.
4602 (setq fetched-articles
4603 (mapcar (lambda (headers) (mail-header-number headers))
4604 gnus-newsgroup-headers))
4605 (setq gnus-newsgroup-articles fetched-articles)
4606 (setq gnus-newsgroup-unreads
4607 (gnus-set-sorted-intersection
4608 gnus-newsgroup-unreads fetched-articles))
4610 (let ((marks (assq 'seen (gnus-info-marks info))))
4611 ;; The `seen' marks are treated specially.
4612 (when (setq gnus-newsgroup-seen (cdr marks))
4613 (dolist (article gnus-newsgroup-articles)
4614 (unless (gnus-member-of-range
4615 article gnus-newsgroup-seen)
4616 (push article gnus-newsgroup-unseen)))))
4618 ;; Removed marked articles that do not exist.
4619 (gnus-update-missing-marks
4620 (gnus-sorted-complement fetched-articles articles))
4621 ;; We might want to build some more threads first.
4622 (when (and gnus-fetch-old-headers
4623 (eq gnus-headers-retrieved-by 'nov))
4624 (if (eq gnus-fetch-old-headers 'invisible)
4625 (gnus-build-all-threads)
4626 (gnus-build-old-threads)))
4627 ;; Let the Gnus agent mark articles as read.
4629 (gnus-agent-get-undownloaded-list))
4630 ;; Remove list identifiers from subject
4631 (when gnus-list-identifiers
4632 (gnus-summary-remove-list-identifiers))
4633 ;; Check whether auto-expire is to be done in this group.
4634 (setq gnus-newsgroup-auto-expire
4635 (gnus-group-auto-expirable-p group))
4636 ;; Set up the article buffer now, if necessary.
4637 (unless gnus-single-article-buffer
4638 (gnus-article-setup-buffer))
4639 ;; First and last article in this newsgroup.
4640 (when gnus-newsgroup-headers
4641 (setq gnus-newsgroup-begin
4642 (mail-header-number (car gnus-newsgroup-headers))
4645 (gnus-last-element gnus-newsgroup-headers))))
4646 ;; GROUP is successfully selected.
4647 (or gnus-newsgroup-headers t)))))
4649 (defun gnus-summary-display-make-predicate (display)
4650 (require 'gnus-agent)
4651 (when (= (length display) 1)
4652 (setq display (car display)))
4653 (unless gnus-summary-display-cache
4654 (dolist (elem (append (list (cons 'read 'read)
4655 (cons 'unseen 'unseen))
4656 gnus-article-mark-lists))
4657 (push (cons (cdr elem)
4659 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
4660 gnus-summary-display-cache)))
4661 (let ((gnus-category-predicate-alist gnus-summary-display-cache))
4662 (gnus-get-predicate display)))
4664 ;; Uses the dynamically bound `number' variable.
4666 (defun gnus-article-marked-p (type &optional article)
4667 (let ((article (or article number)))
4670 (memq article gnus-newsgroup-marked))
4672 (memq article gnus-newsgroup-unsendable))
4673 ((eq type 'undownload)
4674 (memq article gnus-newsgroup-undownloaded))
4675 ((eq type 'download)
4676 (memq article gnus-newsgroup-downloadable))
4678 (memq article gnus-newsgroup-unreads))
4680 (memq article gnus-newsgroup-reads))
4682 (memq article gnus-newsgroup-dormant) )
4684 (memq article gnus-newsgroup-expirable))
4686 (memq article gnus-newsgroup-replied))
4688 (memq article gnus-newsgroup-killed))
4689 ((eq type 'bookmark)
4690 (assq article gnus-newsgroup-bookmarks))
4692 (assq article gnus-newsgroup-scored))
4694 (memq article gnus-newsgroup-saved))
4696 (memq article gnus-newsgroup-cached))
4698 (memq article gnus-newsgroup-forwarded))
4700 (not (memq article gnus-newsgroup-unseen)))
4702 (memq article gnus-newsgroup-recent))
4705 (defun gnus-articles-to-read (group &optional read-all)
4706 "Find out what articles the user wants to read."
4708 ;; Select all articles if `read-all' is non-nil, or if there
4709 ;; are no unread articles.
4711 (and (zerop (length gnus-newsgroup-marked))
4712 (zerop (length gnus-newsgroup-unreads)))
4713 (eq gnus-newsgroup-display 'gnus-not-ignore))
4714 ;; We want to select the headers for all the articles in
4715 ;; the group, so we select either all the active
4716 ;; articles in the group, or (if that's nil), the
4717 ;; articles in the cache.
4719 (gnus-uncompress-range (gnus-active group))
4720 (gnus-cache-articles-in-group group))
4721 ;; Select only the "normal" subset of articles.
4722 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
4723 (copy-sequence gnus-newsgroup-unreads))
4725 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
4726 (scored (length scored-list))
4727 (number (length articles))
4728 (marked (+ (length gnus-newsgroup-marked)
4729 (length gnus-newsgroup-dormant)))
4737 ((and (or (<= scored marked) (= scored number))
4738 (numberp gnus-large-newsgroup)
4739 (> number gnus-large-newsgroup))
4743 "How many articles from %s (default %d): "
4745 (gnus-group-decoded-name gnus-newsgroup-name)
4748 (if (string-match "^[ \t]*$" input) number input)))
4749 ((and (> scored marked) (< scored number)
4750 (> (- scored number) 20))
4753 (format "%s %s (%d scored, %d total): "
4754 "How many articles from"
4755 (gnus-group-decoded-name group)
4757 (if (string-match "^[ \t]*$" input)
4761 (message "Quit getting the articles to read")
4763 (setq select (if (stringp select) (string-to-number select) select))
4764 (if (or (null select) (zerop select))
4766 (if (and (not (zerop scored)) (<= (abs select) scored))
4768 (setq articles (sort scored-list '<))
4769 (setq number (length articles)))
4770 (setq articles (copy-sequence articles)))
4772 (when (< (abs select) number)
4774 ;; Select the N oldest articles.
4775 (setcdr (nthcdr (1- (abs select)) articles) nil)
4776 ;; Select the N most recent articles.
4777 (setq articles (nthcdr (- number select) articles))))
4778 (setq gnus-newsgroup-unselected
4779 (gnus-sorted-intersection
4780 gnus-newsgroup-unreads
4781 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4782 (when gnus-alter-articles-to-read-function
4783 (setq gnus-newsgroup-unreads
4785 (funcall gnus-alter-articles-to-read-function
4786 gnus-newsgroup-name gnus-newsgroup-unreads)
4790 (defun gnus-killed-articles (killed articles)
4793 (when (inline (gnus-member-of-range (car articles) killed))
4794 (push (car articles) out))
4795 (setq articles (cdr articles)))
4798 (defun gnus-uncompress-marks (marks)
4799 "Uncompress the mark ranges in MARKS."
4800 (let ((uncompressed '(score bookmark))
4803 (if (memq (caar marks) uncompressed)
4804 (push (car marks) out)
4805 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
4806 (setq marks (cdr marks)))
4809 (defun gnus-article-mark-to-type (mark)
4810 "Return the type of MARK."
4811 (or (cadr (assq mark gnus-article-special-mark-lists))
4814 (defun gnus-article-unpropagatable-p (mark)
4815 "Return whether MARK should be propagated to backend."
4816 (memq mark gnus-article-unpropagated-mark-lists))
4818 (defun gnus-adjust-marked-articles (info)
4819 "Set all article lists and remove all marks that are no longer valid."
4820 (let* ((marked-lists (gnus-info-marks info))
4821 (active (gnus-active (gnus-info-group info)))
4824 (types gnus-article-mark-lists)
4825 marks var articles article mark mark-type)
4827 (dolist (marks marked-lists)
4828 (setq mark (car marks)
4829 mark-type (gnus-article-mark-to-type mark)
4830 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
4832 ;; We set the variable according to the type of the marks list,
4833 ;; and then adjust the marks to a subset of the active articles.
4835 ;; Adjust "simple" lists.
4836 ((eq mark-type 'list)
4837 (set var (setq articles (gnus-uncompress-range (cdr marks))))
4838 (when (memq mark '(tick dormant expire reply save))
4840 (when (or (< (setq article (pop articles)) min) (> article max))
4841 (set var (delq article (symbol-value var)))))))
4843 ((eq mark-type 'tuple)
4844 (set var (setq articles (cdr marks)))
4845 (when (not (listp (cdr (symbol-value var))))
4846 (set var (list (symbol-value var))))
4847 (when (not (listp (cdr articles)))
4848 (setq articles (list articles)))
4850 (when (or (not (consp (setq article (pop articles))))
4851 (< (car article) min)
4852 (> (car article) max))
4853 (set var (delq article (symbol-value var))))))
4854 ((eq mark-type 'range)
4856 ((eq mark 'seen))))))))
4858 (defun gnus-update-missing-marks (missing)
4859 "Go through the list of MISSING articles and remove them from the mark lists."
4862 ;; Go through all types.
4863 (dolist (elem gnus-article-mark-lists)
4864 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
4865 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
4866 (when (symbol-value var)
4867 ;; This list has articles. So we delete all missing
4868 ;; articles from it.
4871 (set var (delq (pop m) (symbol-value var))))))))))
4873 (defun gnus-update-marks ()
4874 "Enter the various lists of marked articles into the newsgroup info list."
4875 (let ((types gnus-article-mark-lists)
4876 (info (gnus-get-info gnus-newsgroup-name))
4877 type list newmarked symbol delta-marks)
4879 ;; Add all marks lists to the list of marks lists.
4880 (while (setq type (pop types))
4881 (setq list (symbol-value
4883 (intern (format "gnus-newsgroup-%s" (car type))))))
4886 ;; Get rid of the entries of the articles that have the
4888 (when (and (eq (cdr type) 'score)
4892 (prev (cons nil list))
4895 (if (or (not (consp (car arts)))
4896 (= (cdar arts) gnus-summary-default-score))
4897 (setcdr prev (cdr arts))
4899 (setq arts (cdr arts)))
4900 (setq list (cdr all)))))
4902 (when (eq (cdr type) 'seen)
4905 (gnus-add-to-range list gnus-newsgroup-unseen)
4906 (gnus-compress-sequence gnus-newsgroup-articles))))
4908 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
4909 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
4911 (when (and (gnus-check-backend-function
4912 'request-set-mark gnus-newsgroup-name)
4913 (not (gnus-article-unpropagatable-p (cdr type))))
4914 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
4915 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
4916 (add (gnus-remove-from-range
4917 (gnus-copy-sequence list) old)))
4919 (push (list add 'add (list (cdr type))) delta-marks))
4921 (push (list del 'del (list (cdr type))) delta-marks))))
4924 (push (cons (cdr type) list) newmarked)))
4927 (unless (gnus-check-group gnus-newsgroup-name)
4928 (error "Can't open server for %s" gnus-newsgroup-name))
4929 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
4931 ;; Enter these new marks into the info of the group.
4933 (setcar (nthcdr 3 info) newmarked)
4934 ;; Add the marks lists to the end of the info.
4936 (setcdr (nthcdr 2 info) (list newmarked))))
4938 ;; Cut off the end of the info if there's nothing else there.
4942 (when (nthcdr (decf i) info)
4943 (setcdr (nthcdr i info) nil)))))))
4945 (defun gnus-set-mode-line (where)
4946 "Set the mode line of the article or summary buffers.
4947 If WHERE is `summary', the summary mode line format will be used."
4948 ;; Is this mode line one we keep updated?
4949 (when (and (memq where gnus-updated-mode-lines)
4951 (intern (format "gnus-%s-mode-line-format-spec" where))))
4954 ;; We evaluate this in the summary buffer since these
4955 ;; variables are buffer-local to that buffer.
4956 (set-buffer gnus-summary-buffer)
4957 ;; We bind all these variables that are used in the `eval' form
4959 (let* ((mformat (symbol-value
4961 (format "gnus-%s-mode-line-format-spec" where))))
4962 (gnus-tmp-group-name (gnus-group-decoded-name
4963 gnus-newsgroup-name))
4964 (gnus-tmp-article-number (or gnus-current-article 0))
4965 (gnus-tmp-unread gnus-newsgroup-unreads)
4966 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
4967 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
4968 (gnus-tmp-unread-and-unselected
4969 (cond ((and (zerop gnus-tmp-unread-and-unticked)
4970 (zerop gnus-tmp-unselected))
4972 ((zerop gnus-tmp-unselected)
4973 (format "{%d more}" gnus-tmp-unread-and-unticked))
4974 (t (format "{%d(+%d) more}"
4975 gnus-tmp-unread-and-unticked
4976 gnus-tmp-unselected))))
4978 (if (and gnus-current-headers
4979 (vectorp gnus-current-headers))
4980 (gnus-mode-string-quote
4981 (mail-header-subject gnus-current-headers))
4983 bufname-length max-len
4984 gnus-tmp-header) ;; passed as argument to any user-format-funcs
4985 (setq mode-string (eval mformat))
4986 (setq bufname-length (if (string-match "%b" mode-string)
4989 (if (eq where 'summary)
4991 (get-buffer gnus-article-buffer))))
4994 (setq max-len (max 4 (if gnus-mode-non-string-length
4996 gnus-mode-non-string-length
4998 (length mode-string))))
4999 ;; We might have to chop a bit of the string off...
5000 (when (> (length mode-string) max-len)
5002 (concat (truncate-string-to-width mode-string (- max-len 3))
5004 ;; Pad the mode string a bit.
5005 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
5006 ;; Update the mode line.
5007 (setq mode-line-buffer-identification
5008 (gnus-mode-line-buffer-identification (list mode-string)))
5009 (set-buffer-modified-p t))))
5011 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
5012 "Go through the HEADERS list and add all Xrefs to a hash table.
5013 The resulting hash table is returned, or nil if no Xrefs were found."
5014 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
5015 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
5016 (xref-hashtb (gnus-make-hashtable))
5017 start group entry number xrefs header)
5019 (setq header (pop headers))
5020 (when (and (setq xrefs (mail-header-xref header))
5021 (not (memq (setq number (mail-header-number header))
5024 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
5025 (setq start (match-end 0))
5026 (setq group (if prefix
5027 (concat prefix (substring xrefs (match-beginning 1)
5029 (substring xrefs (match-beginning 1) (match-end 1))))
5031 (string-to-int (substring xrefs (match-beginning 2)
5033 (if (setq entry (gnus-gethash group xref-hashtb))
5034 (setcdr entry (cons number (cdr entry)))
5035 (gnus-sethash group (cons number nil) xref-hashtb)))))
5036 (and start xref-hashtb)))
5038 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
5039 "Look through all the headers and mark the Xrefs as read."
5040 (let ((virtual (gnus-virtual-group-p from-newsgroup))
5041 name entry info xref-hashtb idlist method nth4)
5043 (set-buffer gnus-group-buffer)
5044 (when (setq xref-hashtb
5045 (gnus-create-xref-hashtb from-newsgroup headers unreads))
5048 (unless (string= from-newsgroup (setq name (symbol-name group)))
5049 (setq idlist (symbol-value group))
5050 ;; Dead groups are not updated.
5052 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
5054 (when (stringp (setq nth4 (gnus-info-method info)))
5055 (setq nth4 (gnus-server-to-method nth4))))
5056 ;; Only do the xrefs if the group has the same
5057 ;; select method as the group we have just read.
5058 (or (gnus-methods-equal-p
5059 nth4 (gnus-find-method-for-group from-newsgroup))
5061 (equal nth4 (setq method (gnus-find-method-for-group
5063 (and (equal (car nth4) (car method))
5064 (equal (nth 1 nth4) (nth 1 method))))
5065 gnus-use-cross-reference
5066 (or (not (eq gnus-use-cross-reference t))
5068 ;; Only do cross-references on subscribed
5069 ;; groups, if that is what is wanted.
5070 (<= (gnus-info-level info) gnus-level-subscribed))
5071 (gnus-group-make-articles-read name idlist))))
5074 (defun gnus-compute-read-articles (group articles)
5075 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5076 (info (nth 2 entry))
5077 (active (gnus-active group))
5080 ;; First peel off all invalid article numbers.
5082 (let ((ids articles)
5084 (while (setq id (pop ids))
5085 (when (and first (> id (cdr active)))
5086 ;; We'll end up in this situation in one particular
5087 ;; obscure situation. If you re-scan a group and get
5088 ;; a new article that is cross-posted to a different
5089 ;; group that has not been re-scanned, you might get
5090 ;; crossposted article that has a higher number than
5091 ;; Gnus believes possible. So we re-activate this
5092 ;; group as well. This might mean doing the
5093 ;; crossposting thingy will *increase* the number
5094 ;; of articles in some groups. Tsk, tsk.
5095 (setq active (or (gnus-activate-group group) active)))
5096 (when (or (> id (cdr active))
5097 (< id (car active)))
5098 (setq articles (delq id articles))))))
5099 ;; If the read list is nil, we init it.
5101 (null (gnus-info-read info))
5103 (setq ninfo (cons 1 (1- (car active))))
5104 (setq ninfo (gnus-info-read info)))
5105 ;; Then we add the read articles to the range.
5107 ninfo (setq articles (sort articles '<))))))
5109 (defun gnus-group-make-articles-read (group articles)
5110 "Update the info of GROUP to say that ARTICLES are read."
5112 (entry (gnus-gethash group gnus-newsrc-hashtb))
5113 (info (nth 2 entry))
5114 (active (gnus-active group))
5117 (setq range (gnus-compute-read-articles group articles))
5119 (set-buffer gnus-group-buffer)
5122 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
5123 (gnus-info-set-read ',info ',(gnus-info-read info))
5124 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
5125 (gnus-group-update-group ,group t))))
5126 ;; Add the read articles to the range.
5127 (gnus-info-set-read info range)
5128 (gnus-request-set-mark group (list (list range 'add '(read))))
5129 ;; Then we have to re-compute how many unread
5130 ;; articles there are in this group.
5134 (setq num (- (1+ (cdr active)) (car active))))
5135 ((not (listp (cdr range)))
5136 (setq num (- (cdr active) (- (1+ (cdr range))
5140 (if (numberp (car range))
5142 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
5143 (setq range (cdr range)))
5144 (setq num (- (cdr active) num))))
5145 ;; Update the number of unread articles.
5147 ;; Update the group buffer.
5148 (gnus-group-update-group group t)))))
5150 (defvar gnus-newsgroup-none-id 0)
5152 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
5153 (let ((cur nntp-server-buffer)
5156 (save-excursion (set-buffer gnus-summary-buffer)
5157 gnus-newsgroup-dependencies)))
5159 (mail-parse-charset gnus-newsgroup-charset)
5160 (mail-parse-ignored-charsets
5161 (save-excursion (condition-case nil
5162 (set-buffer gnus-summary-buffer)
5164 gnus-newsgroup-ignored-charsets)))
5166 (set-buffer nntp-server-buffer)
5167 ;; Translate all TAB characters into SPACE characters.
5168 (subst-char-in-region (point-min) (point-max) ?\t ? t)
5169 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5170 (gnus-run-hooks 'gnus-parse-headers-hook)
5171 (let ((case-fold-search t)
5172 in-reply-to header p lines chars)
5173 (goto-char (point-min))
5174 ;; Search to the beginning of the next header. Error messages
5175 ;; do not begin with 2 or 3.
5176 (while (re-search-forward "^[23][0-9]+ " nil t)
5179 ;; This implementation of this function, with nine
5180 ;; search-forwards instead of the one re-search-forward and
5181 ;; a case (which basically was the old function) is actually
5182 ;; about twice as fast, even though it looks messier. You
5183 ;; can't have everything, I guess. Speed and elegance
5184 ;; doesn't always go hand in hand.
5193 (narrow-to-region (point)
5194 (or (and (search-forward "\n.\n" nil t)
5200 (if (search-forward "\nsubject:" nil t)
5201 (funcall gnus-decode-encoded-word-function
5202 (nnheader-header-value))
5207 (if (search-forward "\nfrom:" nil t)
5208 (funcall gnus-decode-encoded-word-function
5209 (nnheader-header-value))
5214 (if (search-forward "\ndate:" nil t)
5215 (nnheader-header-value) ""))
5219 (setq id (if (re-search-forward
5220 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
5221 ;; We do it this way to make sure the Message-ID
5222 ;; is (somewhat) syntactically valid.
5223 (buffer-substring (match-beginning 1)
5225 ;; If there was no message-id, we just fake one
5226 ;; to make subsequent routines simpler.
5227 (nnheader-generate-fake-message-id))))
5231 (if (search-forward "\nreferences:" nil t)
5235 (nnheader-header-value)
5240 (search-backward ">" end t)
5243 (search-backward "<" end t)
5245 ;; Get the references from the in-reply-to header if there
5246 ;; were no references and the in-reply-to header looks
5248 (if (and (search-forward "\nin-reply-to:" nil t)
5249 (setq in-reply-to (nnheader-header-value))
5250 (string-match "<[^>]+>" in-reply-to))
5252 (setq ref (substring in-reply-to (match-beginning 0)
5254 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
5255 (setq ref2 (substring in-reply-to (match-beginning 0)
5257 (when (> (length ref2) (length ref))
5264 (if (search-forward "\nchars: " nil t)
5265 (if (numberp (setq chars (ignore-errors (read cur))))
5271 (if (search-forward "\nlines: " nil t)
5272 (if (numberp (setq lines (ignore-errors (read cur))))
5278 (and (search-forward "\nxref:" nil t)
5279 (nnheader-header-value)))
5281 (when gnus-extra-headers
5282 (let ((extra gnus-extra-headers)
5286 (when (search-forward
5287 (concat "\n" (symbol-name (car extra)) ":") nil t)
5288 (push (cons (car extra) (nnheader-header-value))
5292 (when (equal id ref)
5295 (when gnus-alter-header-function
5296 (funcall gnus-alter-header-function header)
5297 (setq id (mail-header-id header)
5298 ref (gnus-parent-id (mail-header-references header))))
5301 (gnus-dependencies-add-header
5302 header dependencies force-new))
5303 (push header headers))
5304 (goto-char (point-max))
5306 (nreverse headers)))))
5308 ;; Goes through the xover lines and returns a list of vectors
5309 (defun gnus-get-newsgroup-headers-xover (sequence &optional
5310 force-new dependencies
5311 group also-fetch-heads)
5312 "Parse the news overview data in the server buffer.
5313 Return a list of headers that match SEQUENCE (see
5314 `nntp-retrieve-headers')."
5315 ;; Get the Xref when the users reads the articles since most/some
5316 ;; NNTP servers do not include Xrefs when using XOVER.
5317 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
5318 (let ((mail-parse-charset gnus-newsgroup-charset)
5319 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
5320 (cur nntp-server-buffer)
5321 (dependencies (or dependencies gnus-newsgroup-dependencies))
5323 ((eq gnus-read-all-available-headers t)
5325 ((stringp gnus-read-all-available-headers)
5326 (string-match gnus-read-all-available-headers group))
5329 number headers header)
5331 (set-buffer nntp-server-buffer)
5332 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5333 ;; Allow the user to mangle the headers before parsing them.
5334 (gnus-run-hooks 'gnus-parse-headers-hook)
5335 (goto-char (point-min))
5338 (while (and (or sequence allp)
5340 (setq number (read cur))
5342 (while (and sequence
5343 (< (car sequence) number))
5344 (setq sequence (cdr sequence))))
5347 (eq number (car sequence))))
5349 (setq sequence (cdr sequence))
5350 (setq header (inline
5351 (gnus-nov-parse-line
5352 number dependencies force-new)))))
5353 (push header headers))
5356 (gnus-error 4 "Strange nov line (%d)"
5357 (count-lines (point-min) (point)))))
5359 ;; A common bug in inn is that if you have posted an article and
5360 ;; then retrieves the active file, it will answer correctly --
5361 ;; the new article is included. However, a NOV entry for the
5362 ;; article may not have been generated yet, so this may fail.
5363 ;; We work around this problem by retrieving the last few
5364 ;; headers using HEAD.
5365 (if (or (not also-fetch-heads)
5367 ;; We (probably) got all the headers.
5369 (let ((gnus-nov-is-evil t))
5372 (when (eq (gnus-retrieve-headers sequence group) 'headers)
5373 (gnus-get-newsgroup-headers))))))))
5375 (defun gnus-article-get-xrefs ()
5376 "Fill in the Xref value in `gnus-current-headers', if necessary.
5377 This is meant to be called in `gnus-article-internal-prepare-hook'."
5378 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
5379 gnus-current-headers)))
5380 (or (not gnus-use-cross-reference)
5382 (and (mail-header-xref headers)
5383 (not (string= (mail-header-xref headers) "")))
5384 (let ((case-fold-search t)
5387 (nnheader-narrow-to-headers)
5388 (goto-char (point-min))
5389 (when (or (and (not (eobp))
5390 (eq (downcase (char-after)) ?x)
5391 (looking-at "Xref:"))
5392 (search-forward "\nXref:" nil t))
5393 (goto-char (1+ (match-end 0)))
5394 (setq xref (buffer-substring (point)
5395 (progn (end-of-line) (point))))
5396 (mail-header-set-xref headers xref)))))))
5398 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
5399 "Find article ID and insert the summary line for that article.
5400 OLD-HEADER can either be a header or a line number to insert
5401 the subject line on."
5402 (let* ((line (and (numberp old-header) old-header))
5403 (old-header (and (vectorp old-header) old-header))
5404 (header (cond ((and old-header use-old-header)
5407 (gnus-number-to-header id))
5408 (gnus-number-to-header id))
5410 (gnus-read-header id))))
5411 (number (and (numberp id) id))
5414 ;; Rebuild the thread that this article is part of and go to the
5415 ;; article we have fetched.
5416 (when (and (not gnus-show-threads)
5419 (setq d (gnus-data-find (mail-header-number old-header))))
5420 (goto-char (gnus-data-pos d))
5423 (- (gnus-point-at-bol)
5425 (1+ (gnus-point-at-eol))
5426 (gnus-delete-line))))))
5428 (mail-header-set-number header (mail-header-number old-header)))
5429 (setq gnus-newsgroup-sparse
5430 (delq (setq number (mail-header-number header))
5431 gnus-newsgroup-sparse))
5432 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
5433 (push number gnus-newsgroup-limit)
5434 (gnus-rebuild-thread (mail-header-id header) line)
5435 (gnus-summary-goto-subject number nil t))
5436 (when (and (numberp number)
5438 ;; We have to update the boundaries even if we can't fetch the
5439 ;; article if ID is a number -- so that the next `P' or `N'
5440 ;; command will fetch the previous (or next) article even
5441 ;; if the one we tried to fetch this time has been canceled.
5442 (when (> number gnus-newsgroup-end)
5443 (setq gnus-newsgroup-end number))
5444 (when (< number gnus-newsgroup-begin)
5445 (setq gnus-newsgroup-begin number))
5446 (setq gnus-newsgroup-unselected
5447 (delq number gnus-newsgroup-unselected)))
5448 ;; Report back a success?
5449 (and header (mail-header-number header))))
5451 ;;; Process/prefix in the summary buffer
5453 (defun gnus-summary-work-articles (n)
5454 "Return a list of articles to be worked upon.
5455 The prefix argument, the list of process marked articles, and the
5456 current article will be taken into consideration."
5458 (set-buffer gnus-summary-buffer)
5461 ;; A numerical prefix has been given.
5462 (setq n (prefix-numeric-value n))
5463 (let ((backward (< n 0))
5464 (n (abs (prefix-numeric-value n)))
5469 (push (setq article (gnus-summary-article-number))
5472 (gnus-summary-find-prev nil article)
5473 (gnus-summary-find-next nil article)))
5475 (nreverse articles)))
5476 ((and (gnus-region-active-p) (mark))
5477 (message "region active")
5478 ;; Work on the region between point and mark.
5479 (let ((max (max (point) (mark)))
5482 (goto-char (min (min (point) (mark))))
5485 (push (setq article (gnus-summary-article-number)) articles)
5486 (gnus-summary-find-next nil article)
5488 (nreverse articles))))
5489 (gnus-newsgroup-processable
5490 ;; There are process-marked articles present.
5491 ;; Save current state.
5492 (gnus-summary-save-process-mark)
5494 (reverse gnus-newsgroup-processable))
5496 ;; Just return the current article.
5497 (list (gnus-summary-article-number))))))
5499 (defmacro gnus-summary-iterate (arg &rest forms)
5500 "Iterate over the process/prefixed articles and do FORMS.
5501 ARG is the interactive prefix given to the command. FORMS will be
5502 executed with point over the summary line of the articles."
5503 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
5504 `(let ((,articles (gnus-summary-work-articles ,arg)))
5506 (gnus-summary-goto-subject (car ,articles))
5510 (put 'gnus-summary-iterate 'lisp-indent-function 1)
5511 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
5513 (defun gnus-summary-save-process-mark ()
5514 "Push the current set of process marked articles on the stack."
5516 (push (copy-sequence gnus-newsgroup-processable)
5517 gnus-newsgroup-process-stack))
5519 (defun gnus-summary-kill-process-mark ()
5520 "Push the current set of process marked articles on the stack and unmark."
5522 (gnus-summary-save-process-mark)
5523 (gnus-summary-unmark-all-processable))
5525 (defun gnus-summary-yank-process-mark ()
5526 "Pop the last process mark state off the stack and restore it."
5528 (unless gnus-newsgroup-process-stack
5529 (error "Empty mark stack"))
5530 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
5532 (defun gnus-summary-process-mark-set (set)
5533 "Make SET into the current process marked articles."
5534 (gnus-summary-unmark-all-processable)
5536 (gnus-summary-set-process-mark (pop set))))
5538 ;;; Searching and stuff
5540 (defun gnus-summary-search-group (&optional backward use-level)
5541 "Search for next unread newsgroup.
5542 If optional argument BACKWARD is non-nil, search backward instead."
5544 (set-buffer gnus-group-buffer)
5545 (when (gnus-group-search-forward
5546 backward nil (if use-level (gnus-group-group-level) nil))
5547 (gnus-group-group-name))))
5549 (defun gnus-summary-best-group (&optional exclude-group)
5550 "Find the name of the best unread group.
5551 If EXCLUDE-GROUP, do not go to this group."
5553 (set-buffer gnus-group-buffer)
5555 (gnus-group-best-unread-group exclude-group))))
5557 (defun gnus-summary-find-next (&optional unread article backward undownloaded)
5558 (if backward (gnus-summary-find-prev)
5559 (let* ((dummy (gnus-summary-article-intangible-p))
5560 (article (or article (gnus-summary-article-number)))
5561 (arts (gnus-data-find-list article))
5563 (when (and (not dummy)
5564 (or (not gnus-summary-check-current)
5566 (not (gnus-data-unread-p (car arts)))))
5567 (setq arts (cdr arts)))
5572 (when (or (and undownloaded
5573 (eq gnus-undownloaded-mark
5574 (gnus-data-mark (car arts))))
5575 (gnus-data-unread-p (car arts)))
5576 (setq result (car arts)
5578 (setq arts (cdr arts)))
5581 (goto-char (gnus-data-pos result))
5582 (gnus-data-number result)))))
5584 (defun gnus-summary-find-prev (&optional unread article)
5585 (let* ((eobp (eobp))
5586 (article (or article (gnus-summary-article-number)))
5587 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
5589 (when (and (not eobp)
5590 (or (not gnus-summary-check-current)
5592 (not (gnus-data-unread-p (car arts)))))
5593 (setq arts (cdr arts)))
5598 (when (gnus-data-unread-p (car arts))
5599 (setq result (car arts)
5601 (setq arts (cdr arts)))
5604 (goto-char (gnus-data-pos result))
5605 (gnus-data-number result))))
5607 (defun gnus-summary-find-subject (subject &optional unread backward article)
5608 (let* ((simp-subject (gnus-simplify-subject-fully subject))
5609 (article (or article (gnus-summary-article-number)))
5610 (articles (gnus-data-list backward))
5611 (arts (gnus-data-find-list article articles))
5613 (when (or (not gnus-summary-check-current)
5615 (not (gnus-data-unread-p (car arts))))
5616 (setq arts (cdr arts)))
5618 (and (or (not unread)
5619 (gnus-data-unread-p (car arts)))
5620 (vectorp (gnus-data-header (car arts)))
5622 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
5623 (setq result (car arts)
5625 (setq arts (cdr arts)))
5627 (goto-char (gnus-data-pos result))
5628 (gnus-data-number result))))
5630 (defun gnus-summary-search-forward (&optional unread subject backward)
5631 "Search forward for an article.
5632 If UNREAD, look for unread articles. If SUBJECT, look for
5633 articles with that subject. If BACKWARD, search backward instead."
5634 (cond (subject (gnus-summary-find-subject subject unread backward))
5635 (backward (gnus-summary-find-prev unread))
5636 (t (gnus-summary-find-next unread))))
5638 (defun gnus-recenter (&optional n)
5639 "Center point in window and redisplay frame.
5640 Also do horizontal recentering."
5642 (when (and gnus-auto-center-summary
5643 (not (eq gnus-auto-center-summary 'vertical)))
5644 (gnus-horizontal-recenter))
5647 (defun gnus-summary-recenter ()
5648 "Center point in the summary window.
5649 If `gnus-auto-center-summary' is nil, or the article buffer isn't
5650 displayed, no centering will be performed."
5651 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
5652 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
5654 (let* ((top (cond ((< (window-height) 4) 0)
5655 ((< (window-height) 7) 1)
5656 (t (if (numberp gnus-auto-center-summary)
5657 gnus-auto-center-summary
5659 (height (1- (window-height)))
5660 (bottom (save-excursion (goto-char (point-max))
5661 (forward-line (- height))
5663 (window (get-buffer-window (current-buffer))))
5664 ;; The user has to want it.
5665 (when gnus-auto-center-summary
5666 (when (get-buffer-window gnus-article-buffer)
5667 ;; Only do recentering when the article buffer is displayed,
5668 ;; Set the window start to either `bottom', which is the biggest
5669 ;; possible valid number, or the second line from the top,
5670 ;; whichever is the least.
5671 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
5672 (if (> bottom top-pos)
5673 ;; Keep the second line from the top visible
5674 (set-window-start window top-pos t)
5675 ;; Try to keep the bottom line visible; if it's partially
5676 ;; obscured, either scroll one more line to make it fully
5677 ;; visible, or revert to using TOP-POS.
5679 (goto-char (point-max))
5681 (let ((last-line-start (point)))
5683 (set-window-start window (point) t)
5684 (when (not (pos-visible-in-window-p last-line-start window))
5686 (set-window-start window (min (point) top-pos) t)))))))
5687 ;; Do horizontal recentering while we're at it.
5688 (when (and (get-buffer-window (current-buffer) t)
5689 (not (eq gnus-auto-center-summary 'vertical)))
5690 (let ((selected (selected-window)))
5691 (select-window (get-buffer-window (current-buffer) t))
5692 (gnus-summary-position-point)
5693 (gnus-horizontal-recenter)
5694 (select-window selected))))))
5696 (defun gnus-summary-jump-to-group (newsgroup)
5697 "Move point to NEWSGROUP in group mode buffer."
5698 ;; Keep update point of group mode buffer if visible.
5699 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
5700 (save-window-excursion
5701 ;; Take care of tree window mode.
5702 (when (get-buffer-window gnus-group-buffer)
5703 (pop-to-buffer gnus-group-buffer))
5704 (gnus-group-jump-to-group newsgroup))
5706 ;; Take care of tree window mode.
5707 (if (get-buffer-window gnus-group-buffer)
5708 (pop-to-buffer gnus-group-buffer)
5709 (set-buffer gnus-group-buffer))
5710 (gnus-group-jump-to-group newsgroup))))
5712 ;; This function returns a list of article numbers based on the
5713 ;; difference between the ranges of read articles in this group and
5714 ;; the range of active articles.
5715 (defun gnus-list-of-unread-articles (group)
5716 (let* ((read (gnus-info-read (gnus-get-info group)))
5717 (active (or (gnus-active group) (gnus-activate-group group)))
5720 ;; If none are read, then all are unread.
5722 (setq first (car active))
5723 ;; If the range of read articles is a single range, then the
5724 ;; first unread article is the article after the last read
5725 ;; article. Sounds logical, doesn't it?
5726 (if (and (not (listp (cdr read)))
5727 (or (< (car read) (car active))
5728 (progn (setq read (list read))
5730 (setq first (max (car active) (1+ (cdr read))))
5731 ;; `read' is a list of ranges.
5732 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
5735 (setq first (car active)))
5738 (while (< first nlast)
5740 (setq first (1+ first))))
5741 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
5742 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
5743 (setq read (cdr read)))))
5744 ;; And add the last unread articles.
5745 (while (<= first last)
5747 (setq first (1+ first)))
5748 ;; Return the list of unread articles.
5749 (delq 0 (nreverse unread))))
5751 (defun gnus-list-of-read-articles (group)
5752 "Return a list of unread, unticked and non-dormant articles."
5753 (let* ((info (gnus-get-info group))
5754 (marked (gnus-info-marks info))
5755 (active (gnus-active group)))
5757 (gnus-set-difference
5758 (gnus-sorted-complement
5759 (gnus-uncompress-range active)
5760 (gnus-list-of-unread-articles group))
5762 (gnus-uncompress-range (cdr (assq 'dormant marked)))
5763 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
5765 ;; Various summary commands
5767 (defun gnus-summary-select-article-buffer ()
5768 "Reconfigure windows to show article buffer."
5770 (if (not (gnus-buffer-live-p gnus-article-buffer))
5771 (error "There is no article buffer for this summary buffer")
5772 (gnus-configure-windows 'article)
5773 (select-window (get-buffer-window gnus-article-buffer))))
5775 (defun gnus-summary-universal-argument (arg)
5776 "Perform any operation on all articles that are process/prefixed."
5778 (let ((articles (gnus-summary-work-articles arg))
5785 (substitute-command-keys
5786 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
5788 (gnus-error 1 "Undefined key")
5791 (gnus-summary-goto-subject (setq article (pop articles)))
5792 (let (gnus-newsgroup-processable)
5793 (command-execute func))
5794 (gnus-summary-remove-process-mark article)))))
5795 (gnus-summary-position-point))
5797 (defun gnus-summary-toggle-truncation (&optional arg)
5798 "Toggle truncation of summary lines.
5799 With arg, turn line truncation on iff arg is positive."
5801 (setq truncate-lines
5802 (if (null arg) (not truncate-lines)
5803 (> (prefix-numeric-value arg) 0)))
5806 (defun gnus-summary-reselect-current-group (&optional all rescan)
5807 "Exit and then reselect the current newsgroup.
5808 The prefix argument ALL means to select all articles."
5810 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
5811 (error "Ephemeral groups can't be reselected"))
5812 (let ((current-subject (gnus-summary-article-number))
5813 (group gnus-newsgroup-name))
5814 (setq gnus-newsgroup-begin nil)
5816 ;; We have to adjust the point of group mode buffer because
5817 ;; point was moved to the next unread newsgroup by exiting.
5818 (gnus-summary-jump-to-group group)
5821 (gnus-group-get-new-news-this-group 1)))
5822 (gnus-group-read-group all t)
5823 (gnus-summary-goto-subject current-subject nil t)))
5825 (defun gnus-summary-rescan-group (&optional all)
5826 "Exit the newsgroup, ask for new articles, and select the newsgroup."
5828 (gnus-summary-reselect-current-group all t))
5830 (defun gnus-summary-update-info (&optional non-destructive)
5832 (let ((group gnus-newsgroup-name))
5834 (when gnus-newsgroup-kill-headers
5835 (setq gnus-newsgroup-killed
5836 (gnus-compress-sequence
5838 (gnus-set-sorted-intersection
5839 (gnus-uncompress-range gnus-newsgroup-killed)
5840 (setq gnus-newsgroup-unselected
5841 (sort gnus-newsgroup-unselected '<)))
5842 (setq gnus-newsgroup-unreads
5843 (sort gnus-newsgroup-unreads '<)))
5845 (unless (listp (cdr gnus-newsgroup-killed))
5846 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
5847 (let ((headers gnus-newsgroup-headers))
5848 ;; Set the new ranges of read articles.
5850 (set-buffer gnus-group-buffer)
5851 (gnus-undo-force-boundary))
5852 (gnus-update-read-articles
5853 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
5854 ;; Set the current article marks.
5855 (let ((gnus-newsgroup-scored
5856 (if (and (not gnus-save-score)
5857 (not non-destructive))
5859 gnus-newsgroup-scored)))
5861 (gnus-update-marks)))
5862 ;; Do the cross-ref thing.
5863 (when gnus-use-cross-reference
5864 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
5865 ;; Do not switch windows but change the buffer to work.
5866 (set-buffer gnus-group-buffer)
5867 (unless (gnus-ephemeral-group-p group)
5868 (gnus-group-update-group group)))))))
5870 (defun gnus-summary-save-newsrc (&optional force)
5871 "Save the current number of read/marked articles in the dribble buffer.
5872 The dribble buffer will then be saved.
5873 If FORCE (the prefix), also save the .newsrc file(s)."
5875 (gnus-summary-update-info t)
5877 (gnus-save-newsrc-file)
5878 (gnus-dribble-save)))
5880 (defun gnus-summary-exit (&optional temporary)
5881 "Exit reading current newsgroup, and then return to group selection mode.
5882 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
5884 (gnus-set-global-variables)
5885 (when (gnus-buffer-live-p gnus-article-buffer)
5887 (set-buffer gnus-article-buffer)
5888 (mm-destroy-parts gnus-article-mime-handles)
5889 ;; Set it to nil for safety reason.
5890 (setq gnus-article-mime-handle-alist nil)
5891 (setq gnus-article-mime-handles nil)))
5892 (gnus-kill-save-kill-buffer)
5893 (gnus-async-halt-prefetch)
5894 (let* ((group gnus-newsgroup-name)
5895 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
5898 (buf (current-buffer)))
5900 ;; Do adaptive scoring, and possibly save score files.
5901 (when gnus-newsgroup-adaptive
5902 (gnus-score-adaptive))
5903 (when gnus-use-scoring
5905 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
5906 ;; If we have several article buffers, we kill them at exit.
5907 (unless gnus-single-article-buffer
5908 (gnus-kill-buffer gnus-original-article-buffer)
5909 (setq gnus-article-current nil))
5910 (when gnus-use-cache
5911 (gnus-cache-possibly-remove-articles)
5912 (gnus-cache-save-buffers))
5913 (gnus-async-prefetch-remove-group group)
5914 (when gnus-suppress-duplicates
5915 (gnus-dup-enter-articles))
5916 (when gnus-use-trees
5917 (gnus-tree-close group))
5918 (when gnus-use-cache
5919 (gnus-cache-write-active))
5920 ;; Remove entries for this group.
5921 (nnmail-purge-split-history (gnus-group-real-name group))
5922 ;; Make all changes in this group permanent.
5924 (gnus-run-hooks 'gnus-exit-group-hook)
5925 (gnus-summary-update-info))
5926 (gnus-close-group group)
5927 ;; Make sure where we were, and go to next newsgroup.
5928 (set-buffer gnus-group-buffer)
5930 (gnus-group-jump-to-group group))
5931 (gnus-run-hooks 'gnus-summary-exit-hook)
5932 (unless (or quit-config
5933 ;; If this group has disappeared from the summary
5934 ;; buffer, don't skip forwards.
5935 (not (string= group (gnus-group-group-name))))
5936 (gnus-group-next-unread-group 1))
5937 (setq group-point (point))
5940 ;; If we have several article buffers, we kill them at exit.
5941 (unless gnus-single-article-buffer
5942 (gnus-kill-buffer gnus-article-buffer)
5943 (gnus-kill-buffer gnus-original-article-buffer)
5944 (setq gnus-article-current nil))
5946 (if (not gnus-kill-summary-on-exit)
5948 (gnus-deaden-summary)
5950 ;; We set all buffer-local variables to nil. It is unclear why
5951 ;; this is needed, but if we don't, buffer-local variables are
5952 ;; not garbage-collected, it seems. This would the lead to en
5953 ;; ever-growing Emacs.
5954 (gnus-summary-clear-local-variables)
5955 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
5956 (gnus-summary-clear-local-variables))
5957 (when (get-buffer gnus-article-buffer)
5958 (bury-buffer gnus-article-buffer))
5959 ;; We clear the global counterparts of the buffer-local
5960 ;; variables as well, just to be on the safe side.
5961 (set-buffer gnus-group-buffer)
5962 (gnus-summary-clear-local-variables)
5963 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
5964 (gnus-summary-clear-local-variables)))
5965 (setq gnus-current-select-method gnus-select-method)
5966 (pop-to-buffer gnus-group-buffer)
5967 (if (not quit-config)
5969 (goto-char group-point)
5970 (gnus-configure-windows 'group 'force))
5971 (gnus-handle-ephemeral-exit quit-config))
5972 ;; Return to group mode buffer.
5973 (when (eq mode 'gnus-summary-mode)
5974 (gnus-kill-buffer buf))
5975 ;; Clear the current group name.
5977 (setq gnus-newsgroup-name nil)))))
5979 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
5980 (defun gnus-summary-exit-no-update (&optional no-questions)
5981 "Quit reading current newsgroup without updating read article info."
5983 (let* ((group gnus-newsgroup-name)
5984 (quit-config (gnus-group-quit-config group)))
5985 (when (or no-questions
5987 (gnus-y-or-n-p "Discard changes to this group and exit? "))
5988 (gnus-async-halt-prefetch)
5990 (delq 'gnus-summary-expire-articles
5991 (copy-sequence gnus-summary-prepare-exit-hook)))
5992 (when (gnus-buffer-live-p gnus-article-buffer)
5994 (set-buffer gnus-article-buffer)
5995 (mm-destroy-parts gnus-article-mime-handles)
5996 ;; Set it to nil for safety reason.
5997 (setq gnus-article-mime-handle-alist nil)
5998 (setq gnus-article-mime-handles nil)))
5999 ;; If we have several article buffers, we kill them at exit.
6000 (unless gnus-single-article-buffer
6001 (gnus-kill-buffer gnus-article-buffer)
6002 (gnus-kill-buffer gnus-original-article-buffer)
6003 (setq gnus-article-current nil))
6004 (if (not gnus-kill-summary-on-exit)
6005 (gnus-deaden-summary)
6006 (gnus-close-group group)
6007 (gnus-summary-clear-local-variables)
6008 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6009 (gnus-summary-clear-local-variables))
6010 (set-buffer gnus-group-buffer)
6011 (gnus-summary-clear-local-variables)
6012 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6013 (gnus-summary-clear-local-variables))
6014 (when (get-buffer gnus-summary-buffer)
6015 (kill-buffer gnus-summary-buffer)))
6016 (unless gnus-single-article-buffer
6017 (setq gnus-article-current nil))
6018 (when gnus-use-trees
6019 (gnus-tree-close group))
6020 (gnus-async-prefetch-remove-group group)
6021 (when (get-buffer gnus-article-buffer)
6022 (bury-buffer gnus-article-buffer))
6023 ;; Return to the group buffer.
6024 (gnus-configure-windows 'group 'force)
6025 ;; Clear the current group name.
6026 (setq gnus-newsgroup-name nil)
6027 (when (equal (gnus-group-group-name) group)
6028 (gnus-group-next-unread-group 1))
6030 (gnus-handle-ephemeral-exit quit-config)))))
6032 (defun gnus-handle-ephemeral-exit (quit-config)
6033 "Handle movement when leaving an ephemeral group.
6034 The state which existed when entering the ephemeral is reset."
6035 (if (not (buffer-name (car quit-config)))
6036 (gnus-configure-windows 'group 'force)
6037 (set-buffer (car quit-config))
6038 (cond ((eq major-mode 'gnus-summary-mode)
6039 (gnus-set-global-variables))
6040 ((eq major-mode 'gnus-article-mode)
6042 ;; The `gnus-summary-buffer' variable may point
6043 ;; to the old summary buffer when using a single
6045 (unless (gnus-buffer-live-p gnus-summary-buffer)
6046 (set-buffer gnus-group-buffer))
6047 (set-buffer gnus-summary-buffer)
6048 (gnus-set-global-variables))))
6049 (if (or (eq (cdr quit-config) 'article)
6050 (eq (cdr quit-config) 'pick))
6052 ;; The current article may be from the ephemeral group
6053 ;; thus it is best that we reload this article
6054 (gnus-summary-show-article)
6055 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
6056 (gnus-configure-windows 'pick 'force)
6057 (gnus-configure-windows (cdr quit-config) 'force)))
6058 (gnus-configure-windows (cdr quit-config) 'force))
6059 (when (eq major-mode 'gnus-summary-mode)
6060 (gnus-summary-next-subject 1 nil t)
6061 (gnus-summary-recenter)
6062 (gnus-summary-position-point))))
6066 (defvar gnus-dead-summary-mode-map nil)
6068 (unless gnus-dead-summary-mode-map
6069 (setq gnus-dead-summary-mode-map (make-keymap))
6070 (suppress-keymap gnus-dead-summary-mode-map)
6071 (substitute-key-definition
6072 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
6073 (let ((keys '("\C-d" "\r" "\177" [delete])))
6075 (define-key gnus-dead-summary-mode-map
6076 (pop keys) 'gnus-summary-wake-up-the-dead))))
6078 (defvar gnus-dead-summary-mode nil
6079 "Minor mode for Gnus summary buffers.")
6081 (defun gnus-dead-summary-mode (&optional arg)
6082 "Minor mode for Gnus summary buffers."
6084 (when (eq major-mode 'gnus-summary-mode)
6085 (make-local-variable 'gnus-dead-summary-mode)
6086 (setq gnus-dead-summary-mode
6087 (if (null arg) (not gnus-dead-summary-mode)
6088 (> (prefix-numeric-value arg) 0)))
6089 (when gnus-dead-summary-mode
6090 (gnus-add-minor-mode
6091 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
6093 (defun gnus-deaden-summary ()
6094 "Make the current summary buffer into a dead summary buffer."
6095 ;; Kill any previous dead summary buffer.
6096 (when (and gnus-dead-summary
6097 (buffer-name gnus-dead-summary))
6099 (set-buffer gnus-dead-summary)
6100 (when gnus-dead-summary-mode
6101 (kill-buffer (current-buffer)))))
6102 ;; Make this the current dead summary.
6103 (setq gnus-dead-summary (current-buffer))
6104 (gnus-dead-summary-mode 1)
6105 (let ((name (buffer-name)))
6106 (when (string-match "Summary" name)
6108 (concat (substring name 0 (match-beginning 0)) "Dead "
6109 (substring name (match-beginning 0)))
6113 (defun gnus-kill-or-deaden-summary (buffer)
6114 "Kill or deaden the summary BUFFER."
6116 (when (and (buffer-name buffer)
6117 (not gnus-single-article-buffer))
6120 (gnus-kill-buffer gnus-article-buffer)
6121 (gnus-kill-buffer gnus-original-article-buffer)))
6122 (cond (gnus-kill-summary-on-exit
6123 (when (and gnus-use-trees
6124 (gnus-buffer-exists-p buffer))
6127 (gnus-tree-close gnus-newsgroup-name)))
6128 (gnus-kill-buffer buffer))
6129 ((gnus-buffer-exists-p buffer)
6132 (gnus-deaden-summary))))))
6134 (defun gnus-summary-wake-up-the-dead (&rest args)
6135 "Wake up the dead summary buffer."
6137 (gnus-dead-summary-mode -1)
6138 (let ((name (buffer-name)))
6139 (when (string-match "Dead " name)
6141 (concat (substring name 0 (match-beginning 0))
6142 (substring name (match-end 0)))
6144 (gnus-message 3 "This dead summary is now alive again"))
6146 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
6147 (defun gnus-summary-fetch-faq (&optional faq-dir)
6148 "Fetch the FAQ for the current group.
6149 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
6153 (when current-prefix-arg
6155 "Faq dir: " (and (listp gnus-group-faq-directory)
6156 (mapcar (lambda (file) (list file))
6157 gnus-group-faq-directory))))))
6158 (let (gnus-faq-buffer)
6159 (when (setq gnus-faq-buffer
6160 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
6161 (gnus-configure-windows 'summary-faq))))
6163 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6164 (defun gnus-summary-describe-group (&optional force)
6165 "Describe the current newsgroup."
6167 (gnus-group-describe-group force gnus-newsgroup-name))
6169 (defun gnus-summary-describe-briefly ()
6170 "Describe summary mode commands briefly."
6172 (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")))
6174 ;; Walking around group mode buffer from summary mode.
6176 (defun gnus-summary-next-group (&optional no-article target-group backward)
6177 "Exit current newsgroup and then select next unread newsgroup.
6178 If prefix argument NO-ARTICLE is non-nil, no article is selected
6179 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
6180 previous group instead."
6182 ;; Stop pre-fetching.
6183 (gnus-async-halt-prefetch)
6184 (let ((current-group gnus-newsgroup-name)
6185 (current-buffer (current-buffer))
6187 ;; First we semi-exit this group to update Xrefs and all variables.
6188 ;; We can't do a real exit, because the window conf must remain
6189 ;; the same in case the user is prompted for info, and we don't
6190 ;; want the window conf to change before that...
6191 (gnus-summary-exit t)
6192 (while (not entered)
6193 ;; Then we find what group we are supposed to enter.
6194 (set-buffer gnus-group-buffer)
6195 (gnus-group-jump-to-group current-group)
6198 (if (eq gnus-keep-same-level 'best)
6199 (gnus-summary-best-group gnus-newsgroup-name)
6200 (gnus-summary-search-group backward gnus-keep-same-level))))
6201 (if (not target-group)
6202 ;; There are no further groups, so we return to the group
6205 (gnus-message 5 "Returning to the group buffer")
6207 (when (gnus-buffer-live-p current-buffer)
6208 (set-buffer current-buffer)
6209 (gnus-summary-exit))
6210 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
6211 ;; We try to enter the target group.
6212 (gnus-group-jump-to-group target-group)
6213 (let ((unreads (gnus-group-group-unread)))
6214 (if (and (or (eq t unreads)
6215 (and unreads (not (zerop unreads))))
6216 (gnus-summary-read-group
6217 target-group nil no-article
6218 (and (buffer-name current-buffer) current-buffer)
6221 (setq current-group target-group
6222 target-group nil)))))))
6224 (defun gnus-summary-prev-group (&optional no-article)
6225 "Exit current newsgroup and then select previous unread newsgroup.
6226 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
6228 (gnus-summary-next-group no-article nil t))
6230 ;; Walking around summary lines.
6232 (defun gnus-summary-first-subject (&optional unread undownloaded)
6233 "Go to the first unread subject.
6234 If UNREAD is non-nil, go to the first unread article.
6235 Returns the article selected or nil if there are no unread articles."
6240 ((null gnus-newsgroup-data)
6241 (gnus-message 3 "No articles in the group")
6243 ;; Pick the first article.
6245 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
6246 (gnus-data-number (car gnus-newsgroup-data)))
6247 ;; No unread articles.
6248 ((null gnus-newsgroup-unreads)
6249 (gnus-message 3 "No more unread articles")
6251 ;; Find the first unread article.
6253 (let ((data gnus-newsgroup-data))
6255 (and (not (and undownloaded
6256 (eq gnus-undownloaded-mark
6257 (gnus-data-mark (car data)))))
6258 (not (gnus-data-unread-p (car data)))))
6259 (setq data (cdr data)))
6261 (goto-char (gnus-data-pos (car data)))
6262 (gnus-data-number (car data))))))
6263 (gnus-summary-position-point)))
6265 (defun gnus-summary-next-subject (n &optional unread dont-display)
6266 "Go to next N'th summary line.
6267 If N is negative, go to the previous N'th subject line.
6268 If UNREAD is non-nil, only unread articles are selected.
6269 The difference between N and the actual number of steps taken is
6272 (let ((backward (< n 0))
6276 (gnus-summary-find-prev unread)
6277 (gnus-summary-find-next unread)))
6278 (unless (zerop (setq n (1- n)))
6279 (gnus-summary-show-thread)))
6281 (gnus-message 7 "No more%s articles"
6282 (if unread " unread" "")))
6283 (unless dont-display
6284 (gnus-summary-recenter)
6285 (gnus-summary-position-point))
6288 (defun gnus-summary-next-unread-subject (n)
6289 "Go to next N'th unread summary line."
6291 (gnus-summary-next-subject n t))
6293 (defun gnus-summary-prev-subject (n &optional unread)
6294 "Go to previous N'th summary line.
6295 If optional argument UNREAD is non-nil, only unread article is selected."
6297 (gnus-summary-next-subject (- n) unread))
6299 (defun gnus-summary-prev-unread-subject (n)
6300 "Go to previous N'th unread summary line."
6302 (gnus-summary-next-subject (- n) t))
6304 (defun gnus-summary-goto-subject (article &optional force silent)
6305 "Go the subject line of ARTICLE.
6306 If FORCE, also allow jumping to articles not currently shown."
6307 (interactive "nArticle number: ")
6309 (data (gnus-data-find article)))
6310 ;; We read in the article if we have to.
6313 (gnus-summary-insert-subject
6315 (if (or (numberp force) (vectorp force)) force)
6317 (setq data (gnus-data-find article)))
6322 (gnus-message 3 "Can't find article %d" article))
6324 (let ((pt (gnus-data-pos data)))
6326 (gnus-summary-set-article-display-arrow pt))
6327 (gnus-summary-position-point)
6330 ;; Walking around summary lines with displaying articles.
6332 (defun gnus-summary-expand-window (&optional arg)
6333 "Make the summary buffer take up the entire Emacs frame.
6334 Given a prefix, will force an `article' buffer configuration."
6337 (gnus-configure-windows 'article 'force)
6338 (gnus-configure-windows 'summary 'force)))
6340 (defun gnus-summary-display-article (article &optional all-header)
6341 "Display ARTICLE in article buffer."
6342 (when (gnus-buffer-live-p gnus-article-buffer)
6343 (with-current-buffer gnus-article-buffer
6344 (mm-enable-multibyte-mule4)))
6345 (gnus-set-global-variables)
6346 (when (gnus-buffer-live-p gnus-article-buffer)
6347 (with-current-buffer gnus-article-buffer
6348 (setq gnus-article-charset gnus-newsgroup-charset)
6349 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
6350 (mm-enable-multibyte-mule4)))
6354 (if gnus-summary-display-article-function
6355 (funcall gnus-summary-display-article-function article all-header)
6356 (gnus-article-prepare article all-header))
6357 (gnus-run-hooks 'gnus-select-article-hook)
6358 (when (and gnus-current-article
6359 (not (zerop gnus-current-article)))
6360 (gnus-summary-goto-subject gnus-current-article))
6361 (gnus-summary-recenter)
6362 (when (and gnus-use-trees gnus-show-threads)
6363 (gnus-possibly-generate-tree article)
6364 (gnus-highlight-selected-tree article))
6365 ;; Successfully display article.
6366 (gnus-article-set-window-start
6367 (cdr (assq article gnus-newsgroup-bookmarks))))))
6369 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
6370 "Select the current article.
6371 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
6372 non-nil, the article will be re-fetched even if it already present in
6373 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
6375 ;; Make sure we are in the summary buffer to work around bbdb bug.
6376 (unless (eq major-mode 'gnus-summary-mode)
6377 (set-buffer gnus-summary-buffer))
6378 (let ((article (or article (gnus-summary-article-number)))
6379 (all-headers (not (not all-headers))) ;Must be T or NIL.
6380 gnus-summary-display-article-function)
6382 (gnus-summary-article-pseudo-p article)
6383 (error "This is a pseudo-article"))
6385 (set-buffer gnus-summary-buffer)
6386 (if (or (and gnus-single-article-buffer
6387 (or (null gnus-current-article)
6388 (null gnus-article-current)
6389 (null (get-buffer gnus-article-buffer))
6390 (not (eq article (cdr gnus-article-current)))
6391 (not (equal (car gnus-article-current)
6392 gnus-newsgroup-name))))
6393 (and (not gnus-single-article-buffer)
6394 (or (null gnus-current-article)
6395 (not (eq gnus-current-article article))))
6397 ;; The requested article is different from the current article.
6399 (gnus-summary-display-article article all-headers)
6400 (when (gnus-buffer-live-p gnus-article-buffer)
6401 (with-current-buffer gnus-article-buffer
6402 (if (not gnus-article-decoded-p) ;; a local variable
6403 (mm-disable-multibyte-mule4))))
6404 (when (or all-headers gnus-show-all-headers)
6405 (gnus-article-show-all-headers))
6406 (gnus-article-set-window-start
6407 (cdr (assq article gnus-newsgroup-bookmarks)))
6409 (when (or all-headers gnus-show-all-headers)
6410 (gnus-article-show-all-headers))
6413 (defun gnus-summary-force-verify-and-decrypt ()
6415 (let ((mm-verify-option 'known)
6416 (mm-decrypt-option 'known))
6417 (gnus-summary-select-article nil 'force)))
6419 (defun gnus-summary-set-current-mark (&optional current-mark)
6420 "Obsolete function."
6423 (defun gnus-summary-next-article (&optional unread subject backward push)
6424 "Select the next article.
6425 If UNREAD, only unread articles are selected.
6426 If SUBJECT, only articles with SUBJECT are selected.
6427 If BACKWARD, the previous article is selected instead of the next."
6430 ;; Is there such an article?
6431 ((and (gnus-summary-search-forward unread subject backward)
6432 (or (gnus-summary-display-article (gnus-summary-article-number))
6433 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
6434 (gnus-summary-position-point))
6435 ;; If not, we try the first unread, if that is wanted.
6437 gnus-auto-select-same
6438 (gnus-summary-first-unread-article))
6439 (gnus-summary-position-point)
6440 (gnus-message 6 "Wrapped"))
6441 ;; Try to get next/previous article not displayed in this group.
6442 ((and gnus-auto-extend-newsgroup
6443 (not unread) (not subject))
6444 (gnus-summary-goto-article
6445 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
6446 nil (count-lines (point-min) (point))))
6447 ;; Go to next/previous group.
6449 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
6450 (gnus-summary-jump-to-group gnus-newsgroup-name))
6451 (let ((cmd last-command-char)
6454 (set-buffer gnus-group-buffer)
6457 (if (eq gnus-keep-same-level 'best)
6458 (gnus-summary-best-group gnus-newsgroup-name)
6459 (gnus-summary-search-group backward gnus-keep-same-level))))
6460 ;; For some reason, the group window gets selected. We change
6462 (select-window (get-buffer-window (current-buffer)))
6463 ;; Select next unread newsgroup automagically.
6465 ((or (not gnus-auto-select-next)
6467 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
6468 ((or (eq gnus-auto-select-next 'quietly)
6469 (and (eq gnus-auto-select-next 'slightly-quietly)
6471 (and (eq gnus-auto-select-next 'almost-quietly)
6472 (gnus-summary-last-article-p)))
6474 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
6476 (gnus-message 7 "No more%s articles (%s)..."
6477 (if unread " unread" "")
6478 (if group (concat "selecting " group)
6480 (gnus-summary-next-group nil group backward)))
6482 (when (gnus-key-press-event-p last-input-event)
6483 (gnus-summary-walk-group-buffer
6484 gnus-newsgroup-name cmd unread backward point))))))))
6486 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
6487 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
6488 (?\C-p (gnus-group-prev-unread-group 1))))
6489 (cursor-in-echo-area t)
6490 keve key group ended)
6492 (set-buffer gnus-group-buffer)
6495 (if (eq gnus-keep-same-level 'best)
6496 (gnus-summary-best-group gnus-newsgroup-name)
6497 (gnus-summary-search-group backward gnus-keep-same-level))))
6500 5 "No more%s articles%s" (if unread " unread" "")
6502 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
6503 (format " (Type %s for %s [%s])"
6504 (single-key-description cmd) group
6505 (car (gnus-gethash group gnus-newsrc-hashtb)))
6506 (format " (Type %s to exit %s)"
6507 (single-key-description cmd)
6508 gnus-newsgroup-name)))
6509 ;; Confirm auto selection.
6510 (setq key (car (setq keve (gnus-read-event-char))))
6513 ((assq key keystrokes)
6514 (let ((obuf (current-buffer)))
6515 (switch-to-buffer gnus-group-buffer)
6517 (gnus-group-jump-to-group group))
6518 (eval (cadr (assq key keystrokes)))
6519 (setq group (gnus-group-group-name))
6520 (switch-to-buffer obuf))
6524 (gnus-ephemeral-group-p gnus-newsgroup-name))
6526 (gnus-summary-next-group nil group backward)))
6528 (push (cdr keve) unread-command-events))))))
6530 (defun gnus-summary-next-unread-article ()
6531 "Select unread article after current one."
6533 (gnus-summary-next-article
6534 (or (not (eq gnus-summary-goto-unread 'never))
6535 (gnus-summary-last-article-p (gnus-summary-article-number)))
6536 (and gnus-auto-select-same
6537 (gnus-summary-article-subject))))
6539 (defun gnus-summary-prev-article (&optional unread subject)
6540 "Select the article after the current one.
6541 If UNREAD is non-nil, only unread articles are selected."
6543 (gnus-summary-next-article unread subject t))
6545 (defun gnus-summary-prev-unread-article ()
6546 "Select unread article before current one."
6548 (gnus-summary-prev-article
6549 (or (not (eq gnus-summary-goto-unread 'never))
6550 (gnus-summary-first-article-p (gnus-summary-article-number)))
6551 (and gnus-auto-select-same
6552 (gnus-summary-article-subject))))
6554 (defun gnus-summary-next-page (&optional lines circular)
6555 "Show next page of the selected article.
6556 If at the end of the current article, select the next article.
6557 LINES says how many lines should be scrolled up.
6559 If CIRCULAR is non-nil, go to the start of the article instead of
6560 selecting the next article when reaching the end of the current
6563 (setq gnus-summary-buffer (current-buffer))
6564 (gnus-set-global-variables)
6565 (let ((article (gnus-summary-article-number))
6566 (article-window (get-buffer-window gnus-article-buffer t))
6568 ;; If the buffer is empty, we have no article.
6570 (error "No article to select"))
6571 (gnus-configure-windows 'article)
6572 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
6573 (if (and (eq gnus-summary-goto-unread 'never)
6574 (not (gnus-summary-last-article-p article)))
6575 (gnus-summary-next-article)
6576 (gnus-summary-next-unread-article))
6577 (if (or (null gnus-current-article)
6578 (null gnus-article-current)
6579 (/= article (cdr gnus-article-current))
6580 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6581 ;; Selected subject is different from current article's.
6582 (gnus-summary-display-article article)
6583 (when article-window
6584 (gnus-eval-in-buffer-window gnus-article-buffer
6585 (setq endp (gnus-article-next-page lines)))
6588 (gnus-summary-beginning-of-article))
6590 (gnus-message 3 "End of message"))
6592 (if (and (eq gnus-summary-goto-unread 'never)
6593 (not (gnus-summary-last-article-p article)))
6594 (gnus-summary-next-article)
6595 (gnus-summary-next-unread-article))))))))
6596 (gnus-summary-recenter)
6597 (gnus-summary-position-point)))
6599 (defun gnus-summary-prev-page (&optional lines move)
6600 "Show previous page of selected article.
6601 Argument LINES specifies lines to be scrolled down.
6602 If MOVE, move to the previous unread article if point is at
6603 the beginning of the buffer."
6605 (let ((article (gnus-summary-article-number))
6606 (article-window (get-buffer-window gnus-article-buffer t))
6608 (gnus-configure-windows 'article)
6609 (if (or (null gnus-current-article)
6610 (null gnus-article-current)
6611 (/= article (cdr gnus-article-current))
6612 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6613 ;; Selected subject is different from current article's.
6614 (gnus-summary-display-article article)
6615 (gnus-summary-recenter)
6616 (when article-window
6617 (gnus-eval-in-buffer-window gnus-article-buffer
6618 (setq endp (gnus-article-prev-page lines)))
6619 (when (and move endp)
6621 (gnus-message 3 "Beginning of message"))
6623 (if (and (eq gnus-summary-goto-unread 'never)
6624 (not (gnus-summary-first-article-p article)))
6625 (gnus-summary-prev-article)
6626 (gnus-summary-prev-unread-article))))))))
6627 (gnus-summary-position-point))
6629 (defun gnus-summary-prev-page-or-article (&optional lines)
6630 "Show previous page of selected article.
6631 Argument LINES specifies lines to be scrolled down.
6632 If at the beginning of the article, go to the next article."
6634 (gnus-summary-prev-page lines t))
6636 (defun gnus-summary-scroll-up (lines)
6637 "Scroll up (or down) one line current article.
6638 Argument LINES specifies lines to be scrolled up (or down if negative)."
6640 (gnus-configure-windows 'article)
6641 (gnus-summary-show-thread)
6642 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
6643 (gnus-eval-in-buffer-window gnus-article-buffer
6645 (when (gnus-article-next-page lines)
6646 (gnus-message 3 "End of message")))
6648 (gnus-article-prev-page (- lines))))))
6649 (gnus-summary-recenter)
6650 (gnus-summary-position-point))
6652 (defun gnus-summary-scroll-down (lines)
6653 "Scroll down (or up) one line current article.
6654 Argument LINES specifies lines to be scrolled down (or up if negative)."
6656 (gnus-summary-scroll-up (- lines)))
6658 (defun gnus-summary-next-same-subject ()
6659 "Select next article which has the same subject as current one."
6661 (gnus-summary-next-article nil (gnus-summary-article-subject)))
6663 (defun gnus-summary-prev-same-subject ()
6664 "Select previous article which has the same subject as current one."
6666 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
6668 (defun gnus-summary-next-unread-same-subject ()
6669 "Select next unread article which has the same subject as current one."
6671 (gnus-summary-next-article t (gnus-summary-article-subject)))
6673 (defun gnus-summary-prev-unread-same-subject ()
6674 "Select previous unread article which has the same subject as current one."
6676 (gnus-summary-prev-article t (gnus-summary-article-subject)))
6678 (defun gnus-summary-first-unread-article ()
6679 "Select the first unread article.
6680 Return nil if there are no unread articles."
6683 (when (gnus-summary-first-subject t)
6684 (gnus-summary-show-thread)
6685 (gnus-summary-first-subject t)
6686 (gnus-summary-display-article (gnus-summary-article-number)))
6687 (gnus-summary-position-point)))
6689 (defun gnus-summary-first-unread-subject ()
6690 "Place the point on the subject line of the first unread article.
6691 Return nil if there are no unread articles."
6694 (when (gnus-summary-first-subject t)
6695 (gnus-summary-show-thread)
6696 (gnus-summary-first-subject t))
6697 (gnus-summary-position-point)))
6699 (defun gnus-summary-first-article ()
6700 "Select the first article.
6701 Return nil if there are no articles."
6704 (when (gnus-summary-first-subject)
6705 (gnus-summary-show-thread)
6706 (gnus-summary-first-subject)
6707 (gnus-summary-display-article (gnus-summary-article-number)))
6708 (gnus-summary-position-point)))
6710 (defun gnus-summary-best-unread-article ()
6711 "Select the unread article with the highest score."
6713 (let ((best -1000000)
6714 (data gnus-newsgroup-data)
6717 (and (gnus-data-unread-p (car data))
6719 (gnus-summary-article-score (gnus-data-number (car data))))
6722 article (gnus-data-number (car data))))
6723 (setq data (cdr data)))
6726 (gnus-summary-goto-article article)
6727 (error "No unread articles"))
6728 (gnus-summary-position-point))))
6730 (defun gnus-summary-last-subject ()
6731 "Go to the last displayed subject line in the group."
6732 (let ((article (gnus-data-number (car (gnus-data-list t)))))
6734 (gnus-summary-goto-subject article))))
6736 (defun gnus-summary-goto-article (article &optional all-headers force)
6737 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
6738 If ALL-HEADERS is non-nil, no header lines are hidden.
6739 If FORCE, go to the article even if it isn't displayed. If FORCE
6740 is a number, it is the line the article is to be displayed on."
6744 "Article number or Message-ID: "
6745 (mapcar (lambda (number) (list (int-to-string number)))
6746 gnus-newsgroup-limit))
6750 (if (and (stringp article)
6751 (string-match "@" article))
6752 (gnus-summary-refer-article article)
6753 (when (stringp article)
6754 (setq article (string-to-number article)))
6755 (if (gnus-summary-goto-subject article force)
6756 (gnus-summary-display-article article all-headers)
6757 (gnus-message 4 "Couldn't go to article %s" article) nil))
6758 (gnus-summary-position-point)))
6760 (defun gnus-summary-goto-last-article ()
6761 "Go to the previously read article."
6764 (when gnus-last-article
6765 (gnus-summary-goto-article gnus-last-article nil t))
6766 (gnus-summary-position-point)))
6768 (defun gnus-summary-pop-article (number)
6769 "Pop one article off the history and go to the previous.
6770 NUMBER articles will be popped off."
6773 (setq gnus-newsgroup-history
6774 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
6776 (gnus-summary-goto-article (car to) nil t)
6777 (error "Article history empty")))
6778 (gnus-summary-position-point))
6780 ;; Summary commands and functions for limiting the summary buffer.
6782 (defun gnus-summary-limit-to-articles (n)
6783 "Limit the summary buffer to the next N articles.
6784 If not given a prefix, use the process marked articles instead."
6787 (let ((articles (gnus-summary-work-articles n)))
6788 (setq gnus-newsgroup-processable nil)
6789 (gnus-summary-limit articles))
6790 (gnus-summary-position-point)))
6792 (defun gnus-summary-pop-limit (&optional total)
6793 "Restore the previous limit.
6794 If given a prefix, remove all limits."
6797 (setq gnus-newsgroup-limits
6798 (list (mapcar (lambda (h) (mail-header-number h))
6799 gnus-newsgroup-headers))))
6800 (unless gnus-newsgroup-limits
6801 (error "No limit to pop"))
6803 (gnus-summary-limit nil 'pop)
6804 (gnus-summary-position-point)))
6806 (defun gnus-summary-limit-to-subject (subject &optional header)
6807 "Limit the summary buffer to articles that have subjects that match a regexp."
6808 (interactive "sLimit to subject (regexp): ")
6810 (setq header "subject"))
6811 (when (not (equal "" subject))
6813 (let ((articles (gnus-summary-find-matching
6814 (or header "subject") subject 'all)))
6816 (error "Found no matches for \"%s\"" subject))
6817 (gnus-summary-limit articles))
6818 (gnus-summary-position-point))))
6820 (defun gnus-summary-limit-to-author (from)
6821 "Limit the summary buffer to articles that have authors that match a regexp."
6822 (interactive "sLimit to author (regexp): ")
6823 (gnus-summary-limit-to-subject from "from"))
6825 (defun gnus-summary-limit-to-age (age &optional younger-p)
6826 "Limit the summary buffer to articles that are older than (or equal) AGE days.
6827 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
6828 articles that are younger than AGE days."
6830 (let ((younger current-prefix-arg)
6833 (while (not days-got)
6834 (setq days (if younger
6835 (read-string "Limit to articles within (in days): ")
6836 (read-string "Limit to articles older than (in days): ")))
6837 (when (> (length days) 0)
6838 (setq days (read days)))
6841 (message "Please enter a number.")
6843 (list days younger)))
6845 (let ((data gnus-newsgroup-data)
6846 (cutoff (days-to-time age))
6847 articles d date is-younger)
6848 (while (setq d (pop data))
6849 (when (and (vectorp (gnus-data-header d))
6850 (setq date (mail-header-date (gnus-data-header d))))
6851 (setq is-younger (time-less-p
6852 (time-since (condition-case ()
6859 (push (gnus-data-number d) articles))))
6860 (gnus-summary-limit (nreverse articles)))
6861 (gnus-summary-position-point)))
6863 (defun gnus-summary-limit-to-extra (header regexp)
6864 "Limit the summary buffer to articles that match an 'extra' header."
6868 (gnus-completing-read
6869 (symbol-name (car gnus-extra-headers))
6870 "Limit extra header:"
6872 (cons (symbol-name x) x))
6877 (read-string (format "Limit to header %s (regexp): " header)))))
6878 (when (not (equal "" regexp))
6880 (let ((articles (gnus-summary-find-matching
6881 (cons 'extra header) regexp 'all)))
6883 (error "Found no matches for \"%s\"" regexp))
6884 (gnus-summary-limit articles))
6885 (gnus-summary-position-point))))
6887 (defun gnus-summary-limit-to-display-predicate ()
6888 "Limit the summary buffer to the predicated in the `display' group parameter."
6890 (unless gnus-newsgroup-display
6891 (error "There is no `diplay' group parameter"))
6893 (dolist (number gnus-newsgroup-articles)
6894 (when (funcall gnus-newsgroup-display)
6895 (push number articles)))
6896 (gnus-summary-limit articles))
6897 (gnus-summary-position-point))
6899 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6901 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6903 (defun gnus-summary-limit-to-unread (&optional all)
6904 "Limit the summary buffer to articles that are not marked as read.
6905 If ALL is non-nil, limit strictly to unread articles."
6908 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
6909 (gnus-summary-limit-to-marks
6910 ;; Concat all the marks that say that an article is read and have
6912 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
6913 gnus-killed-mark gnus-kill-file-mark
6914 gnus-low-score-mark gnus-expirable-mark
6915 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
6916 gnus-duplicate-mark gnus-souped-mark)
6919 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
6920 (make-obsolete 'gnus-summary-delete-marked-with
6921 'gnus-summary-limit-exlude-marks)
6923 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
6924 "Exclude articles that are marked with MARKS (e.g. \"DK\").
6925 If REVERSE, limit the summary buffer to articles that are marked
6926 with MARKS. MARKS can either be a string of marks or a list of marks.
6927 Returns how many articles were removed."
6928 (interactive "sMarks: ")
6929 (gnus-summary-limit-to-marks marks t))
6931 (defun gnus-summary-limit-to-marks (marks &optional reverse)
6932 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
6933 If REVERSE (the prefix), limit the summary buffer to articles that are
6934 not marked with MARKS. MARKS can either be a string of marks or a
6936 Returns how many articles were removed."
6937 (interactive "sMarks: \nP")
6939 (let ((data gnus-newsgroup-data)
6940 (marks (if (listp marks) marks
6941 (append marks nil))) ; Transform to list.
6944 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
6945 (memq (gnus-data-mark (car data)) marks))
6946 (push (gnus-data-number (car data)) articles))
6947 (setq data (cdr data)))
6948 (gnus-summary-limit articles))
6949 (gnus-summary-position-point)))
6951 (defun gnus-summary-limit-to-score (&optional score)
6952 "Limit to articles with score at or above SCORE."
6954 (setq score (if score
6955 (prefix-numeric-value score)
6956 (or gnus-summary-default-score 0)))
6957 (let ((data gnus-newsgroup-data)
6960 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
6962 (push (gnus-data-number (car data)) articles))
6963 (setq data (cdr data)))
6965 (gnus-summary-limit articles)
6966 (gnus-summary-position-point))))
6968 (defun gnus-summary-limit-include-thread (id)
6969 "Display all the hidden articles that is in the thread with ID in it.
6970 When called interactively, ID is the Message-ID of the current
6972 (interactive (list (mail-header-id (gnus-summary-article-header))))
6973 (let ((articles (gnus-articles-in-thread
6974 (gnus-id-to-thread (gnus-root-id id)))))
6976 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
6977 (gnus-summary-limit-include-matching-articles
6979 (regexp-quote (gnus-simplify-subject-re
6980 (mail-header-subject (gnus-id-to-header id)))))
6981 (gnus-summary-position-point))))
6983 (defun gnus-summary-limit-include-matching-articles (header regexp)
6984 "Display all the hidden articles that have HEADERs that match REGEXP."
6985 (interactive (list (read-string "Match on header: ")
6986 (read-string "Regexp: ")))
6987 (let ((articles (gnus-find-matching-articles header regexp)))
6989 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
6990 (gnus-summary-position-point))))
6992 (defun gnus-summary-limit-include-dormant ()
6993 "Display all the hidden articles that are marked as dormant.
6994 Note that this command only works on a subset of the articles currently
6995 fetched for this group."
6997 (unless gnus-newsgroup-dormant
6998 (error "There are no dormant articles in this group"))
7000 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
7001 (gnus-summary-position-point)))
7003 (defun gnus-summary-limit-exclude-dormant ()
7004 "Hide all dormant articles."
7007 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
7008 (gnus-summary-position-point)))
7010 (defun gnus-summary-limit-exclude-childless-dormant ()
7011 "Hide all dormant articles that have no children."
7013 (let ((data (gnus-data-list t))
7014 articles d children)
7015 ;; Find all articles that are either not dormant or have
7017 (while (setq d (pop data))
7018 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
7020 (gnus-article-children (gnus-data-number d)))
7023 (when (memq (car children) articles)
7028 (push (gnus-data-number d) articles)))
7031 (gnus-summary-limit articles)
7032 (gnus-summary-position-point))))
7034 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
7035 "Mark all unread excluded articles as read.
7036 If ALL, mark even excluded ticked and dormants as read."
7038 (let ((articles (gnus-sorted-complement
7040 (mapcar (lambda (h) (mail-header-number h))
7041 gnus-newsgroup-headers)
7043 (sort gnus-newsgroup-limit '<)))
7045 (setq gnus-newsgroup-unreads
7046 (gnus-intersection gnus-newsgroup-unreads gnus-newsgroup-limit))
7048 (setq gnus-newsgroup-dormant nil
7049 gnus-newsgroup-marked nil
7050 gnus-newsgroup-reads
7052 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
7053 gnus-newsgroup-reads))
7054 (while (setq article (pop articles))
7055 (unless (or (memq article gnus-newsgroup-dormant)
7056 (memq article gnus-newsgroup-marked))
7057 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
7059 (defun gnus-summary-limit (articles &optional pop)
7061 ;; We pop the previous limit off the stack and use that.
7062 (setq articles (car gnus-newsgroup-limits)
7063 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
7064 ;; We use the new limit, so we push the old limit on the stack.
7065 (push gnus-newsgroup-limit gnus-newsgroup-limits))
7067 (setq gnus-newsgroup-limit articles)
7068 (let ((total (length gnus-newsgroup-data))
7069 (data (gnus-data-find-list (gnus-summary-article-number)))
7070 (gnus-summary-mark-below nil) ; Inhibit this.
7072 ;; This will do all the work of generating the new summary buffer
7073 ;; according to the new limit.
7074 (gnus-summary-prepare)
7075 ;; Hide any threads, possibly.
7076 (and gnus-show-threads
7077 gnus-thread-hide-subtree
7078 (gnus-summary-hide-all-threads))
7079 ;; Try to return to the article you were at, or one in the
7082 ;; We try to find some article after the current one.
7084 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
7087 (setq data (cdr data))))
7089 ;; If there is no data, that means that we were after the last
7090 ;; article. The same goes when we can't find any articles
7091 ;; after the current one.
7092 (goto-char (point-max))
7093 (gnus-summary-find-prev))
7094 (gnus-set-mode-line 'summary)
7095 ;; We return how many articles were removed from the summary
7096 ;; buffer as a result of the new limit.
7097 (- total (length gnus-newsgroup-data))))
7099 (defsubst gnus-invisible-cut-children (threads)
7102 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
7107 (defsubst gnus-cut-thread (thread)
7108 "Go forwards in the thread until we find an article that we want to display."
7109 (when (or (eq gnus-fetch-old-headers 'some)
7110 (eq gnus-fetch-old-headers 'invisible)
7111 (numberp gnus-fetch-old-headers)
7112 (eq gnus-build-sparse-threads 'some)
7113 (eq gnus-build-sparse-threads 'more))
7114 ;; Deal with old-fetched headers and sparse threads.
7118 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
7119 (gnus-summary-article-ancient-p
7120 (mail-header-number (car thread))))
7121 (if (or (<= (length (cdr thread)) 1)
7122 (eq gnus-fetch-old-headers 'invisible))
7123 (setq gnus-newsgroup-limit
7124 (delq (mail-header-number (car thread))
7125 gnus-newsgroup-limit)
7126 thread (cadr thread))
7127 (when (gnus-invisible-cut-children (cdr thread))
7128 (let ((th (cdr thread)))
7130 (if (memq (mail-header-number (caar th))
7131 gnus-newsgroup-limit)
7132 (setq thread (car th)
7134 (setq th (cdr th))))))))))
7137 (defun gnus-cut-threads (threads)
7138 "Cut off all uninteresting articles from the beginning of threads."
7139 (when (or (eq gnus-fetch-old-headers 'some)
7140 (eq gnus-fetch-old-headers 'invisible)
7141 (numberp gnus-fetch-old-headers)
7142 (eq gnus-build-sparse-threads 'some)
7143 (eq gnus-build-sparse-threads 'more))
7146 (setcar th (gnus-cut-thread (car th)))
7147 (setq th (cdr th)))))
7148 ;; Remove nixed out threads.
7151 (defun gnus-summary-initial-limit (&optional show-if-empty)
7152 "Figure out what the initial limit is supposed to be on group entry.
7153 This entails weeding out unwanted dormants, low-scored articles,
7154 fetch-old-headers verbiage, and so on."
7155 ;; Most groups have nothing to remove.
7156 (if (or gnus-inhibit-limiting
7157 (and (null gnus-newsgroup-dormant)
7158 (eq gnus-newsgroup-display 'gnus-not-ignore)
7159 (not (eq gnus-fetch-old-headers 'some))
7160 (not (numberp gnus-fetch-old-headers))
7161 (not (eq gnus-fetch-old-headers 'invisible))
7162 (null gnus-summary-expunge-below)
7163 (not (eq gnus-build-sparse-threads 'some))
7164 (not (eq gnus-build-sparse-threads 'more))
7165 (null gnus-thread-expunge-below)
7166 (not gnus-use-nocem)))
7168 (push gnus-newsgroup-limit gnus-newsgroup-limits)
7169 (setq gnus-newsgroup-limit nil)
7172 (unless (car (symbol-value node))
7173 ;; These threads have no parents -- they are roots.
7174 (let ((nodes (cdr (symbol-value node)))
7177 (if (and gnus-thread-expunge-below
7178 (< (gnus-thread-total-score (car nodes))
7179 gnus-thread-expunge-below))
7180 (gnus-expunge-thread (pop nodes))
7181 (setq thread (pop nodes))
7182 (gnus-summary-limit-children thread))))))
7183 gnus-newsgroup-dependencies)
7184 ;; If this limitation resulted in an empty group, we might
7185 ;; pop the previous limit and use it instead.
7186 (when (and (not gnus-newsgroup-limit)
7188 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
7189 gnus-newsgroup-limit))
7191 (defun gnus-summary-limit-children (thread)
7192 "Return 1 if this subthread is visible and 0 if it is not."
7193 ;; First we get the number of visible children to this thread. This
7194 ;; is done by recursing down the thread using this function, so this
7195 ;; will really go down to a leaf article first, before slowly
7196 ;; working its way up towards the root.
7200 (apply '+ (mapcar 'gnus-summary-limit-children
7203 (number (mail-header-number (car thread)))
7206 (not (memq number gnus-newsgroup-marked))
7208 ;; If this article is dormant and has absolutely no visible
7209 ;; children, then this article isn't visible.
7210 (and (memq number gnus-newsgroup-dormant)
7212 ;; If this is "fetch-old-headered" and there is no
7213 ;; visible children, then we don't want this article.
7214 (and (or (eq gnus-fetch-old-headers 'some)
7215 (numberp gnus-fetch-old-headers))
7216 (gnus-summary-article-ancient-p number)
7218 ;; If this is "fetch-old-headered" and `invisible', then
7219 ;; we don't want this article.
7220 (and (eq gnus-fetch-old-headers 'invisible)
7221 (gnus-summary-article-ancient-p number))
7222 ;; If this is a sparsely inserted article with no children,
7223 ;; we don't want it.
7224 (and (eq gnus-build-sparse-threads 'some)
7225 (gnus-summary-article-sparse-p number)
7227 ;; If we use expunging, and this article is really
7228 ;; low-scored, then we don't want this article.
7229 (when (and gnus-summary-expunge-below
7231 (or (cdr (assq number gnus-newsgroup-scored))
7232 gnus-summary-default-score))
7233 gnus-summary-expunge-below))
7234 ;; We increase the expunge-tally here, but that has
7235 ;; nothing to do with the limits, really.
7236 (incf gnus-newsgroup-expunged-tally)
7237 ;; We also mark as read here, if that's wanted.
7238 (when (and gnus-summary-mark-below
7239 (< score gnus-summary-mark-below))
7240 (setq gnus-newsgroup-unreads
7241 (delq number gnus-newsgroup-unreads))
7242 (if gnus-newsgroup-auto-expire
7243 (push number gnus-newsgroup-expirable)
7244 (push (cons number gnus-low-score-mark)
7245 gnus-newsgroup-reads)))
7247 ;; Do the `display' group parameter.
7248 (and gnus-newsgroup-display
7249 (not (funcall gnus-newsgroup-display)))
7250 ;; Check NoCeM things.
7251 (if (and gnus-use-nocem
7252 (gnus-nocem-unwanted-article-p
7253 (mail-header-id (car thread))))
7255 (setq gnus-newsgroup-unreads
7256 (delq number gnus-newsgroup-unreads))
7258 ;; Nope, invisible article.
7260 ;; Ok, this article is to be visible, so we add it to the limit
7262 (push number gnus-newsgroup-limit)
7265 (defun gnus-expunge-thread (thread)
7266 "Mark all articles in THREAD as read."
7267 (let* ((number (mail-header-number (car thread))))
7268 (incf gnus-newsgroup-expunged-tally)
7269 ;; We also mark as read here, if that's wanted.
7270 (setq gnus-newsgroup-unreads
7271 (delq number gnus-newsgroup-unreads))
7272 (if gnus-newsgroup-auto-expire
7273 (push number gnus-newsgroup-expirable)
7274 (push (cons number gnus-low-score-mark)
7275 gnus-newsgroup-reads)))
7276 ;; Go recursively through all subthreads.
7277 (mapcar 'gnus-expunge-thread (cdr thread)))
7279 ;; Summary article oriented commands
7281 (defun gnus-summary-refer-parent-article (n)
7282 "Refer parent article N times.
7283 If N is negative, go to ancestor -N instead.
7284 The difference between N and the number of articles fetched is returned."
7288 (when (not (natnump n))
7293 (setq header (gnus-summary-article-header))
7294 (if (and (eq (mail-header-number header)
7295 (cdr gnus-article-current))
7296 (equal gnus-newsgroup-name
7297 (car gnus-article-current)))
7298 ;; If we try to find the parent of the currently
7299 ;; displayed article, then we take a look at the actual
7300 ;; References header, since this is slightly more
7301 ;; reliable than the References field we got from the
7304 (set-buffer gnus-original-article-buffer)
7305 (nnheader-narrow-to-headers)
7306 (unless (setq ref (message-fetch-field "references"))
7307 (setq ref (message-fetch-field "in-reply-to")))
7310 ;; It's not the current article, so we take a bet on
7311 ;; the value we got from the server.
7312 (mail-header-references header)))
7314 (not (equal ref "")))
7315 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
7316 (gnus-message 1 "Couldn't find parent"))
7317 (gnus-message 1 "No references in article %d"
7318 (gnus-summary-article-number))
7321 (gnus-summary-position-point)
7324 (defun gnus-summary-refer-references ()
7325 "Fetch all articles mentioned in the References header.
7326 Return the number of articles fetched."
7328 (let ((ref (mail-header-references (gnus-summary-article-header)))
7329 (current (gnus-summary-article-number))
7333 (error "No References in the current article")
7334 ;; For each Message-ID in the References header...
7335 (while (string-match "<[^>]*>" ref)
7337 ;; ... fetch that article.
7338 (gnus-summary-refer-article
7339 (prog1 (match-string 0 ref)
7340 (setq ref (substring ref (match-end 0))))))
7341 (gnus-summary-goto-subject current)
7342 (gnus-summary-position-point)
7345 (defun gnus-summary-refer-thread (&optional limit)
7346 "Fetch all articles in the current thread.
7347 If LIMIT (the numerical prefix), fetch that many old headers instead
7348 of what's specified by the `gnus-refer-thread-limit' variable."
7350 (let ((id (mail-header-id (gnus-summary-article-header)))
7351 (limit (if limit (prefix-numeric-value limit)
7352 gnus-refer-thread-limit)))
7353 ;; We want to fetch LIMIT *old* headers, but we also have to
7354 ;; re-fetch all the headers in the current buffer, because many of
7355 ;; them may be undisplayed. So we adjust LIMIT.
7356 (when (numberp limit)
7357 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
7358 (unless (eq gnus-fetch-old-headers 'invisible)
7359 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
7360 ;; Retrieve the headers and read them in.
7361 (if (eq (gnus-retrieve-headers
7362 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
7364 (gnus-build-all-threads)
7365 (error "Can't fetch thread from backends that don't support NOV"))
7366 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
7367 (gnus-summary-limit-include-thread id)))
7369 (defun gnus-summary-refer-article (message-id)
7370 "Fetch an article specified by MESSAGE-ID."
7371 (interactive "sMessage-ID: ")
7372 (when (and (stringp message-id)
7373 (not (zerop (length message-id))))
7374 ;; Construct the correct Message-ID if necessary.
7375 ;; Suggested by tale@pawl.rpi.edu.
7376 (unless (string-match "^<" message-id)
7377 (setq message-id (concat "<" message-id)))
7378 (unless (string-match ">$" message-id)
7379 (setq message-id (concat message-id ">")))
7380 (let* ((header (gnus-id-to-header message-id))
7382 (gnus-summary-article-sparse-p
7383 (mail-header-number header))
7384 (memq (mail-header-number header)
7385 gnus-newsgroup-limit)))
7388 ;; If the article is present in the buffer we just go to it.
7390 (or (not (gnus-summary-article-sparse-p
7391 (mail-header-number header)))
7394 (gnus-summary-goto-article
7395 (mail-header-number header) nil t)
7397 (gnus-summary-update-article (mail-header-number header)))))
7399 ;; We fetch the article.
7401 (dolist (gnus-override-method (gnus-refer-article-methods))
7402 (gnus-check-server gnus-override-method)
7403 ;; Fetch the header, and display the article.
7404 (when (setq number (gnus-summary-insert-subject message-id))
7405 (gnus-summary-select-article nil nil nil number)
7407 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
7409 (defun gnus-refer-article-methods ()
7410 "Return a list of referrable methods."
7412 ;; No method, so we default to current and native.
7413 ((null gnus-refer-article-method)
7414 (list gnus-current-select-method gnus-select-method))
7416 ((eq 'current gnus-refer-article-method)
7417 (list gnus-current-select-method))
7418 ;; List of select methods.
7419 ((not (and (symbolp (car gnus-refer-article-method))
7420 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
7422 (dolist (method gnus-refer-article-method)
7423 (push (if (eq 'current method)
7424 gnus-current-select-method
7428 ;; One single select method.
7430 (list gnus-refer-article-method))))
7432 (defun gnus-summary-edit-parameters ()
7433 "Edit the group parameters of the current group."
7435 (gnus-group-edit-group gnus-newsgroup-name 'params))
7437 (defun gnus-summary-customize-parameters ()
7438 "Customize the group parameters of the current group."
7440 (gnus-group-customize gnus-newsgroup-name))
7442 (defun gnus-summary-enter-digest-group (&optional force)
7443 "Enter an nndoc group based on the current article.
7444 If FORCE, force a digest interpretation. If not, try
7445 to guess what the document format is."
7447 (let ((conf gnus-current-window-configuration))
7449 (gnus-summary-select-article))
7450 (setq gnus-current-window-configuration conf)
7451 (let* ((name (format "%s-%d"
7452 (gnus-group-prefixed-name
7453 gnus-newsgroup-name (list 'nndoc ""))
7455 (set-buffer gnus-summary-buffer)
7456 gnus-current-article)))
7457 (ogroup gnus-newsgroup-name)
7458 (params (append (gnus-info-params (gnus-get-info ogroup))
7459 (list (cons 'to-group ogroup))
7460 (list (cons 'save-article-group ogroup))))
7461 (case-fold-search t)
7462 (buf (current-buffer))
7465 (set-buffer gnus-original-article-buffer)
7466 ;; Have the digest group inherit the main mail address of
7467 ;; the parent article.
7468 (when (setq to-address (or (message-fetch-field "reply-to")
7469 (message-fetch-field "from")))
7470 (setq params (append
7471 (list (cons 'to-address
7472 (funcall gnus-decode-encoded-word-function
7474 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
7475 (insert-buffer-substring gnus-original-article-buffer)
7476 ;; Remove lines that may lead nndoc to misinterpret the
7479 (goto-char (point-min))
7480 (or (search-forward "\n\n" nil t) (point)))
7481 (goto-char (point-min))
7482 (delete-matching-lines "^Path:\\|^From ")
7485 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
7486 (gnus-newsgroup-ephemeral-ignored-charsets
7487 gnus-newsgroup-ignored-charsets))
7488 (gnus-group-read-ephemeral-group
7489 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
7491 ,(if force 'mbox 'guess))) t))
7492 ;; Make all postings to this group go to the parent group.
7493 (nconc (gnus-info-params (gnus-get-info name))
7495 ;; Couldn't select this doc group.
7496 (switch-to-buffer buf)
7497 (gnus-set-global-variables)
7498 (gnus-configure-windows 'summary)
7499 (gnus-message 3 "Article couldn't be entered?"))
7500 (kill-buffer dig)))))
7502 (defun gnus-summary-read-document (n)
7503 "Open a new group based on the current article(s).
7504 This will allow you to read digests and other similar
7505 documents as newsgroups.
7506 Obeys the standard process/prefix convention."
7508 (let* ((articles (gnus-summary-work-articles n))
7509 (ogroup gnus-newsgroup-name)
7510 (params (append (gnus-info-params (gnus-get-info ogroup))
7511 (list (cons 'to-group ogroup))))
7512 article group egroup groups vgroup)
7513 (while (setq article (pop articles))
7514 (setq group (format "%s-%d" gnus-newsgroup-name article))
7515 (gnus-summary-remove-process-mark article)
7516 (when (gnus-summary-display-article article)
7519 (insert-buffer-substring gnus-original-article-buffer)
7520 ;; Remove some headers that may lead nndoc to make
7522 (message-narrow-to-head)
7523 (goto-char (point-min))
7524 (delete-matching-lines "^\\(Path\\):\\|^From ")
7527 (gnus-group-read-ephemeral-group
7528 group `(nndoc ,group (nndoc-address ,(current-buffer))
7529 (nndoc-article-type guess))
7532 ;; Make all postings to this group go to the parent group.
7533 (nconc (gnus-info-params (gnus-get-info egroup))
7535 (push egroup groups))
7536 ;; Couldn't select this doc group.
7537 (gnus-error 3 "Article couldn't be entered"))))))
7538 ;; Now we have selected all the documents.
7541 (error "None of the articles could be interpreted as documents"))
7542 ((gnus-group-read-ephemeral-group
7543 (setq vgroup (format
7544 "nnvirtual:%s-%s" gnus-newsgroup-name
7545 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
7546 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
7548 (cons (current-buffer) 'summary)))
7550 (error "Couldn't select virtual nndoc group")))))
7552 (defun gnus-summary-isearch-article (&optional regexp-p)
7553 "Do incremental search forward on the current article.
7554 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
7556 (gnus-summary-select-article)
7557 (gnus-configure-windows 'article)
7558 (gnus-eval-in-buffer-window gnus-article-buffer
7561 (isearch-forward regexp-p))))
7563 (defun gnus-summary-search-article-forward (regexp &optional backward)
7564 "Search for an article containing REGEXP forward.
7565 If BACKWARD, search backward instead."
7568 (format "Search article %s (regexp%s): "
7569 (if current-prefix-arg "backward" "forward")
7570 (if gnus-last-search-regexp
7571 (concat ", default " gnus-last-search-regexp)
7573 current-prefix-arg))
7574 (if (string-equal regexp "")
7575 (setq regexp (or gnus-last-search-regexp ""))
7576 (setq gnus-last-search-regexp regexp)
7577 (setq gnus-article-before-search gnus-current-article))
7578 ;; Intentionally set gnus-last-article.
7579 (setq gnus-last-article gnus-article-before-search)
7580 (let ((gnus-last-article gnus-last-article))
7581 (if (gnus-summary-search-article regexp backward)
7582 (gnus-summary-show-thread)
7583 (error "Search failed: \"%s\"" regexp))))
7585 (defun gnus-summary-search-article-backward (regexp)
7586 "Search for an article containing REGEXP backward."
7589 (format "Search article backward (regexp%s): "
7590 (if gnus-last-search-regexp
7591 (concat ", default " gnus-last-search-regexp)
7593 (gnus-summary-search-article-forward regexp 'backward))
7595 (defun gnus-summary-search-article (regexp &optional backward)
7596 "Search for an article containing REGEXP.
7597 Optional argument BACKWARD means do search for backward.
7598 `gnus-select-article-hook' is not called during the search."
7599 ;; We have to require this here to make sure that the following
7600 ;; dynamic binding isn't shadowed by autoloading.
7601 (require 'gnus-async)
7603 (let ((gnus-select-article-hook nil) ;Disable hook.
7604 (gnus-article-prepare-hook nil)
7605 (gnus-mark-article-hook nil) ;Inhibit marking as read.
7606 (gnus-use-article-prefetch nil)
7607 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
7608 (gnus-use-trees nil) ;Inhibit updating tree buffer.
7609 (sum (current-buffer))
7610 (gnus-display-mime-function nil)
7613 (gnus-save-hidden-threads
7614 (gnus-summary-select-article)
7615 (set-buffer gnus-article-buffer)
7616 (goto-char (window-point (get-buffer-window (current-buffer))))
7620 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
7622 (re-search-backward regexp nil t)
7623 (re-search-forward regexp nil t))
7624 ;; We found the regexp.
7629 (get-buffer-window (current-buffer))
7633 (get-buffer-window (current-buffer))
7636 (setq point (point)))
7637 ;; We didn't find it, so we go to the next article.
7640 (while (eq found 'not)
7641 (if (not (if backward (gnus-summary-find-prev)
7642 (gnus-summary-find-next)))
7643 ;; No more articles.
7645 ;; Select the next article and adjust point.
7646 (unless (gnus-summary-article-sparse-p
7647 (gnus-summary-article-number))
7649 (gnus-summary-select-article)
7650 (set-buffer gnus-article-buffer)
7652 (goto-char (if backward (point-max) (point-min))))))))
7653 (gnus-message 7 ""))
7654 ;; Return whether we found the regexp.
7655 (when (eq found 'found)
7657 (gnus-summary-show-thread)
7658 (gnus-summary-goto-subject gnus-current-article)
7659 (gnus-summary-position-point)
7662 (defun gnus-find-matching-articles (header regexp)
7663 "Return a list of all articles that match REGEXP on HEADER.
7664 This search includes all articles in the current group that Gnus has
7665 fetched headers for, whether they are displayed or not."
7666 (let ((articles nil)
7667 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
7668 (case-fold-search t))
7669 (dolist (header gnus-newsgroup-headers)
7670 (when (string-match regexp (funcall func header))
7671 (push (mail-header-number header) articles)))
7672 (nreverse articles)))
7674 (defun gnus-summary-find-matching (header regexp &optional backward unread
7676 "Return a list of all articles that match REGEXP on HEADER.
7677 The search stars on the current article and goes forwards unless
7678 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
7679 If UNREAD is non-nil, only unread articles will
7680 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
7681 in the comparisons."
7682 (let ((case-fold-search (not not-case-fold))
7685 (if (eq (car header) 'extra)
7688 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
7690 (error "%s is an invalid header" header))
7691 (unless (fboundp (intern (concat "mail-header-" header)))
7692 (error "%s is not a valid header" header))
7693 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
7694 (dolist (d (if (eq backward 'all)
7696 (gnus-data-find-list
7697 (gnus-summary-article-number)
7698 (gnus-data-list backward))))
7699 (when (and (or (not unread) ; We want all articles...
7700 (gnus-data-unread-p d)) ; Or just unreads.
7701 (vectorp (gnus-data-header d)) ; It's not a pseudo.
7702 (string-match regexp
7703 (funcall func (gnus-data-header d)))) ; Match.
7704 (push (gnus-data-number d) articles))) ; Success!
7705 (nreverse articles)))
7707 (defun gnus-summary-execute-command (header regexp command &optional backward)
7708 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
7709 If HEADER is an empty string (or nil), the match is done on the entire
7710 article. If BACKWARD (the prefix) is non-nil, search backward instead."
7712 (list (let ((completion-ignore-case t))
7715 (mapcar (lambda (header) (list (format "%s" header)))
7717 '("Number" "Subject" "From" "Lines" "Date"
7718 "Message-ID" "Xref" "References" "Body")
7719 gnus-extra-headers))
7720 nil 'require-match))
7721 (read-string "Regexp: ")
7722 (read-key-sequence "Command: ")
7723 current-prefix-arg))
7724 (when (equal header "Body")
7726 ;; Hidden thread subtrees must be searched as well.
7727 (gnus-summary-show-all-threads)
7728 ;; We don't want to change current point nor window configuration.
7730 (save-window-excursion
7731 (gnus-message 6 "Executing %s..." (key-description command))
7732 ;; We'd like to execute COMMAND interactively so as to give arguments.
7733 (gnus-execute header regexp
7734 `(call-interactively ',(key-binding command))
7736 (gnus-message 6 "Executing %s...done" (key-description command)))))
7738 (defun gnus-summary-beginning-of-article ()
7739 "Scroll the article back to the beginning."
7741 (gnus-summary-select-article)
7742 (gnus-configure-windows 'article)
7743 (gnus-eval-in-buffer-window gnus-article-buffer
7745 (goto-char (point-min))
7746 (when gnus-page-broken
7747 (gnus-narrow-to-page))))
7749 (defun gnus-summary-end-of-article ()
7750 "Scroll to the end of the article."
7752 (gnus-summary-select-article)
7753 (gnus-configure-windows 'article)
7754 (gnus-eval-in-buffer-window gnus-article-buffer
7756 (goto-char (point-max))
7758 (when gnus-page-broken
7759 (gnus-narrow-to-page))))
7761 (defun gnus-summary-print-article (&optional filename n)
7762 "Generate and print a PostScript image of the N next (mail) articles.
7764 If N is negative, print the N previous articles. If N is nil and articles
7765 have been marked with the process mark, print these instead.
7767 If the optional first argument FILENAME is nil, send the image to the
7768 printer. If FILENAME is a string, save the PostScript image in a file with
7769 that name. If FILENAME is a number, prompt the user for the name of the file
7771 (interactive (list (ps-print-preprint current-prefix-arg)))
7772 (dolist (article (gnus-summary-work-articles n))
7773 (gnus-summary-select-article nil nil 'pseudo article)
7774 (gnus-eval-in-buffer-window gnus-article-buffer
7775 (let ((buffer (generate-new-buffer " *print*")))
7778 (copy-to-buffer buffer (point-min) (point-max))
7780 (gnus-article-delete-invisible-text)
7781 (when (gnus-visual-p 'article-highlight 'highlight)
7782 ;; Copy-to-buffer doesn't copy overlay. So redo
7784 (let ((gnus-article-buffer buffer))
7785 (gnus-article-highlight-citation t)
7786 (gnus-article-highlight-signature)))
7787 (let ((ps-left-header
7790 (mail-header-subject gnus-current-headers) ")")
7792 (mail-header-from gnus-current-headers) ")")))
7795 "/pagenumberstring load"
7797 (mail-header-date gnus-current-headers) ")"))))
7798 (gnus-run-hooks 'gnus-ps-print-hook)
7801 (ps-spool-buffer-with-faces)
7802 (ps-spool-buffer)))))
7803 (kill-buffer buffer))))
7804 (gnus-summary-remove-process-mark article))
7805 (ps-despool filename))
7807 (defun gnus-summary-show-article (&optional arg)
7808 "Force re-fetching of the current article.
7809 If ARG (the prefix) is a number, show the article with the charset
7810 defined in `gnus-summary-show-article-charset-alist', or the charset
7812 If ARG (the prefix) is non-nil and not a number, show the raw article
7813 without any article massaging functions being run."
7817 (gnus-summary-show-article t)
7818 (let ((gnus-newsgroup-charset
7819 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
7820 (mm-read-coding-system
7823 (set-buffer gnus-article-buffer)
7824 (let ((coding-systems
7825 (detect-coding-region (point) (point-max))))
7826 (or (car-safe coding-systems)
7827 coding-systems))))))
7828 (gnus-newsgroup-ignored-charsets 'gnus-all))
7829 (gnus-summary-select-article nil 'force)
7830 (let ((deps gnus-newsgroup-dependencies)
7833 (set-buffer gnus-original-article-buffer)
7835 (message-narrow-to-head)
7836 (setq head (buffer-string)))
7838 (insert (format "211 %d Article retrieved.\n"
7839 (cdr gnus-article-current)))
7842 (let ((nntp-server-buffer (current-buffer)))
7843 (setq header (car (gnus-get-newsgroup-headers deps t))))))
7844 (gnus-data-set-header
7845 (gnus-data-find (cdr gnus-article-current))
7847 (gnus-summary-update-article-line
7848 (cdr gnus-article-current) header)
7849 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
7850 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
7852 ;; Select the article the normal way.
7853 (gnus-summary-select-article nil 'force))
7855 ;; We have to require this here to make sure that the following
7856 ;; dynamic binding isn't shadowed by autoloading.
7857 (require 'gnus-async)
7859 ;; Bind the article treatment functions to nil.
7860 (let ((gnus-have-all-headers t)
7861 gnus-article-prepare-hook
7862 gnus-article-decode-hook
7863 gnus-display-mime-function
7865 ;; Destroy any MIME parts.
7866 (when (gnus-buffer-live-p gnus-article-buffer)
7868 (set-buffer gnus-article-buffer)
7869 (mm-destroy-parts gnus-article-mime-handles)
7870 ;; Set it to nil for safety reason.
7871 (setq gnus-article-mime-handle-alist nil)
7872 (setq gnus-article-mime-handles nil)))
7873 (gnus-summary-select-article nil 'force))))
7874 (gnus-summary-goto-subject gnus-current-article)
7875 (gnus-summary-position-point))
7877 (defun gnus-summary-show-raw-article ()
7878 "Show the raw article without any article massaging functions being run."
7880 (gnus-summary-show-article t))
7882 (defun gnus-summary-verbose-headers (&optional arg)
7883 "Toggle permanent full header display.
7884 If ARG is a positive number, turn header display on.
7885 If ARG is a negative number, turn header display off."
7887 (setq gnus-show-all-headers
7888 (cond ((or (not (numberp arg))
7890 (not gnus-show-all-headers))
7893 (gnus-summary-show-article))
7895 (defun gnus-summary-toggle-header (&optional arg)
7896 "Show the headers if they are hidden, or hide them if they are shown.
7897 If ARG is a positive number, show the entire header.
7898 If ARG is a negative number, hide the unwanted header lines."
7901 (set-buffer gnus-article-buffer)
7903 (let* ((buffer-read-only nil)
7904 (inhibit-point-motion-hooks t)
7910 (article-narrow-to-head)
7911 (gnus-article-hidden-text-p 'headers))))
7912 (goto-char (point-min))
7913 (when (search-forward "\n\n" nil t)
7914 (delete-region (point-min) (1- (point))))
7915 (goto-char (point-min))
7917 (set-buffer gnus-original-article-buffer)
7918 (goto-char (point-min))
7919 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
7920 (insert-buffer-substring gnus-original-article-buffer 1 e)
7922 (narrow-to-region (point-min) (point))
7923 (article-decode-encoded-words)
7925 (let ((gnus-treat-hide-headers nil)
7926 (gnus-treat-hide-boring-headers nil))
7927 (setq gnus-article-wash-types
7928 (delq 'headers gnus-article-wash-types))
7929 (gnus-treat-article 'head))
7930 (gnus-treat-article 'head)))
7931 (gnus-set-mode-line 'article)))))
7933 (defun gnus-summary-show-all-headers ()
7934 "Make all header lines visible."
7936 (gnus-summary-toggle-header 1))
7938 (defun gnus-summary-caesar-message (&optional arg)
7939 "Caesar rotate the current article by 13.
7940 The numerical prefix specifies how many places to rotate each letter
7943 (gnus-summary-select-article)
7944 (let ((mail-header-separator ""))
7945 (gnus-eval-in-buffer-window gnus-article-buffer
7948 (let ((start (window-start))
7950 (message-caesar-buffer-body arg)
7951 (set-window-start (get-buffer-window (current-buffer)) start))))))
7953 (defun gnus-summary-stop-page-breaking ()
7954 "Stop page breaking in the current article."
7956 (gnus-summary-select-article)
7957 (gnus-eval-in-buffer-window gnus-article-buffer
7959 (when (gnus-visual-p 'page-marker)
7960 (let ((buffer-read-only nil))
7961 (gnus-remove-text-with-property 'gnus-prev)
7962 (gnus-remove-text-with-property 'gnus-next))
7963 (setq gnus-page-broken nil))))
7965 (defun gnus-summary-move-article (&optional n to-newsgroup
7966 select-method action)
7967 "Move the current article to a different newsgroup.
7968 If N is a positive number, move the N next articles.
7969 If N is a negative number, move the N previous articles.
7970 If N is nil and any articles have been marked with the process mark,
7971 move those articles instead.
7972 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7973 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7974 re-spool using this method.
7976 For this function to work, both the current newsgroup and the
7977 newsgroup that you want to move to have to support the `request-move'
7978 and `request-accept' functions.
7980 ACTION can be either `move' (the default), `crosspost' or `copy'."
7983 (setq action 'move))
7984 ;; Check whether the source group supports the required functions.
7985 (cond ((and (eq action 'move)
7986 (not (gnus-check-backend-function
7987 'request-move-article gnus-newsgroup-name)))
7988 (error "The current group does not support article moving"))
7989 ((and (eq action 'crosspost)
7990 (not (gnus-check-backend-function
7991 'request-replace-article gnus-newsgroup-name)))
7992 (error "The current group does not support article editing")))
7993 (let ((articles (gnus-summary-work-articles n))
7994 (prefix (if (gnus-check-backend-function
7995 'request-move-article gnus-newsgroup-name)
7996 (gnus-group-real-prefix gnus-newsgroup-name)
7998 (names '((move "Move" "Moving")
7999 (copy "Copy" "Copying")
8000 (crosspost "Crosspost" "Crossposting")))
8001 (copy-buf (save-excursion
8002 (nnheader-set-temp-buffer " *copy article*")))
8003 art-group to-method new-xref article to-groups)
8004 (unless (assq action names)
8005 (error "Unknown action %s" action))
8006 ;; Read the newsgroup name.
8007 (when (and (not to-newsgroup)
8008 (not select-method))
8010 (gnus-read-move-group-name
8011 (cadr (assq action names))
8012 (symbol-value (intern (format "gnus-current-%s-group" action)))
8014 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
8015 (setq to-method (or select-method
8016 (gnus-server-to-method
8017 (gnus-group-method to-newsgroup))))
8018 ;; Check the method we are to move this article to...
8019 (unless (gnus-check-backend-function
8020 'request-accept-article (car to-method))
8021 (error "%s does not support article copying" (car to-method)))
8022 (unless (gnus-check-server to-method)
8023 (error "Can't open server %s" (car to-method)))
8024 (gnus-message 6 "%s to %s: %s..."
8025 (caddr (assq action names))
8026 (or (car select-method) to-newsgroup) articles)
8028 (setq article (pop articles))
8032 ;; Move the article.
8034 ;; Remove this article from future suppression.
8035 (gnus-dup-unsuppress-article article)
8036 (gnus-request-move-article
8037 article ; Article to move
8038 gnus-newsgroup-name ; From newsgroup
8039 (nth 1 (gnus-find-method-for-group
8040 gnus-newsgroup-name)) ; Server
8041 (list 'gnus-request-accept-article
8042 to-newsgroup (list 'quote select-method)
8043 (not articles) t) ; Accept form
8044 (not articles))) ; Only save nov last time
8045 ;; Copy the article.
8048 (set-buffer copy-buf)
8049 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
8050 (gnus-request-accept-article
8051 to-newsgroup select-method (not articles) t))))
8052 ;; Crosspost the article.
8053 ((eq action 'crosspost)
8054 (let ((xref (message-tokenize-header
8055 (mail-header-xref (gnus-summary-article-header article))
8057 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
8060 (setq xref (list (system-name))))
8063 (mapconcat 'identity
8064 (delete "Xref:" (delete new-xref xref))
8068 (set-buffer copy-buf)
8069 ;; First put the article in the destination group.
8070 (gnus-request-article-this-buffer article gnus-newsgroup-name)
8071 (when (consp (setq art-group
8072 (gnus-request-accept-article
8073 to-newsgroup select-method (not articles))))
8074 (setq new-xref (concat new-xref " " (car art-group)
8075 ":" (cdr art-group)))
8076 ;; Now we have the new Xrefs header, so we insert
8077 ;; it and replace the new article.
8078 (nnheader-replace-header "Xref" new-xref)
8079 (gnus-request-replace-article
8080 (cdr art-group) to-newsgroup (current-buffer))
8084 (gnus-message 1 "Couldn't %s article %s: %s"
8085 (cadr (assq action names)) article
8086 (nnheader-get-report (car to-method))))
8087 ((eq art-group 'junk)
8088 (when (eq action 'move)
8089 (gnus-summary-mark-article article gnus-canceled-mark)
8090 (gnus-message 4 "Deleted article %s" article)))
8092 (let* ((pto-group (gnus-group-prefixed-name
8093 (car art-group) to-method))
8095 (gnus-gethash pto-group gnus-newsrc-hashtb))
8096 (info (nth 2 entry))
8097 (to-group (gnus-info-group info))
8099 ;; Update the group that has been moved to.
8101 (memq action '(move copy)))
8102 (unless (member to-group to-groups)
8103 (push to-group to-groups))
8105 (unless (memq article gnus-newsgroup-unreads)
8106 (push 'read to-marks)
8108 info (gnus-add-to-range (gnus-info-read info)
8109 (list (cdr art-group)))))
8111 ;; See whether the article is to be put in the cache.
8112 (let ((marks gnus-article-mark-lists)
8113 (to-article (cdr art-group)))
8115 ;; Enter the article into the cache in the new group,
8116 ;; if that is required.
8117 (when gnus-use-cache
8118 (gnus-cache-possibly-enter-article
8120 (memq article gnus-newsgroup-marked)
8121 (memq article gnus-newsgroup-dormant)
8122 (memq article gnus-newsgroup-unreads)))
8124 (when gnus-preserve-marks
8125 ;; Copy any marks over to the new group.
8126 (when (and (equal to-group gnus-newsgroup-name)
8127 (not (memq article gnus-newsgroup-unreads)))
8128 ;; Mark this article as read in this group.
8129 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
8130 (setcdr (gnus-active to-group) to-article)
8131 (setcdr gnus-newsgroup-active to-article))
8134 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
8135 (when (memq article (symbol-value
8136 (intern (format "gnus-newsgroup-%s"
8138 (push (cdar marks) to-marks)
8139 ;; If the other group is the same as this group,
8140 ;; then we have to add the mark to the list.
8141 (when (equal to-group gnus-newsgroup-name)
8142 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
8145 (intern (format "gnus-newsgroup-%s"
8147 ;; Copy the marks to other group.
8148 (gnus-add-marked-articles
8149 to-group (cdar marks) (list to-article) info)))
8150 (setq marks (cdr marks)))
8152 (gnus-request-set-mark to-group (list (list (list to-article)
8157 (concat "(gnus-group-set-info '"
8158 (gnus-prin1-to-string (gnus-get-info to-group))
8161 ;; Update the Xref header in this article to point to
8162 ;; the new crossposted article we have just created.
8163 (when (eq action 'crosspost)
8165 (set-buffer copy-buf)
8166 (gnus-request-article-this-buffer article gnus-newsgroup-name)
8167 (nnheader-replace-header "Xref" new-xref)
8168 (gnus-request-replace-article
8169 article gnus-newsgroup-name (current-buffer)))))
8171 ;;;!!!Why is this necessary?
8172 (set-buffer gnus-summary-buffer)
8174 (gnus-summary-goto-subject article)
8175 (when (eq action 'move)
8176 (gnus-summary-mark-article article gnus-canceled-mark))))
8177 (gnus-summary-remove-process-mark article))
8178 ;; Re-activate all groups that have been moved to.
8181 (set-buffer gnus-group-buffer)
8182 (when (gnus-group-goto-group (car to-groups) t)
8183 (gnus-group-get-new-news-this-group 1 t))
8186 (gnus-kill-buffer copy-buf)
8187 (gnus-summary-position-point)
8188 (gnus-set-mode-line 'summary)))
8190 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
8191 "Move the current article to a different newsgroup.
8192 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8193 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
8194 re-spool using this method."
8196 (gnus-summary-move-article n to-newsgroup select-method 'copy))
8198 (defun gnus-summary-crosspost-article (&optional n)
8199 "Crosspost the current article to some other group."
8201 (gnus-summary-move-article n nil nil 'crosspost))
8203 (defcustom gnus-summary-respool-default-method nil
8204 "Default method for respooling an article.
8205 If nil, use to the current newsgroup method."
8206 :type '(choice (gnus-select-method :value (nnml ""))
8208 :group 'gnus-summary-mail)
8210 (defun gnus-summary-respool-article (&optional n method)
8211 "Respool the current article.
8212 The article will be squeezed through the mail spooling process again,
8213 which means that it will be put in some mail newsgroup or other
8214 depending on `nnmail-split-methods'.
8215 If N is a positive number, respool the N next articles.
8216 If N is a negative number, respool the N previous articles.
8217 If N is nil and any articles have been marked with the process mark,
8218 respool those articles instead.
8220 Respooling can be done both from mail groups and \"real\" newsgroups.
8221 In the former case, the articles in question will be moved from the
8222 current group into whatever groups they are destined to. In the
8223 latter case, they will be copied into the relevant groups."
8225 (list current-prefix-arg
8226 (let* ((methods (gnus-methods-using 'respool))
8228 (symbol-name (or gnus-summary-respool-default-method
8229 (car (gnus-find-method-for-group
8230 gnus-newsgroup-name)))))
8232 (gnus-completing-read
8233 methname "What backend do you want to use when respooling?"
8234 methods nil t nil 'gnus-mail-method-history))
8237 ((zerop (length (setq ms (gnus-servers-using-backend
8239 (list (intern method) ""))
8243 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
8244 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
8247 (error "No method given for respooling"))
8248 (if (assoc (symbol-name
8249 (car (gnus-find-method-for-group gnus-newsgroup-name)))
8250 (gnus-methods-using 'respool))
8251 (gnus-summary-move-article n nil method)
8252 (gnus-summary-copy-article n nil method)))
8254 (defun gnus-summary-import-article (file &optional edit)
8255 "Import an arbitrary file into a mail newsgroup."
8256 (interactive "fImport file: \nP")
8257 (let ((group gnus-newsgroup-name)
8258 (now (current-time))
8259 atts lines group-art)
8260 (unless (gnus-check-backend-function 'request-accept-article group)
8261 (error "%s does not support article importing" group))
8262 (or (file-readable-p file)
8263 (not (file-regular-p file))
8264 (error "Can't read %s" file))
8266 (set-buffer (gnus-get-buffer-create " *import file*"))
8268 (nnheader-insert-file-contents file)
8269 (goto-char (point-min))
8270 (if (nnheader-article-p)
8272 (goto-char (point-min))
8273 (search-forward "\n\n" nil t)
8274 (narrow-to-region (point-min) (1- (point)))
8275 (goto-char (point-min))
8276 (unless (re-search-forward "^date:" nil t)
8277 (goto-char (point-max))
8278 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
8279 ;; This doesn't look like an article, so we fudge some headers.
8280 (setq atts (file-attributes file)
8281 lines (count-lines (point-min) (point-max)))
8282 (insert "From: " (read-string "From: ") "\n"
8283 "Subject: " (read-string "Subject: ") "\n"
8284 "Date: " (message-make-date (nth 5 atts)) "\n"
8285 "Message-ID: " (message-make-message-id) "\n"
8286 "Lines: " (int-to-string lines) "\n"
8287 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
8288 (setq group-art (gnus-request-accept-article group nil t))
8289 (kill-buffer (current-buffer)))
8290 (setq gnus-newsgroup-active (gnus-activate-group group))
8292 (gnus-summary-goto-article (cdr group-art) nil t)
8294 (gnus-summary-edit-article))))
8296 (defun gnus-summary-create-article ()
8297 "Create an article in a mail newsgroup."
8299 (let ((group gnus-newsgroup-name)
8300 (now (current-time))
8302 (unless (gnus-check-backend-function 'request-accept-article group)
8303 (error "%s does not support article importing" group))
8305 (set-buffer (gnus-get-buffer-create " *import file*"))
8307 (goto-char (point-min))
8308 ;; This doesn't look like an article, so we fudge some headers.
8309 (insert "From: " (read-string "From: ") "\n"
8310 "Subject: " (read-string "Subject: ") "\n"
8311 "Date: " (message-make-date now) "\n"
8312 "Message-ID: " (message-make-message-id) "\n")
8313 (setq group-art (gnus-request-accept-article group nil t))
8314 (kill-buffer (current-buffer)))
8315 (setq gnus-newsgroup-active (gnus-activate-group group))
8317 (gnus-summary-goto-article (cdr group-art) nil t)
8318 (gnus-summary-edit-article)))
8320 (defun gnus-summary-article-posted-p ()
8321 "Say whether the current (mail) article is available from news as well.
8322 This will be the case if the article has both been mailed and posted."
8324 (let ((id (mail-header-references (gnus-summary-article-header)))
8325 (gnus-override-method (car (gnus-refer-article-methods))))
8326 (if (gnus-request-head id "")
8327 (gnus-message 2 "The current message was found on %s"
8328 gnus-override-method)
8329 (gnus-message 2 "The current message couldn't be found on %s"
8330 gnus-override-method)
8333 (defun gnus-summary-expire-articles (&optional now)
8334 "Expire all articles that are marked as expirable in the current group."
8336 (when (gnus-check-backend-function
8337 'request-expire-articles gnus-newsgroup-name)
8338 ;; This backend supports expiry.
8339 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
8340 (expirable (if total
8342 ;; We need to update the info for
8343 ;; this group for `gnus-list-of-read-articles'
8344 ;; to give us the right answer.
8345 (gnus-run-hooks 'gnus-exit-group-hook)
8346 (gnus-summary-update-info)
8347 (gnus-list-of-read-articles gnus-newsgroup-name))
8348 (setq gnus-newsgroup-expirable
8349 (sort gnus-newsgroup-expirable '<))))
8350 (expiry-wait (if now 'immediate
8351 (gnus-group-find-parameter
8352 gnus-newsgroup-name 'expiry-wait)))
8353 (nnmail-expiry-target
8354 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
8355 nnmail-expiry-target))
8358 ;; There are expirable articles in this group, so we run them
8359 ;; through the expiry process.
8360 (gnus-message 6 "Expiring articles...")
8361 (unless (gnus-check-group gnus-newsgroup-name)
8362 (error "Can't open server for %s" gnus-newsgroup-name))
8363 ;; The list of articles that weren't expired is returned.
8366 (let ((nnmail-expiry-wait-function nil)
8367 (nnmail-expiry-wait expiry-wait))
8368 (setq es (gnus-request-expire-articles
8369 expirable gnus-newsgroup-name)))
8370 (setq es (gnus-request-expire-articles
8371 expirable gnus-newsgroup-name)))
8373 (setq gnus-newsgroup-expirable es))
8374 ;; We go through the old list of expirable, and mark all
8375 ;; really expired articles as nonexistent.
8376 (unless (eq es expirable) ;If nothing was expired, we don't mark.
8377 (let ((gnus-use-cache nil))
8379 (unless (memq (car expirable) es)
8380 (when (gnus-data-find (car expirable))
8381 (gnus-summary-mark-article
8382 (car expirable) gnus-canceled-mark)))
8383 (setq expirable (cdr expirable))))))
8384 (gnus-message 6 "Expiring articles...done")))))
8386 (defun gnus-summary-expire-articles-now ()
8387 "Expunge all expirable articles in the current group.
8388 This means that *all* articles that are marked as expirable will be
8389 deleted forever, right now."
8391 (or gnus-expert-user
8393 "Are you really, really, really sure you want to delete all these messages? ")
8395 (gnus-summary-expire-articles t))
8397 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
8398 (defun gnus-summary-delete-article (&optional n)
8399 "Delete the N next (mail) articles.
8400 This command actually deletes articles. This is not a marking
8401 command. The article will disappear forever from your life, never to
8403 If N is negative, delete backwards.
8404 If N is nil and articles have been marked with the process mark,
8405 delete these instead."
8407 (unless (gnus-check-backend-function 'request-expire-articles
8408 gnus-newsgroup-name)
8409 (error "The current newsgroup does not support article deletion"))
8410 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
8411 (error "Couldn't open server"))
8412 ;; Compute the list of articles to delete.
8413 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
8415 (if (and gnus-novice-user
8416 (not (gnus-yes-or-no-p
8417 (format "Do you really want to delete %s forever? "
8418 (if (> (length articles) 1)
8419 (format "these %s articles" (length articles))
8422 ;; Delete the articles.
8423 (setq not-deleted (gnus-request-expire-articles
8424 articles gnus-newsgroup-name 'force))
8426 (gnus-summary-remove-process-mark (car articles))
8427 ;; The backend might not have been able to delete the article
8429 (unless (memq (car articles) not-deleted)
8430 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
8431 (setq articles (cdr articles)))
8433 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
8434 (gnus-summary-position-point)
8435 (gnus-set-mode-line 'summary)
8438 (defun gnus-summary-edit-article (&optional arg)
8439 "Edit the current article.
8440 This will have permanent effect only in mail groups.
8441 If ARG is nil, edit the decoded articles.
8442 If ARG is 1, edit the raw articles.
8443 If ARG is 2, edit the raw articles even in read-only groups.
8444 If ARG is 3, edit the articles with the current handles.
8445 Otherwise, allow editing of articles even in read-only
8448 (let (force raw current-handles)
8451 ((eq arg 1) (setq raw t))
8452 ((eq arg 2) (setq raw t
8454 ((eq arg 3) (setq current-handles
8455 (and (gnus-buffer-live-p gnus-article-buffer)
8456 (with-current-buffer gnus-article-buffer
8458 gnus-article-mime-handles
8459 (setq gnus-article-mime-handles nil))))))
8461 (if (and raw (not force) (equal gnus-newsgroup-name "nndraft:drafts"))
8462 (error "Can't edit the raw article in group nndraft:drafts"))
8464 (set-buffer gnus-summary-buffer)
8465 (let ((mail-parse-charset gnus-newsgroup-charset)
8466 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
8467 (gnus-set-global-variables)
8468 (when (and (not force)
8469 (gnus-group-read-only-p))
8470 (error "The current newsgroup does not support article editing"))
8471 (gnus-summary-show-article t)
8472 (when (and (not raw) (gnus-buffer-live-p gnus-article-buffer))
8473 (with-current-buffer gnus-article-buffer
8474 (mm-enable-multibyte-mule4)))
8475 (if (equal gnus-newsgroup-name "nndraft:drafts")
8477 (gnus-article-edit-article
8480 (let ((mbl mml-buffer-list))
8481 (setq mml-buffer-list nil)
8482 (mime-to-mml ,'current-handles)
8483 (let ((mbl1 mml-buffer-list))
8484 (setq mml-buffer-list mbl)
8485 (set (make-local-variable 'mml-buffer-list) mbl1))
8486 (make-local-hook 'kill-buffer-hook)
8487 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))))
8488 `(lambda (no-highlight)
8489 (let ((mail-parse-charset ',gnus-newsgroup-charset)
8490 (message-options message-options)
8491 (message-options-set-recipient)
8492 (mail-parse-ignored-charsets
8493 ',gnus-newsgroup-ignored-charsets))
8494 ,(if (not raw) '(progn
8496 (mml-destroy-buffers)
8497 (remove-hook 'kill-buffer-hook
8498 'mml-destroy-buffers t)
8499 (kill-local-variable 'mml-buffer-list)))
8500 (gnus-summary-edit-article-done
8501 ,(or (mail-header-references gnus-current-headers) "")
8502 ,(gnus-group-read-only-p)
8503 ,gnus-summary-buffer no-highlight))))))))
8505 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
8507 (defun gnus-summary-edit-article-done (&optional references read-only buffer
8509 "Make edits to the current article permanent."
8512 ;; The buffer restriction contains the entire article if it exists.
8513 (when (article-goto-body)
8514 (let ((lines (count-lines (point) (point-max)))
8515 (length (- (point-max) (point)))
8516 (case-fold-search t)
8517 (body (copy-marker (point))))
8518 (goto-char (point-min))
8519 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
8520 (delete-region (match-beginning 1) (match-end 1))
8521 (insert (number-to-string length)))
8522 (goto-char (point-min))
8523 (when (re-search-forward
8524 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
8525 (delete-region (match-beginning 1) (match-end 1))
8526 (insert (number-to-string length)))
8527 (goto-char (point-min))
8528 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
8529 (delete-region (match-beginning 1) (match-end 1))
8530 (insert (number-to-string lines))))))
8531 ;; Replace the article.
8532 (let ((buf (current-buffer)))
8534 (insert-buffer-substring buf)
8536 (if (and (not read-only)
8537 (not (gnus-request-replace-article
8538 (cdr gnus-article-current) (car gnus-article-current)
8539 (current-buffer) t)))
8540 (error "Couldn't replace article")
8541 ;; Update the summary buffer.
8543 (equal (message-tokenize-header references " ")
8544 (message-tokenize-header
8545 (or (message-fetch-field "references") "") " ")))
8546 ;; We only have to update this line.
8549 (message-narrow-to-head)
8550 (let ((head (buffer-string))
8553 (insert (format "211 %d Article retrieved.\n"
8554 (cdr gnus-article-current)))
8557 (let ((nntp-server-buffer (current-buffer)))
8558 (setq header (car (gnus-get-newsgroup-headers
8560 (set-buffer gnus-summary-buffer)
8561 gnus-newsgroup-dependencies)
8564 (set-buffer gnus-summary-buffer)
8565 (gnus-data-set-header
8566 (gnus-data-find (cdr gnus-article-current))
8568 (gnus-summary-update-article-line
8569 (cdr gnus-article-current) header)
8570 (if (gnus-summary-goto-subject
8571 (cdr gnus-article-current) nil t)
8572 (gnus-summary-update-secondary-mark
8573 (cdr gnus-article-current))))))))
8575 (set-buffer (or buffer gnus-summary-buffer))
8576 (gnus-summary-update-article (cdr gnus-article-current))
8577 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
8578 (gnus-summary-update-secondary-mark
8579 (cdr gnus-article-current))))
8580 ;; Prettify the article buffer again.
8581 (unless no-highlight
8583 (set-buffer gnus-article-buffer)
8584 ;;;!!! Fix this -- article should be rehighlighted.
8585 ;;;(gnus-run-hooks 'gnus-article-display-hook)
8586 (set-buffer gnus-original-article-buffer)
8587 (gnus-request-article
8588 (cdr gnus-article-current)
8589 (car gnus-article-current) (current-buffer))))
8590 ;; Prettify the summary buffer line.
8591 (when (gnus-visual-p 'summary-highlight 'highlight)
8592 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
8594 (defun gnus-summary-edit-wash (key)
8595 "Perform editing command KEY in the article buffer."
8599 (message "%s" (concat (this-command-keys) "- "))
8602 (gnus-summary-edit-article)
8603 (execute-kbd-macro (concat (this-command-keys) key))
8604 (gnus-article-edit-done))
8607 (defun gnus-summary-toggle-smiley (&optional arg)
8608 "Toggle the display of smilies as small graphical icons."
8611 (set-buffer gnus-article-buffer)
8612 (gnus-smiley-display arg)
8617 (defun gnus-summary-respool-query (&optional silent trace)
8618 "Query where the respool algorithm would put this article."
8620 (let (gnus-mark-article-hook)
8621 (gnus-summary-select-article)
8623 (set-buffer gnus-original-article-buffer)
8625 (message-narrow-to-head)
8626 (let ((groups (nnmail-article-group 'identity trace)))
8629 (message "This message would go to %s"
8630 (mapconcat 'car groups ", "))
8631 (message "This message would go to no groups"))
8634 (defun gnus-summary-respool-trace ()
8635 "Trace where the respool algorithm would put this article.
8636 Display a buffer showing all fancy splitting patterns which matched."
8638 (gnus-summary-respool-query nil t))
8640 ;; Summary marking commands.
8642 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
8643 "Mark articles which has the same subject as read, and then select the next.
8644 If UNMARK is positive, remove any kind of mark.
8645 If UNMARK is negative, tick articles."
8648 (setq unmark (prefix-numeric-value unmark)))
8650 (gnus-summary-mark-same-subject
8651 (gnus-summary-article-subject) unmark)))
8652 ;; Select next unread article. If auto-select-same mode, should
8653 ;; select the first unread article.
8654 (gnus-summary-next-article t (and gnus-auto-select-same
8655 (gnus-summary-article-subject)))
8656 (gnus-message 7 "%d article%s marked as %s"
8657 count (if (= count 1) " is" "s are")
8658 (if unmark "unread" "read"))))
8660 (defun gnus-summary-kill-same-subject (&optional unmark)
8661 "Mark articles which has the same subject as read.
8662 If UNMARK is positive, remove any kind of mark.
8663 If UNMARK is negative, tick articles."
8666 (setq unmark (prefix-numeric-value unmark)))
8668 (gnus-summary-mark-same-subject
8669 (gnus-summary-article-subject) unmark)))
8670 ;; If marked as read, go to next unread subject.
8672 ;; Go to next unread subject.
8673 (gnus-summary-next-subject 1 t))
8674 (gnus-message 7 "%d articles are marked as %s"
8675 count (if unmark "unread" "read"))))
8677 (defun gnus-summary-mark-same-subject (subject &optional unmark)
8678 "Mark articles with same SUBJECT as read, and return marked number.
8679 If optional argument UNMARK is positive, remove any kinds of marks.
8680 If optional argument UNMARK is negative, mark articles as unread instead."
8684 ((null unmark) ; Mark as read.
8687 (gnus-summary-mark-article-as-read gnus-killed-mark)
8688 (gnus-summary-show-thread) t)
8689 (gnus-summary-find-subject subject))
8690 (setq count (1+ count))))
8691 ((> unmark 0) ; Tick.
8694 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
8695 (gnus-summary-show-thread) t)
8696 (gnus-summary-find-subject subject))
8697 (setq count (1+ count))))
8698 (t ; Mark as unread.
8701 (gnus-summary-mark-article-as-unread gnus-unread-mark)
8702 (gnus-summary-show-thread) t)
8703 (gnus-summary-find-subject subject))
8704 (setq count (1+ count)))))
8705 (gnus-set-mode-line 'summary)
8706 ;; Return the number of marked articles.
8709 (defun gnus-summary-mark-as-processable (n &optional unmark)
8710 "Set the process mark on the next N articles.
8711 If N is negative, mark backward instead. If UNMARK is non-nil, remove
8712 the process mark instead. The difference between N and the actual
8713 number of articles marked is returned."
8715 (if (and (null n) (gnus-region-active-p))
8716 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
8717 (setq n (prefix-numeric-value n))
8718 (let ((backward (< n 0))
8723 (gnus-summary-remove-process-mark
8724 (gnus-summary-article-number))
8725 (gnus-summary-set-process-mark (gnus-summary-article-number)))
8726 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
8729 (gnus-message 7 "No more articles"))
8730 (gnus-summary-recenter)
8731 (gnus-summary-position-point)
8734 (defun gnus-summary-unmark-as-processable (n)
8735 "Remove the process mark from the next N articles.
8736 If N is negative, unmark backward instead. The difference between N and
8737 the actual number of articles unmarked is returned."
8739 (gnus-summary-mark-as-processable n t))
8741 (defun gnus-summary-unmark-all-processable ()
8742 "Remove the process mark from all articles."
8745 (while gnus-newsgroup-processable
8746 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
8747 (gnus-summary-position-point))
8749 (defun gnus-summary-add-mark (article type)
8750 "Mark ARTICLE with a mark of TYPE."
8751 (let ((vtype (car (assq type gnus-article-mark-lists)))
8754 (error "No such mark type: %s" type)
8755 (setq var (intern (format "gnus-newsgroup-%s" type)))
8756 (set var (cons article (symbol-value var)))
8757 (if (memq type '(processable cached replied forwarded recent saved))
8758 (gnus-summary-update-secondary-mark article)
8759 ;;; !!! This is bogus. We should find out what primary
8760 ;;; !!! mark we want to set.
8761 (gnus-summary-update-mark gnus-del-mark 'unread)))))
8763 (defun gnus-summary-mark-as-expirable (n)
8764 "Mark N articles forward as expirable.
8765 If N is negative, mark backward instead. The difference between N and
8766 the actual number of articles marked is returned."
8768 (gnus-summary-mark-forward n gnus-expirable-mark))
8770 (defun gnus-summary-mark-article-as-replied (article)
8771 "Mark ARTICLE as replied to and update the summary line.
8772 ARTICLE can also be a list of articles."
8773 (interactive (list (gnus-summary-article-number)))
8774 (let ((articles (if (listp article) article (list article))))
8775 (dolist (article articles)
8776 (push article gnus-newsgroup-replied)
8777 (let ((buffer-read-only nil))
8778 (when (gnus-summary-goto-subject article nil t)
8779 (gnus-summary-update-secondary-mark article))))))
8781 (defun gnus-summary-mark-article-as-forwarded (article)
8782 "Mark ARTICLE as forwarded and update the summary line.
8783 ARTICLE can also be a list of articles."
8784 (let ((articles (if (listp article) article (list article))))
8785 (dolist (article articles)
8786 (push article gnus-newsgroup-forwarded)
8787 (let ((buffer-read-only nil))
8788 (when (gnus-summary-goto-subject article nil t)
8789 (gnus-summary-update-secondary-mark article))))))
8791 (defun gnus-summary-set-bookmark (article)
8792 "Set a bookmark in current article."
8793 (interactive (list (gnus-summary-article-number)))
8794 (when (or (not (get-buffer gnus-article-buffer))
8795 (not gnus-current-article)
8796 (not gnus-article-current)
8797 (not (equal gnus-newsgroup-name (car gnus-article-current))))
8798 (error "No current article selected"))
8799 ;; Remove old bookmark, if one exists.
8800 (let ((old (assq article gnus-newsgroup-bookmarks)))
8802 (setq gnus-newsgroup-bookmarks
8803 (delq old gnus-newsgroup-bookmarks))))
8804 ;; Set the new bookmark, which is on the form
8805 ;; (article-number . line-number-in-body).
8809 (set-buffer gnus-article-buffer)
8813 (goto-char (point-min))
8814 (search-forward "\n\n" nil t)
8817 gnus-newsgroup-bookmarks)
8818 (gnus-message 6 "A bookmark has been added to the current article."))
8820 (defun gnus-summary-remove-bookmark (article)
8821 "Remove the bookmark from the current article."
8822 (interactive (list (gnus-summary-article-number)))
8823 ;; Remove old bookmark, if one exists.
8824 (let ((old (assq article gnus-newsgroup-bookmarks)))
8827 (setq gnus-newsgroup-bookmarks
8828 (delq old gnus-newsgroup-bookmarks))
8829 (gnus-message 6 "Removed bookmark."))
8830 (gnus-message 6 "No bookmark in current article."))))
8832 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8833 (defun gnus-summary-mark-as-dormant (n)
8834 "Mark N articles forward as dormant.
8835 If N is negative, mark backward instead. The difference between N and
8836 the actual number of articles marked is returned."
8838 (gnus-summary-mark-forward n gnus-dormant-mark))
8840 (defun gnus-summary-set-process-mark (article)
8841 "Set the process mark on ARTICLE and update the summary line."
8842 (setq gnus-newsgroup-processable
8844 (delq article gnus-newsgroup-processable)))
8845 (when (gnus-summary-goto-subject article)
8846 (gnus-summary-show-thread)
8847 (gnus-summary-goto-subject article)
8848 (gnus-summary-update-secondary-mark article)))
8850 (defun gnus-summary-remove-process-mark (article)
8851 "Remove the process mark from ARTICLE and update the summary line."
8852 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
8853 (when (gnus-summary-goto-subject article)
8854 (gnus-summary-show-thread)
8855 (gnus-summary-goto-subject article)
8856 (gnus-summary-update-secondary-mark article)))
8858 (defun gnus-summary-set-saved-mark (article)
8859 "Set the process mark on ARTICLE and update the summary line."
8860 (push article gnus-newsgroup-saved)
8861 (when (gnus-summary-goto-subject article)
8862 (gnus-summary-update-secondary-mark article)))
8864 (defun gnus-summary-mark-forward (n &optional mark no-expire)
8865 "Mark N articles as read forwards.
8866 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
8867 The difference between N and the actual number of articles marked is
8869 Iff NO-EXPIRE, auto-expiry will be inhibited."
8871 (gnus-summary-show-thread)
8872 (let ((backward (< n 0))
8873 (gnus-summary-goto-unread
8874 (and gnus-summary-goto-unread
8875 (not (eq gnus-summary-goto-unread 'never))
8876 (not (memq mark (list gnus-unread-mark
8877 gnus-ticked-mark gnus-dormant-mark)))))
8879 (mark (or mark gnus-del-mark)))
8881 (gnus-summary-mark-article nil mark no-expire)
8882 (zerop (gnus-summary-next-subject
8884 (and gnus-summary-goto-unread
8885 (not (eq gnus-summary-goto-unread 'never)))
8889 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
8890 (gnus-summary-recenter)
8891 (gnus-summary-position-point)
8892 (gnus-set-mode-line 'summary)
8895 (defun gnus-summary-mark-article-as-read (mark)
8896 "Mark the current article quickly as read with MARK."
8897 (let ((article (gnus-summary-article-number)))
8898 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8899 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8900 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8901 (push (cons article mark) gnus-newsgroup-reads)
8902 ;; Possibly remove from cache, if that is used.
8903 (when gnus-use-cache
8904 (gnus-cache-enter-remove-article article))
8905 ;; Allow the backend to change the mark.
8906 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8907 ;; Check for auto-expiry.
8908 (when (and gnus-newsgroup-auto-expire
8909 (memq mark gnus-auto-expirable-marks))
8910 (setq mark gnus-expirable-mark)
8911 ;; Let the backend know about the mark change.
8912 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8913 (push article gnus-newsgroup-expirable))
8914 ;; Set the mark in the buffer.
8915 (gnus-summary-update-mark mark 'unread)
8918 (defun gnus-summary-mark-article-as-unread (mark)
8919 "Mark the current article quickly as unread with MARK."
8920 (let* ((article (gnus-summary-article-number))
8921 (old-mark (gnus-summary-article-mark article)))
8922 ;; Allow the backend to change the mark.
8923 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8924 (if (eq mark old-mark)
8928 (gnus-error 1 "Can't mark negative article numbers")
8930 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8931 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8932 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
8933 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
8934 (cond ((= mark gnus-ticked-mark)
8935 (push article gnus-newsgroup-marked))
8936 ((= mark gnus-dormant-mark)
8937 (push article gnus-newsgroup-dormant))
8939 (push article gnus-newsgroup-unreads)))
8940 (gnus-pull article gnus-newsgroup-reads)
8942 ;; See whether the article is to be put in the cache.
8944 (vectorp (gnus-summary-article-header article))
8946 (gnus-cache-possibly-enter-article
8947 gnus-newsgroup-name article
8948 (= mark gnus-ticked-mark)
8949 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
8952 (gnus-summary-update-mark mark 'unread)
8955 (defun gnus-summary-mark-article (&optional article mark no-expire)
8956 "Mark ARTICLE with MARK. MARK can be any character.
8957 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
8958 `??' (dormant) and `?E' (expirable).
8959 If MARK is nil, then the default character `?r' is used.
8960 If ARTICLE is nil, then the article on the current line will be
8962 Iff NO-EXPIRE, auto-expiry will be inhibited."
8963 ;; The mark might be a string.
8964 (when (stringp mark)
8965 (setq mark (aref mark 0)))
8966 ;; If no mark is given, then we check auto-expiring.
8968 (setq mark gnus-del-mark))
8969 (when (and (not no-expire)
8970 gnus-newsgroup-auto-expire
8971 (memq mark gnus-auto-expirable-marks))
8972 (setq mark gnus-expirable-mark))
8973 (let ((article (or article (gnus-summary-article-number)))
8974 (old-mark (gnus-summary-article-mark article)))
8975 ;; Allow the backend to change the mark.
8976 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8977 (if (eq mark old-mark)
8980 (error "No article on current line"))
8981 (if (not (if (or (= mark gnus-unread-mark)
8982 (= mark gnus-ticked-mark)
8983 (= mark gnus-dormant-mark))
8984 (gnus-mark-article-as-unread article mark)
8985 (gnus-mark-article-as-read article mark)))
8987 ;; See whether the article is to be put in the cache.
8989 (not (= mark gnus-canceled-mark))
8990 (vectorp (gnus-summary-article-header article))
8992 (gnus-cache-possibly-enter-article
8993 gnus-newsgroup-name article
8994 (= mark gnus-ticked-mark)
8995 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
8997 (when (gnus-summary-goto-subject article nil t)
8998 (let ((buffer-read-only nil))
8999 (gnus-summary-show-thread)
9001 (gnus-summary-update-mark mark 'unread)
9004 (defun gnus-summary-update-secondary-mark (article)
9005 "Update the secondary (read, process, cache) mark."
9006 (gnus-summary-update-mark
9007 (cond ((memq article gnus-newsgroup-processable)
9009 ((memq article gnus-newsgroup-cached)
9011 ((memq article gnus-newsgroup-replied)
9013 ((memq article gnus-newsgroup-forwarded)
9014 gnus-forwarded-mark)
9015 ((memq article gnus-newsgroup-saved)
9017 ((memq article gnus-newsgroup-recent)
9019 ((memq article gnus-newsgroup-unseen)
9023 (when (gnus-visual-p 'summary-highlight 'highlight)
9024 (gnus-run-hooks 'gnus-summary-update-hook))
9027 (defun gnus-summary-update-mark (mark type)
9028 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
9029 (buffer-read-only nil))
9030 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
9032 (when (looking-at "\r")
9034 (when (<= (+ forward (point)) (point-max))
9035 ;; Go to the right position on the line.
9036 (goto-char (+ forward (point)))
9037 ;; Replace the old mark with the new mark.
9038 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
9039 ;; Optionally update the marks by some user rule.
9040 (when (eq type 'unread)
9042 (gnus-data-find (gnus-summary-article-number)) mark)
9043 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
9045 (defun gnus-mark-article-as-read (article &optional mark)
9046 "Enter ARTICLE in the pertinent lists and remove it from others."
9047 ;; Make the article expirable.
9048 (let ((mark (or mark gnus-del-mark)))
9049 (if (= mark gnus-expirable-mark)
9050 (push article gnus-newsgroup-expirable)
9051 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
9052 ;; Remove from unread and marked lists.
9053 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9054 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9055 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9056 (push (cons article mark) gnus-newsgroup-reads)
9057 ;; Possibly remove from cache, if that is used.
9058 (when gnus-use-cache
9059 (gnus-cache-enter-remove-article article))
9062 (defun gnus-mark-article-as-unread (article &optional mark)
9063 "Enter ARTICLE in the pertinent lists and remove it from others."
9064 (let ((mark (or mark gnus-ticked-mark)))
9067 (gnus-error 1 "Can't mark negative article numbers")
9069 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
9070 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
9071 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
9072 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9074 ;; Unsuppress duplicates?
9075 (when gnus-suppress-duplicates
9076 (gnus-dup-unsuppress-article article))
9078 (cond ((= mark gnus-ticked-mark)
9079 (push article gnus-newsgroup-marked))
9080 ((= mark gnus-dormant-mark)
9081 (push article gnus-newsgroup-dormant))
9083 (push article gnus-newsgroup-unreads)))
9084 (gnus-pull article gnus-newsgroup-reads)
9087 (defalias 'gnus-summary-mark-as-unread-forward
9088 'gnus-summary-tick-article-forward)
9089 (make-obsolete 'gnus-summary-mark-as-unread-forward
9090 'gnus-summary-tick-article-forward)
9091 (defun gnus-summary-tick-article-forward (n)
9092 "Tick N articles forwards.
9093 If N is negative, tick backwards instead.
9094 The difference between N and the number of articles ticked is returned."
9096 (gnus-summary-mark-forward n gnus-ticked-mark))
9098 (defalias 'gnus-summary-mark-as-unread-backward
9099 'gnus-summary-tick-article-backward)
9100 (make-obsolete 'gnus-summary-mark-as-unread-backward
9101 'gnus-summary-tick-article-backward)
9102 (defun gnus-summary-tick-article-backward (n)
9103 "Tick N articles backwards.
9104 The difference between N and the number of articles ticked is returned."
9106 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
9108 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9109 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9110 (defun gnus-summary-tick-article (&optional article clear-mark)
9111 "Mark current article as unread.
9112 Optional 1st argument ARTICLE specifies article number to be marked as unread.
9113 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
9115 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
9118 (defun gnus-summary-mark-as-read-forward (n)
9119 "Mark N articles as read forwards.
9120 If N is negative, mark backwards instead.
9121 The difference between N and the actual number of articles marked is
9124 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
9126 (defun gnus-summary-mark-as-read-backward (n)
9127 "Mark the N articles as read backwards.
9128 The difference between N and the actual number of articles marked is
9131 (gnus-summary-mark-forward
9132 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
9134 (defun gnus-summary-mark-as-read (&optional article mark)
9135 "Mark current article as read.
9136 ARTICLE specifies the article to be marked as read.
9137 MARK specifies a string to be inserted at the beginning of the line."
9138 (gnus-summary-mark-article article mark))
9140 (defun gnus-summary-clear-mark-forward (n)
9141 "Clear marks from N articles forward.
9142 If N is negative, clear backward instead.
9143 The difference between N and the number of marks cleared is returned."
9145 (gnus-summary-mark-forward n gnus-unread-mark))
9147 (defun gnus-summary-clear-mark-backward (n)
9148 "Clear marks from N articles backward.
9149 The difference between N and the number of marks cleared is returned."
9151 (gnus-summary-mark-forward (- n) gnus-unread-mark))
9153 (defun gnus-summary-mark-unread-as-read ()
9154 "Intended to be used by `gnus-summary-mark-article-hook'."
9155 (when (memq gnus-current-article gnus-newsgroup-unreads)
9156 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
9158 (defun gnus-summary-mark-read-and-unread-as-read ()
9159 "Intended to be used by `gnus-summary-mark-article-hook'."
9160 (let ((mark (gnus-summary-article-mark)))
9161 (when (or (gnus-unread-mark-p mark)
9162 (gnus-read-mark-p mark))
9163 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
9165 (defun gnus-summary-mark-unread-as-ticked ()
9166 "Intended to be used by `gnus-summary-mark-article-hook'."
9167 (when (memq gnus-current-article gnus-newsgroup-unreads)
9168 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
9170 (defun gnus-summary-mark-region-as-read (point mark all)
9171 "Mark all unread articles between point and mark as read.
9172 If given a prefix, mark all articles between point and mark as read,
9173 even ticked and dormant ones."
9174 (interactive "r\nP")
9183 (memq (setq article (gnus-summary-article-number))
9184 gnus-newsgroup-unreads))
9185 (gnus-summary-mark-article article gnus-del-mark))
9187 (gnus-summary-find-next))))))
9189 (defun gnus-summary-mark-below (score mark)
9190 "Mark articles with score less than SCORE with MARK."
9191 (interactive "P\ncMark: ")
9192 (setq score (if score
9193 (prefix-numeric-value score)
9194 (or gnus-summary-default-score 0)))
9196 (set-buffer gnus-summary-buffer)
9197 (goto-char (point-min))
9200 (and (< (gnus-summary-article-score) score)
9201 (gnus-summary-mark-article nil mark))
9202 (gnus-summary-find-next)))))
9204 (defun gnus-summary-kill-below (&optional score)
9205 "Mark articles with score below SCORE as read."
9207 (gnus-summary-mark-below score gnus-killed-mark))
9209 (defun gnus-summary-clear-above (&optional score)
9210 "Clear all marks from articles with score above SCORE."
9212 (gnus-summary-mark-above score gnus-unread-mark))
9214 (defun gnus-summary-tick-above (&optional score)
9215 "Tick all articles with score above SCORE."
9217 (gnus-summary-mark-above score gnus-ticked-mark))
9219 (defun gnus-summary-mark-above (score mark)
9220 "Mark articles with score over SCORE with MARK."
9221 (interactive "P\ncMark: ")
9222 (setq score (if score
9223 (prefix-numeric-value score)
9224 (or gnus-summary-default-score 0)))
9226 (set-buffer gnus-summary-buffer)
9227 (goto-char (point-min))
9229 (when (> (gnus-summary-article-score) score)
9230 (gnus-summary-mark-article nil mark))
9232 (gnus-summary-find-next)))))
9234 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9235 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
9236 (defun gnus-summary-limit-include-expunged (&optional no-error)
9237 "Display all the hidden articles that were expunged for low scores."
9239 (let ((buffer-read-only nil))
9240 (let ((scored gnus-newsgroup-scored)
9243 (unless (gnus-summary-article-header (caar scored))
9244 (and (setq h (gnus-number-to-header (caar scored)))
9245 (< (cdar scored) gnus-summary-expunge-below)
9247 (setq scored (cdr scored)))
9249 (when (not no-error)
9250 (error "No expunged articles hidden"))
9251 (goto-char (point-min))
9252 (push gnus-newsgroup-limit gnus-newsgroup-limits)
9253 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
9254 (mapcar (lambda (x) (push (mail-header-number x)
9255 gnus-newsgroup-limit))
9257 (gnus-summary-prepare-unthreaded (nreverse headers))
9258 (goto-char (point-min))
9259 (gnus-summary-position-point)
9262 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
9263 "Mark all unread articles in this newsgroup as read.
9264 If prefix argument ALL is non-nil, ticked and dormant articles will
9265 also be marked as read.
9266 If QUIETLY is non-nil, no questions will be asked.
9267 If TO-HERE is non-nil, it should be a point in the buffer. All
9268 articles before (after, if REVERSE is set) this point will be marked as read.
9269 Note that this function will only catch up the unread article
9270 in the current summary buffer limitation.
9271 The number of articles marked as read is returned."
9276 (not gnus-interactive-catchup) ;Without confirmation?
9280 "Mark absolutely all articles as read? "
9281 "Mark all unread articles as read? ")))
9283 (not gnus-newsgroup-adaptive)
9284 (not gnus-newsgroup-auto-expire)
9285 (not gnus-suppress-duplicates)
9286 (or (not gnus-use-cache)
9287 (eq gnus-use-cache 'passive)))
9290 (setq gnus-newsgroup-marked nil
9291 gnus-newsgroup-dormant nil))
9292 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
9293 ;; We actually mark all articles as canceled, which we
9294 ;; have to do when using auto-expiry or adaptive scoring.
9295 (gnus-summary-show-all-threads)
9296 (if (and to-here reverse)
9300 (gnus-summary-mark-article-as-read gnus-catchup-mark)
9301 (gnus-summary-find-next (not all) nil nil t))))
9302 (when (gnus-summary-first-subject (not all) t)
9304 (if to-here (< (point) to-here) t)
9305 (gnus-summary-mark-article-as-read gnus-catchup-mark)
9306 (gnus-summary-find-next (not all) nil nil t)))))
9307 (gnus-set-mode-line 'summary))
9309 (gnus-summary-position-point)))
9311 (defun gnus-summary-catchup-to-here (&optional all)
9312 "Mark all unticked articles before the current one as read.
9313 If ALL is non-nil, also mark ticked and dormant articles as read."
9316 (gnus-save-hidden-threads
9317 (let ((beg (point)))
9318 ;; We check that there are unread articles.
9319 (when (or all (gnus-summary-find-prev))
9320 (gnus-summary-catchup all t beg)))))
9321 (gnus-summary-position-point))
9323 (defun gnus-summary-catchup-from-here (&optional all)
9324 "Mark all unticked articles after the current one as read.
9325 If ALL is non-nil, also mark ticked and dormant articles as read."
9328 (gnus-save-hidden-threads
9329 (let ((beg (point)))
9330 ;; We check that there are unread articles.
9331 (when (or all (gnus-summary-find-next))
9332 (gnus-summary-catchup all t beg nil t)))))
9334 (gnus-summary-position-point))
9335 (defun gnus-summary-catchup-all (&optional quietly)
9336 "Mark all articles in this newsgroup as read."
9338 (gnus-summary-catchup t quietly))
9340 (defun gnus-summary-catchup-and-exit (&optional all quietly)
9341 "Mark all unread articles in this group as read, then exit.
9342 If prefix argument ALL is non-nil, all articles are marked as read.
9343 If QUIETLY is non-nil, no questions will be asked."
9345 (when (gnus-summary-catchup all quietly nil 'fast)
9346 ;; Select next newsgroup or exit.
9347 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
9348 (eq gnus-auto-select-next 'quietly))
9349 (gnus-summary-next-group nil)
9350 (gnus-summary-exit))))
9352 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
9353 "Mark all articles in this newsgroup as read, and then exit."
9355 (gnus-summary-catchup-and-exit t quietly))
9357 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
9358 "Mark all articles in this group as read and select the next group.
9359 If given a prefix, mark all articles, unread as well as ticked, as
9363 (gnus-summary-catchup all))
9364 (gnus-summary-next-group))
9370 (defmacro gnus-with-article (article &rest forms)
9371 "Select ARTICLE and perform FORMS in the original article buffer.
9372 Then replace the article with the result."
9374 ;; We don't want the article to be marked as read.
9375 (let (gnus-mark-article-hook)
9376 (gnus-summary-select-article t t nil ,article))
9377 (set-buffer gnus-original-article-buffer)
9379 (if (not (gnus-check-backend-function
9380 'request-replace-article (car gnus-article-current)))
9381 (gnus-message 5 "Read-only group; not replacing")
9382 (unless (gnus-request-replace-article
9383 ,article (car gnus-article-current)
9385 (error "Couldn't replace article")))
9386 ;; The cache and backlog have to be flushed somewhat.
9387 (when gnus-keep-backlog
9388 (gnus-backlog-remove-article
9389 (car gnus-article-current) (cdr gnus-article-current)))
9390 (when gnus-use-cache
9391 (gnus-cache-update-article
9392 (car gnus-article-current) (cdr gnus-article-current)))))
9394 (put 'gnus-with-article 'lisp-indent-function 1)
9395 (put 'gnus-with-article 'edebug-form-spec '(form body))
9397 ;; Thread-based commands.
9399 (defun gnus-summary-articles-in-thread (&optional article)
9400 "Return a list of all articles in the current thread.
9401 If ARTICLE is non-nil, return all articles in the thread that starts
9403 (let* ((article (or article (gnus-summary-article-number)))
9404 (data (gnus-data-find-list article))
9405 (top-level (gnus-data-level (car data)))
9407 (cond ((null gnus-thread-operation-ignore-subject)
9408 (gnus-simplify-subject-re
9409 (mail-header-subject (gnus-data-header (car data)))))
9410 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
9411 (gnus-simplify-subject-fuzzy
9412 (mail-header-subject (gnus-data-header (car data)))))
9414 (end-point (save-excursion
9415 (if (gnus-summary-go-to-next-thread)
9416 (point) (point-max))))
9419 (< (gnus-data-pos (car data)) end-point))
9420 (when (or (not top-subject)
9421 (string= top-subject
9422 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
9423 (gnus-simplify-subject-fuzzy
9424 (mail-header-subject
9425 (gnus-data-header (car data))))
9426 (gnus-simplify-subject-re
9427 (mail-header-subject
9428 (gnus-data-header (car data)))))))
9429 (push (gnus-data-number (car data)) articles))
9430 (unless (and (setq data (cdr data))
9431 (> (gnus-data-level (car data)) top-level))
9433 ;; Return the list of articles.
9434 (nreverse articles)))
9436 (defun gnus-summary-rethread-current ()
9437 "Rethread the thread the current article is part of."
9439 (let* ((gnus-show-threads t)
9440 (article (gnus-summary-article-number))
9441 (id (mail-header-id (gnus-summary-article-header)))
9442 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
9444 (error "No article on the current line"))
9445 (gnus-rebuild-thread id)
9446 (gnus-summary-goto-subject article)))
9448 (defun gnus-summary-reparent-thread ()
9449 "Make the current article child of the marked (or previous) article.
9451 Note that the re-threading will only work if `gnus-thread-ignore-subject'
9452 is non-nil or the Subject: of both articles are the same."
9454 (unless (not (gnus-group-read-only-p))
9455 (error "The current newsgroup does not support article editing"))
9456 (unless (<= (length gnus-newsgroup-processable) 1)
9457 (error "No more than one article may be marked"))
9458 (save-window-excursion
9459 (let ((gnus-article-buffer " *reparent*")
9460 (current-article (gnus-summary-article-number))
9461 ;; First grab the marked article, otherwise one line up.
9462 (parent-article (if (not (null gnus-newsgroup-processable))
9463 (car gnus-newsgroup-processable)
9465 (if (eq (forward-line -1) 0)
9466 (gnus-summary-article-number)
9467 (error "Beginning of summary buffer"))))))
9468 (unless (not (eq current-article parent-article))
9469 (error "An article may not be self-referential"))
9470 (let ((message-id (mail-header-id
9471 (gnus-summary-article-header parent-article))))
9472 (unless (and message-id (not (equal message-id "")))
9473 (error "No message-id in desired parent"))
9474 (gnus-with-article current-article
9476 (goto-char (point-min))
9477 (message-narrow-to-head)
9478 (if (re-search-forward "^References: " nil t)
9480 (re-search-forward "^[^ \t]" nil t)
9483 (insert " " message-id))
9484 (insert "References: " message-id "\n"))))
9485 (set-buffer gnus-summary-buffer)
9486 (gnus-summary-unmark-all-processable)
9487 (gnus-summary-update-article current-article)
9488 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9489 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
9490 (gnus-summary-rethread-current)
9491 (gnus-message 3 "Article %d is now the child of article %d"
9492 current-article parent-article)))))
9494 (defun gnus-summary-toggle-threads (&optional arg)
9495 "Toggle showing conversation threads.
9496 If ARG is positive number, turn showing conversation threads on."
9498 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
9499 (setq gnus-show-threads
9500 (if (null arg) (not gnus-show-threads)
9501 (> (prefix-numeric-value arg) 0)))
9502 (gnus-summary-prepare)
9503 (gnus-summary-goto-subject current)
9504 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
9505 (gnus-summary-position-point)))
9507 (defun gnus-summary-show-all-threads ()
9511 (let ((buffer-read-only nil))
9512 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
9513 (gnus-summary-position-point))
9515 (defun gnus-summary-show-thread ()
9516 "Show thread subtrees.
9517 Returns nil if no thread was there to be shown."
9519 (let ((buffer-read-only nil)
9521 ;; first goto end then to beg, to have point at beg after let
9522 (end (progn (end-of-line) (point)))
9523 (beg (progn (beginning-of-line) (point))))
9525 ;; Any hidden lines here?
9526 (search-forward "\r" end t)
9527 (subst-char-in-region beg end ?\^M ?\n t)
9529 (gnus-summary-position-point))))
9531 (defun gnus-summary-hide-all-threads ()
9532 "Hide all thread subtrees."
9535 (goto-char (point-min))
9536 (gnus-summary-hide-thread)
9537 (while (zerop (gnus-summary-next-thread 1 t))
9538 (gnus-summary-hide-thread)))
9539 (gnus-summary-position-point))
9541 (defun gnus-summary-hide-thread ()
9542 "Hide thread subtrees.
9543 Returns nil if no threads were there to be hidden."
9545 (let ((buffer-read-only nil)
9547 (article (gnus-summary-article-number)))
9549 ;; Go forward until either the buffer ends or the subthread
9551 (when (and (not (eobp))
9552 (or (zerop (gnus-summary-next-thread 1 t))
9553 (goto-char (point-max))))
9555 (if (and (> (point) start)
9556 (search-backward "\n" start t))
9558 (subst-char-in-region start (point) ?\n ?\^M)
9559 (gnus-summary-goto-subject article))
9563 (defun gnus-summary-go-to-next-thread (&optional previous)
9564 "Go to the same level (or less) next thread.
9565 If PREVIOUS is non-nil, go to previous thread instead.
9566 Return the article number moved to, or nil if moving was impossible."
9567 (let ((level (gnus-summary-thread-level))
9568 (way (if previous -1 1))
9571 (while (and (not (eobp))
9572 (< level (gnus-summary-thread-level)))
9580 (gnus-summary-article-number)
9583 (defun gnus-summary-next-thread (n &optional silent)
9584 "Go to the same level next N'th thread.
9585 If N is negative, search backward instead.
9586 Returns the difference between N and the number of skips actually
9589 If SILENT, don't output messages."
9591 (let ((backward (< n 0))
9594 (gnus-summary-go-to-next-thread backward))
9597 (gnus-summary-position-point))
9598 (when (and (not silent) (/= 0 n))
9599 (gnus-message 7 "No more threads"))
9602 (defun gnus-summary-prev-thread (n)
9603 "Go to the same level previous N'th thread.
9604 Returns the difference between N and the number of skips actually
9607 (gnus-summary-next-thread (- n)))
9609 (defun gnus-summary-go-down-thread ()
9610 "Go down one level in the current thread."
9611 (let ((children (gnus-summary-article-children)))
9613 (gnus-summary-goto-subject (car children)))))
9615 (defun gnus-summary-go-up-thread ()
9616 "Go up one level in the current thread."
9617 (let ((parent (gnus-summary-article-parent)))
9619 (gnus-summary-goto-subject parent))))
9621 (defun gnus-summary-down-thread (n)
9622 "Go down thread N steps.
9623 If N is negative, go up instead.
9624 Returns the difference between N and how many steps down that were
9630 (if up (gnus-summary-go-up-thread)
9631 (gnus-summary-go-down-thread)))
9633 (gnus-summary-position-point)
9635 (gnus-message 7 "Can't go further"))
9638 (defun gnus-summary-up-thread (n)
9639 "Go up thread N steps.
9640 If N is negative, go down instead.
9641 Returns the difference between N and how many steps down that were
9644 (gnus-summary-down-thread (- n)))
9646 (defun gnus-summary-top-thread ()
9647 "Go to the top of the thread."
9649 (while (gnus-summary-go-up-thread))
9650 (gnus-summary-article-number))
9652 (defun gnus-summary-kill-thread (&optional unmark)
9653 "Mark articles under current thread as read.
9654 If the prefix argument is positive, remove any kinds of marks.
9655 If the prefix argument is negative, tick articles instead."
9658 (setq unmark (prefix-numeric-value unmark)))
9659 (let ((articles (gnus-summary-articles-in-thread)))
9661 ;; Expand the thread.
9662 (gnus-summary-show-thread)
9663 ;; Mark all the articles.
9665 (gnus-summary-goto-subject (car articles))
9666 (cond ((null unmark)
9667 (gnus-summary-mark-article-as-read gnus-killed-mark))
9669 (gnus-summary-mark-article-as-unread gnus-unread-mark))
9671 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
9672 (setq articles (cdr articles))))
9673 ;; Hide killed subtrees.
9675 gnus-thread-hide-killed
9676 (gnus-summary-hide-thread))
9677 ;; If marked as read, go to next unread subject.
9679 ;; Go to next unread subject.
9680 (gnus-summary-next-subject 1 t)))
9681 (gnus-set-mode-line 'summary))
9683 ;; Summary sorting commands
9685 (defun gnus-summary-sort-by-number (&optional reverse)
9686 "Sort the summary buffer by article number.
9687 Argument REVERSE means reverse order."
9689 (gnus-summary-sort 'number reverse))
9691 (defun gnus-summary-sort-by-author (&optional reverse)
9692 "Sort the summary buffer by author name alphabetically.
9693 If `case-fold-search' is non-nil, case of letters is ignored.
9694 Argument REVERSE means reverse order."
9696 (gnus-summary-sort 'author reverse))
9698 (defun gnus-summary-sort-by-subject (&optional reverse)
9699 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
9700 If `case-fold-search' is non-nil, case of letters is ignored.
9701 Argument REVERSE means reverse order."
9703 (gnus-summary-sort 'subject reverse))
9705 (defun gnus-summary-sort-by-date (&optional reverse)
9706 "Sort the summary buffer by date.
9707 Argument REVERSE means reverse order."
9709 (gnus-summary-sort 'date reverse))
9711 (defun gnus-summary-sort-by-score (&optional reverse)
9712 "Sort the summary buffer by score.
9713 Argument REVERSE means reverse order."
9715 (gnus-summary-sort 'score reverse))
9717 (defun gnus-summary-sort-by-lines (&optional reverse)
9718 "Sort the summary buffer by the number of lines.
9719 Argument REVERSE means reverse order."
9721 (gnus-summary-sort 'lines reverse))
9723 (defun gnus-summary-sort-by-chars (&optional reverse)
9724 "Sort the summary buffer by article length.
9725 Argument REVERSE means reverse order."
9727 (gnus-summary-sort 'chars reverse))
9729 (defun gnus-summary-sort-by-original (&optional reverse)
9730 "Sort the summary buffer using the default sorting method.
9731 Argument REVERSE means reverse order."
9733 (let* ((buffer-read-only)
9734 (gnus-summary-prepare-hook nil))
9735 ;; We do the sorting by regenerating the threads.
9736 (gnus-summary-prepare)
9737 ;; Hide subthreads if needed.
9738 (when (and gnus-show-threads gnus-thread-hide-subtree)
9739 (gnus-summary-hide-all-threads))))
9741 (defun gnus-summary-sort (predicate reverse)
9742 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
9743 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
9744 (article (intern (format "gnus-article-sort-by-%s" predicate)))
9745 (gnus-thread-sort-functions
9750 (gnus-sort-gathered-threads-function
9751 gnus-thread-sort-functions)
9752 (gnus-article-sort-functions
9758 (gnus-summary-prepare-hook nil))
9759 ;; We do the sorting by regenerating the threads.
9760 (gnus-summary-prepare)
9761 ;; Hide subthreads if needed.
9762 (when (and gnus-show-threads gnus-thread-hide-subtree)
9763 (gnus-summary-hide-all-threads))))
9765 ;; Summary saving commands.
9767 (defun gnus-summary-save-article (&optional n not-saved)
9768 "Save the current article using the default saver function.
9769 If N is a positive number, save the N next articles.
9770 If N is a negative number, save the N previous articles.
9771 If N is nil and any articles have been marked with the process mark,
9772 save those articles instead.
9773 The variable `gnus-default-article-saver' specifies the saver function."
9775 (let* ((articles (gnus-summary-work-articles n))
9776 (save-buffer (save-excursion
9777 (nnheader-set-temp-buffer " *Gnus Save*")))
9778 (num (length articles))
9780 (dolist (article articles)
9781 (setq header (gnus-summary-article-header article))
9782 (if (not (vectorp header))
9783 ;; This is a pseudo-article.
9784 (if (assq 'name header)
9785 (gnus-copy-file (cdr (assq 'name header)))
9786 (gnus-message 1 "Article %d is unsaveable" article))
9787 ;; This is a real article.
9788 (save-window-excursion
9789 (gnus-summary-select-article t nil nil article))
9791 (set-buffer save-buffer)
9793 (insert-buffer-substring gnus-original-article-buffer))
9794 (setq file (gnus-article-save save-buffer file num))
9795 (gnus-summary-remove-process-mark article)
9797 (gnus-summary-set-saved-mark article))))
9798 (gnus-kill-buffer save-buffer)
9799 (gnus-summary-position-point)
9800 (gnus-set-mode-line 'summary)
9803 (defun gnus-summary-pipe-output (&optional arg)
9804 "Pipe the current article to a subprocess.
9805 If N is a positive number, pipe the N next articles.
9806 If N is a negative number, pipe the N previous articles.
9807 If N is nil and any articles have been marked with the process mark,
9808 pipe those articles instead."
9811 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
9812 (gnus-summary-save-article arg t))
9813 (let ((buffer (get-buffer "*Shell Command Output*")))
9815 (with-current-buffer buffer (> (point-max) (point-min))))
9816 (gnus-configure-windows 'pipe))))
9818 (defun gnus-summary-save-article-mail (&optional arg)
9819 "Append the current article to an mail file.
9820 If N is a positive number, save the N next articles.
9821 If N is a negative number, save the N previous articles.
9822 If N is nil and any articles have been marked with the process mark,
9823 save those articles instead."
9826 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
9827 (gnus-summary-save-article arg)))
9829 (defun gnus-summary-save-article-rmail (&optional arg)
9830 "Append the current article to an rmail file.
9831 If N is a positive number, save the N next articles.
9832 If N is a negative number, save the N previous articles.
9833 If N is nil and any articles have been marked with the process mark,
9834 save those articles instead."
9837 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
9838 (gnus-summary-save-article arg)))
9840 (defun gnus-summary-save-article-file (&optional arg)
9841 "Append the current article to a file.
9842 If N is a positive number, save the N next articles.
9843 If N is a negative number, save the N previous articles.
9844 If N is nil and any articles have been marked with the process mark,
9845 save those articles instead."
9848 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
9849 (gnus-summary-save-article arg)))
9851 (defun gnus-summary-write-article-file (&optional arg)
9852 "Write the current article to a file, deleting the previous file.
9853 If N is a positive number, save the N next articles.
9854 If N is a negative number, save the N previous articles.
9855 If N is nil and any articles have been marked with the process mark,
9856 save those articles instead."
9859 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
9860 (gnus-summary-save-article arg)))
9862 (defun gnus-summary-save-article-body-file (&optional arg)
9863 "Append the current article body to a file.
9864 If N is a positive number, save the N next articles.
9865 If N is a negative number, save the N previous articles.
9866 If N is nil and any articles have been marked with the process mark,
9867 save those articles instead."
9870 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
9871 (gnus-summary-save-article arg)))
9873 (defun gnus-summary-pipe-message (program)
9874 "Pipe the current article through PROGRAM."
9875 (interactive "sProgram: ")
9876 (gnus-summary-select-article)
9877 (let ((mail-header-separator ""))
9878 (gnus-eval-in-buffer-window gnus-article-buffer
9881 (let ((start (window-start))
9883 (message-pipe-buffer-body program)
9884 (set-window-start (get-buffer-window (current-buffer)) start))))))
9886 (defun gnus-get-split-value (methods)
9887 "Return a value based on the split METHODS."
9888 (let (split-name method result match)
9891 (set-buffer gnus-original-article-buffer)
9893 (nnheader-narrow-to-headers)
9894 (while (and methods (not split-name))
9895 (goto-char (point-min))
9896 (setq method (pop methods))
9897 (setq match (car method))
9900 ;; Regular expression.
9902 (re-search-forward match nil t)))
9903 ((gnus-functionp match)
9907 (setq result (funcall match gnus-newsgroup-name))))
9912 (setq result (eval match)))))
9913 (setq split-name (cdr method))
9914 (cond ((stringp result)
9915 (push (expand-file-name
9916 result gnus-article-save-directory)
9919 (setq split-name (append result split-name)))))))))
9920 (nreverse split-name)))
9922 (defun gnus-valid-move-group-p (group)
9925 (symbol-value group)
9926 (gnus-get-function (gnus-find-method-for-group
9927 (symbol-name group)) 'request-accept-article t)))
9929 (defun gnus-read-move-group-name (prompt default articles prefix)
9930 "Read a group name."
9931 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
9932 (minibuffer-confirm-incomplete nil) ; XEmacs
9936 (if (> (length articles) 1)
9937 (format "these %d articles" (length articles))
9942 (gnus-completing-read default prom
9944 'gnus-valid-move-group-p
9946 'gnus-group-history))
9947 ((= 1 (length split-name))
9948 (gnus-completing-read (car split-name) prom
9950 'gnus-valid-move-group-p
9952 'gnus-group-history))
9954 (gnus-completing-read nil prom
9955 (mapcar (lambda (el) (list el))
9956 (nreverse split-name))
9958 'gnus-group-history))))
9959 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
9961 (if (or (string= to-newsgroup "")
9962 (string= to-newsgroup prefix))
9963 (setq to-newsgroup default))
9964 (unless to-newsgroup
9965 (error "No group name entered"))
9966 (or (gnus-active to-newsgroup)
9967 (gnus-activate-group to-newsgroup nil nil to-method)
9968 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
9970 (or (and (gnus-request-create-group to-newsgroup to-method)
9971 (gnus-activate-group
9972 to-newsgroup nil nil to-method)
9973 (gnus-subscribe-group to-newsgroup))
9974 (error "Couldn't create group %s" to-newsgroup)))
9975 (error "No such group: %s" to-newsgroup)))
9978 (defun gnus-summary-save-parts (type dir n &optional reverse)
9979 "Save parts matching TYPE to DIR.
9980 If REVERSE, save parts that do not match TYPE."
9982 (list (read-string "Save parts of type: "
9983 (or (car gnus-summary-save-parts-type-history)
9984 gnus-summary-save-parts-default-mime)
9985 'gnus-summary-save-parts-type-history)
9986 (setq gnus-summary-save-parts-last-directory
9987 (read-file-name "Save to directory: "
9988 gnus-summary-save-parts-last-directory
9990 current-prefix-arg))
9991 (gnus-summary-iterate n
9992 (let ((gnus-display-mime-function nil)
9993 (gnus-inhibit-treatment t))
9994 (gnus-summary-select-article))
9996 (set-buffer gnus-article-buffer)
9997 (let ((handles (or gnus-article-mime-handles
9998 (mm-dissect-buffer) (mm-uu-dissect))))
10000 (gnus-summary-save-parts-1 type dir handles reverse)
10001 (unless gnus-article-mime-handles ;; Don't destroy this case.
10002 (mm-destroy-parts handles)))))))
10004 (defun gnus-summary-save-parts-1 (type dir handle reverse)
10005 (if (stringp (car handle))
10006 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
10009 (not (string-match type (mm-handle-media-type handle)))
10010 (string-match type (mm-handle-media-type handle)))
10011 (let ((file (expand-file-name
10012 (file-name-nondirectory
10014 (mail-content-type-get
10015 (mm-handle-disposition handle) 'filename)
10016 (concat gnus-newsgroup-name
10017 "." (number-to-string
10018 (cdr gnus-article-current)))))
10020 (unless (file-exists-p file)
10021 (mm-save-part-to-file handle file))))))
10023 ;; Summary extract commands
10025 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
10026 (let ((buffer-read-only nil)
10027 (article (gnus-summary-article-number))
10029 (unless (gnus-summary-goto-subject article)
10030 (error "No such article: %d" article))
10031 (gnus-summary-position-point)
10032 ;; If all commands are to be bunched up on one line, we collect
10034 (unless gnus-view-pseudos-separately
10035 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
10038 (setq action (cdr (assq 'action (car ps))))
10039 (setq files (list (cdr (assq 'name (car ps)))))
10040 (while (and ps (cdr ps)
10041 (string= (or action "1")
10042 (or (cdr (assq 'action (cadr ps))) "2")))
10043 (push (cdr (assq 'name (cadr ps))) files)
10044 (setcdr ps (cddr ps)))
10046 (when (not (string-match "%s" action))
10049 (when (assq 'execute (car ps))
10050 (setcdr (assq 'execute (car ps))
10051 (funcall (if (string-match "%s" action)
10060 (setq ps (cdr ps)))))
10061 (if (and gnus-view-pseudos (not not-view))
10063 (when (assq 'execute (car pslist))
10064 (gnus-execute-command (cdr (assq 'execute (car pslist)))
10065 (eq gnus-view-pseudos 'not-confirm)))
10066 (setq pslist (cdr pslist)))
10069 (setq after-article (or (cdr (assq 'article (car pslist)))
10070 (gnus-summary-article-number)))
10071 (gnus-summary-goto-subject after-article)
10074 (insert " " (file-name-nondirectory
10075 (cdr (assq 'name (car pslist))))
10076 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
10078 (forward-line -1) ; back to `b'
10079 (gnus-add-text-properties
10080 b (1- e) (list 'gnus-number gnus-reffed-article-number
10081 gnus-mouse-face-prop gnus-mouse-face))
10083 after-article gnus-reffed-article-number
10084 gnus-unread-mark b (car pslist) 0 (- e b))
10085 (push gnus-reffed-article-number gnus-newsgroup-unreads)
10086 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
10087 (setq pslist (cdr pslist)))))))
10089 (defun gnus-pseudos< (p1 p2)
10090 (let ((c1 (cdr (assq 'action p1)))
10091 (c2 (cdr (assq 'action p2))))
10092 (and c1 c2 (string< c1 c2))))
10094 (defun gnus-request-pseudo-article (props)
10095 (cond ((assq 'execute props)
10096 (gnus-execute-command (cdr (assq 'execute props)))))
10097 (let ((gnus-current-article (gnus-summary-article-number)))
10098 (gnus-run-hooks 'gnus-mark-article-hook)))
10100 (defun gnus-execute-command (command &optional automatic)
10102 (gnus-article-setup-buffer)
10103 (set-buffer gnus-article-buffer)
10104 (setq buffer-read-only nil)
10105 (let ((command (if automatic command
10106 (read-string "Command: " (cons command 0)))))
10108 (insert "$ " command "\n\n")
10109 (if gnus-view-pseudo-asynchronously
10110 (start-process "gnus-execute" (current-buffer) shell-file-name
10111 shell-command-switch command)
10112 (call-process shell-file-name nil t nil
10113 shell-command-switch command)))))
10115 ;; Summary kill commands.
10117 (defun gnus-summary-edit-global-kill (article)
10118 "Edit the \"global\" kill file."
10119 (interactive (list (gnus-summary-article-number)))
10120 (gnus-group-edit-global-kill article))
10122 (defun gnus-summary-edit-local-kill ()
10123 "Edit a local kill file applied to the current newsgroup."
10125 (setq gnus-current-headers (gnus-summary-article-header))
10126 (gnus-group-edit-local-kill
10127 (gnus-summary-article-number) gnus-newsgroup-name))
10129 ;;; Header reading.
10131 (defun gnus-read-header (id &optional header)
10132 "Read the headers of article ID and enter them into the Gnus system."
10133 (let ((group gnus-newsgroup-name)
10134 (gnus-override-method
10136 gnus-override-method
10137 (and (gnus-news-group-p gnus-newsgroup-name)
10138 (car (gnus-refer-article-methods)))))
10140 ;; First we check to see whether the header in question is already
10143 ;; This is a Message-ID.
10144 (setq header (or header (gnus-id-to-header id)))
10145 ;; This is an article number.
10146 (setq header (or header (gnus-summary-article-header id))))
10148 (not (gnus-summary-article-sparse-p (mail-header-number header))))
10149 ;; We have found the header.
10151 ;; If this is a sparse article, we have to nix out its
10152 ;; previous entry in the thread hashtb.
10154 (gnus-summary-article-sparse-p (mail-header-number header)))
10155 (let* ((parent (gnus-parent-id (mail-header-references header)))
10156 (thread (and parent (gnus-id-to-thread parent))))
10158 (delq (assq header thread) thread))))
10159 ;; We have to really fetch the header to this article.
10161 (set-buffer nntp-server-buffer)
10162 (when (setq where (gnus-request-head id group))
10163 (nnheader-fold-continuation-lines)
10164 (goto-char (point-max))
10166 (goto-char (point-min))
10170 ((cdr where) (cdr where))
10171 (header (mail-header-number header))
10172 (t gnus-reffed-article-number))
10174 (insert " Article retrieved.\n"))
10175 (if (or (not where)
10176 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
10177 () ; Malformed head.
10178 (unless (gnus-summary-article-sparse-p (mail-header-number header))
10179 (when (and (stringp id)
10180 (not (string= (gnus-group-real-name group)
10182 ;; If we fetched by Message-ID and the article came
10183 ;; from a different group, we fudge some bogus article
10184 ;; numbers for this article.
10185 (mail-header-set-number header gnus-reffed-article-number))
10187 (set-buffer gnus-summary-buffer)
10188 (decf gnus-reffed-article-number)
10189 (gnus-remove-header (mail-header-number header))
10190 (push header gnus-newsgroup-headers)
10191 (setq gnus-current-headers header)
10192 (push (mail-header-number header) gnus-newsgroup-limit)))
10195 (defun gnus-remove-header (number)
10196 "Remove header NUMBER from `gnus-newsgroup-headers'."
10197 (if (and gnus-newsgroup-headers
10198 (= number (mail-header-number (car gnus-newsgroup-headers))))
10199 (pop gnus-newsgroup-headers)
10200 (let ((headers gnus-newsgroup-headers))
10201 (while (and (cdr headers)
10202 (not (= number (mail-header-number (cadr headers)))))
10204 (when (cdr headers)
10205 (setcdr headers (cddr headers))))))
10208 ;;; summary highlights
10211 (defun gnus-highlight-selected-summary ()
10212 "Highlight selected article in summary buffer."
10213 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
10214 (when gnus-summary-selected-face
10216 (let* ((beg (progn (beginning-of-line) (point)))
10217 (end (progn (end-of-line) (point)))
10218 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
10219 (from (if (get-text-property beg gnus-mouse-face-prop)
10221 (or (next-single-property-change
10222 beg gnus-mouse-face-prop nil end)
10227 (or (next-single-property-change
10228 from gnus-mouse-face-prop nil end)
10230 ;; If no mouse-face prop on line we will have to = from = end,
10231 ;; so we highlight the entire line instead.
10232 (when (= (+ to 2) from)
10235 (if gnus-newsgroup-selected-overlay
10236 ;; Move old overlay.
10238 gnus-newsgroup-selected-overlay from to (current-buffer))
10239 ;; Create new overlay.
10241 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
10242 'face gnus-summary-selected-face))))))
10244 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
10245 (defun gnus-summary-highlight-line ()
10246 "Highlight current line according to `gnus-summary-highlight'."
10247 (let* ((list gnus-summary-highlight)
10249 (end (progn (end-of-line) (point)))
10250 ;; now find out where the line starts and leave point there.
10251 (beg (progn (beginning-of-line) (point)))
10252 (article (gnus-summary-article-number))
10253 (score (or (cdr (assq (or article gnus-current-article)
10254 gnus-newsgroup-scored))
10255 gnus-summary-default-score 0))
10256 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
10257 (inhibit-read-only t))
10258 ;; Eval the cars of the lists until we find a match.
10259 (let ((default gnus-summary-default-score)
10260 (default-high gnus-summary-default-high-score)
10261 (default-low gnus-summary-default-low-score))
10263 (not (eval (caar list))))
10264 (setq list (cdr list))))
10265 (let ((face (cdar list)))
10266 (unless (eq face (get-text-property beg 'face))
10267 (gnus-put-text-property-excluding-characters-with-faces
10269 (setq face (if (boundp face) (symbol-value face) face)))
10270 (when gnus-summary-highlight-line-function
10271 (funcall gnus-summary-highlight-line-function article face))))
10274 (defun gnus-update-read-articles (group unread &optional compute)
10275 "Update the list of read articles in GROUP."
10276 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
10277 (entry (gnus-gethash group gnus-newsrc-hashtb))
10278 (info (nth 2 entry))
10280 (unread (sort (copy-sequence unread) '<))
10282 (if (or (not info) (not active))
10283 ;; There is no info on this group if it was, in fact,
10284 ;; killed. Gnus stores no information on killed groups, so
10285 ;; there's nothing to be done.
10286 ;; One could store the information somewhere temporarily,
10287 ;; perhaps... Hmmm...
10289 ;; Remove any negative articles numbers.
10290 (while (and unread (< (car unread) 0))
10291 (setq unread (cdr unread)))
10292 ;; Remove any expired article numbers
10293 (while (and unread (< (car unread) (car active)))
10294 (setq unread (cdr unread)))
10295 ;; Compute the ranges of read articles by looking at the list of
10296 ;; unread articles.
10298 (when (/= (car unread) prev)
10299 (push (if (= prev (1- (car unread))) prev
10300 (cons prev (1- (car unread))))
10302 (setq prev (1+ (car unread)))
10303 (setq unread (cdr unread)))
10304 (when (<= prev (cdr active))
10305 (push (cons prev (cdr active)) read))
10306 (setq read (if (> (length read) 1) (nreverse read) read))
10311 ;; Propagate the read marks to the backend.
10312 (when (gnus-check-backend-function 'request-set-mark group)
10313 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
10314 (add (gnus-remove-from-range read (gnus-info-read info))))
10316 (unless (gnus-check-group group)
10317 (error "Can't open server for %s" group))
10318 (gnus-request-set-mark
10319 group (delq nil (list (if add (list add 'add '(read)))
10320 (if del (list del 'del '(read))))))
10322 `(gnus-request-set-mark
10325 (if del (list del 'add '(read)))
10326 (if add (list add 'del '(read))))))))))
10327 (set-buffer gnus-group-buffer)
10328 (gnus-undo-register
10330 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
10331 (gnus-info-set-read ',info ',(gnus-info-read info))
10332 (gnus-get-unread-articles-in-group ',info
10333 (gnus-active ,group))
10334 (gnus-group-update-group ,group t)
10336 ;; Enter this list into the group info.
10337 (gnus-info-set-read info read)
10338 ;; Set the number of unread articles in gnus-newsrc-hashtb.
10339 (gnus-get-unread-articles-in-group info (gnus-active group))
10342 (defun gnus-offer-save-summaries ()
10343 "Offer to save all active summary buffers."
10345 ;; Go through all buffers and find all summaries.
10346 (dolist (buffer (buffer-list))
10347 (when (and (setq buffer (buffer-name buffer))
10348 (string-match "Summary" buffer)
10350 (set-buffer buffer)
10351 ;; We check that this is, indeed, a summary buffer.
10352 (and (eq major-mode 'gnus-summary-mode)
10353 ;; Also make sure this isn't bogus.
10354 gnus-newsgroup-prepared
10355 ;; Also make sure that this isn't a
10356 ;; dead summary buffer.
10357 (not gnus-dead-summary-mode))))
10358 (push buffer buffers)))
10359 ;; Go through all these summary buffers and offer to save them.
10363 "Update summary buffer %s? "
10365 (switch-to-buffer buf)
10366 (gnus-summary-exit))
10369 (defun gnus-summary-setup-default-charset ()
10370 "Setup newsgroup default charset."
10371 (if (equal gnus-newsgroup-name "nndraft:drafts")
10372 (setq gnus-newsgroup-charset nil)
10373 (let* ((ignored-charsets
10374 (or gnus-newsgroup-ephemeral-ignored-charsets
10376 (and gnus-newsgroup-name
10377 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
10378 gnus-newsgroup-ignored-charsets))))
10379 (setq gnus-newsgroup-charset
10380 (or gnus-newsgroup-ephemeral-charset
10381 (and gnus-newsgroup-name
10382 (gnus-parameter-charset gnus-newsgroup-name))
10383 gnus-default-charset))
10384 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
10385 ignored-charsets))))
10391 (defun gnus-summary-display-buttonized (&optional show-all-parts)
10392 "Display the current article buffer fully MIME-buttonized.
10393 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
10394 treated as multipart/mixed."
10396 (require 'gnus-art)
10397 (let ((gnus-unbuttonized-mime-types nil)
10398 (gnus-mime-display-multipart-as-mixed show-all-parts))
10399 (gnus-summary-show-article)))
10401 (defun gnus-summary-repair-multipart (article)
10402 "Add a Content-Type header to a multipart article without one."
10403 (interactive (list (gnus-summary-article-number)))
10404 (gnus-with-article article
10405 (message-narrow-to-head)
10406 (message-remove-header "Mime-Version")
10407 (goto-char (point-max))
10408 (insert "Mime-Version: 1.0\n")
10410 (when (search-forward "\n--" nil t)
10411 (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
10412 (message-narrow-to-head)
10413 (message-remove-header "Content-Type")
10414 (goto-char (point-max))
10415 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
10418 (let (gnus-mark-article-hook)
10419 (gnus-summary-select-article t t nil article)))
10421 (defun gnus-summary-toggle-display-buttonized ()
10422 "Toggle the buttonizing of the article buffer."
10424 (require 'gnus-art)
10425 (if (setq gnus-inhibit-mime-unbuttonizing
10426 (not gnus-inhibit-mime-unbuttonizing))
10427 (let ((gnus-unbuttonized-mime-types nil))
10428 (gnus-summary-show-article))
10429 (gnus-summary-show-article)))
10432 ;;; Generic summary marking commands
10435 (defvar gnus-summary-marking-alist
10436 '((read gnus-del-mark "d")
10437 (unread gnus-unread-mark "u")
10438 (ticked gnus-ticked-mark "!")
10439 (dormant gnus-dormant-mark "?")
10440 (expirable gnus-expirable-mark "e"))
10441 "An alist of names/marks/keystrokes.")
10443 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
10444 (defvar gnus-summary-mark-map)
10446 (defun gnus-summary-make-all-marking-commands ()
10447 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
10448 (dolist (elem gnus-summary-marking-alist)
10449 (apply 'gnus-summary-make-marking-command elem)))
10451 (defun gnus-summary-make-marking-command (name mark keystroke)
10452 (let ((map (make-sparse-keymap)))
10453 (define-key gnus-summary-generic-mark-map keystroke map)
10454 (dolist (lway `((next "next" next nil "n")
10455 (next-unread "next unread" next t "N")
10456 (prev "previous" prev nil "p")
10457 (prev-unread "previous unread" prev t "P")
10458 (nomove "" nil nil ,keystroke)))
10459 (let ((func (gnus-summary-make-marking-command-1
10460 mark (car lway) lway name)))
10461 (setq func (eval func))
10462 (define-key map (nth 4 lway) func)))))
10464 (defun gnus-summary-make-marking-command-1 (mark way lway name)
10466 (format "gnus-summary-put-mark-as-%s%s"
10467 name (if (eq way 'nomove)
10469 (concat "-" (symbol-name way)))))
10472 "Mark the current article as %s%s.
10473 If N, the prefix, then repeat N times.
10474 If N is negative, move in reverse order.
10475 The difference between N and the actual number of articles marked is
10479 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
10481 (defun gnus-summary-generic-mark (n mark move unread)
10482 "Mark N articles with MARK."
10483 (unless (eq major-mode 'gnus-summary-mode)
10484 (error "This command can only be used in the summary buffer"))
10485 (gnus-summary-show-thread)
10488 ((eq move 'next) 1)
10489 ((eq move 'prev) -1)
10491 (if (zerop nummove)
10495 nummove (* -1 nummove))))
10496 (while (and (> n 0)
10497 (gnus-summary-mark-article nil mark)
10498 (zerop (gnus-summary-next-subject nummove unread t)))
10501 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
10502 (gnus-summary-recenter)
10503 (gnus-summary-position-point)
10504 (gnus-set-mode-line 'summary)
10507 (defun gnus-summary-insert-articles (articles)
10508 (when (setq articles
10509 (gnus-set-difference articles
10510 (mapcar (lambda (h) (mail-header-number h))
10511 gnus-newsgroup-headers)))
10512 (setq gnus-newsgroup-headers
10514 gnus-newsgroup-headers
10515 (gnus-fetch-headers articles)
10516 'gnus-article-sort-by-number))
10517 ;; Suppress duplicates?
10518 (when gnus-suppress-duplicates
10519 (gnus-dup-suppress-articles))
10521 ;; We might want to build some more threads first.
10522 (when (and gnus-fetch-old-headers
10523 (eq gnus-headers-retrieved-by 'nov))
10524 (if (eq gnus-fetch-old-headers 'invisible)
10525 (gnus-build-all-threads)
10526 (gnus-build-old-threads)))
10527 ;; Let the Gnus agent mark articles as read.
10529 (gnus-agent-get-undownloaded-list))
10530 ;; Remove list identifiers from subject
10531 (when gnus-list-identifiers
10532 (gnus-summary-remove-list-identifiers))
10533 ;; First and last article in this newsgroup.
10534 (when gnus-newsgroup-headers
10535 (setq gnus-newsgroup-begin
10536 (mail-header-number (car gnus-newsgroup-headers))
10538 (mail-header-number
10539 (gnus-last-element gnus-newsgroup-headers))))
10540 (when gnus-use-scoring
10541 (gnus-possibly-score-headers))))
10543 (defun gnus-summary-insert-old-articles (&optional all)
10544 "Insert all old articles in this group.
10545 If ALL is non-nil, already read articles become readable.
10546 If ALL is a number, fetch this number of articles."
10549 (let ((old (mapcar 'car gnus-newsgroup-data))
10550 (i (car gnus-newsgroup-active))
10552 (while (<= i (cdr gnus-newsgroup-active))
10553 (or (memq i old) (push i older))
10555 (setq len (length older))
10560 (setq older (subseq older 0 all))))
10563 (if (and (numberp gnus-large-newsgroup)
10564 (> len gnus-large-newsgroup))
10568 "How many articles from %s (default %d): "
10570 (gnus-group-decoded-name gnus-newsgroup-name) 35)
10572 (unless (string-match "^[ \t]*$" input)
10573 (setq all (string-to-number input))
10575 (setq older (subseq older 0 all))))))))
10577 (message "No old news.")
10578 (gnus-summary-insert-articles older)
10579 (gnus-summary-limit (gnus-union older old))))
10580 (gnus-summary-position-point)))
10582 (defun gnus-summary-insert-new-articles ()
10583 "Insert all new articles in this group."
10586 (let ((old (mapcar 'car gnus-newsgroup-data))
10587 (old-active gnus-newsgroup-active)
10588 (nnmail-fetched-sources (list t))
10590 (setq gnus-newsgroup-active
10591 (gnus-activate-group gnus-newsgroup-name 'scan))
10592 (setq i (1+ (cdr old-active)))
10593 (while (<= i (cdr gnus-newsgroup-active))
10597 (message "No gnus is bad news.")
10598 (setq new (nreverse new))
10599 (gnus-summary-insert-articles new)
10600 (setq gnus-newsgroup-unreads
10601 (append gnus-newsgroup-unreads new))
10602 (gnus-summary-limit (gnus-union old new))))
10603 (gnus-summary-position-point)))
10605 (gnus-summary-make-all-marking-commands)
10607 (gnus-ems-redefine)
10609 (provide 'gnus-sum)
10611 (run-hooks 'gnus-sum-load-hook)
10613 ;;; gnus-sum.el ends here