1 ;;; gnus-sum.el --- summary mode commands for Gnus
2 ;; Copyright (C) 1996,97,98 Free Software Foundation, Inc.
4 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
7 ;; This file is part of GNU Emacs.
9 ;; GNU Emacs is free software; you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation; either version 2, or (at your option)
14 ;; GNU Emacs is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 ;; Boston, MA 02111-1307, USA.
28 (eval-when-compile (require 'cl))
37 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
39 (defcustom gnus-kill-summary-on-exit t
40 "*If non-nil, kill the summary buffer when you exit from it.
41 If nil, the summary will become a \"*Dead Summary*\" buffer, and
42 it will be killed sometime later."
43 :group 'gnus-summary-exit
46 (defcustom gnus-fetch-old-headers nil
47 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
48 If an unread article in the group refers to an older, already read (or
49 just marked as read) article, the old article will not normally be
50 displayed in the Summary buffer. If this variable is non-nil, Gnus
51 will attempt to grab the headers to the old articles, and thereby
52 build complete threads. If it has the value `some', only enough
53 headers to connect otherwise loose threads will be displayed. This
54 variable can also be a number. In that case, no more than that number
55 of old headers will be fetched. If it has the value `invisible', all
56 old headers will be fetched, but none will be displayed.
58 The server has to support NOV for any of this to work."
60 :type '(choice (const :tag "off" nil)
63 (sexp :menu-tag "other" t)))
65 (defcustom gnus-refer-thread-limit 200
66 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
67 If t, fetch all the available old headers."
70 (sexp :menu-tag "other" t)))
72 (defcustom gnus-summary-make-false-root 'adopt
73 "*nil means that Gnus won't gather loose threads.
74 If the root of a thread has expired or been read in a previous
75 session, the information necessary to build a complete thread has been
76 lost. Instead of having many small sub-threads from this original thread
77 scattered all over the summary buffer, Gnus can gather them.
79 If non-nil, Gnus will try to gather all loose sub-threads from an
80 original thread into one large thread.
82 If this variable is non-nil, it should be one of `none', `adopt',
85 If this variable is `none', Gnus will not make a false root, but just
86 present the sub-threads after another.
87 If this variable is `dummy', Gnus will create a dummy root that will
88 have all the sub-threads as children.
89 If this variable is `adopt', Gnus will make one of the \"children\"
90 the parent and mark all the step-children as such.
91 If this variable is `empty', the \"children\" are printed with empty
92 subject fields. (Or rather, they will be printed with a string
93 given by the `gnus-summary-same-subject' variable.)"
95 :type '(choice (const :tag "off" nil)
101 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
102 "*A regexp to match subjects to be excluded from loose thread gathering.
103 As loose thread gathering is done on subjects only, that means that
104 there can be many false gatherings performed. By rooting out certain
105 common subjects, gathering might become saner."
109 (defcustom gnus-summary-gather-subject-limit nil
110 "*Maximum length of subject comparisons when gathering loose threads.
111 Use nil to compare full subjects. Setting this variable to a low
112 number will help gather threads that have been corrupted by
113 newsreaders chopping off subject lines, but it might also mean that
114 unrelated articles that have subject that happen to begin with the
115 same few characters will be incorrectly gathered.
117 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
120 :type '(choice (const :tag "off" nil)
122 (sexp :menu-tag "on" t)))
124 (defcustom gnus-simplify-subject-functions nil
125 "List of functions taking a string argument that simplify subjects.
126 The functions are applied recursively.
128 Useful functions to put in this list include: `gnus-simplify-subject-re',
129 `gnus-simplify-subject-fuzzy' and `gnus-simplify-whitespace'."
131 :type '(repeat function))
133 (defcustom gnus-simplify-ignored-prefixes nil
134 "*Regexp, matches for which are removed from subject lines when simplifying fuzzily."
136 :type '(choice (const :tag "off" nil)
139 (defcustom gnus-build-sparse-threads nil
140 "*If non-nil, fill in the gaps in threads.
141 If `some', only fill in the gaps that are needed to tie loose threads
142 together. If `more', fill in all leaf nodes that Gnus can find. If
143 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
145 :type '(choice (const :tag "off" nil)
148 (sexp :menu-tag "all" t)))
150 (defcustom gnus-summary-thread-gathering-function
151 'gnus-gather-threads-by-subject
152 "*Function used for gathering loose threads.
153 There are two pre-defined functions: `gnus-gather-threads-by-subject',
154 which only takes Subjects into consideration; and
155 `gnus-gather-threads-by-references', which compared the References
156 headers of the articles to find matches."
158 :type '(radio (function-item gnus-gather-threads-by-subject)
159 (function-item gnus-gather-threads-by-references)
160 (function :tag "other")))
162 (defcustom gnus-summary-same-subject ""
163 "*String indicating that the current article has the same subject as the previous.
164 This variable will only be used if the value of
165 `gnus-summary-make-false-root' is `empty'."
166 :group 'gnus-summary-format
169 (defcustom gnus-summary-goto-unread t
170 "*If t, marking commands will go to the next unread article.
171 If `never', commands that usually go to the next unread article, will
172 go to the next article, whether it is read or not.
173 If nil, only the marking commands will go to the next (un)read article."
174 :group 'gnus-summary-marks
175 :link '(custom-manual "(gnus)Setting Marks")
176 :type '(choice (const :tag "off" nil)
178 (sexp :menu-tag "on" t)))
180 (defcustom gnus-summary-default-score 0
181 "*Default article score level.
182 All scores generated by the score files will be added to this score.
183 If this variable is nil, scoring will be disabled."
184 :group 'gnus-score-default
185 :type '(choice (const :tag "disable")
188 (defcustom gnus-summary-zcore-fuzz 0
189 "*Fuzziness factor for the zcore in the summary buffer.
190 Articles with scores closer than this to `gnus-summary-default-score'
192 :group 'gnus-summary-format
195 (defcustom gnus-simplify-subject-fuzzy-regexp nil
196 "*Strings to be removed when doing fuzzy matches.
197 This can either be a regular expression or list of regular expressions
198 that will be removed from subject strings if fuzzy subject
199 simplification is selected."
201 :type '(repeat regexp))
203 (defcustom gnus-show-threads t
204 "*If non-nil, display threads in summary mode."
208 (defcustom gnus-thread-hide-subtree nil
209 "*If non-nil, hide all threads initially.
210 If threads are hidden, you have to run the command
211 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
212 to expose hidden threads."
216 (defcustom gnus-thread-hide-killed t
217 "*If non-nil, hide killed threads automatically."
221 (defcustom gnus-thread-ignore-subject nil
222 "*If non-nil, ignore subjects and do all threading based on the Reference header.
223 If nil, which is the default, articles that have different subjects
224 from their parents will start separate threads."
228 (defcustom gnus-thread-operation-ignore-subject t
229 "*If non-nil, subjects will be ignored when doing thread commands.
230 This affects commands like `gnus-summary-kill-thread' and
231 `gnus-summary-lower-thread'.
233 If this variable is nil, articles in the same thread with different
234 subjects will not be included in the operation in question. If this
235 variable is `fuzzy', only articles that have subjects that are fuzzily
236 equal will be included."
238 :type '(choice (const :tag "off" nil)
242 (defcustom gnus-thread-indent-level 4
243 "*Number that says how much each sub-thread should be indented."
247 (defcustom gnus-auto-extend-newsgroup t
248 "*If non-nil, extend newsgroup forward and backward when requested."
249 :group 'gnus-summary-choose
252 (defcustom gnus-auto-select-first t
253 "*If nil, don't select the first unread article when entering a group.
254 If this variable is `best', select the highest-scored unread article
255 in the group. If neither nil nor `best', select the first unread
258 If you want to prevent automatic selection of the first unread article
259 in some newsgroups, set the variable to nil in
260 `gnus-select-group-hook'."
261 :group 'gnus-group-select
262 :type '(choice (const :tag "none" nil)
264 (sexp :menu-tag "first" t)))
266 (defcustom gnus-auto-select-next t
267 "*If non-nil, offer to go to the next group from the end of the previous.
268 If the value is t and the next newsgroup is empty, Gnus will exit
269 summary mode and go back to group mode. If the value is neither nil
270 nor t, Gnus will select the following unread newsgroup. In
271 particular, if the value is the symbol `quietly', the next unread
272 newsgroup will be selected without any confirmation, and if it is
273 `almost-quietly', the next group will be selected without any
274 confirmation if you are located on the last article in the group.
275 Finally, if this variable is `slightly-quietly', the `Z n' command
276 will go to the next group without confirmation."
277 :group 'gnus-summary-maneuvering
278 :type '(choice (const :tag "off" nil)
280 (const almost-quietly)
281 (const slightly-quietly)
282 (sexp :menu-tag "on" t)))
284 (defcustom gnus-auto-select-same nil
285 "*If non-nil, select the next article with the same subject."
286 :group 'gnus-summary-maneuvering
289 (defcustom gnus-summary-check-current nil
290 "*If non-nil, consider the current article when moving.
291 The \"unread\" movement commands will stay on the same line if the
292 current article is unread."
293 :group 'gnus-summary-maneuvering
296 (defcustom gnus-auto-center-summary t
297 "*If non-nil, always center the current summary buffer.
298 In particular, if `vertical' do only vertical recentering. If non-nil
299 and non-`vertical', do both horizontal and vertical recentering."
300 :group 'gnus-summary-maneuvering
301 :type '(choice (const :tag "none" nil)
303 (sexp :menu-tag "both" t)))
305 (defcustom gnus-show-all-headers nil
306 "*If non-nil, don't hide any headers."
307 :group 'gnus-article-hiding
308 :group 'gnus-article-headers
311 (defcustom gnus-summary-ignore-duplicates nil
312 "*If non-nil, ignore articles with identical Message-ID headers."
316 (defcustom gnus-single-article-buffer t
317 "*If non-nil, display all articles in the same buffer.
318 If nil, each group will get its own article buffer."
319 :group 'gnus-article-various
322 (defcustom gnus-break-pages t
323 "*If non-nil, do page breaking on articles.
324 The page delimiter is specified by the `gnus-page-delimiter'
326 :group 'gnus-article-various
329 (defcustom gnus-show-mime nil
330 "*If non-nil, do mime processing of articles.
331 The articles will simply be fed to the function given by
332 `gnus-show-mime-method'."
333 :group 'gnus-article-mime
336 (defcustom gnus-move-split-methods nil
337 "*Variable used to suggest where articles are to be moved to.
338 It uses the same syntax as the `gnus-split-methods' variable."
339 :group 'gnus-summary-mail
340 :type '(repeat (choice (list :value (fun) function)
341 (cons :value ("" "") regexp (repeat string))
344 (defcustom gnus-unread-mark ?
345 "*Mark used for unread articles."
346 :group 'gnus-summary-marks
349 (defcustom gnus-ticked-mark ?!
350 "*Mark used for ticked articles."
351 :group 'gnus-summary-marks
354 (defcustom gnus-dormant-mark ??
355 "*Mark used for dormant articles."
356 :group 'gnus-summary-marks
359 (defcustom gnus-del-mark ?r
360 "*Mark used for del'd articles."
361 :group 'gnus-summary-marks
364 (defcustom gnus-read-mark ?R
365 "*Mark used for read articles."
366 :group 'gnus-summary-marks
369 (defcustom gnus-expirable-mark ?E
370 "*Mark used for expirable articles."
371 :group 'gnus-summary-marks
374 (defcustom gnus-killed-mark ?K
375 "*Mark used for killed articles."
376 :group 'gnus-summary-marks
379 (defcustom gnus-souped-mark ?F
380 "*Mark used for killed articles."
381 :group 'gnus-summary-marks
384 (defcustom gnus-kill-file-mark ?X
385 "*Mark used for articles killed by kill files."
386 :group 'gnus-summary-marks
389 (defcustom gnus-low-score-mark ?Y
390 "*Mark used for articles with a low score."
391 :group 'gnus-summary-marks
394 (defcustom gnus-catchup-mark ?C
395 "*Mark used for articles that are caught up."
396 :group 'gnus-summary-marks
399 (defcustom gnus-replied-mark ?A
400 "*Mark used for articles that have been replied to."
401 :group 'gnus-summary-marks
404 (defcustom gnus-cached-mark ?*
405 "*Mark used for articles that are in the cache."
406 :group 'gnus-summary-marks
409 (defcustom gnus-saved-mark ?S
410 "*Mark used for articles that have been saved to."
411 :group 'gnus-summary-marks
414 (defcustom gnus-ancient-mark ?O
415 "*Mark used for ancient articles."
416 :group 'gnus-summary-marks
419 (defcustom gnus-sparse-mark ?Q
420 "*Mark used for sparsely reffed articles."
421 :group 'gnus-summary-marks
424 (defcustom gnus-canceled-mark ?G
425 "*Mark used for canceled articles."
426 :group 'gnus-summary-marks
429 (defcustom gnus-duplicate-mark ?M
430 "*Mark used for duplicate articles."
431 :group 'gnus-summary-marks
434 (defcustom gnus-undownloaded-mark ?@
435 "*Mark used for articles that weren't downloaded."
436 :group 'gnus-summary-marks
439 (defcustom gnus-downloadable-mark ?%
440 "*Mark used for articles that are to be downloaded."
441 :group 'gnus-summary-marks
444 (defcustom gnus-unsendable-mark ?=
445 "*Mark used for articles that won't be sent."
446 :group 'gnus-summary-marks
449 (defcustom gnus-score-over-mark ?+
450 "*Score mark used for articles with high scores."
451 :group 'gnus-summary-marks
454 (defcustom gnus-score-below-mark ?-
455 "*Score mark used for articles with low scores."
456 :group 'gnus-summary-marks
459 (defcustom gnus-empty-thread-mark ?
460 "*There is no thread under the article."
461 :group 'gnus-summary-marks
464 (defcustom gnus-not-empty-thread-mark ?=
465 "*There is a thread under the article."
466 :group 'gnus-summary-marks
469 (defcustom gnus-view-pseudo-asynchronously nil
470 "*If non-nil, Gnus will view pseudo-articles asynchronously."
471 :group 'gnus-extract-view
474 (defcustom gnus-view-pseudos nil
475 "*If `automatic', pseudo-articles will be viewed automatically.
476 If `not-confirm', pseudos will be viewed automatically, and the user
477 will not be asked to confirm the command."
478 :group 'gnus-extract-view
479 :type '(choice (const :tag "off" nil)
481 (const not-confirm)))
483 (defcustom gnus-view-pseudos-separately t
484 "*If non-nil, one pseudo-article will be created for each file to be viewed.
485 If nil, all files that use the same viewing command will be given as a
486 list of parameters to that command."
487 :group 'gnus-extract-view
490 (defcustom gnus-insert-pseudo-articles t
491 "*If non-nil, insert pseudo-articles when decoding articles."
492 :group 'gnus-extract-view
495 (defcustom gnus-summary-dummy-line-format
497 "*The format specification for the dummy roots in the summary buffer.
498 It works along the same lines as a normal formatting string,
499 with some simple extensions.
502 :group 'gnus-threading
505 (defcustom gnus-summary-mode-line-format "Gnus: %%b [%A] %Z"
506 "*The format specification for the summary mode line.
507 It works along the same lines as a normal formatting string,
508 with some simple extensions:
511 %p Unprefixed group name
512 %A Current article number
513 %z Current article score
515 %U Number of unread articles in the group
516 %e Number of unselected articles in the group
517 %Z A string with unread/unselected article counts
518 %g Shortish group name
519 %S Subject of the current article
521 %s Current score file name
522 %d Number of dormant articles
523 %r Number of articles that have been marked as read in this session
524 %E Number of articles expunged by the score files"
525 :group 'gnus-summary-format
528 (defcustom gnus-summary-mark-below 0
529 "*Mark all articles with a score below this variable as read.
530 This variable is local to each summary buffer and usually set by the
532 :group 'gnus-score-default
535 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
536 "*List of functions used for sorting articles in the summary buffer.
537 This variable is only used when not using a threaded display."
538 :group 'gnus-summary-sort
539 :type '(repeat (choice (function-item gnus-article-sort-by-number)
540 (function-item gnus-article-sort-by-author)
541 (function-item gnus-article-sort-by-subject)
542 (function-item gnus-article-sort-by-date)
543 (function-item gnus-article-sort-by-score)
544 (function :tag "other"))))
546 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
547 "*List of functions used for sorting threads in the summary buffer.
548 By default, threads are sorted by article number.
550 Each function takes two threads and return non-nil if the first thread
551 should be sorted before the other. If you use more than one function,
552 the primary sort function should be the last. You should probably
553 always include `gnus-thread-sort-by-number' in the list of sorting
554 functions -- preferably first.
556 Ready-made functions include `gnus-thread-sort-by-number',
557 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
558 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
559 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function')."
560 :group 'gnus-summary-sort
561 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
562 (function-item gnus-thread-sort-by-author)
563 (function-item gnus-thread-sort-by-subject)
564 (function-item gnus-thread-sort-by-date)
565 (function-item gnus-thread-sort-by-score)
566 (function-item gnus-thread-sort-by-total-score)
567 (function :tag "other"))))
569 (defcustom gnus-thread-score-function '+
570 "*Function used for calculating the total score of a thread.
572 The function is called with the scores of the article and each
573 subthread and should then return the score of the thread.
575 Some functions you can use are `+', `max', or `min'."
576 :group 'gnus-summary-sort
579 (defcustom gnus-summary-expunge-below nil
580 "All articles that have a score less than this variable will be expunged.
581 This variable is local to the summary buffers."
582 :group 'gnus-score-default
583 :type '(choice (const :tag "off" nil)
586 (defcustom gnus-thread-expunge-below nil
587 "All threads that have a total score less than this variable will be expunged.
588 See `gnus-thread-score-function' for en explanation of what a
591 This variable is local to the summary buffers."
592 :group 'gnus-treading
593 :group 'gnus-score-default
594 :type '(choice (const :tag "off" nil)
597 (defcustom gnus-summary-mode-hook nil
598 "*A hook for Gnus summary mode.
599 This hook is run before any variables are set in the summary buffer."
600 :group 'gnus-summary-various
603 (defcustom gnus-summary-menu-hook nil
604 "*Hook run after the creation of the summary mode menu."
605 :group 'gnus-summary-visual
608 (defcustom gnus-summary-exit-hook nil
609 "*A hook called on exit from the summary buffer.
610 It will be called with point in the group buffer."
611 :group 'gnus-summary-exit
614 (defcustom gnus-summary-prepare-hook nil
615 "*A hook called after the summary buffer has been generated.
616 If you want to modify the summary buffer, you can use this hook."
617 :group 'gnus-summary-various
620 (defcustom gnus-summary-prepared-hook nil
621 "*A hook called as the last thing after the summary buffer has been generated."
622 :group 'gnus-summary-various
625 (defcustom gnus-summary-generate-hook nil
626 "*A hook run just before generating the summary buffer.
627 This hook is commonly used to customize threading variables and the
629 :group 'gnus-summary-various
632 (defcustom gnus-select-group-hook nil
633 "*A hook called when a newsgroup is selected.
635 If you'd like to simplify subjects like the
636 `gnus-summary-next-same-subject' command does, you can use the
639 (setq gnus-select-group-hook
642 (mapcar (lambda (header)
643 (mail-header-set-subject
645 (gnus-simplify-subject
646 (mail-header-subject header) 're-only)))
647 gnus-newsgroup-headers))))"
648 :group 'gnus-group-select
651 (defcustom gnus-select-article-hook nil
652 "*A hook called when an article is selected."
653 :group 'gnus-summary-choose
656 (defcustom gnus-visual-mark-article-hook
657 (list 'gnus-highlight-selected-summary)
658 "*Hook run after selecting an article in the summary buffer.
659 It is meant to be used for highlighting the article in some way. It
660 is not run if `gnus-visual' is nil."
661 :group 'gnus-summary-visual
664 (defcustom gnus-structured-field-decoder 'identity
665 "Function to decode non-ASCII characters in structured field for summary."
669 (defcustom gnus-unstructured-field-decoder 'identity
670 "Function to decode non-ASCII characters in unstructured field for summary."
674 (defcustom gnus-parse-headers-hook
675 (list 'gnus-hack-decode-rfc1522 'gnus-decode-rfc1522)
676 "*A hook called before parsing the headers."
680 (defcustom gnus-exit-group-hook nil
681 "*A hook called when exiting (not quitting) summary mode."
685 (defcustom gnus-summary-update-hook
686 (list 'gnus-summary-highlight-line)
687 "*A hook called when a summary line is changed.
688 The hook will not be called if `gnus-visual' is nil.
690 The default function `gnus-summary-highlight-line' will
691 highlight the line according to the `gnus-summary-highlight'
693 :group 'gnus-summary-visual
696 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
697 "*A hook called when an article is selected for the first time.
698 The hook is intended to mark an article as read (or unread)
699 automatically when it is selected."
700 :group 'gnus-summary-choose
703 (defcustom gnus-group-no-more-groups-hook nil
704 "*A hook run when returning to group mode having no more (unread) groups."
705 :group 'gnus-group-select
708 (defcustom gnus-ps-print-hook nil
709 "*A hook run before ps-printing something from Gnus."
713 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
714 "Face used for highlighting the current article in the summary buffer."
715 :group 'gnus-summary-visual
718 (defcustom gnus-summary-highlight
719 '(((= mark gnus-canceled-mark)
720 . gnus-summary-cancelled-face)
721 ((and (> score default)
722 (or (= mark gnus-dormant-mark)
723 (= mark gnus-ticked-mark)))
724 . gnus-summary-high-ticked-face)
725 ((and (< score default)
726 (or (= mark gnus-dormant-mark)
727 (= mark gnus-ticked-mark)))
728 . gnus-summary-low-ticked-face)
729 ((or (= mark gnus-dormant-mark)
730 (= mark gnus-ticked-mark))
731 . gnus-summary-normal-ticked-face)
732 ((and (> score default) (= mark gnus-ancient-mark))
733 . gnus-summary-high-ancient-face)
734 ((and (< score default) (= mark gnus-ancient-mark))
735 . gnus-summary-low-ancient-face)
736 ((= mark gnus-ancient-mark)
737 . gnus-summary-normal-ancient-face)
738 ((and (> score default) (= mark gnus-unread-mark))
739 . gnus-summary-high-unread-face)
740 ((and (< score default) (= mark gnus-unread-mark))
741 . gnus-summary-low-unread-face)
742 ((= mark gnus-unread-mark)
743 . gnus-summary-normal-unread-face)
744 ((and (> score default) (memq mark (list gnus-downloadable-mark
745 gnus-undownloaded-mark)))
746 . gnus-summary-high-unread-face)
747 ((and (< score default) (memq mark (list gnus-downloadable-mark
748 gnus-undownloaded-mark)))
749 . gnus-summary-low-unread-face)
750 ((memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
751 . gnus-summary-normal-unread-face)
753 . gnus-summary-high-read-face)
755 . gnus-summary-low-read-face)
757 . gnus-summary-normal-read-face))
758 "*Controls the highlighting of summary buffer lines.
760 A list of (FORM . FACE) pairs. When deciding how a a particular
761 summary line should be displayed, each form is evaluated. The content
762 of the face field after the first true form is used. You can change
763 how those summary lines are displayed, by editing the face field.
765 You can use the following variables in the FORM field.
767 score: The articles score
768 default: The default article score.
769 below: The score below which articles are automatically marked as read.
770 mark: The articles mark."
771 :group 'gnus-summary-visual
772 :type '(repeat (cons (sexp :tag "Form" nil)
775 (defcustom gnus-alter-header-function nil
776 "Function called to allow alteration of article header structures.
777 The function is called with one parameter, the article header vector,
778 which it may alter in any way.")
780 ;;; Internal variables
782 (defvar gnus-scores-exclude-files nil)
783 (defvar gnus-page-broken nil)
785 (defvar gnus-original-article nil)
786 (defvar gnus-article-internal-prepare-hook nil)
787 (defvar gnus-newsgroup-process-stack nil)
789 (defvar gnus-thread-indent-array nil)
790 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
792 ;; Avoid highlighting in kill files.
793 (defvar gnus-summary-inhibit-highlight nil)
794 (defvar gnus-newsgroup-selected-overlay nil)
795 (defvar gnus-inhibit-limiting nil)
796 (defvar gnus-newsgroup-adaptive-score-file nil)
797 (defvar gnus-current-score-file nil)
798 (defvar gnus-current-move-group nil)
799 (defvar gnus-current-copy-group nil)
800 (defvar gnus-current-crosspost-group nil)
802 (defvar gnus-newsgroup-dependencies nil)
803 (defvar gnus-newsgroup-adaptive nil)
804 (defvar gnus-summary-display-article-function nil)
805 (defvar gnus-summary-highlight-line-function nil
806 "Function called after highlighting a summary line.")
808 (defvar gnus-summary-line-format-alist
809 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
810 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
811 (?s gnus-tmp-subject-or-nil ?s)
812 (?n gnus-tmp-name ?s)
813 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
815 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
817 (?F gnus-tmp-from ?s)
818 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
819 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
820 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
821 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
822 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
823 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
824 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
825 (?L gnus-tmp-lines ?d)
826 (?I gnus-tmp-indentation ?s)
827 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
828 (?R gnus-tmp-replied ?c)
829 (?\[ gnus-tmp-opening-bracket ?c)
830 (?\] gnus-tmp-closing-bracket ?c)
831 (?\> (make-string gnus-tmp-level ? ) ?s)
832 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
833 (?i gnus-tmp-score ?d)
834 (?z gnus-tmp-score-char ?c)
835 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
836 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
837 (?U gnus-tmp-unread ?c)
838 (?t (gnus-summary-number-of-articles-in-thread
839 (and (boundp 'thread) (car thread)) gnus-tmp-level)
841 (?e (gnus-summary-number-of-articles-in-thread
842 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
844 (?u gnus-tmp-user-defined ?s)
845 (?P (gnus-pick-line-number) ?d))
846 "An alist of format specifications that can appear in summary lines,
847 and what variables they correspond with, along with the type of the
848 variable (string, integer, character, etc).")
850 (defvar gnus-summary-dummy-line-format-alist
851 `((?S gnus-tmp-subject ?s)
852 (?N gnus-tmp-number ?d)
853 (?u gnus-tmp-user-defined ?s)))
855 (defvar gnus-summary-mode-line-format-alist
856 `((?G gnus-tmp-group-name ?s)
857 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
858 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
859 (?A gnus-tmp-article-number ?d)
860 (?Z gnus-tmp-unread-and-unselected ?s)
862 (?U gnus-tmp-unread-and-unticked ?d)
863 (?S gnus-tmp-subject ?s)
864 (?e gnus-tmp-unselected ?d)
865 (?u gnus-tmp-user-defined ?s)
866 (?d (length gnus-newsgroup-dormant) ?d)
867 (?t (length gnus-newsgroup-marked) ?d)
868 (?r (length gnus-newsgroup-reads) ?d)
869 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
870 (?E gnus-newsgroup-expunged-tally ?d)
871 (?s (gnus-current-score-file-nondirectory) ?s)))
873 (defvar gnus-last-search-regexp nil
874 "Default regexp for article search command.")
876 (defvar gnus-last-shell-command nil
877 "Default shell command on article.")
879 (defvar gnus-newsgroup-begin nil)
880 (defvar gnus-newsgroup-end nil)
881 (defvar gnus-newsgroup-last-rmail nil)
882 (defvar gnus-newsgroup-last-mail nil)
883 (defvar gnus-newsgroup-last-folder nil)
884 (defvar gnus-newsgroup-last-file nil)
885 (defvar gnus-newsgroup-auto-expire nil)
886 (defvar gnus-newsgroup-active nil)
888 (defvar gnus-newsgroup-data nil)
889 (defvar gnus-newsgroup-data-reverse nil)
890 (defvar gnus-newsgroup-limit nil)
891 (defvar gnus-newsgroup-limits nil)
893 (defvar gnus-newsgroup-unreads nil
894 "List of unread articles in the current newsgroup.")
896 (defvar gnus-newsgroup-unselected nil
897 "List of unselected unread articles in the current newsgroup.")
899 (defvar gnus-newsgroup-reads nil
900 "Alist of read articles and article marks in the current newsgroup.")
902 (defvar gnus-newsgroup-expunged-tally nil)
904 (defvar gnus-newsgroup-marked nil
905 "List of ticked articles in the current newsgroup (a subset of unread art).")
907 (defvar gnus-newsgroup-killed nil
908 "List of ranges of articles that have been through the scoring process.")
910 (defvar gnus-newsgroup-cached nil
911 "List of articles that come from the article cache.")
913 (defvar gnus-newsgroup-saved nil
914 "List of articles that have been saved.")
916 (defvar gnus-newsgroup-kill-headers nil)
918 (defvar gnus-newsgroup-replied nil
919 "List of articles that have been replied to in the current newsgroup.")
921 (defvar gnus-newsgroup-expirable nil
922 "List of articles in the current newsgroup that can be expired.")
924 (defvar gnus-newsgroup-processable nil
925 "List of articles in the current newsgroup that can be processed.")
927 (defvar gnus-newsgroup-downloadable nil
928 "List of articles in the current newsgroup that can be processed.")
930 (defvar gnus-newsgroup-undownloaded nil
931 "List of articles in the current newsgroup that haven't been downloaded..")
933 (defvar gnus-newsgroup-unsendable nil
934 "List of articles in the current newsgroup that won't be sent.")
936 (defvar gnus-newsgroup-bookmarks nil
937 "List of articles in the current newsgroup that have bookmarks.")
939 (defvar gnus-newsgroup-dormant nil
940 "List of dormant articles in the current newsgroup.")
942 (defvar gnus-newsgroup-scored nil
943 "List of scored articles in the current newsgroup.")
945 (defvar gnus-newsgroup-headers nil
946 "List of article headers in the current newsgroup.")
948 (defvar gnus-newsgroup-threads nil)
950 (defvar gnus-newsgroup-prepared nil
951 "Whether the current group has been prepared properly.")
953 (defvar gnus-newsgroup-ancient nil
954 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
956 (defvar gnus-newsgroup-sparse nil)
958 (defvar gnus-current-article nil)
959 (defvar gnus-article-current nil)
960 (defvar gnus-current-headers nil)
961 (defvar gnus-have-all-headers nil)
962 (defvar gnus-last-article nil)
963 (defvar gnus-newsgroup-history nil)
965 (defconst gnus-summary-local-variables
966 '(gnus-newsgroup-name
967 gnus-newsgroup-begin gnus-newsgroup-end
968 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
969 gnus-newsgroup-last-folder gnus-newsgroup-last-file
970 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
971 gnus-newsgroup-unselected gnus-newsgroup-marked
972 gnus-newsgroup-reads gnus-newsgroup-saved
973 gnus-newsgroup-replied gnus-newsgroup-expirable
974 gnus-newsgroup-processable gnus-newsgroup-killed
975 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
976 gnus-newsgroup-unsendable
977 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
978 gnus-newsgroup-headers gnus-newsgroup-threads
979 gnus-newsgroup-prepared gnus-summary-highlight-line-function
980 gnus-current-article gnus-current-headers gnus-have-all-headers
981 gnus-last-article gnus-article-internal-prepare-hook
982 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
983 gnus-newsgroup-scored gnus-newsgroup-kill-headers
984 gnus-thread-expunge-below
985 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
986 (gnus-summary-mark-below . global)
987 gnus-newsgroup-active gnus-scores-exclude-files
988 gnus-newsgroup-history gnus-newsgroup-ancient
989 gnus-newsgroup-sparse gnus-newsgroup-process-stack
990 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
991 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
992 (gnus-newsgroup-expunged-tally . 0)
993 gnus-cache-removable-articles gnus-newsgroup-cached
994 gnus-newsgroup-data gnus-newsgroup-data-reverse
995 gnus-newsgroup-limit gnus-newsgroup-limits)
996 "Variables that are buffer-local to the summary buffers.")
998 ;; Byte-compiler warning.
999 (defvar gnus-article-mode-map)
1001 ;; Subject simplification.
1003 (defun gnus-simplify-whitespace (str)
1004 "Remove excessive whitespace."
1007 (while (string-match "[ \t][ \t]+" mystr)
1008 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1010 (substring mystr (match-end 0)))))
1012 (when (string-match "^[ \t]+" mystr)
1013 (setq mystr (substring mystr (match-end 0))))
1015 (when (string-match "[ \t]+$" mystr)
1016 (setq mystr (substring mystr 0 (match-beginning 0))))
1019 (defsubst gnus-simplify-subject-re (subject)
1020 "Remove \"Re:\" from subject lines."
1021 (if (string-match "^[Rr][Ee]: *" subject)
1022 (substring subject (match-end 0))
1025 (defun gnus-simplify-subject (subject &optional re-only)
1026 "Remove `Re:' and words in parentheses.
1027 If RE-ONLY is non-nil, strip leading `Re:'s only."
1028 (let ((case-fold-search t)) ;Ignore case.
1029 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1030 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1031 (setq subject (substring subject (match-end 0))))
1032 ;; Remove uninteresting prefixes.
1033 (when (and (not re-only)
1034 gnus-simplify-ignored-prefixes
1035 (string-match gnus-simplify-ignored-prefixes subject))
1036 (setq subject (substring subject (match-end 0))))
1037 ;; Remove words in parentheses from end.
1039 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1040 (setq subject (substring subject 0 (match-beginning 0)))))
1041 ;; Return subject string.
1044 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1046 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1047 (goto-char (point-min))
1048 (while (re-search-forward regexp nil t)
1049 (replace-match (or newtext ""))))
1051 (defun gnus-simplify-buffer-fuzzy ()
1052 "Simplify string in the buffer fuzzily.
1053 The string in the accessible portion of the current buffer is simplified.
1054 It is assumed to be a single-line subject.
1055 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1056 matter is removed. Additional things can be deleted by setting
1057 gnus-simplify-subject-fuzzy-regexp."
1058 (let ((case-fold-search t)
1060 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1062 (while (not (eq modified-tick (buffer-modified-tick)))
1063 (setq modified-tick (buffer-modified-tick))
1065 ((listp gnus-simplify-subject-fuzzy-regexp)
1066 (mapcar 'gnus-simplify-buffer-fuzzy-step
1067 gnus-simplify-subject-fuzzy-regexp))
1068 (gnus-simplify-subject-fuzzy-regexp
1069 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1070 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1071 (gnus-simplify-buffer-fuzzy-step
1072 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1073 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1075 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1076 (gnus-simplify-buffer-fuzzy-step " +" " ")
1077 (gnus-simplify-buffer-fuzzy-step " $")
1078 (gnus-simplify-buffer-fuzzy-step "^ +")))
1080 (defun gnus-simplify-subject-fuzzy (subject)
1081 "Simplify a subject string fuzzily.
1082 See `gnus-simplify-buffer-fuzzy' for details."
1084 (gnus-set-work-buffer)
1085 (let ((case-fold-search t))
1086 ;; Remove uninteresting prefixes.
1087 (when (and gnus-simplify-ignored-prefixes
1088 (string-match gnus-simplify-ignored-prefixes subject))
1089 (setq subject (substring subject (match-end 0))))
1091 (inline (gnus-simplify-buffer-fuzzy))
1094 (defsubst gnus-simplify-subject-fully (subject)
1095 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1097 (gnus-simplify-subject-functions
1098 (gnus-map-function gnus-simplify-subject-functions subject))
1099 ((null gnus-summary-gather-subject-limit)
1100 (gnus-simplify-subject-re subject))
1101 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1102 (gnus-simplify-subject-fuzzy subject))
1103 ((numberp gnus-summary-gather-subject-limit)
1104 (gnus-limit-string (gnus-simplify-subject-re subject)
1105 gnus-summary-gather-subject-limit))
1109 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1110 "Check whether two subjects are equal.
1111 If optional argument simple-first is t, first argument is already
1114 ((null simple-first)
1115 (equal (gnus-simplify-subject-fully s1)
1116 (gnus-simplify-subject-fully s2)))
1119 (gnus-simplify-subject-fully s2)))))
1121 (defun gnus-summary-bubble-group ()
1122 "Increase the score of the current group.
1123 This is a handy function to add to `gnus-summary-exit-hook' to
1124 increase the score of each group you read."
1125 (gnus-group-add-score gnus-newsgroup-name))
1129 ;;; Gnus summary mode
1132 (put 'gnus-summary-mode 'mode-class 'special)
1135 ;; Non-orthogonal keys
1137 (gnus-define-keys gnus-summary-mode-map
1138 " " gnus-summary-next-page
1139 "\177" gnus-summary-prev-page
1140 [delete] gnus-summary-prev-page
1141 [backspace] gnus-summary-prev-page
1142 "\r" gnus-summary-scroll-up
1143 "n" gnus-summary-next-unread-article
1144 "p" gnus-summary-prev-unread-article
1145 "N" gnus-summary-next-article
1146 "P" gnus-summary-prev-article
1147 "\M-\C-n" gnus-summary-next-same-subject
1148 "\M-\C-p" gnus-summary-prev-same-subject
1149 "\M-n" gnus-summary-next-unread-subject
1150 "\M-p" gnus-summary-prev-unread-subject
1151 "." gnus-summary-first-unread-article
1152 "," gnus-summary-best-unread-article
1153 "\M-s" gnus-summary-search-article-forward
1154 "\M-r" gnus-summary-search-article-backward
1155 "<" gnus-summary-beginning-of-article
1156 ">" gnus-summary-end-of-article
1157 "j" gnus-summary-goto-article
1158 "^" gnus-summary-refer-parent-article
1159 "\M-^" gnus-summary-refer-article
1160 "u" gnus-summary-tick-article-forward
1161 "!" gnus-summary-tick-article-forward
1162 "U" gnus-summary-tick-article-backward
1163 "d" gnus-summary-mark-as-read-forward
1164 "D" gnus-summary-mark-as-read-backward
1165 "E" gnus-summary-mark-as-expirable
1166 "\M-u" gnus-summary-clear-mark-forward
1167 "\M-U" gnus-summary-clear-mark-backward
1168 "k" gnus-summary-kill-same-subject-and-select
1169 "\C-k" gnus-summary-kill-same-subject
1170 "\M-\C-k" gnus-summary-kill-thread
1171 "\M-\C-l" gnus-summary-lower-thread
1172 "e" gnus-summary-edit-article
1173 "#" gnus-summary-mark-as-processable
1174 "\M-#" gnus-summary-unmark-as-processable
1175 "\M-\C-t" gnus-summary-toggle-threads
1176 "\M-\C-s" gnus-summary-show-thread
1177 "\M-\C-h" gnus-summary-hide-thread
1178 "\M-\C-f" gnus-summary-next-thread
1179 "\M-\C-b" gnus-summary-prev-thread
1180 "\M-\C-u" gnus-summary-up-thread
1181 "\M-\C-d" gnus-summary-down-thread
1182 "&" gnus-summary-execute-command
1183 "c" gnus-summary-catchup-and-exit
1184 "\C-w" gnus-summary-mark-region-as-read
1185 "\C-t" gnus-summary-toggle-truncation
1186 "?" gnus-summary-mark-as-dormant
1187 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1188 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1189 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1190 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1191 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1192 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1193 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1194 "=" gnus-summary-expand-window
1195 "\C-x\C-s" gnus-summary-reselect-current-group
1196 "\M-g" gnus-summary-rescan-group
1197 "w" gnus-summary-stop-page-breaking
1198 "\C-c\C-r" gnus-summary-caesar-message
1199 "\M-t" gnus-summary-toggle-mime
1200 "f" gnus-summary-followup
1201 "F" gnus-summary-followup-with-original
1202 "C" gnus-summary-cancel-article
1203 "r" gnus-summary-reply
1204 "R" gnus-summary-reply-with-original
1205 "\C-c\C-f" gnus-summary-mail-forward
1206 "o" gnus-summary-save-article
1207 "\C-o" gnus-summary-save-article-mail
1208 "|" gnus-summary-pipe-output
1209 "\M-k" gnus-summary-edit-local-kill
1210 "\M-K" gnus-summary-edit-global-kill
1212 "\C-c\C-d" gnus-summary-describe-group
1213 "q" gnus-summary-exit
1214 "Q" gnus-summary-exit-no-update
1215 "\C-c\C-i" gnus-info-find-node
1216 gnus-mouse-2 gnus-mouse-pick-article
1217 "m" gnus-summary-mail-other-window
1218 "a" gnus-summary-post-news
1219 "x" gnus-summary-limit-to-unread
1220 "s" gnus-summary-isearch-article
1221 "t" gnus-article-hide-headers
1222 "g" gnus-summary-show-article
1223 "l" gnus-summary-goto-last-article
1224 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1225 "\C-d" gnus-summary-enter-digest-group
1226 "\M-\C-d" gnus-summary-read-document
1227 "\M-\C-e" gnus-summary-edit-parameters
1229 "*" gnus-cache-enter-article
1230 "\M-*" gnus-cache-remove-article
1231 "\M-&" gnus-summary-universal-argument
1232 "\C-l" gnus-recenter
1233 "I" gnus-summary-increase-score
1234 "L" gnus-summary-lower-score
1235 "\M-i" gnus-symbolic-argument
1236 "h" gnus-summary-select-article-buffer
1238 "V" gnus-summary-score-map
1239 "X" gnus-uu-extract-map
1240 "S" gnus-summary-send-map)
1242 ;; Sort of orthogonal keymap
1243 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1244 "t" gnus-summary-tick-article-forward
1245 "!" gnus-summary-tick-article-forward
1246 "d" gnus-summary-mark-as-read-forward
1247 "r" gnus-summary-mark-as-read-forward
1248 "c" gnus-summary-clear-mark-forward
1249 " " gnus-summary-clear-mark-forward
1250 "e" gnus-summary-mark-as-expirable
1251 "x" gnus-summary-mark-as-expirable
1252 "?" gnus-summary-mark-as-dormant
1253 "b" gnus-summary-set-bookmark
1254 "B" gnus-summary-remove-bookmark
1255 "#" gnus-summary-mark-as-processable
1256 "\M-#" gnus-summary-unmark-as-processable
1257 "S" gnus-summary-limit-include-expunged
1258 "C" gnus-summary-catchup
1259 "H" gnus-summary-catchup-to-here
1260 "\C-c" gnus-summary-catchup-all
1261 "k" gnus-summary-kill-same-subject-and-select
1262 "K" gnus-summary-kill-same-subject
1263 "P" gnus-uu-mark-map)
1265 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1266 "c" gnus-summary-clear-above
1267 "u" gnus-summary-tick-above
1268 "m" gnus-summary-mark-above
1269 "k" gnus-summary-kill-below)
1271 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1272 "/" gnus-summary-limit-to-subject
1273 "n" gnus-summary-limit-to-articles
1274 "w" gnus-summary-pop-limit
1275 "s" gnus-summary-limit-to-subject
1276 "a" gnus-summary-limit-to-author
1277 "u" gnus-summary-limit-to-unread
1278 "m" gnus-summary-limit-to-marks
1279 "v" gnus-summary-limit-to-score
1280 "*" gnus-summary-limit-include-cached
1281 "D" gnus-summary-limit-include-dormant
1282 "T" gnus-summary-limit-include-thread
1283 "d" gnus-summary-limit-exclude-dormant
1284 "t" gnus-summary-limit-to-age
1285 "E" gnus-summary-limit-include-expunged
1286 "c" gnus-summary-limit-exclude-childless-dormant
1287 "C" gnus-summary-limit-mark-excluded-as-read)
1289 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1290 "n" gnus-summary-next-unread-article
1291 "p" gnus-summary-prev-unread-article
1292 "N" gnus-summary-next-article
1293 "P" gnus-summary-prev-article
1294 "\C-n" gnus-summary-next-same-subject
1295 "\C-p" gnus-summary-prev-same-subject
1296 "\M-n" gnus-summary-next-unread-subject
1297 "\M-p" gnus-summary-prev-unread-subject
1298 "f" gnus-summary-first-unread-article
1299 "b" gnus-summary-best-unread-article
1300 "j" gnus-summary-goto-article
1301 "g" gnus-summary-goto-subject
1302 "l" gnus-summary-goto-last-article
1303 "o" gnus-summary-pop-article)
1305 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1306 "k" gnus-summary-kill-thread
1307 "l" gnus-summary-lower-thread
1308 "i" gnus-summary-raise-thread
1309 "T" gnus-summary-toggle-threads
1310 "t" gnus-summary-rethread-current
1311 "^" gnus-summary-reparent-thread
1312 "s" gnus-summary-show-thread
1313 "S" gnus-summary-show-all-threads
1314 "h" gnus-summary-hide-thread
1315 "H" gnus-summary-hide-all-threads
1316 "n" gnus-summary-next-thread
1317 "p" gnus-summary-prev-thread
1318 "u" gnus-summary-up-thread
1319 "o" gnus-summary-top-thread
1320 "d" gnus-summary-down-thread
1321 "#" gnus-uu-mark-thread
1322 "\M-#" gnus-uu-unmark-thread)
1324 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1325 "g" gnus-summary-prepare
1326 "c" gnus-summary-insert-cached-articles)
1328 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1329 "c" gnus-summary-catchup-and-exit
1330 "C" gnus-summary-catchup-all-and-exit
1331 "E" gnus-summary-exit-no-update
1332 "Q" gnus-summary-exit
1333 "Z" gnus-summary-exit
1334 "n" gnus-summary-catchup-and-goto-next-group
1335 "R" gnus-summary-reselect-current-group
1336 "G" gnus-summary-rescan-group
1337 "N" gnus-summary-next-group
1338 "s" gnus-summary-save-newsrc
1339 "P" gnus-summary-prev-group)
1341 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1342 " " gnus-summary-next-page
1343 "n" gnus-summary-next-page
1344 "\177" gnus-summary-prev-page
1345 [delete] gnus-summary-prev-page
1346 "p" gnus-summary-prev-page
1347 "\r" gnus-summary-scroll-up
1348 "<" gnus-summary-beginning-of-article
1349 ">" gnus-summary-end-of-article
1350 "b" gnus-summary-beginning-of-article
1351 "e" gnus-summary-end-of-article
1352 "^" gnus-summary-refer-parent-article
1353 "r" gnus-summary-refer-parent-article
1354 "R" gnus-summary-refer-references
1355 "T" gnus-summary-refer-thread
1356 "g" gnus-summary-show-article
1357 "s" gnus-summary-isearch-article
1358 "P" gnus-summary-print-article)
1360 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1361 "b" gnus-article-add-buttons
1362 "B" gnus-article-add-buttons-to-head
1363 "o" gnus-article-treat-overstrike
1364 "e" gnus-article-emphasize
1365 "w" gnus-article-fill-cited-article
1366 "c" gnus-article-remove-cr
1367 "q" gnus-article-de-quoted-unreadable
1368 "f" gnus-article-display-x-face
1369 "l" gnus-summary-stop-page-breaking
1370 "r" gnus-summary-caesar-message
1371 "t" gnus-article-hide-headers
1372 "v" gnus-summary-verbose-headers
1373 "m" gnus-summary-toggle-mime
1374 "h" gnus-article-treat-html
1375 "d" gnus-article-treat-dumbquotes)
1377 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1378 "a" gnus-article-hide
1379 "h" gnus-article-hide-headers
1380 "b" gnus-article-hide-boring-headers
1381 "s" gnus-article-hide-signature
1382 "c" gnus-article-hide-citation
1383 "p" gnus-article-hide-pgp
1384 "P" gnus-article-hide-pem
1385 "\C-c" gnus-article-hide-citation-maybe)
1387 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1388 "a" gnus-article-highlight
1389 "h" gnus-article-highlight-headers
1390 "c" gnus-article-highlight-citation
1391 "s" gnus-article-highlight-signature)
1393 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1394 "z" gnus-article-date-ut
1395 "u" gnus-article-date-ut
1396 "l" gnus-article-date-local
1397 "e" gnus-article-date-lapsed
1398 "o" gnus-article-date-original
1399 "i" gnus-article-date-iso8601
1400 "s" gnus-article-date-user)
1402 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1403 "t" gnus-article-remove-trailing-blank-lines
1404 "l" gnus-article-strip-leading-blank-lines
1405 "m" gnus-article-strip-multiple-blank-lines
1406 "a" gnus-article-strip-blank-lines
1407 "A" gnus-article-strip-all-blank-lines
1408 "s" gnus-article-strip-leading-space)
1410 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1412 "f" gnus-summary-fetch-faq
1413 "d" gnus-summary-describe-group
1414 "h" gnus-summary-describe-briefly
1415 "i" gnus-info-find-node)
1417 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1418 "e" gnus-summary-expire-articles
1419 "\M-\C-e" gnus-summary-expire-articles-now
1420 "\177" gnus-summary-delete-article
1421 [delete] gnus-summary-delete-article
1422 "m" gnus-summary-move-article
1423 "r" gnus-summary-respool-article
1424 "w" gnus-summary-edit-article
1425 "c" gnus-summary-copy-article
1426 "B" gnus-summary-crosspost-article
1427 "q" gnus-summary-respool-query
1428 "t" gnus-summary-respool-trace
1429 "i" gnus-summary-import-article
1430 "p" gnus-summary-article-posted-p)
1432 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1433 "o" gnus-summary-save-article
1434 "m" gnus-summary-save-article-mail
1435 "F" gnus-summary-write-article-file
1436 "r" gnus-summary-save-article-rmail
1437 "f" gnus-summary-save-article-file
1438 "b" gnus-summary-save-article-body-file
1439 "h" gnus-summary-save-article-folder
1440 "v" gnus-summary-save-article-vm
1441 "p" gnus-summary-pipe-output
1442 "s" gnus-soup-add-article))
1444 (defun gnus-summary-make-menu-bar ()
1445 (gnus-turn-off-edit-menu 'summary)
1447 (unless (boundp 'gnus-summary-misc-menu)
1450 gnus-summary-kill-menu gnus-summary-mode-map ""
1455 ["Enter score..." gnus-summary-score-entry t]
1456 ["Customize" gnus-score-customize t])
1457 (gnus-make-score-map 'increase)
1458 (gnus-make-score-map 'lower)
1460 ["Kill below" gnus-summary-kill-below t]
1461 ["Mark above" gnus-summary-mark-above t]
1462 ["Tick above" gnus-summary-tick-above t]
1463 ["Clear above" gnus-summary-clear-above t])
1464 ["Current score" gnus-summary-current-score t]
1465 ["Set score" gnus-summary-set-score t]
1466 ["Switch current score file..." gnus-score-change-score-file t]
1467 ["Set mark below..." gnus-score-set-mark-below t]
1468 ["Set expunge below..." gnus-score-set-expunge-below t]
1469 ["Edit current score file" gnus-score-edit-current-scores t]
1470 ["Edit score file" gnus-score-edit-file t]
1471 ["Trace score" gnus-score-find-trace t]
1472 ["Find words" gnus-score-find-favourite-words t]
1473 ["Rescore buffer" gnus-summary-rescore t]
1474 ["Increase score..." gnus-summary-increase-score t]
1475 ["Lower score..." gnus-summary-lower-score t]))))
1477 ;; Define both the Article menu in the summary buffer and the equivalent
1478 ;; Commands menu in the article buffer here for consistency.
1481 ["All" gnus-article-hide t]
1482 ["Headers" gnus-article-hide-headers t]
1483 ["Signature" gnus-article-hide-signature t]
1484 ["Citation" gnus-article-hide-citation t]
1485 ["PGP" gnus-article-hide-pgp t]
1486 ["Boring headers" gnus-article-hide-boring-headers t])
1488 ["All" gnus-article-highlight t]
1489 ["Headers" gnus-article-highlight-headers t]
1490 ["Signature" gnus-article-highlight-signature t]
1491 ["Citation" gnus-article-highlight-citation t])
1493 ["Local" gnus-article-date-local t]
1494 ["ISO8601" gnus-article-date-iso8601 t]
1495 ["UT" gnus-article-date-ut t]
1496 ["Original" gnus-article-date-original t]
1497 ["Lapsed" gnus-article-date-lapsed t]
1498 ["User-defined" gnus-article-date-user t])
1501 ["Leading" gnus-article-strip-leading-blank-lines t]
1502 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1503 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1504 ["All of the above" gnus-article-strip-blank-lines t]
1505 ["All" gnus-article-strip-all-blank-lines t]
1506 ["Leading space" gnus-article-strip-leading-space t])
1507 ["Overstrike" gnus-article-treat-overstrike t]
1508 ["Dumb quotes" gnus-article-treat-dumbquotes t]
1509 ["Emphasis" gnus-article-emphasize t]
1510 ["Word wrap" gnus-article-fill-cited-article t]
1511 ["CR" gnus-article-remove-cr t]
1512 ["Show X-Face" gnus-article-display-x-face t]
1513 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
1514 ["UnHTMLize" gnus-article-treat-html t]
1515 ["Rot 13" gnus-summary-caesar-message t]
1516 ["Unix pipe" gnus-summary-pipe-message t]
1517 ["Add buttons" gnus-article-add-buttons t]
1518 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1519 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1520 ["Toggle MIME" gnus-summary-toggle-mime t]
1521 ["Verbose header" gnus-summary-verbose-headers t]
1522 ["Toggle header" gnus-summary-toggle-header t])
1524 ["Save in default format" gnus-summary-save-article t]
1525 ["Save in file" gnus-summary-save-article-file t]
1526 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1527 ["Save in MH folder" gnus-summary-save-article-folder t]
1528 ["Save in VM folder" gnus-summary-save-article-vm t]
1529 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1530 ["Save body in file" gnus-summary-save-article-body-file t]
1531 ["Pipe through a filter" gnus-summary-pipe-output t]
1532 ["Add to SOUP packet" gnus-soup-add-article t]
1533 ["Print" gnus-summary-print-article t])
1535 ["Respool article..." gnus-summary-respool-article t]
1536 ["Move article..." gnus-summary-move-article
1537 (gnus-check-backend-function
1538 'request-move-article gnus-newsgroup-name)]
1539 ["Copy article..." gnus-summary-copy-article t]
1540 ["Crosspost article..." gnus-summary-crosspost-article
1541 (gnus-check-backend-function
1542 'request-replace-article gnus-newsgroup-name)]
1543 ["Import file..." gnus-summary-import-article t]
1544 ["Check if posted" gnus-summary-article-posted-p t]
1545 ["Edit article" gnus-summary-edit-article
1546 (not (gnus-group-read-only-p))]
1547 ["Delete article" gnus-summary-delete-article
1548 (gnus-check-backend-function
1549 'request-expire-articles gnus-newsgroup-name)]
1550 ["Query respool" gnus-summary-respool-query t]
1551 ["Trace respool" gnus-summary-respool-trace t]
1552 ["Delete expirable articles" gnus-summary-expire-articles-now
1553 (gnus-check-backend-function
1554 'request-expire-articles gnus-newsgroup-name)])
1556 ["Uudecode" gnus-uu-decode-uu t]
1557 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1558 ["Unshar" gnus-uu-decode-unshar t]
1559 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1560 ["Save" gnus-uu-decode-save t]
1561 ["Binhex" gnus-uu-decode-binhex t]
1562 ["Postscript" gnus-uu-decode-postscript t])
1564 ["Enter article" gnus-cache-enter-article t]
1565 ["Remove article" gnus-cache-remove-article t])
1566 ["Select article buffer" gnus-summary-select-article-buffer t]
1567 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1568 ["Isearch article..." gnus-summary-isearch-article t]
1569 ["Beginning of the article" gnus-summary-beginning-of-article t]
1570 ["End of the article" gnus-summary-end-of-article t]
1571 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1572 ["Fetch referenced articles" gnus-summary-refer-references t]
1573 ["Fetch current thread" gnus-summary-refer-thread t]
1574 ["Fetch article with id..." gnus-summary-refer-article t]
1575 ["Redisplay" gnus-summary-show-article t])))
1577 gnus-summary-article-menu gnus-summary-mode-map ""
1578 (cons "Article" innards))
1581 gnus-article-commands-menu gnus-article-mode-map ""
1582 (cons "Commands" innards)))
1585 gnus-summary-thread-menu gnus-summary-mode-map ""
1587 ["Toggle threading" gnus-summary-toggle-threads t]
1588 ["Hide threads" gnus-summary-hide-all-threads t]
1589 ["Show threads" gnus-summary-show-all-threads t]
1590 ["Hide thread" gnus-summary-hide-thread t]
1591 ["Show thread" gnus-summary-show-thread t]
1592 ["Go to next thread" gnus-summary-next-thread t]
1593 ["Go to previous thread" gnus-summary-prev-thread t]
1594 ["Go down thread" gnus-summary-down-thread t]
1595 ["Go up thread" gnus-summary-up-thread t]
1596 ["Top of thread" gnus-summary-top-thread t]
1597 ["Mark thread as read" gnus-summary-kill-thread t]
1598 ["Lower thread score" gnus-summary-lower-thread t]
1599 ["Raise thread score" gnus-summary-raise-thread t]
1600 ["Rethread current" gnus-summary-rethread-current t]
1604 gnus-summary-post-menu gnus-summary-mode-map ""
1606 ["Post an article" gnus-summary-post-news t]
1607 ["Followup" gnus-summary-followup t]
1608 ["Followup and yank" gnus-summary-followup-with-original t]
1609 ["Supersede article" gnus-summary-supersede-article t]
1610 ["Cancel article" gnus-summary-cancel-article t]
1611 ["Reply" gnus-summary-reply t]
1612 ["Reply and yank" gnus-summary-reply-with-original t]
1613 ["Wide reply" gnus-summary-wide-reply t]
1614 ["Wide reply and yank" gnus-summary-wide-reply-with-original t]
1615 ["Mail forward" gnus-summary-mail-forward t]
1616 ["Post forward" gnus-summary-post-forward t]
1617 ["Digest and mail" gnus-uu-digest-mail-forward t]
1618 ["Digest and post" gnus-uu-digest-post-forward t]
1619 ["Resend message" gnus-summary-resend-message t]
1620 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
1621 ["Send a mail" gnus-summary-mail-other-window t]
1622 ["Uuencode and post" gnus-uu-post-news t]
1623 ["Followup via news" gnus-summary-followup-to-mail t]
1624 ["Followup via news and yank"
1625 gnus-summary-followup-to-mail-with-original t]
1627 ;;["Send" gnus-summary-send-draft t]
1628 ;;["Send bounced" gnus-resend-bounced-mail t])
1632 gnus-summary-misc-menu gnus-summary-mode-map ""
1635 ["Mark as read" gnus-summary-mark-as-read-forward t]
1636 ["Mark same subject and select"
1637 gnus-summary-kill-same-subject-and-select t]
1638 ["Mark same subject" gnus-summary-kill-same-subject t]
1639 ["Catchup" gnus-summary-catchup t]
1640 ["Catchup all" gnus-summary-catchup-all t]
1641 ["Catchup to here" gnus-summary-catchup-to-here t]
1642 ["Catchup region" gnus-summary-mark-region-as-read t]
1643 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
1645 ["Tick" gnus-summary-tick-article-forward t]
1646 ["Mark as dormant" gnus-summary-mark-as-dormant t]
1647 ["Remove marks" gnus-summary-clear-mark-forward t]
1648 ["Set expirable mark" gnus-summary-mark-as-expirable t]
1649 ["Set bookmark" gnus-summary-set-bookmark t]
1650 ["Remove bookmark" gnus-summary-remove-bookmark t])
1652 ["Marks..." gnus-summary-limit-to-marks t]
1653 ["Subject..." gnus-summary-limit-to-subject t]
1654 ["Author..." gnus-summary-limit-to-author t]
1655 ["Age..." gnus-summary-limit-to-age t]
1656 ["Score" gnus-summary-limit-to-score t]
1657 ["Unread" gnus-summary-limit-to-unread t]
1658 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
1659 ["Articles" gnus-summary-limit-to-articles t]
1660 ["Pop limit" gnus-summary-pop-limit t]
1661 ["Show dormant" gnus-summary-limit-include-dormant t]
1662 ["Hide childless dormant"
1663 gnus-summary-limit-exclude-childless-dormant t]
1664 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
1665 ["Show expunged" gnus-summary-show-all-expunged t])
1667 ["Set mark" gnus-summary-mark-as-processable t]
1668 ["Remove mark" gnus-summary-unmark-as-processable t]
1669 ["Remove all marks" gnus-summary-unmark-all-processable t]
1670 ["Mark above" gnus-uu-mark-over t]
1671 ["Mark series" gnus-uu-mark-series t]
1672 ["Mark region" gnus-uu-mark-region t]
1673 ["Unmark region" gnus-uu-unmark-region t]
1674 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
1675 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
1676 ["Mark all" gnus-uu-mark-all t]
1677 ["Mark buffer" gnus-uu-mark-buffer t]
1678 ["Mark sparse" gnus-uu-mark-sparse t]
1679 ["Mark thread" gnus-uu-mark-thread t]
1680 ["Unmark thread" gnus-uu-unmark-thread t]
1681 ("Process Mark Sets"
1682 ["Kill" gnus-summary-kill-process-mark t]
1683 ["Yank" gnus-summary-yank-process-mark
1684 gnus-newsgroup-process-stack]
1685 ["Save" gnus-summary-save-process-mark t]))
1687 ["Page forward" gnus-summary-next-page t]
1688 ["Page backward" gnus-summary-prev-page t]
1689 ["Line forward" gnus-summary-scroll-up t])
1691 ["Next unread article" gnus-summary-next-unread-article t]
1692 ["Previous unread article" gnus-summary-prev-unread-article t]
1693 ["Next article" gnus-summary-next-article t]
1694 ["Previous article" gnus-summary-prev-article t]
1695 ["Next unread subject" gnus-summary-next-unread-subject t]
1696 ["Previous unread subject" gnus-summary-prev-unread-subject t]
1697 ["Next article same subject" gnus-summary-next-same-subject t]
1698 ["Previous article same subject" gnus-summary-prev-same-subject t]
1699 ["First unread article" gnus-summary-first-unread-article t]
1700 ["Best unread article" gnus-summary-best-unread-article t]
1701 ["Go to subject number..." gnus-summary-goto-subject t]
1702 ["Go to article number..." gnus-summary-goto-article t]
1703 ["Go to the last article" gnus-summary-goto-last-article t]
1704 ["Pop article off history" gnus-summary-pop-article t])
1706 ["Sort by number" gnus-summary-sort-by-number t]
1707 ["Sort by author" gnus-summary-sort-by-author t]
1708 ["Sort by subject" gnus-summary-sort-by-subject t]
1709 ["Sort by date" gnus-summary-sort-by-date t]
1710 ["Sort by score" gnus-summary-sort-by-score t]
1711 ["Sort by lines" gnus-summary-sort-by-lines t])
1713 ["Fetch group FAQ" gnus-summary-fetch-faq t]
1714 ["Describe group" gnus-summary-describe-group t]
1715 ["Read manual" gnus-info-find-node t])
1717 ["Pick and read" gnus-pick-mode t]
1718 ["Binary" gnus-binary-mode t])
1720 ["Regenerate" gnus-summary-prepare t]
1721 ["Insert cached articles" gnus-summary-insert-cached-articles t]
1722 ["Toggle threading" gnus-summary-toggle-threads t])
1723 ["Filter articles..." gnus-summary-execute-command t]
1724 ["Run command on subjects..." gnus-summary-universal-argument t]
1725 ["Search articles forward..." gnus-summary-search-article-forward t]
1726 ["Search articles backward..." gnus-summary-search-article-backward t]
1727 ["Toggle line truncation" gnus-summary-toggle-truncation t]
1728 ["Expand window" gnus-summary-expand-window t]
1729 ["Expire expirable articles" gnus-summary-expire-articles
1730 (gnus-check-backend-function
1731 'request-expire-articles gnus-newsgroup-name)]
1732 ["Edit local kill file" gnus-summary-edit-local-kill t]
1733 ["Edit main kill file" gnus-summary-edit-global-kill t]
1734 ["Edit group parameters" gnus-summary-edit-parameters t]
1735 ["Send a bug report" gnus-bug t]
1737 ["Catchup and exit" gnus-summary-catchup-and-exit t]
1738 ["Catchup all and exit" gnus-summary-catchup-and-exit t]
1739 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
1740 ["Exit group" gnus-summary-exit t]
1741 ["Exit group without updating" gnus-summary-exit-no-update t]
1742 ["Exit and goto next group" gnus-summary-next-group t]
1743 ["Exit and goto prev group" gnus-summary-prev-group t]
1744 ["Reselect group" gnus-summary-reselect-current-group t]
1745 ["Rescan group" gnus-summary-rescan-group t]
1746 ["Update dribble" gnus-summary-save-newsrc t])))
1748 (gnus-run-hooks 'gnus-summary-menu-hook)))
1750 (defun gnus-score-set-default (var value)
1751 "A version of set that updates the GNU Emacs menu-bar."
1753 ;; It is the message that forces the active status to be updated.
1756 (defun gnus-make-score-map (type)
1757 "Make a summary score map of type TYPE."
1760 (let ((headers '(("author" "from" string)
1761 ("subject" "subject" string)
1762 ("article body" "body" string)
1763 ("article head" "head" string)
1764 ("xref" "xref" string)
1765 ("lines" "lines" number)
1766 ("followups to author" "followup" string)))
1767 (types '((number ("less than" <)
1770 (string ("substring" s)
1774 (perms '(("temporary" (current-time-string))
1782 (if (eq type 'lower)
1787 (setq header (car headers))
1793 (let ((ts (cdr (assoc (nth 2 header) types)))
1809 'gnus-summary-score-entry
1811 (if (or (string= (nth 1 header)
1813 (string= (nth 1 header)
1816 (list 'gnus-summary-header
1818 (list 'quote (nth 1 (car ts)))
1819 (list 'gnus-score-default nil)
1825 (list (nreverse outp))))
1828 (list (nreverse outt))))
1830 (setq headers (cdr headers)))
1831 (list (nreverse outh))))))))
1835 (defun gnus-summary-mode (&optional group)
1836 "Major mode for reading articles.
1838 All normal editing commands are switched off.
1839 \\<gnus-summary-mode-map>
1840 Each line in this buffer represents one article. To read an
1841 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
1842 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
1845 You can also post articles and send mail from this buffer. To
1846 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
1847 of an article, type `\\[gnus-summary-reply]'.
1849 There are approx. one gazillion commands you can execute in this
1850 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
1852 The following commands are available:
1854 \\{gnus-summary-mode-map}"
1856 (when (gnus-visual-p 'summary-menu 'menu)
1857 (gnus-summary-make-menu-bar))
1858 (kill-all-local-variables)
1859 (gnus-summary-make-local-variables)
1860 (gnus-make-thread-indent-array)
1861 (gnus-simplify-mode-line)
1862 (setq major-mode 'gnus-summary-mode)
1863 (setq mode-name "Summary")
1864 (make-local-variable 'minor-mode-alist)
1865 (use-local-map gnus-summary-mode-map)
1866 (buffer-disable-undo (current-buffer))
1867 (setq buffer-read-only t) ;Disable modification
1868 (setq truncate-lines t)
1869 (setq selective-display t)
1870 (setq selective-display-ellipses t) ;Display `...'
1871 (gnus-summary-set-display-table)
1872 (gnus-set-default-directory)
1873 (setq gnus-newsgroup-name group)
1874 (make-local-variable 'gnus-summary-line-format)
1875 (make-local-variable 'gnus-summary-line-format-spec)
1876 (make-local-variable 'gnus-summary-dummy-line-format)
1877 (make-local-variable 'gnus-summary-dummy-line-format-spec)
1878 (make-local-variable 'gnus-summary-mark-positions)
1879 (make-local-hook 'post-command-hook)
1880 (add-hook 'post-command-hook 'gnus-clear-inboxes-moved nil t)
1881 (make-local-hook 'pre-command-hook)
1882 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
1883 (gnus-run-hooks 'gnus-summary-mode-hook)
1884 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
1885 (gnus-update-summary-mark-positions))
1887 (defun gnus-summary-make-local-variables ()
1888 "Make all the local summary buffer variables."
1889 (let ((locals gnus-summary-local-variables)
1891 (while (setq local (pop locals))
1894 (if (eq (cdr local) 'global)
1895 ;; Copy the global value of the variable.
1896 (setq global (symbol-value (car local)))
1897 ;; Use the value from the list.
1898 (setq global (eval (cdr local))))
1899 (make-local-variable (car local))
1900 (set (car local) global))
1901 ;; Simple nil-valued local variable.
1902 (make-local-variable local)
1905 (defun gnus-summary-clear-local-variables ()
1906 (let ((locals gnus-summary-local-variables))
1908 (if (consp (car locals))
1909 (and (vectorp (caar locals))
1910 (set (caar locals) nil))
1911 (and (vectorp (car locals))
1912 (set (car locals) nil)))
1913 (setq locals (cdr locals)))))
1915 ;; Summary data functions.
1917 (defmacro gnus-data-number (data)
1920 (defmacro gnus-data-set-number (data number)
1921 `(setcar ,data ,number))
1923 (defmacro gnus-data-mark (data)
1926 (defmacro gnus-data-set-mark (data mark)
1927 `(setcar (nthcdr 1 ,data) ,mark))
1929 (defmacro gnus-data-pos (data)
1932 (defmacro gnus-data-set-pos (data pos)
1933 `(setcar (nthcdr 2 ,data) ,pos))
1935 (defmacro gnus-data-header (data)
1938 (defmacro gnus-data-set-header (data header)
1939 `(setf (nth 3 ,data) ,header))
1941 (defmacro gnus-data-level (data)
1944 (defmacro gnus-data-unread-p (data)
1945 `(= (nth 1 ,data) gnus-unread-mark))
1947 (defmacro gnus-data-read-p (data)
1948 `(/= (nth 1 ,data) gnus-unread-mark))
1950 (defmacro gnus-data-pseudo-p (data)
1951 `(consp (nth 3 ,data)))
1953 (defmacro gnus-data-find (number)
1954 `(assq ,number gnus-newsgroup-data))
1956 (defmacro gnus-data-find-list (number &optional data)
1957 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
1958 (memq (assq ,number bdata)
1961 (defmacro gnus-data-make (number mark pos header level)
1962 `(list ,number ,mark ,pos ,header ,level))
1964 (defun gnus-data-enter (after-article number mark pos header level offset)
1965 (let ((data (gnus-data-find-list after-article)))
1967 (error "No such article: %d" after-article))
1968 (setcdr data (cons (gnus-data-make number mark pos header level)
1970 (setq gnus-newsgroup-data-reverse nil)
1971 (gnus-data-update-list (cddr data) offset)))
1973 (defun gnus-data-enter-list (after-article list &optional offset)
1975 (let ((data (and after-article (gnus-data-find-list after-article)))
1977 (or data (not after-article) (error "No such article: %d" after-article))
1978 ;; Find the last element in the list to be spliced into the main
1981 (setq list (cdr list)))
1984 (setcdr list gnus-newsgroup-data)
1985 (setq gnus-newsgroup-data ilist)
1987 (gnus-data-update-list (cdr list) offset)))
1988 (setcdr list (cdr data))
1991 (gnus-data-update-list (cdr list) offset)))
1992 (setq gnus-newsgroup-data-reverse nil))))
1994 (defun gnus-data-remove (article &optional offset)
1995 (let ((data gnus-newsgroup-data))
1996 (if (= (gnus-data-number (car data)) article)
1998 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
1999 gnus-newsgroup-data-reverse nil)
2001 (gnus-data-update-list gnus-newsgroup-data offset)))
2003 (when (= (gnus-data-number (cadr data)) article)
2004 (setcdr data (cddr data))
2006 (gnus-data-update-list (cdr data) offset))
2008 gnus-newsgroup-data-reverse nil))
2009 (setq data (cdr data))))))
2011 (defmacro gnus-data-list (backward)
2013 (or gnus-newsgroup-data-reverse
2014 (setq gnus-newsgroup-data-reverse
2015 (reverse gnus-newsgroup-data)))
2016 gnus-newsgroup-data))
2018 (defun gnus-data-update-list (data offset)
2019 "Add OFFSET to the POS of all data entries in DATA."
2020 (setq gnus-newsgroup-data-reverse nil)
2022 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2023 (setq data (cdr data))))
2025 (defun gnus-data-compute-positions ()
2026 "Compute the positions of all articles."
2027 (setq gnus-newsgroup-data-reverse nil)
2028 (let ((data gnus-newsgroup-data)
2031 (when (setq pos (text-property-any
2032 (point-min) (point-max)
2033 'gnus-number (gnus-data-number (car data))))
2034 (gnus-data-set-pos (car data) (+ pos 3)))
2035 (setq data (cdr data)))))
2037 (defun gnus-summary-article-pseudo-p (article)
2038 "Say whether this article is a pseudo article or not."
2039 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2041 (defmacro gnus-summary-article-sparse-p (article)
2042 "Say whether this article is a sparse article or not."
2043 `(memq ,article gnus-newsgroup-sparse))
2045 (defmacro gnus-summary-article-ancient-p (article)
2046 "Say whether this article is a sparse article or not."
2047 `(memq ,article gnus-newsgroup-ancient))
2049 (defun gnus-article-parent-p (number)
2050 "Say whether this article is a parent or not."
2051 (let ((data (gnus-data-find-list number)))
2052 (and (cdr data) ; There has to be an article after...
2053 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2054 (gnus-data-level (nth 1 data))))))
2056 (defun gnus-article-children (number)
2057 "Return a list of all children to NUMBER."
2058 (let* ((data (gnus-data-find-list number))
2059 (level (gnus-data-level (car data)))
2061 (setq data (cdr data))
2063 (= (gnus-data-level (car data)) (1+ level)))
2064 (push (gnus-data-number (car data)) children)
2065 (setq data (cdr data)))
2068 (defmacro gnus-summary-skip-intangible ()
2069 "If the current article is intangible, then jump to a different article."
2070 '(let ((to (get-text-property (point) 'gnus-intangible)))
2071 (and to (gnus-summary-goto-subject to))))
2073 (defmacro gnus-summary-article-intangible-p ()
2074 "Say whether this article is intangible or not."
2075 '(get-text-property (point) 'gnus-intangible))
2077 (defun gnus-article-read-p (article)
2078 "Say whether ARTICLE is read or not."
2079 (not (or (memq article gnus-newsgroup-marked)
2080 (memq article gnus-newsgroup-unreads)
2081 (memq article gnus-newsgroup-unselected)
2082 (memq article gnus-newsgroup-dormant))))
2084 ;; Some summary mode macros.
2086 (defmacro gnus-summary-article-number ()
2087 "The article number of the article on the current line.
2088 If there isn's an article number here, then we return the current
2091 (gnus-summary-skip-intangible)
2092 (or (get-text-property (point) 'gnus-number)
2093 (gnus-summary-last-subject))))
2095 (defmacro gnus-summary-article-header (&optional number)
2096 "Return the header of article NUMBER."
2097 `(gnus-data-header (gnus-data-find
2098 ,(or number '(gnus-summary-article-number)))))
2100 (defmacro gnus-summary-thread-level (&optional number)
2101 "Return the level of thread that starts with article NUMBER."
2102 `(if (and (eq gnus-summary-make-false-root 'dummy)
2103 (get-text-property (point) 'gnus-intangible))
2105 (gnus-data-level (gnus-data-find
2106 ,(or number '(gnus-summary-article-number))))))
2108 (defmacro gnus-summary-article-mark (&optional number)
2109 "Return the mark of article NUMBER."
2110 `(gnus-data-mark (gnus-data-find
2111 ,(or number '(gnus-summary-article-number)))))
2113 (defmacro gnus-summary-article-pos (&optional number)
2114 "Return the position of the line of article NUMBER."
2115 `(gnus-data-pos (gnus-data-find
2116 ,(or number '(gnus-summary-article-number)))))
2118 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2119 (defmacro gnus-summary-article-subject (&optional number)
2120 "Return current subject string or nil if nothing."
2123 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2124 '(gnus-data-header (assq (gnus-summary-article-number)
2125 gnus-newsgroup-data)))))
2128 (mail-header-subject headers))))
2130 (defmacro gnus-summary-article-score (&optional number)
2131 "Return current article score."
2132 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2133 gnus-newsgroup-scored))
2134 gnus-summary-default-score 0))
2136 (defun gnus-summary-article-children (&optional number)
2137 "Return a list of article numbers that are children of article NUMBER."
2138 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2139 (level (gnus-data-level (car data)))
2141 (while (and (setq data (cdr data))
2142 (> (setq l (gnus-data-level (car data))) level))
2143 (and (= (1+ level) l)
2144 (push (gnus-data-number (car data))
2146 (nreverse children)))
2148 (defun gnus-summary-article-parent (&optional number)
2149 "Return the article number of the parent of article NUMBER."
2150 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2151 (gnus-data-list t)))
2152 (level (gnus-data-level (car data))))
2154 () ; This is a root.
2155 ;; We search until we find an article with a level less than
2156 ;; this one. That function has to be the parent.
2157 (while (and (setq data (cdr data))
2158 (not (< (gnus-data-level (car data)) level))))
2159 (and data (gnus-data-number (car data))))))
2161 (defun gnus-unread-mark-p (mark)
2162 "Say whether MARK is the unread mark."
2163 (= mark gnus-unread-mark))
2165 (defun gnus-read-mark-p (mark)
2166 "Say whether MARK is one of the marks that mark as read.
2167 This is all marks except unread, ticked, dormant, and expirable."
2168 (not (or (= mark gnus-unread-mark)
2169 (= mark gnus-ticked-mark)
2170 (= mark gnus-dormant-mark)
2171 (= mark gnus-expirable-mark))))
2173 (defmacro gnus-article-mark (number)
2174 "Return the MARK of article NUMBER.
2175 This macro should only be used when computing the mark the \"first\"
2176 time; i.e., when generating the summary lines. After that,
2177 `gnus-summary-article-mark' should be used to examine the
2180 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2181 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2182 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2183 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2184 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2185 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2186 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2187 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2188 gnus-ancient-mark))))
2190 ;; Saving hidden threads.
2192 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2193 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2195 (defmacro gnus-save-hidden-threads (&rest forms)
2196 "Save hidden threads, eval FORMS, and restore the hidden threads."
2197 (let ((config (make-symbol "config")))
2198 `(let ((,config (gnus-hidden-threads-configuration)))
2202 (gnus-restore-hidden-threads-configuration ,config)))))
2204 (defun gnus-hidden-threads-configuration ()
2205 "Return the current hidden threads configuration."
2208 (goto-char (point-min))
2209 (while (search-forward "\r" nil t)
2210 (push (1- (point)) config))
2213 (defun gnus-restore-hidden-threads-configuration (config)
2214 "Restore hidden threads configuration from CONFIG."
2215 (let (point buffer-read-only)
2216 (while (setq point (pop config))
2217 (when (and (< point (point-max))
2219 (= (following-char) ?\n))
2220 (subst-char-in-region point (1+ point) ?\n ?\r)))))
2222 ;; Various summary mode internalish functions.
2224 (defun gnus-mouse-pick-article (e)
2227 (gnus-summary-next-page nil t))
2229 (defun gnus-summary-set-display-table ()
2230 ;; Change the display table. Odd characters have a tendency to mess
2231 ;; up nicely formatted displays - we make all possible glyphs
2232 ;; display only a single character.
2234 ;; We start from the standard display table, if any.
2235 (let ((table (or (copy-sequence standard-display-table)
2236 (make-display-table)))
2238 ;; Nix out all the control chars...
2239 (while (>= (setq i (1- i)) 0)
2240 (aset table i [??]))
2241 ;; ... but not newline and cr, of course. (cr is necessary for the
2242 ;; selective display).
2243 (aset table ?\n nil)
2244 (aset table ?\r nil)
2245 ;; We keep TAB as well.
2246 (aset table ?\t nil)
2247 ;; We nix out any glyphs over 126 that are not set already.
2249 (while (>= (setq i (1- i)) 127)
2250 ;; Only modify if the entry is nil.
2251 (unless (aref table i)
2252 (aset table i [??]))))
2253 (setq buffer-display-table table)))
2255 (defun gnus-summary-setup-buffer (group)
2256 "Initialize summary buffer."
2257 (let ((buffer (concat "*Summary " group "*")))
2258 (if (get-buffer buffer)
2261 (setq gnus-summary-buffer (current-buffer))
2262 (not gnus-newsgroup-prepared))
2263 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2264 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
2265 (gnus-add-current-to-buffer-list)
2266 (gnus-summary-mode group)
2268 (gnus-carpal-setup-buffer 'summary))
2269 (unless gnus-single-article-buffer
2270 (make-local-variable 'gnus-article-buffer)
2271 (make-local-variable 'gnus-article-current)
2272 (make-local-variable 'gnus-original-article-buffer))
2273 (setq gnus-newsgroup-name group)
2276 (defun gnus-set-global-variables ()
2277 ;; Set the global equivalents of the summary buffer-local variables
2278 ;; to the latest values they had. These reflect the summary buffer
2279 ;; that was in action when the last article was fetched.
2280 (when (eq major-mode 'gnus-summary-mode)
2281 (setq gnus-summary-buffer (current-buffer))
2282 (let ((name gnus-newsgroup-name)
2283 (marked gnus-newsgroup-marked)
2284 (unread gnus-newsgroup-unreads)
2285 (headers gnus-current-headers)
2286 (data gnus-newsgroup-data)
2287 (summary gnus-summary-buffer)
2288 (article-buffer gnus-article-buffer)
2289 (original gnus-original-article-buffer)
2290 (gac gnus-article-current)
2291 (reffed gnus-reffed-article-number)
2292 (score-file gnus-current-score-file))
2294 (set-buffer gnus-group-buffer)
2295 (setq gnus-newsgroup-name name
2296 gnus-newsgroup-marked marked
2297 gnus-newsgroup-unreads unread
2298 gnus-current-headers headers
2299 gnus-newsgroup-data data
2300 gnus-article-current gac
2301 gnus-summary-buffer summary
2302 gnus-article-buffer article-buffer
2303 gnus-original-article-buffer original
2304 gnus-reffed-article-number reffed
2305 gnus-current-score-file score-file)
2306 ;; The article buffer also has local variables.
2307 (when (gnus-buffer-live-p gnus-article-buffer)
2308 (set-buffer gnus-article-buffer)
2309 (setq gnus-summary-buffer summary))))))
2311 (defun gnus-summary-article-unread-p (article)
2312 "Say whether ARTICLE is unread or not."
2313 (memq article gnus-newsgroup-unreads))
2315 (defun gnus-summary-first-article-p (&optional article)
2316 "Return whether ARTICLE is the first article in the buffer."
2317 (if (not (setq article (or article (gnus-summary-article-number))))
2319 (eq article (caar gnus-newsgroup-data))))
2321 (defun gnus-summary-last-article-p (&optional article)
2322 "Return whether ARTICLE is the last article in the buffer."
2323 (if (not (setq article (or article (gnus-summary-article-number))))
2324 t ; All non-existent numbers are the last article. :-)
2325 (not (cdr (gnus-data-find-list article)))))
2327 (defun gnus-make-thread-indent-array ()
2329 (unless (and gnus-thread-indent-array
2330 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2331 (setq gnus-thread-indent-array (make-vector 201 "")
2332 gnus-thread-indent-array-level gnus-thread-indent-level)
2334 (aset gnus-thread-indent-array n
2335 (make-string (* n gnus-thread-indent-level) ? ))
2338 (defun gnus-update-summary-mark-positions ()
2339 "Compute where the summary marks are to go."
2341 (when (gnus-buffer-exists-p gnus-summary-buffer)
2342 (set-buffer gnus-summary-buffer))
2343 (let ((gnus-replied-mark 129)
2344 (gnus-score-below-mark 130)
2345 (gnus-score-over-mark 130)
2346 (gnus-download-mark 131)
2347 (spec gnus-summary-line-format-spec)
2348 thread gnus-visual pos)
2350 (gnus-set-work-buffer)
2351 (let ((gnus-summary-line-format-spec spec)
2352 (gnus-newsgroup-downloadable '((0 . t))))
2353 (gnus-summary-insert-line
2354 [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
2355 (goto-char (point-min))
2356 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2358 (goto-char (point-min))
2359 (push (cons 'replied (and (search-forward "\201" nil t)
2362 (goto-char (point-min))
2363 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2365 (goto-char (point-min))
2366 (push (cons 'download
2367 (and (search-forward "\203" nil t) (- (point) 2)))
2369 (setq gnus-summary-mark-positions pos))))
2371 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2372 "Insert a dummy root in the summary buffer."
2374 (gnus-add-text-properties
2375 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2376 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2378 (defun gnus-summary-insert-line (gnus-tmp-header
2379 gnus-tmp-level gnus-tmp-current
2380 gnus-tmp-unread gnus-tmp-replied
2381 gnus-tmp-expirable gnus-tmp-subject-or-nil
2382 &optional gnus-tmp-dummy gnus-tmp-score
2384 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2385 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2386 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2387 (gnus-tmp-score-char
2388 (if (or (null gnus-summary-default-score)
2389 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2390 gnus-summary-zcore-fuzz))
2392 (if (< gnus-tmp-score gnus-summary-default-score)
2393 gnus-score-below-mark gnus-score-over-mark)))
2395 (cond (gnus-tmp-process gnus-process-mark)
2396 ((memq gnus-tmp-current gnus-newsgroup-cached)
2398 (gnus-tmp-replied gnus-replied-mark)
2399 ((memq gnus-tmp-current gnus-newsgroup-saved)
2401 (t gnus-unread-mark)))
2402 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2405 ((string-match "<[^>]+> *$" gnus-tmp-from)
2406 (let ((beg (match-beginning 0)))
2407 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
2408 (substring gnus-tmp-from (1+ (match-beginning 0))
2409 (1- (match-end 0))))
2410 (substring gnus-tmp-from 0 beg))))
2411 ((string-match "(.+)" gnus-tmp-from)
2412 (substring gnus-tmp-from
2413 (1+ (match-beginning 0)) (1- (match-end 0))))
2415 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2416 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2417 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2418 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
2419 (buffer-read-only nil))
2420 (when (string= gnus-tmp-name "")
2421 (setq gnus-tmp-name gnus-tmp-from))
2422 (unless (numberp gnus-tmp-lines)
2423 (setq gnus-tmp-lines 0))
2424 (gnus-put-text-property-excluding-characters-with-faces
2426 (progn (eval gnus-summary-line-format-spec) (point))
2427 'gnus-number gnus-tmp-number)
2428 (when (gnus-visual-p 'summary-highlight 'highlight)
2430 (gnus-run-hooks 'gnus-summary-update-hook)
2433 (defun gnus-summary-update-line (&optional dont-update)
2434 ;; Update summary line after change.
2435 (when (and gnus-summary-default-score
2436 (not gnus-summary-inhibit-highlight))
2437 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
2438 (article (gnus-summary-article-number))
2439 (score (gnus-summary-article-score article)))
2441 (if (and gnus-summary-mark-below
2442 (< (gnus-summary-article-score)
2443 gnus-summary-mark-below))
2444 ;; This article has a low score, so we mark it as read.
2445 (when (memq article gnus-newsgroup-unreads)
2446 (gnus-summary-mark-article-as-read gnus-low-score-mark))
2447 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
2448 ;; This article was previously marked as read on account
2449 ;; of a low score, but now it has risen, so we mark it as
2451 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
2452 (gnus-summary-update-mark
2453 (if (or (null gnus-summary-default-score)
2454 (<= (abs (- score gnus-summary-default-score))
2455 gnus-summary-zcore-fuzz))
2457 (if (< score gnus-summary-default-score)
2458 gnus-score-below-mark gnus-score-over-mark))
2460 ;; Do visual highlighting.
2461 (when (gnus-visual-p 'summary-highlight 'highlight)
2462 (gnus-run-hooks 'gnus-summary-update-hook)))))
2464 (defvar gnus-tmp-new-adopts nil)
2466 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
2467 "Return the number of articles in THREAD.
2468 This may be 0 in some cases -- if none of the articles in
2469 the thread are to be displayed."
2471 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
2473 ((not (listp thread))
2475 ((and (consp thread) (cdr thread))
2478 'gnus-summary-number-of-articles-in-thread (cdr thread))))
2481 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
2484 (when (and level (zerop level) gnus-tmp-new-adopts)
2487 'gnus-summary-number-of-articles-in-thread
2488 gnus-tmp-new-adopts))))
2490 (if (> number 1) gnus-not-empty-thread-mark
2491 gnus-empty-thread-mark)
2494 (defun gnus-summary-set-local-parameters (group)
2495 "Go through the local params of GROUP and set all variable specs in that list."
2496 (let ((params (gnus-group-find-parameter group))
2499 (setq elem (car params)
2500 params (cdr params))
2501 (and (consp elem) ; Has to be a cons.
2502 (consp (cdr elem)) ; The cdr has to be a list.
2503 (symbolp (car elem)) ; Has to be a symbol in there.
2504 (not (memq (car elem) '(quit-config))) ; Ignore quit-config.
2505 (ignore-errors ; So we set it.
2506 (make-local-variable (car elem))
2507 (set (car elem) (eval (nth 1 elem))))))))
2509 (defun gnus-summary-read-group (group &optional show-all no-article
2510 kill-buffer no-display backward
2512 "Start reading news in newsgroup GROUP.
2513 If SHOW-ALL is non-nil, already read articles are also listed.
2514 If NO-ARTICLE is non-nil, no article is selected initially.
2515 If NO-DISPLAY, don't generate a summary buffer."
2519 (let ((gnus-auto-select-next nil))
2520 (or (gnus-summary-read-group-1
2521 group show-all no-article
2522 kill-buffer no-display)
2525 (eq gnus-auto-select-next 'quietly))
2526 (set-buffer gnus-group-buffer)
2527 ;; The entry function called above goes to the next
2528 ;; group automatically, so we go two groups back
2529 ;; if we are searching for the previous group.
2531 (gnus-group-prev-unread-group 2))
2532 (if (not (equal group (gnus-group-group-name)))
2533 (setq group (gnus-group-group-name))
2537 (defun gnus-summary-read-group-1 (group show-all no-article
2538 kill-buffer no-display
2539 &optional select-articles)
2540 ;; Killed foreign groups can't be entered.
2541 (when (and (not (gnus-group-native-p group))
2542 (not (gnus-gethash group gnus-newsrc-hashtb)))
2543 (error "Dead non-native groups can't be entered"))
2544 (gnus-message 5 "Retrieving newsgroup: %s..." group)
2545 (let* ((new-group (gnus-summary-setup-buffer group))
2546 (quit-config (gnus-group-quit-config group))
2547 (did-select (and new-group (gnus-select-newsgroup
2548 group show-all select-articles))))
2550 ;; This summary buffer exists already, so we just select it.
2552 (gnus-set-global-variables)
2554 (gnus-kill-or-deaden-summary kill-buffer))
2555 (gnus-configure-windows 'summary 'force)
2556 (gnus-set-mode-line 'summary)
2557 (gnus-summary-position-point)
2560 ;; We couldn't select this group.
2562 (when (and (eq major-mode 'gnus-summary-mode)
2563 (not (equal (current-buffer) kill-buffer)))
2564 (kill-buffer (current-buffer))
2565 (if (not quit-config)
2567 ;; Update the info -- marks might need to be removed,
2569 (gnus-summary-update-info)
2570 (set-buffer gnus-group-buffer)
2571 (gnus-group-jump-to-group group)
2572 (gnus-group-next-unread-group 1))
2573 (gnus-handle-ephemeral-exit quit-config)))
2574 (gnus-message 3 "Can't select group")
2576 ;; The user did a `C-g' while prompting for number of articles,
2577 ;; so we exit this group.
2578 ((eq did-select 'quit)
2579 (and (eq major-mode 'gnus-summary-mode)
2580 (not (equal (current-buffer) kill-buffer))
2581 (kill-buffer (current-buffer)))
2583 (gnus-kill-or-deaden-summary kill-buffer))
2584 (if (not quit-config)
2586 (set-buffer gnus-group-buffer)
2587 (gnus-group-jump-to-group group)
2588 (gnus-group-next-unread-group 1)
2589 (gnus-configure-windows 'group 'force))
2590 (gnus-handle-ephemeral-exit quit-config))
2591 ;; Finally signal the quit.
2593 ;; The group was successfully selected.
2595 (gnus-set-global-variables)
2596 ;; Save the active value in effect when the group was entered.
2597 (setq gnus-newsgroup-active
2599 (gnus-active gnus-newsgroup-name)))
2600 ;; You can change the summary buffer in some way with this hook.
2601 (gnus-run-hooks 'gnus-select-group-hook)
2602 ;; Set any local variables in the group parameters.
2603 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2604 (gnus-update-format-specifications
2605 nil 'summary 'summary-mode 'summary-dummy)
2606 ;; Do score processing.
2607 (when gnus-use-scoring
2608 (gnus-possibly-score-headers))
2609 ;; Check whether to fill in the gaps in the threads.
2610 (when gnus-build-sparse-threads
2611 (gnus-build-sparse-threads))
2612 ;; Find the initial limit.
2613 (if gnus-show-threads
2615 (let ((gnus-newsgroup-dormant nil))
2616 (gnus-summary-initial-limit show-all))
2617 (gnus-summary-initial-limit show-all))
2618 (setq gnus-newsgroup-limit
2620 (lambda (header) (mail-header-number header))
2621 gnus-newsgroup-headers)))
2622 ;; Generate the summary buffer.
2624 (gnus-summary-prepare))
2625 (when gnus-use-trees
2626 (gnus-tree-open group)
2627 (setq gnus-summary-highlight-line-function
2628 'gnus-tree-highlight-article))
2629 ;; If the summary buffer is empty, but there are some low-scored
2630 ;; articles or some excluded dormants, we include these in the
2632 (when (and (zerop (buffer-size))
2634 (cond (gnus-newsgroup-dormant
2635 (gnus-summary-limit-include-dormant))
2636 ((and gnus-newsgroup-scored show-all)
2637 (gnus-summary-limit-include-expunged t))))
2638 ;; Function `gnus-apply-kill-file' must be called in this hook.
2639 (gnus-run-hooks 'gnus-apply-kill-hook)
2640 (if (and (zerop (buffer-size))
2643 ;; This newsgroup is empty.
2644 (gnus-summary-catchup-and-exit nil t)
2645 (gnus-message 6 "No unread news")
2647 (gnus-kill-or-deaden-summary kill-buffer))
2648 ;; Return nil from this function.
2650 ;; Hide conversation thread subtrees. We cannot do this in
2651 ;; gnus-summary-prepare-hook since kill processing may not
2652 ;; work with hidden articles.
2653 (and gnus-show-threads
2654 gnus-thread-hide-subtree
2655 (gnus-summary-hide-all-threads))
2657 (gnus-kill-or-deaden-summary kill-buffer))
2658 ;; Show first unread article if requested.
2659 (if (and (not no-article)
2661 gnus-newsgroup-unreads
2662 gnus-auto-select-first)
2663 (unless (if (eq gnus-auto-select-first 'best)
2664 (gnus-summary-best-unread-article)
2665 (gnus-summary-first-unread-article))
2666 (gnus-configure-windows 'summary))
2667 ;; Don't select any articles, just move point to the first
2668 ;; article in the group.
2669 (goto-char (point-min))
2670 (gnus-summary-position-point)
2671 (gnus-configure-windows 'summary 'force)
2672 (gnus-set-mode-line 'summary))
2673 (when (get-buffer-window gnus-group-buffer t)
2674 ;; Gotta use windows, because recenter does weird stuff if
2675 ;; the current buffer ain't the displayed window.
2676 (let ((owin (selected-window)))
2677 (select-window (get-buffer-window gnus-group-buffer t))
2678 (when (gnus-group-goto-group group)
2680 (select-window owin)))
2681 ;; Mark this buffer as "prepared".
2682 (setq gnus-newsgroup-prepared t)
2683 (gnus-run-hooks 'gnus-summary-prepared-hook)
2686 (defun gnus-summary-prepare ()
2687 "Generate the summary buffer."
2689 (let ((buffer-read-only nil))
2691 (setq gnus-newsgroup-data nil
2692 gnus-newsgroup-data-reverse nil)
2693 (gnus-run-hooks 'gnus-summary-generate-hook)
2694 ;; Generate the buffer, either with threads or without.
2695 (when gnus-newsgroup-headers
2696 (gnus-summary-prepare-threads
2697 (if gnus-show-threads
2698 (gnus-sort-gathered-threads
2699 (funcall gnus-summary-thread-gathering-function
2701 (gnus-cut-threads (gnus-make-threads)))))
2702 ;; Unthreaded display.
2703 (gnus-sort-articles gnus-newsgroup-headers))))
2704 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
2705 ;; Call hooks for modifying summary buffer.
2706 (goto-char (point-min))
2707 (gnus-run-hooks 'gnus-summary-prepare-hook)))
2709 (defsubst gnus-general-simplify-subject (subject)
2710 "Simply subject by the same rules as gnus-gather-threads-by-subject."
2713 ;; Truncate the subject.
2714 (gnus-simplify-subject-functions
2715 (gnus-map-function gnus-simplify-subject-functions subject))
2716 ((numberp gnus-summary-gather-subject-limit)
2717 (setq subject (gnus-simplify-subject-re subject))
2718 (if (> (length subject) gnus-summary-gather-subject-limit)
2719 (substring subject 0 gnus-summary-gather-subject-limit)
2721 ;; Fuzzily simplify it.
2722 ((eq 'fuzzy gnus-summary-gather-subject-limit)
2723 (gnus-simplify-subject-fuzzy subject))
2724 ;; Just remove the leading "Re:".
2726 (gnus-simplify-subject-re subject))))
2728 (if (and gnus-summary-gather-exclude-subject
2729 (string-match gnus-summary-gather-exclude-subject subject))
2730 nil ; This article shouldn't be gathered
2733 (defun gnus-summary-simplify-subject-query ()
2734 "Query where the respool algorithm would put this article."
2736 (gnus-summary-select-article)
2737 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
2739 (defun gnus-gather-threads-by-subject (threads)
2740 "Gather threads by looking at Subject headers."
2741 (if (not gnus-summary-make-false-root)
2743 (let ((hashtb (gnus-make-hashtable 1024))
2746 subject hthread whole-subject)
2748 (setq subject (gnus-general-simplify-subject
2749 (setq whole-subject (mail-header-subject
2752 (if (setq hthread (gnus-gethash subject hashtb))
2754 ;; We enter a dummy root into the thread, if we
2755 ;; haven't done that already.
2756 (unless (stringp (caar hthread))
2757 (setcar hthread (list whole-subject (car hthread))))
2758 ;; We add this new gathered thread to this gathered
2760 (setcdr (car hthread)
2761 (nconc (cdar hthread) (list (car threads))))
2762 ;; Remove it from the list of threads.
2763 (setcdr prev (cdr threads))
2764 (setq threads prev))
2765 ;; Enter this thread into the hash table.
2766 (gnus-sethash subject threads hashtb)))
2768 (setq threads (cdr threads)))
2771 (defun gnus-gather-threads-by-references (threads)
2772 "Gather threads by looking at References headers."
2773 (let ((idhashtb (gnus-make-hashtable 1024))
2774 (thhashtb (gnus-make-hashtable 1024))
2777 ids references id gthread gid entered ref)
2779 (when (setq references (mail-header-references (caar threads)))
2780 (setq id (mail-header-id (caar threads))
2781 ids (gnus-split-references references)
2783 (while (setq ref (pop ids))
2784 (setq ids (delete ref ids))
2785 (if (not (setq gid (gnus-gethash ref idhashtb)))
2787 (gnus-sethash ref id idhashtb)
2788 (gnus-sethash id threads thhashtb))
2789 (setq gthread (gnus-gethash gid thhashtb))
2791 ;; We enter a dummy root into the thread, if we
2792 ;; haven't done that already.
2793 (unless (stringp (caar gthread))
2794 (setcar gthread (list (mail-header-subject (caar gthread))
2796 ;; We add this new gathered thread to this gathered
2798 (setcdr (car gthread)
2799 (nconc (cdar gthread) (list (car threads)))))
2800 ;; Add it into the thread hash table.
2801 (gnus-sethash id gthread thhashtb)
2803 ;; Remove it from the list of threads.
2804 (setcdr prev (cdr threads))
2805 (setq threads prev))))
2807 (setq threads (cdr threads)))
2810 (defun gnus-sort-gathered-threads (threads)
2811 "Sort subtreads inside each gathered thread by article number."
2812 (let ((result threads))
2814 (when (stringp (caar threads))
2815 (setcdr (car threads)
2816 (sort (cdar threads) 'gnus-thread-sort-by-number)))
2817 (setq threads (cdr threads)))
2820 (defun gnus-thread-loop-p (root thread)
2821 "Say whether ROOT is in THREAD."
2822 (let ((stack (list thread))
2825 (while (setq thread (pop stack))
2826 (setq th (cdr thread))
2828 (not (eq (caar th) root)))
2831 ;; We have found a loop.
2833 (setcdr thread (delq (car th) (cdr thread)))
2834 (if (boundp (setq ref-dep (intern "none"
2835 gnus-newsgroup-dependencies)))
2836 (setcdr (symbol-value ref-dep)
2837 (nconc (cdr (symbol-value ref-dep))
2839 (set ref-dep (list nil (car th))))
2842 ;; Push all the subthreads onto the stack.
2843 (push (cdr thread) stack)))
2846 (defun gnus-make-threads ()
2847 "Go through the dependency hashtb and find the roots. Return all threads."
2849 (while (catch 'infloop
2852 ;; Deal with self-referencing References loops.
2853 (when (and (car (symbol-value refs))
2860 (car (symbol-value refs)) thread))
2861 (cdr (symbol-value refs)))))))
2864 (unless (car (symbol-value refs))
2865 ;; These threads do not refer back to any other articles,
2866 ;; so they're roots.
2867 (setq threads (append (cdr (symbol-value refs)) threads))))
2868 gnus-newsgroup-dependencies)))
2871 ;; Build the thread tree.
2872 (defun gnus-dependencies-add-header (header dependencies force-new)
2873 "Enter HEADER into the DEPENDENCIES table if it is not already there.
2875 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
2876 if it was already present.
2878 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
2879 will not be entered in the DEPENDENCIES table. Otherwise duplicate
2880 Message-IDs will be renamed be renamed to a unique Message-ID before
2883 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
2884 (let* ((id (mail-header-id header))
2885 (id-dep (and id (intern id dependencies)))
2886 ref ref-dep ref-header)
2887 ;; Enter this `header' in the `dependencies' table.
2891 ;; The first two cases do the normal part: enter a new `header'
2892 ;; in the `dependencies' table.
2893 ((not (boundp id-dep))
2894 (set id-dep (list header)))
2895 ((null (car (symbol-value id-dep)))
2896 (setcar (symbol-value id-dep) header))
2898 ;; From here the `header' was already present in the
2899 ;; `dependencies' table.
2901 ;; Overrides an existing entry;
2902 ;; just set the header part of the entry.
2903 (setcar (symbol-value id-dep) header))
2905 ;; Renames the existing `header' to a unique Message-ID.
2906 ((not gnus-summary-ignore-duplicates)
2907 ;; An article with this Message-ID has already been seen.
2908 ;; We rename the Message-ID.
2909 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
2911 (mail-header-set-id header id))
2913 ;; The last case ignores an existing entry, except it adds any
2914 ;; additional Xrefs (in case the two articles came from different
2916 ;; Also sets `header' to `nil' meaning that the `dependencies'
2917 ;; table was *not* modified.
2919 (mail-header-set-xref
2920 (car (symbol-value id-dep))
2921 (concat (or (mail-header-xref (car (symbol-value id-dep)))
2923 (or (mail-header-xref header) "")))
2927 ;; First check if that we are not creating a References loop.
2928 (setq ref (gnus-parent-id (mail-header-references header)))
2930 (setq ref-dep (intern-soft ref dependencies))
2932 (setq ref-header (car (symbol-value ref-dep))))
2933 (if (string= id ref)
2934 ;; Yuk! This is a reference loop. Make the article be a
2937 (mail-header-set-references (car (symbol-value id-dep)) "none")
2939 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
2940 (setq ref (gnus-parent-id (mail-header-references header)))
2941 (setq ref-dep (intern (or ref "none") dependencies))
2942 (if (boundp ref-dep)
2943 (setcdr (symbol-value ref-dep)
2944 (nconc (cdr (symbol-value ref-dep))
2945 (list (symbol-value id-dep))))
2946 (set ref-dep (list nil (symbol-value id-dep)))))
2949 (defun gnus-build-sparse-threads ()
2950 (let ((headers gnus-newsgroup-headers)
2951 (gnus-summary-ignore-duplicates t)
2952 header references generation relations
2953 cthread subject child end pthread relation new-child date)
2954 ;; First we create an alist of generations/relations, where
2955 ;; generations is how much we trust the relation, and the relation
2957 (gnus-message 7 "Making sparse threads...")
2959 (nnheader-set-temp-buffer " *gnus sparse threads*")
2960 (while (setq header (pop headers))
2961 (when (and (setq references (mail-header-references header))
2962 (not (string= references "")))
2964 (setq child (mail-header-id header)
2965 subject (mail-header-subject header)
2966 date (mail-header-date header)
2968 (while (search-backward ">" nil t)
2969 (setq end (1+ (point)))
2970 (when (search-backward "<" nil t)
2971 (setq new-child (buffer-substring (point) end))
2972 (push (list (incf generation)
2973 child (setq child new-child)
2977 (push (list (1+ generation) child nil subject) relations))
2979 (kill-buffer (current-buffer)))
2980 ;; Sort over trustworthiness.
2983 (when (gnus-dependencies-add-header
2984 (make-full-mail-header
2985 gnus-reffed-article-number
2986 (nth 3 relation) "" (or (nth 4 relation) "")
2988 (or (nth 2 relation) "") 0 0 "")
2989 gnus-newsgroup-dependencies nil)
2990 (push gnus-reffed-article-number gnus-newsgroup-limit)
2991 (push gnus-reffed-article-number gnus-newsgroup-sparse)
2992 (push (cons gnus-reffed-article-number gnus-sparse-mark)
2993 gnus-newsgroup-reads)
2994 (decf gnus-reffed-article-number)))
2995 (sort relations 'car-less-than-car))
2996 (gnus-message 7 "Making sparse threads...done")))
2998 (defun gnus-build-old-threads ()
2999 ;; Look at all the articles that refer back to old articles, and
3000 ;; fetch the headers for the articles that aren't there. This will
3001 ;; build complete threads - if the roots haven't been expired by the
3006 (when (not (car (symbol-value refs)))
3007 (setq heads (cdr (symbol-value refs)))
3009 (if (memq (mail-header-number (caar heads))
3010 gnus-newsgroup-dormant)
3011 (setq heads (cdr heads))
3012 (setq id (symbol-name refs))
3013 (while (and (setq id (gnus-build-get-header id))
3014 (not (car (gnus-id-to-thread id)))))
3015 (setq heads nil)))))
3016 gnus-newsgroup-dependencies)))
3018 ;; The following macros and functions were written by Felix Lee
3019 ;; <flee@cse.psu.edu>.
3021 (defmacro gnus-nov-read-integer ()
3023 (if (= (following-char) ?\t)
3025 (let ((num (ignore-errors (read buffer))))
3026 (if (numberp num) num 0)))
3028 (search-forward "\t" eol 'move))))
3030 (defmacro gnus-nov-skip-field ()
3031 '(search-forward "\t" eol 'move))
3033 (defmacro gnus-nov-field ()
3034 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
3036 ;; This function has to be called with point after the article number
3037 ;; on the beginning of the line.
3038 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3039 (let ((eol (gnus-point-at-eol))
3040 (buffer (current-buffer))
3043 ;; overview: [num subject from date id refs chars lines misc]
3046 (narrow-to-region (point) eol)
3051 (make-full-mail-header
3054 gnus-unstructured-field-decoder (gnus-nov-field)) ; subject
3056 gnus-structured-field-decoder (gnus-nov-field)) ; from
3057 (gnus-nov-field) ; date
3058 (or (gnus-nov-field)
3059 (nnheader-generate-fake-message-id)) ; id
3060 (gnus-nov-field) ; refs
3061 (gnus-nov-read-integer) ; chars
3062 (gnus-nov-read-integer) ; lines
3063 (unless (= (following-char) ?\n)
3064 (gnus-nov-field))))) ; misc
3068 (when gnus-alter-header-function
3069 (funcall gnus-alter-header-function header))
3070 (gnus-dependencies-add-header header dependencies force-new)))
3072 (defun gnus-build-get-header (id)
3073 ;; Look through the buffer of NOV lines and find the header to
3074 ;; ID. Enter this line into the dependencies hash table, and return
3075 ;; the id of the parent article (if any).
3076 (let ((deps gnus-newsgroup-dependencies)
3080 (set-buffer nntp-server-buffer)
3081 (let ((case-fold-search nil))
3082 (goto-char (point-min))
3083 (while (and (not found)
3084 (search-forward id nil t))
3086 (setq found (looking-at
3087 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3088 (regexp-quote id))))
3089 (or found (beginning-of-line 2)))
3093 (setq header (gnus-nov-parse-line
3094 (read (current-buffer)) deps))
3095 (gnus-parent-id (mail-header-references header))))))
3097 (let ((number (mail-header-number header)))
3098 (push number gnus-newsgroup-limit)
3099 (push header gnus-newsgroup-headers)
3100 (if (memq number gnus-newsgroup-unselected)
3102 (push number gnus-newsgroup-unreads)
3103 (setq gnus-newsgroup-unselected
3104 (delq number gnus-newsgroup-unselected)))
3105 (push number gnus-newsgroup-ancient)))))))
3107 (defun gnus-build-all-threads ()
3108 "Read all the headers."
3109 (let ((gnus-summary-ignore-duplicates t)
3110 (dependencies gnus-newsgroup-dependencies)
3111 found header article)
3113 (set-buffer nntp-server-buffer)
3114 (let ((case-fold-search nil))
3115 (goto-char (point-min))
3118 (setq article (read (current-buffer))
3119 header (gnus-nov-parse-line
3120 article dependencies)))
3122 (push header gnus-newsgroup-headers)
3123 (if (memq (setq article (mail-header-number header))
3124 gnus-newsgroup-unselected)
3126 (push article gnus-newsgroup-unreads)
3127 (setq gnus-newsgroup-unselected
3128 (delq article gnus-newsgroup-unselected)))
3129 (push article gnus-newsgroup-ancient))
3130 (forward-line 1)))))))
3132 (defun gnus-summary-update-article-line (article header)
3133 "Update the line for ARTICLE using HEADERS."
3134 (let* ((id (mail-header-id header))
3135 (thread (gnus-id-to-thread id)))
3137 (error "Article in no thread"))
3138 ;; Update the thread.
3139 (setcar thread header)
3140 (gnus-summary-goto-subject article)
3141 (let* ((datal (gnus-data-find-list article))
3143 (length (when (cdr datal)
3144 (- (gnus-data-pos data)
3145 (gnus-data-pos (cadr datal)))))
3146 (buffer-read-only nil)
3147 (level (gnus-summary-thread-level)))
3149 (gnus-summary-insert-line
3150 header level nil (gnus-article-mark article)
3151 (memq article gnus-newsgroup-replied)
3152 (memq article gnus-newsgroup-expirable)
3153 ;; Only insert the Subject string when it's different
3154 ;; from the previous Subject string.
3155 (if (gnus-subject-equal
3157 (mail-header-subject
3160 (gnus-data-find-list
3162 (gnus-data-list t)))))
3163 ;; Error on the side of excessive subjects.
3165 (mail-header-subject header))
3167 (mail-header-subject header))
3168 nil (cdr (assq article gnus-newsgroup-scored))
3169 (memq article gnus-newsgroup-processable))
3171 (gnus-data-update-list
3172 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3174 (defun gnus-summary-update-article (article &optional iheader)
3175 "Update ARTICLE in the summary buffer."
3176 (set-buffer gnus-summary-buffer)
3177 (let* ((header (gnus-summary-article-header article))
3178 (id (mail-header-id header))
3179 (data (gnus-data-find article))
3180 (thread (gnus-id-to-thread id))
3181 (references (mail-header-references header))
3185 (when (and references
3186 (not (equal "" references)))
3189 (buffer-read-only nil)
3191 (number (mail-header-number header))
3197 (delq thread parent)))
3198 (if (gnus-summary-insert-subject id header)
3199 ;; Set the (possibly) new article number in the data structure.
3200 (gnus-data-set-number data (gnus-id-to-article id))
3204 (defun gnus-rebuild-thread (id &optional line)
3205 "Rebuild the thread containing ID.
3206 If LINE, insert the rebuilt thread starting on line LINE."
3207 (let ((buffer-read-only nil)
3208 old-pos current thread data)
3209 (if (not gnus-show-threads)
3210 (setq thread (list (car (gnus-id-to-thread id))))
3211 ;; Get the thread this article is part of.
3212 (setq thread (gnus-remove-thread id)))
3213 (setq old-pos (gnus-point-at-bol))
3214 (setq current (save-excursion
3215 (and (zerop (forward-line -1))
3216 (gnus-summary-article-number))))
3217 ;; If this is a gathered thread, we have to go some re-gathering.
3218 (when (stringp (car thread))
3219 (let ((subject (car thread))
3221 (setq thread (cdr thread))
3223 (unless (memq (setq thr (gnus-id-to-thread
3225 (mail-header-id (caar thread)))))
3228 (setq thread (cdr thread)))
3229 ;; We now have all (unique) roots.
3230 (if (= (length roots) 1)
3231 ;; All the loose roots are now one solid root.
3232 (setq thread (car roots))
3233 (setq thread (cons subject (gnus-sort-threads roots))))))
3235 ;; We then insert this thread into the summary buffer.
3237 (goto-char (point-min))
3238 (forward-line (1- line)))
3239 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3240 (if gnus-show-threads
3241 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3242 (gnus-summary-prepare-unthreaded thread))
3243 (setq data (nreverse gnus-newsgroup-data))
3244 (setq threads gnus-newsgroup-threads))
3245 ;; We splice the new data into the data structure.
3246 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
3247 ;;!!! then we want to insert at the beginning of the buffer.
3248 ;;!!! That happens to be true with Gnus now, but that may
3249 ;;!!! change in the future. Perhaps.
3250 (gnus-data-enter-list (if line nil current) data (- (point) old-pos))
3251 (setq gnus-newsgroup-threads (nconc threads gnus-newsgroup-threads))
3253 (gnus-data-compute-positions)))))
3255 (defun gnus-number-to-header (number)
3256 "Return the header for article NUMBER."
3257 (let ((headers gnus-newsgroup-headers))
3259 (not (= number (mail-header-number (car headers)))))
3264 (defun gnus-parent-headers (in-headers &optional generation)
3265 "Return the headers of the GENERATIONeth parent of HEADERS."
3267 (setq generation 1))
3269 (headers in-headers)
3272 (not (zerop generation))
3273 (setq references (mail-header-references headers)))
3274 (setq headers (if (and references
3275 (setq parent (gnus-parent-id references)))
3276 (car (gnus-id-to-thread parent))
3279 (and (not (eq headers in-headers))
3282 (defun gnus-id-to-thread (id)
3283 "Return the (sub-)thread where ID appears."
3284 (gnus-gethash id gnus-newsgroup-dependencies))
3286 (defun gnus-id-to-article (id)
3287 "Return the article number of ID."
3288 (let ((thread (gnus-id-to-thread id)))
3291 (mail-header-number (car thread)))))
3293 (defun gnus-id-to-header (id)
3294 "Return the article headers of ID."
3295 (car (gnus-id-to-thread id)))
3297 (defun gnus-article-displayed-root-p (article)
3298 "Say whether ARTICLE is a root(ish) article."
3299 (let ((level (gnus-summary-thread-level article))
3300 (refs (mail-header-references (gnus-summary-article-header article)))
3306 ((null (gnus-parent-id refs)) t)
3308 (null (setq particle (gnus-id-to-article
3309 (gnus-parent-id refs))))
3310 (null (gnus-summary-thread-level particle)))))))
3312 (defun gnus-root-id (id)
3313 "Return the id of the root of the thread where ID appears."
3315 (while (and id (setq prev (car (gnus-id-to-thread id))))
3317 id (gnus-parent-id (mail-header-references prev))))
3320 (defun gnus-articles-in-thread (thread)
3321 "Return the list of articles in THREAD."
3322 (cons (mail-header-number (car thread))
3323 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
3325 (defun gnus-remove-thread (id &optional dont-remove)
3326 "Remove the thread that has ID in it."
3327 (let (headers thread last-id)
3328 ;; First go up in this thread until we find the root.
3329 (setq last-id (gnus-root-id id))
3330 (setq headers (list (car (gnus-id-to-thread last-id))
3331 (caadr (gnus-id-to-thread last-id))))
3332 ;; We have now found the real root of this thread. It might have
3333 ;; been gathered into some loose thread, so we have to search
3334 ;; through the threads to find the thread we wanted.
3335 (let ((threads gnus-newsgroup-threads)
3338 (setq sub (car threads))
3339 (if (stringp (car sub))
3340 ;; This is a gathered thread, so we look at the roots
3341 ;; below it to find whether this article is in this
3344 (setq sub (cdr sub))
3346 (when (member (caar sub) headers)
3347 (setq thread (car threads)
3350 (setq sub (cdr sub))))
3351 ;; It's an ordinary thread, so we check it.
3352 (when (eq (car sub) (car headers))
3355 (setq threads (cdr threads)))
3356 ;; If this article is in no thread, then it's a root.
3359 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
3360 (setq thread (gnus-id-to-thread last-id)))
3363 thread ; We return this thread.
3365 (if (stringp (car thread))
3367 ;; If we use dummy roots, then we have to remove the
3368 ;; dummy root as well.
3369 (when (eq gnus-summary-make-false-root 'dummy)
3370 ;; We go to the dummy root by going to
3371 ;; the first sub-"thread", and then one line up.
3372 (gnus-summary-goto-article
3373 (mail-header-number (caadr thread)))
3376 (gnus-data-compute-positions))
3377 (setq thread (cdr thread))
3379 (gnus-remove-thread-1 (car thread))
3380 (setq thread (cdr thread))))
3381 (gnus-remove-thread-1 thread))))))))
3383 (defun gnus-remove-thread-1 (thread)
3384 "Remove the thread THREAD recursively."
3385 (let ((number (mail-header-number (pop thread)))
3387 (setq thread (reverse thread))
3389 (gnus-remove-thread-1 (pop thread)))
3390 (when (setq d (gnus-data-find number))
3391 (goto-char (gnus-data-pos d))
3394 (- (gnus-point-at-bol)
3396 (1+ (gnus-point-at-eol))
3397 (gnus-delete-line)))))))
3399 (defun gnus-sort-threads (threads)
3401 (if (not gnus-thread-sort-functions)
3403 (gnus-message 7 "Sorting threads...")
3405 (sort threads (gnus-make-sort-function gnus-thread-sort-functions))
3406 (gnus-message 7 "Sorting threads...done"))))
3408 (defun gnus-sort-articles (articles)
3410 (when gnus-article-sort-functions
3411 (gnus-message 7 "Sorting articles...")
3413 (setq gnus-newsgroup-headers
3414 (sort articles (gnus-make-sort-function
3415 gnus-article-sort-functions)))
3416 (gnus-message 7 "Sorting articles...done"))))
3418 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3419 (defmacro gnus-thread-header (thread)
3420 ;; Return header of first article in THREAD.
3421 ;; Note that THREAD must never, ever be anything else than a variable -
3422 ;; using some other form will lead to serious barfage.
3423 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
3424 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
3425 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
3428 (defsubst gnus-article-sort-by-number (h1 h2)
3429 "Sort articles by article number."
3430 (< (mail-header-number h1)
3431 (mail-header-number h2)))
3433 (defun gnus-thread-sort-by-number (h1 h2)
3434 "Sort threads by root article number."
3435 (gnus-article-sort-by-number
3436 (gnus-thread-header h1) (gnus-thread-header h2)))
3438 (defsubst gnus-article-sort-by-lines (h1 h2)
3439 "Sort articles by article Lines header."
3440 (< (mail-header-lines h1)
3441 (mail-header-lines h2)))
3443 (defun gnus-thread-sort-by-lines (h1 h2)
3444 "Sort threads by root article Lines header."
3445 (gnus-article-sort-by-lines
3446 (gnus-thread-header h1) (gnus-thread-header h2)))
3448 (defsubst gnus-article-sort-by-author (h1 h2)
3449 "Sort articles by root author."
3451 (let ((extract (funcall
3452 gnus-extract-address-components
3453 (mail-header-from h1))))
3454 (or (car extract) (cadr extract) ""))
3455 (let ((extract (funcall
3456 gnus-extract-address-components
3457 (mail-header-from h2))))
3458 (or (car extract) (cadr extract) ""))))
3460 (defun gnus-thread-sort-by-author (h1 h2)
3461 "Sort threads by root author."
3462 (gnus-article-sort-by-author
3463 (gnus-thread-header h1) (gnus-thread-header h2)))
3465 (defsubst gnus-article-sort-by-subject (h1 h2)
3466 "Sort articles by root subject."
3468 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
3469 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
3471 (defun gnus-thread-sort-by-subject (h1 h2)
3472 "Sort threads by root subject."
3473 (gnus-article-sort-by-subject
3474 (gnus-thread-header h1) (gnus-thread-header h2)))
3476 (defsubst gnus-article-sort-by-date (h1 h2)
3477 "Sort articles by root article date."
3479 (gnus-date-get-time (mail-header-date h1))
3480 (gnus-date-get-time (mail-header-date h2))))
3482 (defun gnus-thread-sort-by-date (h1 h2)
3483 "Sort threads by root article date."
3484 (gnus-article-sort-by-date
3485 (gnus-thread-header h1) (gnus-thread-header h2)))
3487 (defsubst gnus-article-sort-by-score (h1 h2)
3488 "Sort articles by root article score.
3489 Unscored articles will be counted as having a score of zero."
3490 (> (or (cdr (assq (mail-header-number h1)
3491 gnus-newsgroup-scored))
3492 gnus-summary-default-score 0)
3493 (or (cdr (assq (mail-header-number h2)
3494 gnus-newsgroup-scored))
3495 gnus-summary-default-score 0)))
3497 (defun gnus-thread-sort-by-score (h1 h2)
3498 "Sort threads by root article score."
3499 (gnus-article-sort-by-score
3500 (gnus-thread-header h1) (gnus-thread-header h2)))
3502 (defun gnus-thread-sort-by-total-score (h1 h2)
3503 "Sort threads by the sum of all scores in the thread.
3504 Unscored articles will be counted as having a score of zero."
3505 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
3507 (defun gnus-thread-total-score (thread)
3508 ;; This function find the total score of THREAD.
3509 (cond ((null thread)
3512 (if (stringp (car thread))
3513 (apply gnus-thread-score-function 0
3514 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
3515 (gnus-thread-total-score-1 thread)))
3517 (gnus-thread-total-score-1 (list thread)))))
3519 (defun gnus-thread-total-score-1 (root)
3520 ;; This function find the total score of the thread below ROOT.
3521 (setq root (car root))
3522 (apply gnus-thread-score-function
3524 (mapcar 'gnus-thread-total-score
3525 (cdr (gnus-id-to-thread (mail-header-id root))))
3526 (when (> (mail-header-number root) 0)
3527 (list (or (cdr (assq (mail-header-number root)
3528 gnus-newsgroup-scored))
3529 gnus-summary-default-score 0))))
3530 (list gnus-summary-default-score)
3533 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
3534 (defvar gnus-tmp-prev-subject nil)
3535 (defvar gnus-tmp-false-parent nil)
3536 (defvar gnus-tmp-root-expunged nil)
3537 (defvar gnus-tmp-dummy-line nil)
3539 (defun gnus-summary-prepare-threads (threads)
3540 "Prepare summary buffer from THREADS and indentation LEVEL.
3541 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
3542 or a straight list of headers."
3543 (gnus-message 7 "Generating summary...")
3545 (setq gnus-newsgroup-threads threads)
3548 (let ((gnus-tmp-level 0)
3549 (default-score (or gnus-summary-default-score 0))
3550 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
3551 thread number subject stack state gnus-tmp-gathered beg-match
3552 new-roots gnus-tmp-new-adopts thread-end
3553 gnus-tmp-header gnus-tmp-unread
3554 gnus-tmp-replied gnus-tmp-subject-or-nil
3555 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
3556 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
3557 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
3559 (setq gnus-tmp-prev-subject nil)
3561 (if (vectorp (car threads))
3562 ;; If this is a straight (sic) list of headers, then a
3563 ;; threaded summary display isn't required, so we just create
3564 ;; an unthreaded one.
3565 (gnus-summary-prepare-unthreaded threads)
3567 ;; Do the threaded display.
3569 (while (or threads stack gnus-tmp-new-adopts new-roots)
3571 (if (and (= gnus-tmp-level 0)
3574 (not gnus-tmp-false-parent)
3575 (or gnus-tmp-new-adopts new-roots))
3576 (if gnus-tmp-new-adopts
3577 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
3578 thread (list (car gnus-tmp-new-adopts))
3579 gnus-tmp-header (caar thread)
3580 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
3582 (setq thread (list (car new-roots))
3583 gnus-tmp-header (caar thread)
3584 new-roots (cdr new-roots))))
3587 ;; If there are some threads, we do them before the
3588 ;; threads on the stack.
3589 (setq thread threads
3590 gnus-tmp-header (caar thread))
3591 ;; There were no current threads, so we pop something off
3593 (setq state (car stack)
3594 gnus-tmp-level (car state)
3597 gnus-tmp-header (caar thread))))
3599 (setq gnus-tmp-false-parent nil)
3600 (setq gnus-tmp-root-expunged nil)
3601 (setq thread-end nil)
3603 (if (stringp gnus-tmp-header)
3604 ;; The header is a dummy root.
3606 ((eq gnus-summary-make-false-root 'adopt)
3607 ;; We let the first article adopt the rest.
3608 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
3610 (setq gnus-tmp-gathered
3612 (lambda (h) (mail-header-number (car h)))
3615 (setq thread (cons (list (caar thread)
3618 (setq gnus-tmp-level -1
3619 gnus-tmp-false-parent t))
3620 ((eq gnus-summary-make-false-root 'empty)
3621 ;; We print adopted articles with empty subject fields.
3622 (setq gnus-tmp-gathered
3624 (lambda (h) (mail-header-number (car h)))
3627 (setq gnus-tmp-level -1))
3628 ((eq gnus-summary-make-false-root 'dummy)
3629 ;; We remember that we probably want to output a dummy
3631 (setq gnus-tmp-dummy-line gnus-tmp-header)
3632 (setq gnus-tmp-prev-subject gnus-tmp-header))
3634 ;; We do not make a root for the gathered
3635 ;; sub-threads at all.
3636 (setq gnus-tmp-level -1)))
3638 (setq number (mail-header-number gnus-tmp-header)
3639 subject (mail-header-subject gnus-tmp-header))
3642 ;; If the thread has changed subject, we might want to make
3643 ;; this subthread into a root.
3644 ((and (null gnus-thread-ignore-subject)
3645 (not (zerop gnus-tmp-level))
3646 gnus-tmp-prev-subject
3648 (gnus-subject-equal gnus-tmp-prev-subject subject))))
3649 (setq new-roots (nconc new-roots (list (car thread)))
3651 gnus-tmp-header nil))
3652 ;; If the article lies outside the current limit,
3653 ;; then we do not display it.
3654 ((not (memq number gnus-newsgroup-limit))
3655 (setq gnus-tmp-gathered
3657 (lambda (h) (mail-header-number (car h)))
3660 (setq gnus-tmp-new-adopts (if (cdar thread)
3661 (append gnus-tmp-new-adopts
3663 gnus-tmp-new-adopts)
3665 gnus-tmp-header nil)
3666 (when (zerop gnus-tmp-level)
3667 (setq gnus-tmp-root-expunged t)))
3668 ;; Perhaps this article is to be marked as read?
3669 ((and gnus-summary-mark-below
3670 (< (or (cdr (assq number gnus-newsgroup-scored))
3672 gnus-summary-mark-below)
3673 ;; Don't touch sparse articles.
3674 (not (gnus-summary-article-sparse-p number))
3675 (not (gnus-summary-article-ancient-p number)))
3676 (setq gnus-newsgroup-unreads
3677 (delq number gnus-newsgroup-unreads))
3678 (if gnus-newsgroup-auto-expire
3679 (push number gnus-newsgroup-expirable)
3680 (push (cons number gnus-low-score-mark)
3681 gnus-newsgroup-reads))))
3683 (when gnus-tmp-header
3684 ;; We may have an old dummy line to output before this
3686 (when (and gnus-tmp-dummy-line
3689 (mail-header-subject gnus-tmp-header)))
3690 (gnus-summary-insert-dummy-line
3691 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
3692 (setq gnus-tmp-dummy-line nil))
3694 ;; Compute the mark.
3695 (setq gnus-tmp-unread (gnus-article-mark number))
3697 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
3698 gnus-tmp-header gnus-tmp-level)
3699 gnus-newsgroup-data)
3701 ;; Actually insert the line.
3703 gnus-tmp-subject-or-nil
3705 ((and gnus-thread-ignore-subject
3706 gnus-tmp-prev-subject
3707 (not (inline (gnus-subject-equal
3708 gnus-tmp-prev-subject subject))))
3710 ((zerop gnus-tmp-level)
3711 (if (and (eq gnus-summary-make-false-root 'empty)
3712 (memq number gnus-tmp-gathered)
3713 gnus-tmp-prev-subject
3714 (inline (gnus-subject-equal
3715 gnus-tmp-prev-subject subject)))
3716 gnus-summary-same-subject
3718 (t gnus-summary-same-subject)))
3719 (if (and (eq gnus-summary-make-false-root 'adopt)
3720 (= gnus-tmp-level 1)
3721 (memq number gnus-tmp-gathered))
3722 (setq gnus-tmp-opening-bracket ?\<
3723 gnus-tmp-closing-bracket ?\>)
3724 (setq gnus-tmp-opening-bracket ?\[
3725 gnus-tmp-closing-bracket ?\]))
3727 gnus-tmp-indentation
3728 (aref gnus-thread-indent-array gnus-tmp-level)
3729 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
3730 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
3731 gnus-summary-default-score 0)
3733 (if (or (null gnus-summary-default-score)
3734 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3735 gnus-summary-zcore-fuzz))
3737 (if (< gnus-tmp-score gnus-summary-default-score)
3738 gnus-score-below-mark gnus-score-over-mark))
3740 (cond ((memq number gnus-newsgroup-processable)
3742 ((memq number gnus-newsgroup-cached)
3744 ((memq number gnus-newsgroup-replied)
3746 ((memq number gnus-newsgroup-saved)
3748 (t gnus-unread-mark))
3749 gnus-tmp-from (mail-header-from gnus-tmp-header)
3752 ((string-match "<[^>]+> *$" gnus-tmp-from)
3753 (setq beg-match (match-beginning 0))
3754 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
3755 (substring gnus-tmp-from (1+ (match-beginning 0))
3756 (1- (match-end 0))))
3757 (substring gnus-tmp-from 0 beg-match)))
3758 ((string-match "(.+)" gnus-tmp-from)
3759 (substring gnus-tmp-from
3760 (1+ (match-beginning 0)) (1- (match-end 0))))
3762 (when (string= gnus-tmp-name "")
3763 (setq gnus-tmp-name gnus-tmp-from))
3764 (unless (numberp gnus-tmp-lines)
3765 (setq gnus-tmp-lines 0))
3766 (gnus-put-text-property-excluding-characters-with-faces
3768 (progn (eval gnus-summary-line-format-spec) (point))
3769 'gnus-number number)
3772 (gnus-run-hooks 'gnus-summary-update-hook)
3775 (setq gnus-tmp-prev-subject subject)))
3777 (when (nth 1 thread)
3778 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
3779 (incf gnus-tmp-level)
3780 (setq threads (if thread-end nil (cdar thread)))
3782 (setq gnus-tmp-level 0)))))
3783 (gnus-message 7 "Generating summary...done"))
3785 (defun gnus-summary-prepare-unthreaded (headers)
3786 "Generate an unthreaded summary buffer based on HEADERS."
3787 (let (header number mark)
3792 ;; We may have to root out some bad articles...
3793 (when (memq (setq number (mail-header-number
3794 (setq header (pop headers))))
3795 gnus-newsgroup-limit)
3796 ;; Mark article as read when it has a low score.
3797 (when (and gnus-summary-mark-below
3798 (< (or (cdr (assq number gnus-newsgroup-scored))
3799 gnus-summary-default-score 0)
3800 gnus-summary-mark-below)
3801 (not (gnus-summary-article-ancient-p number)))
3802 (setq gnus-newsgroup-unreads
3803 (delq number gnus-newsgroup-unreads))
3804 (if gnus-newsgroup-auto-expire
3805 (push number gnus-newsgroup-expirable)
3806 (push (cons number gnus-low-score-mark)
3807 gnus-newsgroup-reads)))
3809 (setq mark (gnus-article-mark number))
3810 (push (gnus-data-make number mark (1+ (point)) header 0)
3811 gnus-newsgroup-data)
3812 (gnus-summary-insert-line
3814 mark (memq number gnus-newsgroup-replied)
3815 (memq number gnus-newsgroup-expirable)
3816 (mail-header-subject header) nil
3817 (cdr (assq number gnus-newsgroup-scored))
3818 (memq number gnus-newsgroup-processable))))))
3820 (defun gnus-select-newsgroup (group &optional read-all select-articles)
3821 "Select newsgroup GROUP.
3822 If READ-ALL is non-nil, all articles in the group are selected.
3823 If SELECT-ARTICLES, only select those articles from GROUP."
3824 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
3825 ;;!!! Dirty hack; should be removed.
3826 (gnus-summary-ignore-duplicates
3827 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
3829 gnus-summary-ignore-duplicates))
3830 (info (nth 2 entry))
3831 articles fetched-articles cached)
3833 (unless (gnus-check-server
3834 (setq gnus-current-select-method
3835 (gnus-find-method-for-group group)))
3836 (error "Couldn't open server"))
3838 (or (and entry (not (eq (car entry) t))) ; Either it's active...
3839 (gnus-activate-group group) ; Or we can activate it...
3840 (progn ; Or we bug out.
3841 (when (equal major-mode 'gnus-summary-mode)
3842 (kill-buffer (current-buffer)))
3843 (error "Couldn't request group %s: %s"
3844 group (gnus-status-message group))))
3846 (unless (gnus-request-group group t)
3847 (when (equal major-mode 'gnus-summary-mode)
3848 (kill-buffer (current-buffer)))
3849 (error "Couldn't request group %s: %s"
3850 group (gnus-status-message group)))
3852 (setq gnus-newsgroup-name group)
3853 (setq gnus-newsgroup-unselected nil)
3854 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
3856 ;; Adjust and set lists of article marks.
3858 (gnus-adjust-marked-articles info))
3860 ;; Kludge to avoid having cached articles nixed out in virtual groups.
3861 (when (gnus-virtual-group-p group)
3862 (setq cached gnus-newsgroup-cached))
3864 (setq gnus-newsgroup-unreads
3865 (gnus-set-difference
3866 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
3867 gnus-newsgroup-dormant))
3869 (setq gnus-newsgroup-processable nil)
3871 (gnus-update-read-articles group gnus-newsgroup-unreads)
3872 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
3873 (gnus-group-update-group group))
3875 (setq articles (or select-articles (gnus-articles-to-read group read-all)))
3879 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
3881 ((eq articles 0) nil)
3883 ;; Init the dependencies hash table.
3884 (setq gnus-newsgroup-dependencies
3885 (gnus-make-hashtable (length articles)))
3886 ;; Retrieve the headers and read them in.
3887 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
3888 (setq gnus-newsgroup-headers
3890 (setq gnus-headers-retrieved-by
3891 (gnus-retrieve-headers
3892 articles gnus-newsgroup-name
3893 ;; We might want to fetch old headers, but
3894 ;; not if there is only 1 article.
3896 (not (eq gnus-fetch-old-headers 'some))
3897 (not (numberp gnus-fetch-old-headers)))
3898 (> (length articles) 1))
3899 gnus-fetch-old-headers))))
3900 (gnus-get-newsgroup-headers-xover
3901 articles nil nil gnus-newsgroup-name t)
3902 (gnus-get-newsgroup-headers)))
3903 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
3905 ;; Kludge to avoid having cached articles nixed out in virtual groups.
3907 (setq gnus-newsgroup-cached cached))
3909 ;; Suppress duplicates?
3910 (when gnus-suppress-duplicates
3911 (gnus-dup-suppress-articles))
3913 ;; Set the initial limit.
3914 (setq gnus-newsgroup-limit (copy-sequence articles))
3915 ;; Remove canceled articles from the list of unread articles.
3916 (setq gnus-newsgroup-unreads
3917 (gnus-set-sorted-intersection
3918 gnus-newsgroup-unreads
3919 (setq fetched-articles
3920 (mapcar (lambda (headers) (mail-header-number headers))
3921 gnus-newsgroup-headers))))
3922 ;; Removed marked articles that do not exist.
3923 (gnus-update-missing-marks
3924 (gnus-sorted-complement fetched-articles articles))
3925 ;; We might want to build some more threads first.
3926 (when (and gnus-fetch-old-headers
3927 (eq gnus-headers-retrieved-by 'nov))
3928 (if (eq gnus-fetch-old-headers 'invisible)
3929 (gnus-build-all-threads)
3930 (gnus-build-old-threads)))
3931 ;; Let the Gnus agent mark articles as read.
3933 (gnus-agent-get-undownloaded-list))
3934 ;; Check whether auto-expire is to be done in this group.
3935 (setq gnus-newsgroup-auto-expire
3936 (gnus-group-auto-expirable-p group))
3937 ;; Set up the article buffer now, if necessary.
3938 (unless gnus-single-article-buffer
3939 (gnus-article-setup-buffer))
3940 ;; First and last article in this newsgroup.
3941 (when gnus-newsgroup-headers
3942 (setq gnus-newsgroup-begin
3943 (mail-header-number (car gnus-newsgroup-headers))
3946 (gnus-last-element gnus-newsgroup-headers))))
3947 ;; GROUP is successfully selected.
3948 (or gnus-newsgroup-headers t)))))
3950 (defun gnus-articles-to-read (group &optional read-all)
3951 ;; Find out what articles the user wants to read.
3953 ;; Select all articles if `read-all' is non-nil, or if there
3954 ;; are no unread articles.
3956 (and (zerop (length gnus-newsgroup-marked))
3957 (zerop (length gnus-newsgroup-unreads)))
3958 (eq (gnus-group-find-parameter group 'display)
3960 (gnus-uncompress-range (gnus-active group))
3961 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
3962 (copy-sequence gnus-newsgroup-unreads))
3964 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
3965 (scored (length scored-list))
3966 (number (length articles))
3967 (marked (+ (length gnus-newsgroup-marked)
3968 (length gnus-newsgroup-dormant)))
3976 ((and (or (<= scored marked) (= scored number))
3977 (numberp gnus-large-newsgroup)
3978 (> number gnus-large-newsgroup))
3982 "How many articles from %s (default %d): "
3983 (gnus-limit-string gnus-newsgroup-name 35)
3985 (if (string-match "^[ \t]*$" input) number input)))
3986 ((and (> scored marked) (< scored number)
3987 (> (- scored number) 20))
3990 (format "%s %s (%d scored, %d total): "
3991 "How many articles from"
3992 group scored number))))
3993 (if (string-match "^[ \t]*$" input)
3997 (setq select (if (stringp select) (string-to-number select) select))
3998 (if (or (null select) (zerop select))
4000 (if (and (not (zerop scored)) (<= (abs select) scored))
4002 (setq articles (sort scored-list '<))
4003 (setq number (length articles)))
4004 (setq articles (copy-sequence articles)))
4006 (when (< (abs select) number)
4008 ;; Select the N oldest articles.
4009 (setcdr (nthcdr (1- (abs select)) articles) nil)
4010 ;; Select the N most recent articles.
4011 (setq articles (nthcdr (- number select) articles))))
4012 (setq gnus-newsgroup-unselected
4013 (gnus-sorted-intersection
4014 gnus-newsgroup-unreads
4015 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4018 (defun gnus-killed-articles (killed articles)
4021 (when (inline (gnus-member-of-range (car articles) killed))
4022 (push (car articles) out))
4023 (setq articles (cdr articles)))
4026 (defun gnus-uncompress-marks (marks)
4027 "Uncompress the mark ranges in MARKS."
4028 (let ((uncompressed '(score bookmark))
4031 (if (memq (caar marks) uncompressed)
4032 (push (car marks) out)
4033 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
4034 (setq marks (cdr marks)))
4037 (defun gnus-adjust-marked-articles (info)
4038 "Set all article lists and remove all marks that are no longer legal."
4039 (let* ((marked-lists (gnus-info-marks info))
4040 (active (gnus-active (gnus-info-group info)))
4043 (types gnus-article-mark-lists)
4044 (uncompressed '(score bookmark killed))
4045 marks var articles article mark)
4048 (setq marks (pop marked-lists))
4049 (set (setq var (intern (format "gnus-newsgroup-%s"
4050 (car (rassq (setq mark (car marks))
4052 (if (memq (car marks) uncompressed) (cdr marks)
4053 (gnus-uncompress-range (cdr marks))))
4055 (setq articles (symbol-value var))
4057 ;; All articles have to be subsets of the active articles.
4059 ;; Adjust "simple" lists.
4060 ((memq mark '(tick dormant expire reply save))
4062 (when (or (< (setq article (pop articles)) min) (> article max))
4063 (set var (delq article (symbol-value var))))))
4065 ((memq mark uncompressed)
4066 (when (not (listp (cdr (symbol-value var))))
4067 (set var (list (symbol-value var))))
4068 (when (not (listp (cdr articles)))
4069 (setq articles (list articles)))
4071 (when (or (not (consp (setq article (pop articles))))
4072 (< (car article) min)
4073 (> (car article) max))
4074 (set var (delq article (symbol-value var))))))))))
4076 (defun gnus-update-missing-marks (missing)
4077 "Go through the list of MISSING articles and remove them from the mark lists."
4079 (let ((types gnus-article-mark-lists)
4081 ;; Go through all types.
4083 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
4084 (when (symbol-value var)
4085 ;; This list has articles. So we delete all missing articles
4089 (set var (delq (pop m) (symbol-value var)))))))))
4091 (defun gnus-update-marks ()
4092 "Enter the various lists of marked articles into the newsgroup info list."
4093 (let ((types gnus-article-mark-lists)
4094 (info (gnus-get-info gnus-newsgroup-name))
4095 (uncompressed '(score bookmark killed))
4096 type list newmarked symbol)
4098 ;; Add all marks lists that are non-nil to the list of marks lists.
4099 (while (setq type (pop types))
4100 (when (setq list (symbol-value
4102 (intern (format "gnus-newsgroup-%s"
4105 ;; Get rid of the entries of the articles that have the
4107 (when (and (eq (cdr type) 'score)
4111 (prev (cons nil list))
4114 (if (or (not (consp (car arts)))
4115 (= (cdar arts) gnus-summary-default-score))
4116 (setcdr prev (cdr arts))
4118 (setq arts (cdr arts)))
4119 (setq list (cdr all))))
4121 (push (cons (cdr type)
4122 (if (memq (cdr type) uncompressed) list
4123 (gnus-compress-sequence
4124 (set symbol (sort list '<)) t)))
4127 ;; Enter these new marks into the info of the group.
4129 (setcar (nthcdr 3 info) newmarked)
4130 ;; Add the marks lists to the end of the info.
4132 (setcdr (nthcdr 2 info) (list newmarked))))
4134 ;; Cut off the end of the info if there's nothing else there.
4138 (when (nthcdr (decf i) info)
4139 (setcdr (nthcdr i info) nil)))))))
4141 (defun gnus-set-mode-line (where)
4142 "This function sets the mode line of the article or summary buffers.
4143 If WHERE is `summary', the summary mode line format will be used."
4144 ;; Is this mode line one we keep updated?
4145 (when (memq where gnus-updated-mode-lines)
4148 ;; We evaluate this in the summary buffer since these
4149 ;; variables are buffer-local to that buffer.
4150 (set-buffer gnus-summary-buffer)
4151 ;; We bind all these variables that are used in the `eval' form
4153 (let* ((mformat (symbol-value
4155 (format "gnus-%s-mode-line-format-spec" where))))
4156 (gnus-tmp-group-name gnus-newsgroup-name)
4157 (gnus-tmp-article-number (or gnus-current-article 0))
4158 (gnus-tmp-unread gnus-newsgroup-unreads)
4159 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
4160 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
4161 (gnus-tmp-unread-and-unselected
4162 (cond ((and (zerop gnus-tmp-unread-and-unticked)
4163 (zerop gnus-tmp-unselected))
4165 ((zerop gnus-tmp-unselected)
4166 (format "{%d more}" gnus-tmp-unread-and-unticked))
4167 (t (format "{%d(+%d) more}"
4168 gnus-tmp-unread-and-unticked
4169 gnus-tmp-unselected))))
4171 (if (and gnus-current-headers
4172 (vectorp gnus-current-headers))
4173 (gnus-mode-string-quote
4174 (mail-header-subject gnus-current-headers))
4176 bufname-length max-len
4177 gnus-tmp-header);; passed as argument to any user-format-funcs
4178 (setq mode-string (eval mformat))
4179 (setq bufname-length (if (string-match "%b" mode-string)
4182 (if (eq where 'summary)
4184 (get-buffer gnus-article-buffer))))
4187 (setq max-len (max 4 (if gnus-mode-non-string-length
4189 gnus-mode-non-string-length
4191 (length mode-string))))
4192 ;; We might have to chop a bit of the string off...
4193 (when (> (length mode-string) max-len)
4195 (concat (gnus-truncate-string mode-string (- max-len 3))
4197 ;; Pad the mode string a bit.
4198 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
4199 ;; Update the mode line.
4200 (setq mode-line-buffer-identification
4201 (gnus-mode-line-buffer-identification (list mode-string)))
4202 (set-buffer-modified-p t))))
4204 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
4205 "Go through the HEADERS list and add all Xrefs to a hash table.
4206 The resulting hash table is returned, or nil if no Xrefs were found."
4207 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
4208 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
4209 (xref-hashtb (gnus-make-hashtable))
4210 start group entry number xrefs header)
4212 (setq header (pop headers))
4213 (when (and (setq xrefs (mail-header-xref header))
4214 (not (memq (setq number (mail-header-number header))
4217 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
4218 (setq start (match-end 0))
4219 (setq group (if prefix
4220 (concat prefix (substring xrefs (match-beginning 1)
4222 (substring xrefs (match-beginning 1) (match-end 1))))
4224 (string-to-int (substring xrefs (match-beginning 2)
4226 (if (setq entry (gnus-gethash group xref-hashtb))
4227 (setcdr entry (cons number (cdr entry)))
4228 (gnus-sethash group (cons number nil) xref-hashtb)))))
4229 (and start xref-hashtb)))
4231 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
4232 "Look through all the headers and mark the Xrefs as read."
4233 (let ((virtual (gnus-virtual-group-p from-newsgroup))
4234 name entry info xref-hashtb idlist method nth4)
4236 (set-buffer gnus-group-buffer)
4237 (when (setq xref-hashtb
4238 (gnus-create-xref-hashtb from-newsgroup headers unreads))
4241 (unless (string= from-newsgroup (setq name (symbol-name group)))
4242 (setq idlist (symbol-value group))
4243 ;; Dead groups are not updated.
4245 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
4247 (when (stringp (setq nth4 (gnus-info-method info)))
4248 (setq nth4 (gnus-server-to-method nth4))))
4249 ;; Only do the xrefs if the group has the same
4250 ;; select method as the group we have just read.
4251 (or (gnus-methods-equal-p
4252 nth4 (gnus-find-method-for-group from-newsgroup))
4254 (equal nth4 (setq method (gnus-find-method-for-group
4256 (and (equal (car nth4) (car method))
4257 (equal (nth 1 nth4) (nth 1 method))))
4258 gnus-use-cross-reference
4259 (or (not (eq gnus-use-cross-reference t))
4261 ;; Only do cross-references on subscribed
4262 ;; groups, if that is what is wanted.
4263 (<= (gnus-info-level info) gnus-level-subscribed))
4264 (gnus-group-make-articles-read name idlist))))
4267 (defun gnus-compute-read-articles (group articles)
4268 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4269 (info (nth 2 entry))
4270 (active (gnus-active group))
4273 ;; First peel off all illegal article numbers.
4275 (let ((ids articles)
4277 (while (setq id (pop ids))
4278 (when (and first (> id (cdr active)))
4279 ;; We'll end up in this situation in one particular
4280 ;; obscure situation. If you re-scan a group and get
4281 ;; a new article that is cross-posted to a different
4282 ;; group that has not been re-scanned, you might get
4283 ;; crossposted article that has a higher number than
4284 ;; Gnus believes possible. So we re-activate this
4285 ;; group as well. This might mean doing the
4286 ;; crossposting thingy will *increase* the number
4287 ;; of articles in some groups. Tsk, tsk.
4288 (setq active (or (gnus-activate-group group) active)))
4289 (when (or (> id (cdr active))
4290 (< id (car active)))
4291 (setq articles (delq id articles))))))
4292 ;; If the read list is nil, we init it.
4294 (null (gnus-info-read info))
4296 (setq ninfo (cons 1 (1- (car active))))
4297 (setq ninfo (gnus-info-read info)))
4298 ;; Then we add the read articles to the range.
4300 ninfo (setq articles (sort articles '<))))))
4302 (defun gnus-group-make-articles-read (group articles)
4303 "Update the info of GROUP to say that ARTICLES are read."
4305 (entry (gnus-gethash group gnus-newsrc-hashtb))
4306 (info (nth 2 entry))
4307 (active (gnus-active group))
4310 (setq range (gnus-compute-read-articles group articles))
4312 (set-buffer gnus-group-buffer)
4315 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
4316 (gnus-info-set-read ',info ',(gnus-info-read info))
4317 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
4318 (gnus-group-update-group ,group t))))
4319 ;; Add the read articles to the range.
4320 (gnus-info-set-read info range)
4321 ;; Then we have to re-compute how many unread
4322 ;; articles there are in this group.
4326 (setq num (- (1+ (cdr active)) (car active))))
4327 ((not (listp (cdr range)))
4328 (setq num (- (cdr active) (- (1+ (cdr range))
4332 (if (numberp (car range))
4334 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
4335 (setq range (cdr range)))
4336 (setq num (- (cdr active) num))))
4337 ;; Update the number of unread articles.
4339 ;; Update the group buffer.
4340 (gnus-group-update-group group t)))))
4342 (defun gnus-methods-equal-p (m1 m2)
4343 (let ((m1 (or m1 gnus-select-method))
4344 (m2 (or m2 gnus-select-method)))
4346 (and (eq (car m1) (car m2))
4347 (or (not (memq 'address (assoc (symbol-name (car m1))
4348 gnus-valid-select-methods)))
4349 (equal (nth 1 m1) (nth 1 m2)))))))
4351 (defvar gnus-newsgroup-none-id 0)
4353 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
4354 (let ((cur nntp-server-buffer)
4357 (save-excursion (set-buffer gnus-summary-buffer)
4358 gnus-newsgroup-dependencies)))
4359 headers id id-dep ref-dep end ref)
4361 (set-buffer nntp-server-buffer)
4362 ;; Translate all TAB characters into SPACE characters.
4363 (subst-char-in-region (point-min) (point-max) ?\t ? t)
4364 (gnus-run-hooks 'gnus-parse-headers-hook)
4365 (let ((case-fold-search t)
4366 in-reply-to header p lines chars)
4367 (goto-char (point-min))
4368 ;; Search to the beginning of the next header. Error messages
4369 ;; do not begin with 2 or 3.
4370 (while (re-search-forward "^[23][0-9]+ " nil t)
4373 ;; This implementation of this function, with nine
4374 ;; search-forwards instead of the one re-search-forward and
4375 ;; a case (which basically was the old function) is actually
4376 ;; about twice as fast, even though it looks messier. You
4377 ;; can't have everything, I guess. Speed and elegance
4378 ;; doesn't always go hand in hand.
4387 (narrow-to-region (point)
4388 (or (and (search-forward "\n.\n" nil t)
4394 (if (search-forward "\nsubject: " nil t)
4396 gnus-unstructured-field-decoder (nnheader-header-value))
4401 (if (search-forward "\nfrom: " nil t)
4403 gnus-structured-field-decoder (nnheader-header-value))
4408 (if (search-forward "\ndate: " nil t)
4409 (nnheader-header-value) ""))
4413 (setq id (if (re-search-forward
4414 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
4415 ;; We do it this way to make sure the Message-ID
4416 ;; is (somewhat) syntactically valid.
4417 (buffer-substring (match-beginning 1)
4419 ;; If there was no message-id, we just fake one
4420 ;; to make subsequent routines simpler.
4421 (nnheader-generate-fake-message-id))))
4425 (if (search-forward "\nreferences: " nil t)
4429 (nnheader-header-value)
4434 (search-backward ">" end t)
4437 (search-backward "<" end t)
4439 ;; Get the references from the in-reply-to header if there
4440 ;; were no references and the in-reply-to header looks
4442 (if (and (search-forward "\nin-reply-to: " nil t)
4443 (setq in-reply-to (nnheader-header-value))
4444 (string-match "<[^>]+>" in-reply-to))
4446 (setq ref (substring in-reply-to (match-beginning 0)
4448 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
4449 (setq ref2 (substring in-reply-to (match-beginning 0)
4451 (when (> (length ref2) (length ref))
4457 (if (search-forward "\nchars: " nil t)
4458 (if (numberp (setq chars (ignore-errors (read cur))))
4464 (if (search-forward "\nlines: " nil t)
4465 (if (numberp (setq lines (ignore-errors (read cur))))
4471 (and (search-forward "\nxref: " nil t)
4472 (nnheader-header-value)))))
4473 (when (equal id ref)
4476 (when gnus-alter-header-function
4477 (funcall gnus-alter-header-function header)
4478 (setq id (mail-header-id header)
4479 ref (gnus-parent-id (mail-header-references header))))
4482 (gnus-dependencies-add-header
4483 header dependencies force-new))
4484 (push header headers))
4485 (goto-char (point-max))
4487 (nreverse headers)))))
4489 ;; Goes through the xover lines and returns a list of vectors
4490 (defun gnus-get-newsgroup-headers-xover (sequence &optional
4491 force-new dependencies
4492 group also-fetch-heads)
4493 "Parse the news overview data in the server buffer, and return a
4494 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
4495 ;; Get the Xref when the users reads the articles since most/some
4496 ;; NNTP servers do not include Xrefs when using XOVER.
4497 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
4498 (let ((cur nntp-server-buffer)
4499 (dependencies (or dependencies gnus-newsgroup-dependencies))
4500 number headers header)
4502 (set-buffer nntp-server-buffer)
4503 ;; Allow the user to mangle the headers before parsing them.
4504 (gnus-run-hooks 'gnus-parse-headers-hook)
4505 (goto-char (point-min))
4508 (while (and sequence (not (eobp)))
4509 (setq number (read cur))
4510 (while (and sequence
4511 (< (car sequence) number))
4512 (setq sequence (cdr sequence)))
4514 (eq number (car sequence))
4516 (setq sequence (cdr sequence))
4517 (setq header (inline
4518 (gnus-nov-parse-line
4519 number dependencies force-new))))
4520 (push header headers))
4523 (gnus-error 4 "Strange nov line (%d)"
4524 (count-lines (point-min) (point)))))
4526 ;; A common bug in inn is that if you have posted an article and
4527 ;; then retrieves the active file, it will answer correctly --
4528 ;; the new article is included. However, a NOV entry for the
4529 ;; article may not have been generated yet, so this may fail.
4530 ;; We work around this problem by retrieving the last few
4531 ;; headers using HEAD.
4532 (if (or (not also-fetch-heads)
4534 ;; We (probably) got all the headers.
4536 (let ((gnus-nov-is-evil t))
4539 (when (gnus-retrieve-headers sequence group)
4540 (gnus-get-newsgroup-headers))))))))
4542 (defun gnus-article-get-xrefs ()
4543 "Fill in the Xref value in `gnus-current-headers', if necessary.
4544 This is meant to be called in `gnus-article-internal-prepare-hook'."
4545 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
4546 gnus-current-headers)))
4547 (or (not gnus-use-cross-reference)
4549 (and (mail-header-xref headers)
4550 (not (string= (mail-header-xref headers) "")))
4551 (let ((case-fold-search t)
4554 (nnheader-narrow-to-headers)
4555 (goto-char (point-min))
4556 (when (or (and (eq (downcase (following-char)) ?x)
4557 (looking-at "Xref:"))
4558 (search-forward "\nXref:" nil t))
4559 (goto-char (1+ (match-end 0)))
4560 (setq xref (buffer-substring (point)
4561 (progn (end-of-line) (point))))
4562 (mail-header-set-xref headers xref)))))))
4564 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
4565 "Find article ID and insert the summary line for that article.
4566 OLD-HEADER can either be a header or a line number to insert
4567 the subject line on."
4568 (let* ((line (and (numberp old-header) old-header))
4569 (old-header (and (vectorp old-header) old-header))
4570 (header (cond ((and old-header use-old-header)
4573 (gnus-number-to-header id))
4574 (gnus-number-to-header id))
4576 (gnus-read-header id))))
4577 (number (and (numberp id) id))
4580 ;; Rebuild the thread that this article is part of and go to the
4581 ;; article we have fetched.
4582 (when (and (not gnus-show-threads)
4585 (setq d (gnus-data-find (mail-header-number old-header))))
4586 (goto-char (gnus-data-pos d))
4589 (- (gnus-point-at-bol)
4591 (1+ (gnus-point-at-eol))
4592 (gnus-delete-line))))))
4594 (mail-header-set-number header (mail-header-number old-header)))
4595 (setq gnus-newsgroup-sparse
4596 (delq (setq number (mail-header-number header))
4597 gnus-newsgroup-sparse))
4598 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
4599 (push number gnus-newsgroup-limit)
4600 (gnus-rebuild-thread (mail-header-id header) line)
4601 (gnus-summary-goto-subject number nil t))
4602 (when (and (numberp number)
4604 ;; We have to update the boundaries even if we can't fetch the
4605 ;; article if ID is a number -- so that the next `P' or `N'
4606 ;; command will fetch the previous (or next) article even
4607 ;; if the one we tried to fetch this time has been canceled.
4608 (when (> number gnus-newsgroup-end)
4609 (setq gnus-newsgroup-end number))
4610 (when (< number gnus-newsgroup-begin)
4611 (setq gnus-newsgroup-begin number))
4612 (setq gnus-newsgroup-unselected
4613 (delq number gnus-newsgroup-unselected)))
4614 ;; Report back a success?
4615 (and header (mail-header-number header))))
4617 ;;; Process/prefix in the summary buffer
4619 (defun gnus-summary-work-articles (n)
4620 "Return a list of articles to be worked upon.
4621 The prefix argument, the list of process marked articles, and the
4622 current article will be taken into consideration."
4624 (set-buffer gnus-summary-buffer)
4627 ;; A numerical prefix has been given.
4628 (setq n (prefix-numeric-value n))
4629 (let ((backward (< n 0))
4630 (n (abs (prefix-numeric-value n)))
4635 (push (setq article (gnus-summary-article-number))
4638 (gnus-summary-find-prev nil article)
4639 (gnus-summary-find-next nil article)))
4641 (nreverse articles)))
4642 ((and (gnus-region-active-p) (mark))
4643 (message "region active")
4644 ;; Work on the region between point and mark.
4645 (let ((max (max (point) (mark)))
4648 (goto-char (min (min (point) (mark))))
4651 (push (setq article (gnus-summary-article-number)) articles)
4652 (gnus-summary-find-next nil article)
4654 (nreverse articles))))
4655 (gnus-newsgroup-processable
4656 ;; There are process-marked articles present.
4657 ;; Save current state.
4658 (gnus-summary-save-process-mark)
4660 (reverse gnus-newsgroup-processable))
4662 ;; Just return the current article.
4663 (list (gnus-summary-article-number))))))
4665 (defmacro gnus-summary-iterate (arg &rest forms)
4666 "Iterate over the process/prefixed articles and do FORMS.
4667 ARG is the interactive prefix given to the command. FORMS will be
4668 executed with point over the summary line of the articles."
4669 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
4670 `(let ((,articles (gnus-summary-work-articles ,arg)))
4672 (gnus-summary-goto-subject (car ,articles))
4675 (put 'gnus-summary-iterate 'lisp-indent-function 1)
4676 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
4678 (defun gnus-summary-save-process-mark ()
4679 "Push the current set of process marked articles on the stack."
4681 (push (copy-sequence gnus-newsgroup-processable)
4682 gnus-newsgroup-process-stack))
4684 (defun gnus-summary-kill-process-mark ()
4685 "Push the current set of process marked articles on the stack and unmark."
4687 (gnus-summary-save-process-mark)
4688 (gnus-summary-unmark-all-processable))
4690 (defun gnus-summary-yank-process-mark ()
4691 "Pop the last process mark state off the stack and restore it."
4693 (unless gnus-newsgroup-process-stack
4694 (error "Empty mark stack"))
4695 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
4697 (defun gnus-summary-process-mark-set (set)
4698 "Make SET into the current process marked articles."
4699 (gnus-summary-unmark-all-processable)
4701 (gnus-summary-set-process-mark (pop set))))
4703 ;;; Searching and stuff
4705 (defun gnus-summary-search-group (&optional backward use-level)
4706 "Search for next unread newsgroup.
4707 If optional argument BACKWARD is non-nil, search backward instead."
4709 (set-buffer gnus-group-buffer)
4710 (when (gnus-group-search-forward
4711 backward nil (if use-level (gnus-group-group-level) nil))
4712 (gnus-group-group-name))))
4714 (defun gnus-summary-best-group (&optional exclude-group)
4715 "Find the name of the best unread group.
4716 If EXCLUDE-GROUP, do not go to this group."
4718 (set-buffer gnus-group-buffer)
4720 (gnus-group-best-unread-group exclude-group))))
4722 (defun gnus-summary-find-next (&optional unread article backward undownloaded)
4723 (if backward (gnus-summary-find-prev)
4724 (let* ((dummy (gnus-summary-article-intangible-p))
4725 (article (or article (gnus-summary-article-number)))
4726 (arts (gnus-data-find-list article))
4728 (when (and (not dummy)
4729 (or (not gnus-summary-check-current)
4731 (not (gnus-data-unread-p (car arts)))))
4732 (setq arts (cdr arts)))
4737 (when (or (and undownloaded
4738 (eq gnus-undownloaded-mark
4739 (gnus-data-mark (car arts))))
4740 (gnus-data-unread-p (car arts)))
4741 (setq result (car arts)
4743 (setq arts (cdr arts)))
4746 (goto-char (gnus-data-pos result))
4747 (gnus-data-number result)))))
4749 (defun gnus-summary-find-prev (&optional unread article)
4750 (let* ((eobp (eobp))
4751 (article (or article (gnus-summary-article-number)))
4752 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
4754 (when (and (not eobp)
4755 (or (not gnus-summary-check-current)
4757 (not (gnus-data-unread-p (car arts)))))
4758 (setq arts (cdr arts)))
4763 (when (gnus-data-unread-p (car arts))
4764 (setq result (car arts)
4766 (setq arts (cdr arts)))
4769 (goto-char (gnus-data-pos result))
4770 (gnus-data-number result))))
4772 (defun gnus-summary-find-subject (subject &optional unread backward article)
4773 (let* ((simp-subject (gnus-simplify-subject-fully subject))
4774 (article (or article (gnus-summary-article-number)))
4775 (articles (gnus-data-list backward))
4776 (arts (gnus-data-find-list article articles))
4778 (when (or (not gnus-summary-check-current)
4780 (not (gnus-data-unread-p (car arts))))
4781 (setq arts (cdr arts)))
4783 (and (or (not unread)
4784 (gnus-data-unread-p (car arts)))
4785 (vectorp (gnus-data-header (car arts)))
4787 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
4788 (setq result (car arts)
4790 (setq arts (cdr arts)))
4792 (goto-char (gnus-data-pos result))
4793 (gnus-data-number result))))
4795 (defun gnus-summary-search-forward (&optional unread subject backward)
4796 "Search forward for an article.
4797 If UNREAD, look for unread articles. If SUBJECT, look for
4798 articles with that subject. If BACKWARD, search backward instead."
4799 (cond (subject (gnus-summary-find-subject subject unread backward))
4800 (backward (gnus-summary-find-prev unread))
4801 (t (gnus-summary-find-next unread))))
4803 (defun gnus-recenter (&optional n)
4804 "Center point in window and redisplay frame.
4805 Also do horizontal recentering."
4807 (when (and gnus-auto-center-summary
4808 (not (eq gnus-auto-center-summary 'vertical)))
4809 (gnus-horizontal-recenter))
4812 (defun gnus-summary-recenter ()
4813 "Center point in the summary window.
4814 If `gnus-auto-center-summary' is nil, or the article buffer isn't
4815 displayed, no centering will be performed."
4816 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
4817 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
4818 (let* ((top (cond ((< (window-height) 4) 0)
4819 ((< (window-height) 7) 1)
4821 (height (1- (window-height)))
4822 (bottom (save-excursion (goto-char (point-max))
4823 (forward-line (- height))
4825 (window (get-buffer-window (current-buffer))))
4826 ;; The user has to want it.
4827 (when gnus-auto-center-summary
4828 (when (get-buffer-window gnus-article-buffer)
4829 ;; Only do recentering when the article buffer is displayed,
4830 ;; Set the window start to either `bottom', which is the biggest
4831 ;; possible valid number, or the second line from the top,
4832 ;; whichever is the least.
4834 window (min bottom (save-excursion
4835 (forward-line (- top)) (point)))))
4836 ;; Do horizontal recentering while we're at it.
4837 (when (and (get-buffer-window (current-buffer) t)
4838 (not (eq gnus-auto-center-summary 'vertical)))
4839 (let ((selected (selected-window)))
4840 (select-window (get-buffer-window (current-buffer) t))
4841 (gnus-summary-position-point)
4842 (gnus-horizontal-recenter)
4843 (select-window selected))))))
4845 (defun gnus-summary-jump-to-group (newsgroup)
4846 "Move point to NEWSGROUP in group mode buffer."
4847 ;; Keep update point of group mode buffer if visible.
4848 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
4849 (save-window-excursion
4850 ;; Take care of tree window mode.
4851 (when (get-buffer-window gnus-group-buffer)
4852 (pop-to-buffer gnus-group-buffer))
4853 (gnus-group-jump-to-group newsgroup))
4855 ;; Take care of tree window mode.
4856 (if (get-buffer-window gnus-group-buffer)
4857 (pop-to-buffer gnus-group-buffer)
4858 (set-buffer gnus-group-buffer))
4859 (gnus-group-jump-to-group newsgroup))))
4861 ;; This function returns a list of article numbers based on the
4862 ;; difference between the ranges of read articles in this group and
4863 ;; the range of active articles.
4864 (defun gnus-list-of-unread-articles (group)
4865 (let* ((read (gnus-info-read (gnus-get-info group)))
4866 (active (or (gnus-active group) (gnus-activate-group group)))
4869 ;; If none are read, then all are unread.
4871 (setq first (car active))
4872 ;; If the range of read articles is a single range, then the
4873 ;; first unread article is the article after the last read
4874 ;; article. Sounds logical, doesn't it?
4875 (if (not (listp (cdr read)))
4876 (setq first (max (car active) (1+ (cdr read))))
4877 ;; `read' is a list of ranges.
4878 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
4881 (setq first (car active)))
4884 (while (< first nlast)
4886 (setq first (1+ first))))
4887 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
4888 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
4889 (setq read (cdr read)))))
4890 ;; And add the last unread articles.
4891 (while (<= first last)
4893 (setq first (1+ first)))
4894 ;; Return the list of unread articles.
4895 (delq 0 (nreverse unread))))
4897 (defun gnus-list-of-read-articles (group)
4898 "Return a list of unread, unticked and non-dormant articles."
4899 (let* ((info (gnus-get-info group))
4900 (marked (gnus-info-marks info))
4901 (active (gnus-active group)))
4903 (gnus-set-difference
4904 (gnus-sorted-complement
4905 (gnus-uncompress-range active)
4906 (gnus-list-of-unread-articles group))
4908 (gnus-uncompress-range (cdr (assq 'dormant marked)))
4909 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
4911 ;; Various summary commands
4913 (defun gnus-summary-select-article-buffer ()
4914 "Reconfigure windows to show article buffer."
4916 (if (not (gnus-buffer-live-p gnus-article-buffer))
4917 (error "There is no article buffer for this summary buffer")
4918 (gnus-configure-windows 'article)
4919 (select-window (get-buffer-window gnus-article-buffer))))
4921 (defun gnus-summary-universal-argument (arg)
4922 "Perform any operation on all articles that are process/prefixed."
4924 (let ((articles (gnus-summary-work-articles arg))
4931 (substitute-command-keys
4932 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
4935 (gnus-error 1 "Undefined key")
4938 (gnus-summary-goto-subject (setq article (pop articles)))
4939 (let (gnus-newsgroup-processable)
4940 (command-execute func))
4941 (gnus-summary-remove-process-mark article)))))
4942 (gnus-summary-position-point))
4944 (defun gnus-summary-toggle-truncation (&optional arg)
4945 "Toggle truncation of summary lines.
4946 With arg, turn line truncation on iff arg is positive."
4948 (setq truncate-lines
4949 (if (null arg) (not truncate-lines)
4950 (> (prefix-numeric-value arg) 0)))
4953 (defun gnus-summary-reselect-current-group (&optional all rescan)
4954 "Exit and then reselect the current newsgroup.
4955 The prefix argument ALL means to select all articles."
4957 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
4958 (error "Ephemeral groups can't be reselected"))
4959 (let ((current-subject (gnus-summary-article-number))
4960 (group gnus-newsgroup-name))
4961 (setq gnus-newsgroup-begin nil)
4963 ;; We have to adjust the point of group mode buffer because
4964 ;; point was moved to the next unread newsgroup by exiting.
4965 (gnus-summary-jump-to-group group)
4968 (gnus-group-get-new-news-this-group 1)))
4969 (gnus-group-read-group all t)
4970 (gnus-summary-goto-subject current-subject nil t)))
4972 (defun gnus-summary-rescan-group (&optional all)
4973 "Exit the newsgroup, ask for new articles, and select the newsgroup."
4975 (gnus-summary-reselect-current-group all t))
4977 (defun gnus-summary-update-info (&optional non-destructive)
4979 (let ((group gnus-newsgroup-name))
4981 (when gnus-newsgroup-kill-headers
4982 (setq gnus-newsgroup-killed
4983 (gnus-compress-sequence
4985 (gnus-set-sorted-intersection
4986 (gnus-uncompress-range gnus-newsgroup-killed)
4987 (setq gnus-newsgroup-unselected
4988 (sort gnus-newsgroup-unselected '<)))
4989 (setq gnus-newsgroup-unreads
4990 (sort gnus-newsgroup-unreads '<)))
4992 (unless (listp (cdr gnus-newsgroup-killed))
4993 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
4994 (let ((headers gnus-newsgroup-headers))
4995 ;; Set the new ranges of read articles.
4997 (set-buffer gnus-group-buffer)
4998 (gnus-undo-force-boundary))
4999 (gnus-update-read-articles
5000 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
5001 ;; Set the current article marks.
5002 (let ((gnus-newsgroup-scored
5003 (if (and (not gnus-save-score)
5004 (not non-destructive))
5006 gnus-newsgroup-scored)))
5008 (gnus-update-marks)))
5009 ;; Do the cross-ref thing.
5010 (when gnus-use-cross-reference
5011 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
5012 ;; Do not switch windows but change the buffer to work.
5013 (set-buffer gnus-group-buffer)
5014 (unless (gnus-ephemeral-group-p group)
5015 (gnus-group-update-group group)))))))
5017 (defun gnus-summary-save-newsrc (&optional force)
5018 "Save the current number of read/marked articles in the dribble buffer.
5019 The dribble buffer will then be saved.
5020 If FORCE (the prefix), also save the .newsrc file(s)."
5022 (gnus-summary-update-info t)
5024 (gnus-save-newsrc-file)
5025 (gnus-dribble-save)))
5027 (defun gnus-summary-exit (&optional temporary)
5028 "Exit reading current newsgroup, and then return to group selection mode.
5029 gnus-exit-group-hook is called with no arguments if that value is non-nil."
5031 (gnus-set-global-variables)
5032 (gnus-kill-save-kill-buffer)
5033 (gnus-async-halt-prefetch)
5034 (let* ((group gnus-newsgroup-name)
5035 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
5038 (buf (current-buffer)))
5039 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
5040 ;; If we have several article buffers, we kill them at exit.
5041 (unless gnus-single-article-buffer
5042 (gnus-kill-buffer gnus-original-article-buffer)
5043 (setq gnus-article-current nil))
5044 (when gnus-use-cache
5045 (gnus-cache-possibly-remove-articles)
5046 (gnus-cache-save-buffers))
5047 (gnus-async-prefetch-remove-group group)
5048 (when gnus-suppress-duplicates
5049 (gnus-dup-enter-articles))
5050 (when gnus-use-trees
5051 (gnus-tree-close group))
5052 ;; Remove entries for this group.
5053 (nnmail-purge-split-history (gnus-group-real-name group))
5054 ;; Make all changes in this group permanent.
5056 (gnus-run-hooks 'gnus-exit-group-hook)
5057 (gnus-summary-update-info)
5058 ;; Do adaptive scoring, and possibly save score files.
5059 (when gnus-newsgroup-adaptive
5060 (gnus-score-adaptive))
5061 (when gnus-use-scoring
5063 (gnus-close-group group)
5064 ;; Make sure where we were, and go to next newsgroup.
5065 (set-buffer gnus-group-buffer)
5067 (gnus-group-jump-to-group group))
5068 (gnus-run-hooks 'gnus-summary-exit-hook)
5069 (unless (or quit-config
5070 ;; If this group has disappeared from the summary
5071 ;; buffer, don't skip forwards.
5072 (not (string= group (gnus-group-group-name))))
5073 (gnus-group-next-unread-group 1))
5074 (setq group-point (point))
5077 ;; If we have several article buffers, we kill them at exit.
5078 (unless gnus-single-article-buffer
5079 (gnus-kill-buffer gnus-article-buffer)
5080 (gnus-kill-buffer gnus-original-article-buffer)
5081 (setq gnus-article-current nil))
5083 (if (not gnus-kill-summary-on-exit)
5084 (gnus-deaden-summary)
5085 ;; We set all buffer-local variables to nil. It is unclear why
5086 ;; this is needed, but if we don't, buffer-local variables are
5087 ;; not garbage-collected, it seems. This would the lead to en
5088 ;; ever-growing Emacs.
5089 (gnus-summary-clear-local-variables)
5090 (when (get-buffer gnus-article-buffer)
5091 (bury-buffer gnus-article-buffer))
5092 ;; We clear the global counterparts of the buffer-local
5093 ;; variables as well, just to be on the safe side.
5094 (set-buffer gnus-group-buffer)
5095 (gnus-summary-clear-local-variables)
5096 ;; Return to group mode buffer.
5097 (when (eq mode 'gnus-summary-mode)
5098 (gnus-kill-buffer buf)))
5099 (setq gnus-current-select-method gnus-select-method)
5100 (pop-to-buffer gnus-group-buffer)
5101 ;; Clear the current group name.
5102 (if (not quit-config)
5104 (goto-char group-point)
5105 (gnus-configure-windows 'group 'force))
5106 (gnus-handle-ephemeral-exit quit-config))
5108 (setq gnus-newsgroup-name nil)))))
5110 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
5111 (defun gnus-summary-exit-no-update (&optional no-questions)
5112 "Quit reading current newsgroup without updating read article info."
5114 (let* ((group gnus-newsgroup-name)
5115 (quit-config (gnus-group-quit-config group)))
5116 (when (or no-questions
5118 (gnus-y-or-n-p "Discard changes to this group and exit? "))
5119 (gnus-async-halt-prefetch)
5120 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
5121 ;; If we have several article buffers, we kill them at exit.
5122 (unless gnus-single-article-buffer
5123 (gnus-kill-buffer gnus-article-buffer)
5124 (gnus-kill-buffer gnus-original-article-buffer)
5125 (setq gnus-article-current nil))
5126 (if (not gnus-kill-summary-on-exit)
5127 (gnus-deaden-summary)
5128 (gnus-close-group group)
5129 (gnus-summary-clear-local-variables)
5130 (set-buffer gnus-group-buffer)
5131 (gnus-summary-clear-local-variables)
5132 (when (get-buffer gnus-summary-buffer)
5133 (kill-buffer gnus-summary-buffer)))
5134 (unless gnus-single-article-buffer
5135 (setq gnus-article-current nil))
5136 (when gnus-use-trees
5137 (gnus-tree-close group))
5138 (gnus-async-prefetch-remove-group group)
5139 (when (get-buffer gnus-article-buffer)
5140 (bury-buffer gnus-article-buffer))
5141 ;; Return to the group buffer.
5142 (gnus-configure-windows 'group 'force)
5143 ;; Clear the current group name.
5144 (setq gnus-newsgroup-name nil)
5145 (when (equal (gnus-group-group-name) group)
5146 (gnus-group-next-unread-group 1))
5148 (gnus-handle-ephemeral-exit quit-config)))))
5150 (defun gnus-handle-ephemeral-exit (quit-config)
5151 "Handle movement when leaving an ephemeral group.
5152 The state which existed when entering the ephemeral is reset."
5153 (if (not (buffer-name (car quit-config)))
5154 (gnus-configure-windows 'group 'force)
5155 (set-buffer (car quit-config))
5156 (cond ((eq major-mode 'gnus-summary-mode)
5157 (gnus-set-global-variables))
5158 ((eq major-mode 'gnus-article-mode)
5160 ;; The `gnus-summary-buffer' variable may point
5161 ;; to the old summary buffer when using a single
5163 (unless (gnus-buffer-live-p gnus-summary-buffer)
5164 (set-buffer gnus-group-buffer))
5165 (set-buffer gnus-summary-buffer)
5166 (gnus-set-global-variables))))
5167 (if (or (eq (cdr quit-config) 'article)
5168 (eq (cdr quit-config) 'pick))
5170 ;; The current article may be from the ephemeral group
5171 ;; thus it is best that we reload this article
5172 (gnus-summary-show-article)
5173 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
5174 (gnus-configure-windows 'pick 'force)
5175 (gnus-configure-windows (cdr quit-config) 'force)))
5176 (gnus-configure-windows (cdr quit-config) 'force))
5177 (when (eq major-mode 'gnus-summary-mode)
5178 (gnus-summary-next-subject 1 nil t)
5179 (gnus-summary-recenter)
5180 (gnus-summary-position-point))))
5184 (defvar gnus-dead-summary-mode-map nil)
5186 (unless gnus-dead-summary-mode-map
5187 (setq gnus-dead-summary-mode-map (make-keymap))
5188 (suppress-keymap gnus-dead-summary-mode-map)
5189 (substitute-key-definition
5190 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
5191 (let ((keys '("\C-d" "\r" "\177" [delete])))
5193 (define-key gnus-dead-summary-mode-map
5194 (pop keys) 'gnus-summary-wake-up-the-dead))))
5196 (defvar gnus-dead-summary-mode nil
5197 "Minor mode for Gnus summary buffers.")
5199 (defun gnus-dead-summary-mode (&optional arg)
5200 "Minor mode for Gnus summary buffers."
5202 (when (eq major-mode 'gnus-summary-mode)
5203 (make-local-variable 'gnus-dead-summary-mode)
5204 (setq gnus-dead-summary-mode
5205 (if (null arg) (not gnus-dead-summary-mode)
5206 (> (prefix-numeric-value arg) 0)))
5207 (when gnus-dead-summary-mode
5208 (gnus-add-minor-mode
5209 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
5211 (defun gnus-deaden-summary ()
5212 "Make the current summary buffer into a dead summary buffer."
5213 ;; Kill any previous dead summary buffer.
5214 (when (and gnus-dead-summary
5215 (buffer-name gnus-dead-summary))
5217 (set-buffer gnus-dead-summary)
5218 (when gnus-dead-summary-mode
5219 (kill-buffer (current-buffer)))))
5220 ;; Make this the current dead summary.
5221 (setq gnus-dead-summary (current-buffer))
5222 (gnus-dead-summary-mode 1)
5223 (let ((name (buffer-name)))
5224 (when (string-match "Summary" name)
5226 (concat (substring name 0 (match-beginning 0)) "Dead "
5227 (substring name (match-beginning 0)))
5230 (defun gnus-kill-or-deaden-summary (buffer)
5231 "Kill or deaden the summary BUFFER."
5233 (when (and (buffer-name buffer)
5234 (not gnus-single-article-buffer))
5237 (gnus-kill-buffer gnus-article-buffer)
5238 (gnus-kill-buffer gnus-original-article-buffer)))
5239 (cond (gnus-kill-summary-on-exit
5240 (when (and gnus-use-trees
5241 (gnus-buffer-exists-p buffer))
5244 (gnus-tree-close gnus-newsgroup-name)))
5245 (gnus-kill-buffer buffer))
5246 ((gnus-buffer-exists-p buffer)
5249 (gnus-deaden-summary))))))
5251 (defun gnus-summary-wake-up-the-dead (&rest args)
5252 "Wake up the dead summary buffer."
5254 (gnus-dead-summary-mode -1)
5255 (let ((name (buffer-name)))
5256 (when (string-match "Dead " name)
5258 (concat (substring name 0 (match-beginning 0))
5259 (substring name (match-end 0)))
5261 (gnus-message 3 "This dead summary is now alive again"))
5263 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
5264 (defun gnus-summary-fetch-faq (&optional faq-dir)
5265 "Fetch the FAQ for the current group.
5266 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
5270 (when current-prefix-arg
5272 "Faq dir: " (and (listp gnus-group-faq-directory)
5273 (mapcar (lambda (file) (list file))
5274 gnus-group-faq-directory))))))
5275 (let (gnus-faq-buffer)
5276 (when (setq gnus-faq-buffer
5277 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
5278 (gnus-configure-windows 'summary-faq))))
5280 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
5281 (defun gnus-summary-describe-group (&optional force)
5282 "Describe the current newsgroup."
5284 (gnus-group-describe-group force gnus-newsgroup-name))
5286 (defun gnus-summary-describe-briefly ()
5287 "Describe summary mode commands briefly."
5290 (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")))
5292 ;; Walking around group mode buffer from summary mode.
5294 (defun gnus-summary-next-group (&optional no-article target-group backward)
5295 "Exit current newsgroup and then select next unread newsgroup.
5296 If prefix argument NO-ARTICLE is non-nil, no article is selected
5297 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
5298 previous group instead."
5300 ;; Stop pre-fetching.
5301 (gnus-async-halt-prefetch)
5302 (let ((current-group gnus-newsgroup-name)
5303 (current-buffer (current-buffer))
5305 ;; First we semi-exit this group to update Xrefs and all variables.
5306 ;; We can't do a real exit, because the window conf must remain
5307 ;; the same in case the user is prompted for info, and we don't
5308 ;; want the window conf to change before that...
5309 (gnus-summary-exit t)
5310 (while (not entered)
5311 ;; Then we find what group we are supposed to enter.
5312 (set-buffer gnus-group-buffer)
5313 (gnus-group-jump-to-group current-group)
5316 (if (eq gnus-keep-same-level 'best)
5317 (gnus-summary-best-group gnus-newsgroup-name)
5318 (gnus-summary-search-group backward gnus-keep-same-level))))
5319 (if (not target-group)
5320 ;; There are no further groups, so we return to the group
5323 (gnus-message 5 "Returning to the group buffer")
5325 (when (gnus-buffer-live-p current-buffer)
5326 (set-buffer current-buffer)
5327 (gnus-summary-exit))
5328 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
5329 ;; We try to enter the target group.
5330 (gnus-group-jump-to-group target-group)
5331 (let ((unreads (gnus-group-group-unread)))
5332 (if (and (or (eq t unreads)
5333 (and unreads (not (zerop unreads))))
5334 (gnus-summary-read-group
5335 target-group nil no-article
5336 (and (buffer-name current-buffer) current-buffer)
5339 (setq current-group target-group
5340 target-group nil)))))))
5342 (defun gnus-summary-prev-group (&optional no-article)
5343 "Exit current newsgroup and then select previous unread newsgroup.
5344 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
5346 (gnus-summary-next-group no-article nil t))
5348 ;; Walking around summary lines.
5350 (defun gnus-summary-first-subject (&optional unread undownloaded)
5351 "Go to the first unread subject.
5352 If UNREAD is non-nil, go to the first unread article.
5353 Returns the article selected or nil if there are no unread articles."
5358 ((null gnus-newsgroup-data)
5359 (gnus-message 3 "No articles in the group")
5361 ;; Pick the first article.
5363 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
5364 (gnus-data-number (car gnus-newsgroup-data)))
5365 ;; No unread articles.
5366 ((null gnus-newsgroup-unreads)
5367 (gnus-message 3 "No more unread articles")
5369 ;; Find the first unread article.
5371 (let ((data gnus-newsgroup-data))
5373 (and (not (and undownloaded
5374 (eq gnus-undownloaded-mark
5375 (gnus-data-mark (car data)))))
5376 (not (gnus-data-unread-p (car data)))))
5377 (setq data (cdr data)))
5379 (goto-char (gnus-data-pos (car data)))
5380 (gnus-data-number (car data))))))
5381 (gnus-summary-position-point)))
5383 (defun gnus-summary-next-subject (n &optional unread dont-display)
5384 "Go to next N'th summary line.
5385 If N is negative, go to the previous N'th subject line.
5386 If UNREAD is non-nil, only unread articles are selected.
5387 The difference between N and the actual number of steps taken is
5390 (let ((backward (< n 0))
5394 (gnus-summary-find-prev unread)
5395 (gnus-summary-find-next unread)))
5396 (gnus-summary-show-thread)
5399 (gnus-message 7 "No more%s articles"
5400 (if unread " unread" "")))
5401 (unless dont-display
5402 (gnus-summary-recenter)
5403 (gnus-summary-position-point))
5406 (defun gnus-summary-next-unread-subject (n)
5407 "Go to next N'th unread summary line."
5409 (gnus-summary-next-subject n t))
5411 (defun gnus-summary-prev-subject (n &optional unread)
5412 "Go to previous N'th summary line.
5413 If optional argument UNREAD is non-nil, only unread article is selected."
5415 (gnus-summary-next-subject (- n) unread))
5417 (defun gnus-summary-prev-unread-subject (n)
5418 "Go to previous N'th unread summary line."
5420 (gnus-summary-next-subject (- n) t))
5422 (defun gnus-summary-goto-subject (article &optional force silent)
5423 "Go the subject line of ARTICLE.
5424 If FORCE, also allow jumping to articles not currently shown."
5425 (interactive "nArticle number: ")
5427 (data (gnus-data-find article)))
5428 ;; We read in the article if we have to.
5431 (gnus-summary-insert-subject
5433 (if (or (numberp force) (vectorp force)) force)
5435 (setq data (gnus-data-find article)))
5440 (gnus-message 3 "Can't find article %d" article))
5442 (goto-char (gnus-data-pos data))
5443 (gnus-summary-position-point)
5446 ;; Walking around summary lines with displaying articles.
5448 (defun gnus-summary-expand-window (&optional arg)
5449 "Make the summary buffer take up the entire Emacs frame.
5450 Given a prefix, will force an `article' buffer configuration."
5453 (gnus-configure-windows 'article 'force)
5454 (gnus-configure-windows 'summary 'force)))
5456 (defun gnus-summary-display-article (article &optional all-header)
5457 "Display ARTICLE in article buffer."
5458 (gnus-set-global-variables)
5462 (if gnus-summary-display-article-function
5463 (funcall gnus-summary-display-article-function article all-header)
5464 (gnus-article-prepare article all-header))
5465 (gnus-run-hooks 'gnus-select-article-hook)
5466 (when (and gnus-current-article
5467 (not (zerop gnus-current-article)))
5468 (gnus-summary-goto-subject gnus-current-article))
5469 (gnus-summary-recenter)
5470 (when (and gnus-use-trees gnus-show-threads)
5471 (gnus-possibly-generate-tree article)
5472 (gnus-highlight-selected-tree article))
5473 ;; Successfully display article.
5474 (gnus-article-set-window-start
5475 (cdr (assq article gnus-newsgroup-bookmarks))))))
5477 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
5478 "Select the current article.
5479 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
5480 non-nil, the article will be re-fetched even if it already present in
5481 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
5483 ;; Make sure we are in the summary buffer to work around bbdb bug.
5484 (unless (eq major-mode 'gnus-summary-mode)
5485 (set-buffer gnus-summary-buffer))
5486 (let ((article (or article (gnus-summary-article-number)))
5487 (all-headers (not (not all-headers))) ;Must be T or NIL.
5488 gnus-summary-display-article-function
5491 (gnus-summary-article-pseudo-p article)
5492 (error "This is a pseudo-article"))
5495 (set-buffer gnus-summary-buffer)
5496 (if (or (and gnus-single-article-buffer
5497 (or (null gnus-current-article)
5498 (null gnus-article-current)
5499 (null (get-buffer gnus-article-buffer))
5500 (not (eq article (cdr gnus-article-current)))
5501 (not (equal (car gnus-article-current)
5502 gnus-newsgroup-name))))
5503 (and (not gnus-single-article-buffer)
5504 (or (null gnus-current-article)
5505 (not (eq gnus-current-article article))))
5507 ;; The requested article is different from the current article.
5509 (gnus-summary-display-article article all-headers)
5511 (when (or all-headers gnus-show-all-headers)
5512 (gnus-article-show-all-headers))
5515 (gnus-article-set-window-start
5516 (cdr (assq article gnus-newsgroup-bookmarks)))))))
5518 (defun gnus-summary-set-current-mark (&optional current-mark)
5519 "Obsolete function."
5522 (defun gnus-summary-next-article (&optional unread subject backward push)
5523 "Select the next article.
5524 If UNREAD, only unread articles are selected.
5525 If SUBJECT, only articles with SUBJECT are selected.
5526 If BACKWARD, the previous article is selected instead of the next."
5529 ;; Is there such an article?
5530 ((and (gnus-summary-search-forward unread subject backward)
5531 (or (gnus-summary-display-article (gnus-summary-article-number))
5532 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
5533 (gnus-summary-position-point))
5534 ;; If not, we try the first unread, if that is wanted.
5536 gnus-auto-select-same
5537 (gnus-summary-first-unread-article))
5538 (gnus-summary-position-point)
5539 (gnus-message 6 "Wrapped"))
5540 ;; Try to get next/previous article not displayed in this group.
5541 ((and gnus-auto-extend-newsgroup
5542 (not unread) (not subject))
5543 (gnus-summary-goto-article
5544 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
5545 nil (count-lines (point-min) (point))))
5546 ;; Go to next/previous group.
5548 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
5549 (gnus-summary-jump-to-group gnus-newsgroup-name))
5550 (let ((cmd last-command-char)
5553 (set-buffer gnus-group-buffer)
5556 (if (eq gnus-keep-same-level 'best)
5557 (gnus-summary-best-group gnus-newsgroup-name)
5558 (gnus-summary-search-group backward gnus-keep-same-level))))
5559 ;; For some reason, the group window gets selected. We change
5561 (select-window (get-buffer-window (current-buffer)))
5562 ;; Select next unread newsgroup automagically.
5564 ((or (not gnus-auto-select-next)
5566 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
5567 ((or (eq gnus-auto-select-next 'quietly)
5568 (and (eq gnus-auto-select-next 'slightly-quietly)
5570 (and (eq gnus-auto-select-next 'almost-quietly)
5571 (gnus-summary-last-article-p)))
5573 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
5575 (gnus-message 7 "No more%s articles (%s)..."
5576 (if unread " unread" "")
5577 (if group (concat "selecting " group)
5579 (gnus-summary-next-group nil group backward)))
5581 (when (gnus-key-press-event-p last-input-event)
5582 (gnus-summary-walk-group-buffer
5583 gnus-newsgroup-name cmd unread backward point))))))))
5585 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
5586 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
5587 (?\C-p (gnus-group-prev-unread-group 1))))
5588 (cursor-in-echo-area t)
5589 keve key group ended)
5591 (set-buffer gnus-group-buffer)
5594 (if (eq gnus-keep-same-level 'best)
5595 (gnus-summary-best-group gnus-newsgroup-name)
5596 (gnus-summary-search-group backward gnus-keep-same-level))))
5599 5 "No more%s articles%s" (if unread " unread" "")
5601 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
5602 (format " (Type %s for %s [%s])"
5603 (single-key-description cmd) group
5604 (car (gnus-gethash group gnus-newsrc-hashtb)))
5605 (format " (Type %s to exit %s)"
5606 (single-key-description cmd)
5607 gnus-newsgroup-name)))
5608 ;; Confirm auto selection.
5609 (setq key (car (setq keve (gnus-read-event-char))))
5612 ((assq key keystrokes)
5613 (let ((obuf (current-buffer)))
5614 (switch-to-buffer gnus-group-buffer)
5616 (gnus-group-jump-to-group group))
5617 (eval (cadr (assq key keystrokes)))
5618 (setq group (gnus-group-group-name))
5619 (switch-to-buffer obuf))
5623 (gnus-ephemeral-group-p gnus-newsgroup-name))
5625 (gnus-summary-next-group nil group backward)))
5627 (push (cdr keve) unread-command-events))))))
5629 (defun gnus-summary-next-unread-article ()
5630 "Select unread article after current one."
5632 (gnus-summary-next-article
5633 (or (not (eq gnus-summary-goto-unread 'never))
5634 (gnus-summary-last-article-p (gnus-summary-article-number)))
5635 (and gnus-auto-select-same
5636 (gnus-summary-article-subject))))
5638 (defun gnus-summary-prev-article (&optional unread subject)
5639 "Select the article after the current one.
5640 If UNREAD is non-nil, only unread articles are selected."
5642 (gnus-summary-next-article unread subject t))
5644 (defun gnus-summary-prev-unread-article ()
5645 "Select unread article before current one."
5647 (gnus-summary-prev-article
5648 (or (not (eq gnus-summary-goto-unread 'never))
5649 (gnus-summary-first-article-p (gnus-summary-article-number)))
5650 (and gnus-auto-select-same
5651 (gnus-summary-article-subject))))
5653 (defun gnus-summary-next-page (&optional lines circular)
5654 "Show next page of the selected article.
5655 If at the end of the current article, select the next article.
5656 LINES says how many lines should be scrolled up.
5658 If CIRCULAR is non-nil, go to the start of the article instead of
5659 selecting the next article when reaching the end of the current
5662 (setq gnus-summary-buffer (current-buffer))
5663 (gnus-set-global-variables)
5664 (let ((article (gnus-summary-article-number))
5665 (article-window (get-buffer-window gnus-article-buffer t))
5667 ;; If the buffer is empty, we have no article.
5669 (error "No article to select"))
5670 (gnus-configure-windows 'article)
5671 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
5672 (if (and (eq gnus-summary-goto-unread 'never)
5673 (not (gnus-summary-last-article-p article)))
5674 (gnus-summary-next-article)
5675 (gnus-summary-next-unread-article))
5676 (if (or (null gnus-current-article)
5677 (null gnus-article-current)
5678 (/= article (cdr gnus-article-current))
5679 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5680 ;; Selected subject is different from current article's.
5681 (gnus-summary-display-article article)
5682 (when article-window
5683 (gnus-eval-in-buffer-window gnus-article-buffer
5684 (setq endp (gnus-article-next-page lines)))
5687 (gnus-summary-beginning-of-article))
5689 (gnus-message 3 "End of message"))
5691 (if (and (eq gnus-summary-goto-unread 'never)
5692 (not (gnus-summary-last-article-p article)))
5693 (gnus-summary-next-article)
5694 (gnus-summary-next-unread-article))))))))
5695 (gnus-summary-recenter)
5696 (gnus-summary-position-point)))
5698 (defun gnus-summary-prev-page (&optional lines move)
5699 "Show previous page of selected article.
5700 Argument LINES specifies lines to be scrolled down.
5701 If MOVE, move to the previous unread article if point is at
5702 the beginning of the buffer."
5704 (let ((article (gnus-summary-article-number))
5705 (article-window (get-buffer-window gnus-article-buffer t))
5707 (gnus-configure-windows 'article)
5708 (if (or (null gnus-current-article)
5709 (null gnus-article-current)
5710 (/= article (cdr gnus-article-current))
5711 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5712 ;; Selected subject is different from current article's.
5713 (gnus-summary-display-article article)
5714 (gnus-summary-recenter)
5715 (when article-window
5716 (gnus-eval-in-buffer-window gnus-article-buffer
5717 (setq endp (gnus-article-prev-page lines)))
5718 (when (and move endp)
5720 (gnus-message 3 "Beginning of message"))
5722 (if (and (eq gnus-summary-goto-unread 'never)
5723 (not (gnus-summary-first-article-p article)))
5724 (gnus-summary-prev-article)
5725 (gnus-summary-prev-unread-article))))))))
5726 (gnus-summary-position-point))
5728 (defun gnus-summary-prev-page-or-article (&optional lines)
5729 "Show previous page of selected article.
5730 Argument LINES specifies lines to be scrolled down.
5731 If at the beginning of the article, go to the next article."
5733 (gnus-summary-prev-page lines t))
5735 (defun gnus-summary-scroll-up (lines)
5736 "Scroll up (or down) one line current article.
5737 Argument LINES specifies lines to be scrolled up (or down if negative)."
5739 (gnus-configure-windows 'article)
5740 (gnus-summary-show-thread)
5741 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
5742 (gnus-eval-in-buffer-window gnus-article-buffer
5744 (when (gnus-article-next-page lines)
5745 (gnus-message 3 "End of message")))
5747 (gnus-article-prev-page (- lines))))))
5748 (gnus-summary-recenter)
5749 (gnus-summary-position-point))
5751 (defun gnus-summary-next-same-subject ()
5752 "Select next article which has the same subject as current one."
5754 (gnus-summary-next-article nil (gnus-summary-article-subject)))
5756 (defun gnus-summary-prev-same-subject ()
5757 "Select previous article which has the same subject as current one."
5759 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
5761 (defun gnus-summary-next-unread-same-subject ()
5762 "Select next unread article which has the same subject as current one."
5764 (gnus-summary-next-article t (gnus-summary-article-subject)))
5766 (defun gnus-summary-prev-unread-same-subject ()
5767 "Select previous unread article which has the same subject as current one."
5769 (gnus-summary-prev-article t (gnus-summary-article-subject)))
5771 (defun gnus-summary-first-unread-article ()
5772 "Select the first unread article.
5773 Return nil if there are no unread articles."
5776 (when (gnus-summary-first-subject t)
5777 (gnus-summary-show-thread)
5778 (gnus-summary-first-subject t)
5779 (gnus-summary-display-article (gnus-summary-article-number)))
5780 (gnus-summary-position-point)))
5782 (defun gnus-summary-first-article ()
5783 "Select the first article.
5784 Return nil if there are no articles."
5787 (when (gnus-summary-first-subject)
5788 (gnus-summary-show-thread)
5789 (gnus-summary-first-subject)
5790 (gnus-summary-display-article (gnus-summary-article-number)))
5791 (gnus-summary-position-point)))
5793 (defun gnus-summary-best-unread-article ()
5794 "Select the unread article with the highest score."
5796 (let ((best -1000000)
5797 (data gnus-newsgroup-data)
5800 (and (gnus-data-unread-p (car data))
5802 (gnus-summary-article-score (gnus-data-number (car data))))
5805 article (gnus-data-number (car data))))
5806 (setq data (cdr data)))
5809 (gnus-summary-goto-article article)
5810 (error "No unread articles"))
5811 (gnus-summary-position-point))))
5813 (defun gnus-summary-last-subject ()
5814 "Go to the last displayed subject line in the group."
5815 (let ((article (gnus-data-number (car (gnus-data-list t)))))
5817 (gnus-summary-goto-subject article))))
5819 (defun gnus-summary-goto-article (article &optional all-headers force)
5820 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
5821 If ALL-HEADERS is non-nil, no header lines are hidden.
5822 If FORCE, go to the article even if it isn't displayed. If FORCE
5823 is a number, it is the line the article is to be displayed on."
5827 "Article number or Message-ID: "
5828 (mapcar (lambda (number) (list (int-to-string number)))
5829 gnus-newsgroup-limit))
5833 (if (and (stringp article)
5834 (string-match "@" article))
5835 (gnus-summary-refer-article article)
5836 (when (stringp article)
5837 (setq article (string-to-number article)))
5838 (if (gnus-summary-goto-subject article force)
5839 (gnus-summary-display-article article all-headers)
5840 (gnus-message 4 "Couldn't go to article %s" article) nil))
5841 (gnus-summary-position-point)))
5843 (defun gnus-summary-goto-last-article ()
5844 "Go to the previously read article."
5847 (when gnus-last-article
5848 (gnus-summary-goto-article gnus-last-article nil t))
5849 (gnus-summary-position-point)))
5851 (defun gnus-summary-pop-article (number)
5852 "Pop one article off the history and go to the previous.
5853 NUMBER articles will be popped off."
5856 (setq gnus-newsgroup-history
5857 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
5859 (gnus-summary-goto-article (car to) nil t)
5860 (error "Article history empty")))
5861 (gnus-summary-position-point))
5863 ;; Summary commands and functions for limiting the summary buffer.
5865 (defun gnus-summary-limit-to-articles (n)
5866 "Limit the summary buffer to the next N articles.
5867 If not given a prefix, use the process marked articles instead."
5870 (let ((articles (gnus-summary-work-articles n)))
5871 (setq gnus-newsgroup-processable nil)
5872 (gnus-summary-limit articles))
5873 (gnus-summary-position-point)))
5875 (defun gnus-summary-pop-limit (&optional total)
5876 "Restore the previous limit.
5877 If given a prefix, remove all limits."
5880 (setq gnus-newsgroup-limits
5881 (list (mapcar (lambda (h) (mail-header-number h))
5882 gnus-newsgroup-headers))))
5883 (unless gnus-newsgroup-limits
5884 (error "No limit to pop"))
5886 (gnus-summary-limit nil 'pop)
5887 (gnus-summary-position-point)))
5889 (defun gnus-summary-limit-to-subject (subject &optional header)
5890 "Limit the summary buffer to articles that have subjects that match a regexp."
5891 (interactive "sLimit to subject (regexp): ")
5893 (setq header "subject"))
5894 (when (not (equal "" subject))
5896 (let ((articles (gnus-summary-find-matching
5897 (or header "subject") subject 'all)))
5899 (error "Found no matches for \"%s\"" subject))
5900 (gnus-summary-limit articles))
5901 (gnus-summary-position-point))))
5903 (defun gnus-summary-limit-to-author (from)
5904 "Limit the summary buffer to articles that have authors that match a regexp."
5905 (interactive "sLimit to author (regexp): ")
5906 (gnus-summary-limit-to-subject from "from"))
5908 (defun gnus-summary-limit-to-age (age &optional younger-p)
5909 "Limit the summary buffer to articles that are older than (or equal) AGE days.
5910 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
5911 articles that are younger than AGE days."
5912 (interactive "nTime in days: \nP")
5914 (let ((data gnus-newsgroup-data)
5915 (cutoff (nnmail-days-to-time age))
5916 articles d date is-younger)
5917 (while (setq d (pop data))
5918 (when (and (vectorp (gnus-data-header d))
5919 (setq date (mail-header-date (gnus-data-header d))))
5920 (setq is-younger (nnmail-time-less
5921 (nnmail-time-since (nnmail-date-to-time date))
5926 (push (gnus-data-number d) articles))))
5927 (gnus-summary-limit (nreverse articles)))
5928 (gnus-summary-position-point)))
5930 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
5932 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
5934 (defun gnus-summary-limit-to-unread (&optional all)
5935 "Limit the summary buffer to articles that are not marked as read.
5936 If ALL is non-nil, limit strictly to unread articles."
5939 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
5940 (gnus-summary-limit-to-marks
5941 ;; Concat all the marks that say that an article is read and have
5943 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
5944 gnus-killed-mark gnus-kill-file-mark
5945 gnus-low-score-mark gnus-expirable-mark
5946 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
5947 gnus-duplicate-mark gnus-souped-mark)
5950 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
5951 (make-obsolete 'gnus-summary-delete-marked-with
5952 'gnus-summary-limit-exlude-marks)
5954 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
5955 "Exclude articles that are marked with MARKS (e.g. \"DK\").
5956 If REVERSE, limit the summary buffer to articles that are marked
5957 with MARKS. MARKS can either be a string of marks or a list of marks.
5958 Returns how many articles were removed."
5959 (interactive "sMarks: ")
5960 (gnus-summary-limit-to-marks marks t))
5962 (defun gnus-summary-limit-to-marks (marks &optional reverse)
5963 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
5964 If REVERSE (the prefix), limit the summary buffer to articles that are
5965 not marked with MARKS. MARKS can either be a string of marks or a
5967 Returns how many articles were removed."
5968 (interactive "sMarks: \nP")
5970 (let ((data gnus-newsgroup-data)
5971 (marks (if (listp marks) marks
5972 (append marks nil))) ; Transform to list.
5975 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
5976 (memq (gnus-data-mark (car data)) marks))
5977 (push (gnus-data-number (car data)) articles))
5978 (setq data (cdr data)))
5979 (gnus-summary-limit articles))
5980 (gnus-summary-position-point)))
5982 (defun gnus-summary-limit-to-score (&optional score)
5983 "Limit to articles with score at or above SCORE."
5985 (setq score (if score
5986 (prefix-numeric-value score)
5987 (or gnus-summary-default-score 0)))
5988 (let ((data gnus-newsgroup-data)
5991 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
5993 (push (gnus-data-number (car data)) articles))
5994 (setq data (cdr data)))
5996 (gnus-summary-limit articles)
5997 (gnus-summary-position-point))))
5999 (defun gnus-summary-limit-include-thread (id)
6000 "Display all the hidden articles that in the current thread."
6001 (interactive (list (mail-header-id (gnus-summary-article-header))))
6002 (let ((articles (gnus-articles-in-thread
6003 (gnus-id-to-thread (gnus-root-id id)))))
6005 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
6006 (gnus-summary-position-point))))
6008 (defun gnus-summary-limit-include-dormant ()
6009 "Display all the hidden articles that are marked as dormant.
6010 Note that this command only works on a subset of the articles currently
6011 fetched for this group."
6013 (unless gnus-newsgroup-dormant
6014 (error "There are no dormant articles in this group"))
6016 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
6017 (gnus-summary-position-point)))
6019 (defun gnus-summary-limit-exclude-dormant ()
6020 "Hide all dormant articles."
6023 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
6024 (gnus-summary-position-point)))
6026 (defun gnus-summary-limit-exclude-childless-dormant ()
6027 "Hide all dormant articles that have no children."
6029 (let ((data (gnus-data-list t))
6030 articles d children)
6031 ;; Find all articles that are either not dormant or have
6033 (while (setq d (pop data))
6034 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
6036 (gnus-article-children (gnus-data-number d)))
6039 (when (memq (car children) articles)
6044 (push (gnus-data-number d) articles)))
6047 (gnus-summary-limit articles)
6048 (gnus-summary-position-point))))
6050 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
6051 "Mark all unread excluded articles as read.
6052 If ALL, mark even excluded ticked and dormants as read."
6054 (let ((articles (gnus-sorted-complement
6056 (mapcar (lambda (h) (mail-header-number h))
6057 gnus-newsgroup-headers)
6059 (sort gnus-newsgroup-limit '<)))
6061 (setq gnus-newsgroup-unreads
6062 (gnus-intersection gnus-newsgroup-unreads gnus-newsgroup-limit))
6064 (setq gnus-newsgroup-dormant nil
6065 gnus-newsgroup-marked nil
6066 gnus-newsgroup-reads
6068 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
6069 gnus-newsgroup-reads))
6070 (while (setq article (pop articles))
6071 (unless (or (memq article gnus-newsgroup-dormant)
6072 (memq article gnus-newsgroup-marked))
6073 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
6075 (defun gnus-summary-limit (articles &optional pop)
6077 ;; We pop the previous limit off the stack and use that.
6078 (setq articles (car gnus-newsgroup-limits)
6079 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
6080 ;; We use the new limit, so we push the old limit on the stack.
6081 (push gnus-newsgroup-limit gnus-newsgroup-limits))
6083 (setq gnus-newsgroup-limit articles)
6084 (let ((total (length gnus-newsgroup-data))
6085 (data (gnus-data-find-list (gnus-summary-article-number)))
6086 (gnus-summary-mark-below nil) ; Inhibit this.
6088 ;; This will do all the work of generating the new summary buffer
6089 ;; according to the new limit.
6090 (gnus-summary-prepare)
6091 ;; Hide any threads, possibly.
6092 (and gnus-show-threads
6093 gnus-thread-hide-subtree
6094 (gnus-summary-hide-all-threads))
6095 ;; Try to return to the article you were at, or one in the
6098 ;; We try to find some article after the current one.
6100 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
6103 (setq data (cdr data))))
6105 ;; If there is no data, that means that we were after the last
6106 ;; article. The same goes when we can't find any articles
6107 ;; after the current one.
6108 (goto-char (point-max))
6109 (gnus-summary-find-prev))
6110 (gnus-set-mode-line 'summary)
6111 ;; We return how many articles were removed from the summary
6112 ;; buffer as a result of the new limit.
6113 (- total (length gnus-newsgroup-data))))
6115 (defsubst gnus-invisible-cut-children (threads)
6118 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
6123 (defsubst gnus-cut-thread (thread)
6124 "Go forwards in the thread until we find an article that we want to display."
6125 (when (or (eq gnus-fetch-old-headers 'some)
6126 (eq gnus-fetch-old-headers 'invisible)
6127 (eq gnus-build-sparse-threads 'some)
6128 (eq gnus-build-sparse-threads 'more))
6129 ;; Deal with old-fetched headers and sparse threads.
6133 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
6134 (gnus-summary-article-ancient-p
6135 (mail-header-number (car thread))))
6136 (if (or (<= (length (cdr thread)) 1)
6137 (eq gnus-fetch-old-headers 'invisible))
6138 (setq gnus-newsgroup-limit
6139 (delq (mail-header-number (car thread))
6140 gnus-newsgroup-limit)
6141 thread (cadr thread))
6142 (when (gnus-invisible-cut-children (cdr thread))
6143 (let ((th (cdr thread)))
6145 (if (memq (mail-header-number (caar th))
6146 gnus-newsgroup-limit)
6147 (setq thread (car th)
6149 (setq th (cdr th))))))))))
6152 (defun gnus-cut-threads (threads)
6153 "Cut off all uninteresting articles from the beginning of threads."
6154 (when (or (eq gnus-fetch-old-headers 'some)
6155 (eq gnus-fetch-old-headers 'invisible)
6156 (eq gnus-build-sparse-threads 'some)
6157 (eq gnus-build-sparse-threads 'more))
6160 (setcar th (gnus-cut-thread (car th)))
6161 (setq th (cdr th)))))
6162 ;; Remove nixed out threads.
6165 (defun gnus-summary-initial-limit (&optional show-if-empty)
6166 "Figure out what the initial limit is supposed to be on group entry.
6167 This entails weeding out unwanted dormants, low-scored articles,
6168 fetch-old-headers verbiage, and so on."
6169 ;; Most groups have nothing to remove.
6170 (if (or gnus-inhibit-limiting
6171 (and (null gnus-newsgroup-dormant)
6172 (not (eq gnus-fetch-old-headers 'some))
6173 (not (eq gnus-fetch-old-headers 'invisible))
6174 (null gnus-summary-expunge-below)
6175 (not (eq gnus-build-sparse-threads 'some))
6176 (not (eq gnus-build-sparse-threads 'more))
6177 (null gnus-thread-expunge-below)
6178 (not gnus-use-nocem)))
6180 (push gnus-newsgroup-limit gnus-newsgroup-limits)
6181 (setq gnus-newsgroup-limit nil)
6184 (unless (car (symbol-value node))
6185 ;; These threads have no parents -- they are roots.
6186 (let ((nodes (cdr (symbol-value node)))
6189 (if (and gnus-thread-expunge-below
6190 (< (gnus-thread-total-score (car nodes))
6191 gnus-thread-expunge-below))
6192 (gnus-expunge-thread (pop nodes))
6193 (setq thread (pop nodes))
6194 (gnus-summary-limit-children thread))))))
6195 gnus-newsgroup-dependencies)
6196 ;; If this limitation resulted in an empty group, we might
6197 ;; pop the previous limit and use it instead.
6198 (when (and (not gnus-newsgroup-limit)
6200 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
6201 gnus-newsgroup-limit))
6203 (defun gnus-summary-limit-children (thread)
6204 "Return 1 if this subthread is visible and 0 if it is not."
6205 ;; First we get the number of visible children to this thread. This
6206 ;; is done by recursing down the thread using this function, so this
6207 ;; will really go down to a leaf article first, before slowly
6208 ;; working its way up towards the root.
6212 (apply '+ (mapcar 'gnus-summary-limit-children
6215 (number (mail-header-number (car thread)))
6218 (not (memq number gnus-newsgroup-marked))
6220 ;; If this article is dormant and has absolutely no visible
6221 ;; children, then this article isn't visible.
6222 (and (memq number gnus-newsgroup-dormant)
6224 ;; If this is "fetch-old-headered" and there is no
6225 ;; visible children, then we don't want this article.
6226 (and (eq gnus-fetch-old-headers 'some)
6227 (gnus-summary-article-ancient-p number)
6229 ;; If this is "fetch-old-headered" and `invisible', then
6230 ;; we don't want this article.
6231 (and (eq gnus-fetch-old-headers 'invisible)
6232 (gnus-summary-article-ancient-p number))
6233 ;; If this is a sparsely inserted article with no children,
6234 ;; we don't want it.
6235 (and (eq gnus-build-sparse-threads 'some)
6236 (gnus-summary-article-sparse-p number)
6238 ;; If we use expunging, and this article is really
6239 ;; low-scored, then we don't want this article.
6240 (when (and gnus-summary-expunge-below
6242 (or (cdr (assq number gnus-newsgroup-scored))
6243 gnus-summary-default-score))
6244 gnus-summary-expunge-below))
6245 ;; We increase the expunge-tally here, but that has
6246 ;; nothing to do with the limits, really.
6247 (incf gnus-newsgroup-expunged-tally)
6248 ;; We also mark as read here, if that's wanted.
6249 (when (and gnus-summary-mark-below
6250 (< score gnus-summary-mark-below))
6251 (setq gnus-newsgroup-unreads
6252 (delq number gnus-newsgroup-unreads))
6253 (if gnus-newsgroup-auto-expire
6254 (push number gnus-newsgroup-expirable)
6255 (push (cons number gnus-low-score-mark)
6256 gnus-newsgroup-reads)))
6258 ;; Check NoCeM things.
6259 (if (and gnus-use-nocem
6260 (gnus-nocem-unwanted-article-p
6261 (mail-header-id (car thread))))
6263 (setq gnus-newsgroup-unreads
6264 (delq number gnus-newsgroup-unreads))
6266 ;; Nope, invisible article.
6268 ;; Ok, this article is to be visible, so we add it to the limit
6270 (push number gnus-newsgroup-limit)
6273 (defun gnus-expunge-thread (thread)
6274 "Mark all articles in THREAD as read."
6275 (let* ((number (mail-header-number (car thread))))
6276 (incf gnus-newsgroup-expunged-tally)
6277 ;; We also mark as read here, if that's wanted.
6278 (setq gnus-newsgroup-unreads
6279 (delq number gnus-newsgroup-unreads))
6280 (if gnus-newsgroup-auto-expire
6281 (push number gnus-newsgroup-expirable)
6282 (push (cons number gnus-low-score-mark)
6283 gnus-newsgroup-reads)))
6284 ;; Go recursively through all subthreads.
6285 (mapcar 'gnus-expunge-thread (cdr thread)))
6287 ;; Summary article oriented commands
6289 (defun gnus-summary-refer-parent-article (n)
6290 "Refer parent article N times.
6291 If N is negative, go to ancestor -N instead.
6292 The difference between N and the number of articles fetched is returned."
6296 (when (not (natnump n))
6301 (setq header (gnus-summary-article-header))
6302 (if (and (eq (mail-header-number header)
6303 (cdr gnus-article-current))
6304 (equal gnus-newsgroup-name
6305 (car gnus-article-current)))
6306 ;; If we try to find the parent of the currently
6307 ;; displayed article, then we take a look at the actual
6308 ;; References header, since this is slightly more
6309 ;; reliable than the References field we got from the
6312 (set-buffer gnus-original-article-buffer)
6313 (nnheader-narrow-to-headers)
6314 (unless (setq ref (message-fetch-field "references"))
6315 (setq ref (message-fetch-field "in-reply-to")))
6318 ;; It's not the current article, so we take a bet on
6319 ;; the value we got from the server.
6320 (mail-header-references header)))
6322 (not (equal ref "")))
6323 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
6324 (gnus-message 1 "Couldn't find parent"))
6325 (gnus-message 1 "No references in article %d"
6326 (gnus-summary-article-number))
6329 (gnus-summary-position-point)
6332 (defun gnus-summary-refer-references ()
6333 "Fetch all articles mentioned in the References header.
6334 Return the number of articles fetched."
6336 (let ((ref (mail-header-references (gnus-summary-article-header)))
6337 (current (gnus-summary-article-number))
6341 (error "No References in the current article")
6342 ;; For each Message-ID in the References header...
6343 (while (string-match "<[^>]*>" ref)
6345 ;; ... fetch that article.
6346 (gnus-summary-refer-article
6347 (prog1 (match-string 0 ref)
6348 (setq ref (substring ref (match-end 0))))))
6349 (gnus-summary-goto-subject current)
6350 (gnus-summary-position-point)
6353 (defun gnus-summary-refer-thread (&optional limit)
6354 "Fetch all articles in the current thread.
6355 If LIMIT (the numerical prefix), fetch that many old headers instead
6356 of what's specified by the `gnus-refer-thread-limit' variable."
6358 (let ((id (mail-header-id (gnus-summary-article-header)))
6359 (limit (if limit (prefix-numeric-value limit)
6360 gnus-refer-thread-limit))
6362 ;; We want to fetch LIMIT *old* headers, but we also have to
6363 ;; re-fetch all the headers in the current buffer, because many of
6364 ;; them may be undisplayed. So we adjust LIMIT.
6365 (when (numberp limit)
6366 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
6367 (unless (eq gnus-fetch-old-headers 'invisible)
6368 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
6369 ;; Retrieve the headers and read them in.
6370 (if (eq (gnus-retrieve-headers
6371 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
6373 (gnus-build-all-threads)
6374 (error "Can't fetch thread from backends that don't support NOV"))
6375 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
6376 (gnus-summary-limit-include-thread id)))
6378 (defun gnus-summary-refer-article (message-id &optional arg)
6379 "Fetch an article specified by MESSAGE-ID.
6380 If ARG (the prefix), fetch the article using `gnus-refer-article-method'
6381 or `gnus-select-method', no matter what backend the article comes from."
6382 (interactive "sMessage-ID: \nP")
6383 (when (and (stringp message-id)
6384 (not (zerop (length message-id))))
6385 ;; Construct the correct Message-ID if necessary.
6386 ;; Suggested by tale@pawl.rpi.edu.
6387 (unless (string-match "^<" message-id)
6388 (setq message-id (concat "<" message-id)))
6389 (unless (string-match ">$" message-id)
6390 (setq message-id (concat message-id ">")))
6391 (let* ((header (gnus-id-to-header message-id))
6393 (gnus-summary-article-sparse-p
6394 (mail-header-number header))
6395 (memq (mail-header-number header)
6396 gnus-newsgroup-limit)))
6399 ;; If the article is present in the buffer we just go to it.
6401 (or (not (gnus-summary-article-sparse-p
6402 (mail-header-number header)))
6405 (gnus-summary-goto-article
6406 (mail-header-number header) nil t)
6408 (gnus-summary-update-article (mail-header-number header)))))
6410 ;; We fetch the article
6411 (let ((gnus-override-method
6412 (cond ((gnus-news-group-p gnus-newsgroup-name)
6413 gnus-refer-article-method)
6415 (or gnus-refer-article-method gnus-select-method))
6418 ;; Start the special refer-article method, if necessary.
6419 (when (and gnus-refer-article-method
6420 (gnus-news-group-p gnus-newsgroup-name))
6421 (gnus-check-server gnus-refer-article-method))
6422 ;; Fetch the header, and display the article.
6423 (if (setq number (gnus-summary-insert-subject message-id))
6424 (gnus-summary-select-article nil nil nil number)
6425 (gnus-message 3 "Couldn't fetch article %s" message-id))))))))
6427 (defun gnus-summary-edit-parameters ()
6428 "Edit the group parameters of the current group."
6430 (gnus-group-edit-group gnus-newsgroup-name 'params))
6432 (defun gnus-summary-enter-digest-group (&optional force)
6433 "Enter an nndoc group based on the current article.
6434 If FORCE, force a digest interpretation. If not, try
6435 to guess what the document format is."
6437 (let ((conf gnus-current-window-configuration))
6439 (gnus-summary-select-article))
6440 (setq gnus-current-window-configuration conf)
6441 (let* ((name (format "%s-%d"
6442 (gnus-group-prefixed-name
6443 gnus-newsgroup-name (list 'nndoc ""))
6445 (set-buffer gnus-summary-buffer)
6446 gnus-current-article)))
6447 (ogroup gnus-newsgroup-name)
6448 (params (append (gnus-info-params (gnus-get-info ogroup))
6449 (list (cons 'to-group ogroup))
6450 (list (cons 'save-article-group ogroup))))
6451 (case-fold-search t)
6452 (buf (current-buffer))
6455 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
6456 (insert-buffer-substring gnus-original-article-buffer)
6457 ;; Remove lines that may lead nndoc to misinterpret the
6460 (goto-char (point-min))
6461 (or (search-forward "\n\n" nil t) (point)))
6462 (goto-char (point-min))
6463 (delete-matching-lines "^\\(Path\\):\\|^From ")
6466 (if (gnus-group-read-ephemeral-group
6467 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
6469 ,(if force 'digest 'guess))) t)
6470 ;; Make all postings to this group go to the parent group.
6471 (nconc (gnus-info-params (gnus-get-info name))
6473 ;; Couldn't select this doc group.
6474 (switch-to-buffer buf)
6475 (gnus-set-global-variables)
6476 (gnus-configure-windows 'summary)
6477 (gnus-message 3 "Article couldn't be entered?"))
6478 (kill-buffer dig)))))
6480 (defun gnus-summary-read-document (n)
6481 "Open a new group based on the current article(s).
6482 This will allow you to read digests and other similar
6483 documents as newsgroups.
6484 Obeys the standard process/prefix convention."
6486 (let* ((articles (gnus-summary-work-articles n))
6487 (ogroup gnus-newsgroup-name)
6488 (params (append (gnus-info-params (gnus-get-info ogroup))
6489 (list (cons 'to-group ogroup))))
6490 article group egroup groups vgroup)
6491 (while (setq article (pop articles))
6492 (setq group (format "%s-%d" gnus-newsgroup-name article))
6493 (gnus-summary-remove-process-mark article)
6494 (when (gnus-summary-display-article article)
6496 (nnheader-temp-write nil
6497 (insert-buffer-substring gnus-original-article-buffer)
6498 ;; Remove some headers that may lead nndoc to make
6500 (message-narrow-to-head)
6501 (goto-char (point-min))
6502 (delete-matching-lines "^\\(Path\\):\\|^From ")
6505 (gnus-group-read-ephemeral-group
6506 group `(nndoc ,group (nndoc-address ,(current-buffer))
6507 (nndoc-article-type guess))
6510 ;; Make all postings to this group go to the parent group.
6511 (nconc (gnus-info-params (gnus-get-info egroup))
6513 (push egroup groups))
6514 ;; Couldn't select this doc group.
6515 (gnus-error 3 "Article couldn't be entered"))))))
6516 ;; Now we have selected all the documents.
6519 (error "None of the articles could be interpreted as documents"))
6520 ((gnus-group-read-ephemeral-group
6521 (setq vgroup (format
6522 "nnvirtual:%s-%s" gnus-newsgroup-name
6523 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
6524 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
6526 (cons (current-buffer) 'summary)))
6528 (error "Couldn't select virtual nndoc group")))))
6530 (defun gnus-summary-isearch-article (&optional regexp-p)
6531 "Do incremental search forward on the current article.
6532 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
6534 (gnus-summary-select-article)
6535 (gnus-configure-windows 'article)
6536 (gnus-eval-in-buffer-window gnus-article-buffer
6539 (isearch-forward regexp-p))))
6541 (defun gnus-summary-search-article-forward (regexp &optional backward)
6542 "Search for an article containing REGEXP forward.
6543 If BACKWARD, search backward instead."
6546 (format "Search article %s (regexp%s): "
6547 (if current-prefix-arg "backward" "forward")
6548 (if gnus-last-search-regexp
6549 (concat ", default " gnus-last-search-regexp)
6551 current-prefix-arg))
6552 (if (string-equal regexp "")
6553 (setq regexp (or gnus-last-search-regexp ""))
6554 (setq gnus-last-search-regexp regexp))
6555 (if (gnus-summary-search-article regexp backward)
6556 (gnus-summary-show-thread)
6557 (error "Search failed: \"%s\"" regexp)))
6559 (defun gnus-summary-search-article-backward (regexp)
6560 "Search for an article containing REGEXP backward."
6563 (format "Search article backward (regexp%s): "
6564 (if gnus-last-search-regexp
6565 (concat ", default " gnus-last-search-regexp)
6567 (gnus-summary-search-article-forward regexp 'backward))
6569 (defun gnus-summary-search-article (regexp &optional backward)
6570 "Search for an article containing REGEXP.
6571 Optional argument BACKWARD means do search for backward.
6572 `gnus-select-article-hook' is not called during the search."
6573 ;; We have to require this here to make sure that the following
6574 ;; dynamic binding isn't shadowed by autoloading.
6575 (require 'gnus-async)
6576 (let ((gnus-select-article-hook nil) ;Disable hook.
6577 (gnus-article-display-hook nil)
6578 (gnus-mark-article-hook nil) ;Inhibit marking as read.
6579 (gnus-use-article-prefetch nil)
6580 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
6581 (gnus-use-trees nil) ;Inhibit updating tree buffer.
6582 (sum (current-buffer))
6585 (gnus-save-hidden-threads
6586 (gnus-summary-select-article)
6587 (set-buffer gnus-article-buffer)
6591 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
6593 (re-search-backward regexp nil t)
6594 (re-search-forward regexp nil t))
6595 ;; We found the regexp.
6600 (get-buffer-window (current-buffer))
6604 (setq point (point)))
6605 ;; We didn't find it, so we go to the next article.
6608 (while (eq found 'not)
6609 (if (not (if backward (gnus-summary-find-prev)
6610 (gnus-summary-find-next)))
6611 ;; No more articles.
6613 ;; Select the next article and adjust point.
6614 (unless (gnus-summary-article-sparse-p
6615 (gnus-summary-article-number))
6617 (gnus-summary-select-article)
6618 (set-buffer gnus-article-buffer)
6620 (goto-char (if backward (point-max) (point-min))))))))
6621 (gnus-message 7 ""))
6622 ;; Return whether we found the regexp.
6623 (when (eq found 'found)
6625 (gnus-summary-show-thread)
6626 (gnus-summary-goto-subject gnus-current-article)
6627 (gnus-summary-position-point)
6630 (defun gnus-summary-find-matching (header regexp &optional backward unread
6632 "Return a list of all articles that match REGEXP on HEADER.
6633 The search stars on the current article and goes forwards unless
6634 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
6635 If UNREAD is non-nil, only unread articles will
6636 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
6637 in the comparisons."
6638 (let ((data (if (eq backward 'all) gnus-newsgroup-data
6639 (gnus-data-find-list
6640 (gnus-summary-article-number) (gnus-data-list backward))))
6641 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
6642 (case-fold-search (not not-case-fold))
6644 (unless (fboundp (intern (concat "mail-header-" header)))
6645 (error "%s is not a valid header" header))
6648 (and (or (not unread) ; We want all articles...
6649 (gnus-data-unread-p d)) ; Or just unreads.
6650 (vectorp (gnus-data-header d)) ; It's not a pseudo.
6651 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
6652 (push (gnus-data-number d) articles)) ; Success!
6653 (setq data (cdr data)))
6654 (nreverse articles)))
6656 (defun gnus-summary-execute-command (header regexp command &optional backward)
6657 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
6658 If HEADER is an empty string (or nil), the match is done on the entire
6659 article. If BACKWARD (the prefix) is non-nil, search backward instead."
6661 (list (let ((completion-ignore-case t))
6664 (mapcar (lambda (string) (list string))
6665 '("Number" "Subject" "From" "Lines" "Date"
6666 "Message-ID" "Xref" "References" "Body"))
6667 nil 'require-match))
6668 (read-string "Regexp: ")
6669 (read-key-sequence "Command: ")
6670 current-prefix-arg))
6671 (when (equal header "Body")
6673 ;; Hidden thread subtrees must be searched as well.
6674 (gnus-summary-show-all-threads)
6675 ;; We don't want to change current point nor window configuration.
6677 (save-window-excursion
6678 (gnus-message 6 "Executing %s..." (key-description command))
6679 ;; We'd like to execute COMMAND interactively so as to give arguments.
6680 (gnus-execute header regexp
6681 `(call-interactively ',(key-binding command))
6683 (gnus-message 6 "Executing %s...done" (key-description command)))))
6685 (defun gnus-summary-beginning-of-article ()
6686 "Scroll the article back to the beginning."
6688 (gnus-summary-select-article)
6689 (gnus-configure-windows 'article)
6690 (gnus-eval-in-buffer-window gnus-article-buffer
6692 (goto-char (point-min))
6693 (when gnus-page-broken
6694 (gnus-narrow-to-page))))
6696 (defun gnus-summary-end-of-article ()
6697 "Scroll to the end of the article."
6699 (gnus-summary-select-article)
6700 (gnus-configure-windows 'article)
6701 (gnus-eval-in-buffer-window gnus-article-buffer
6703 (goto-char (point-max))
6705 (when gnus-page-broken
6706 (gnus-narrow-to-page))))
6708 (defun gnus-summary-print-article (&optional filename n)
6709 "Generate and print a PostScript image of the N next (mail) articles.
6711 If N is negative, print the N previous articles. If N is nil and articles
6712 have been marked with the process mark, print these instead.
6714 If the optional second argument FILENAME is nil, send the image to the
6715 printer. If FILENAME is a string, save the PostScript image in a file with
6716 that name. If FILENAME is a number, prompt the user for the name of the file
6718 (interactive (list (ps-print-preprint current-prefix-arg)
6719 current-prefix-arg))
6720 (dolist (article (gnus-summary-work-articles n))
6721 (gnus-summary-select-article nil nil 'pseudo article)
6722 (gnus-eval-in-buffer-window gnus-article-buffer
6723 (let ((buffer (generate-new-buffer " *print*")))
6726 (copy-to-buffer buffer (point-min) (point-max))
6728 (gnus-article-delete-invisible-text)
6729 (let ((ps-left-header
6732 (mail-header-subject gnus-current-headers) ")")
6734 (mail-header-from gnus-current-headers) ")")))
6737 "/pagenumberstring load"
6739 (mail-header-date gnus-current-headers) ")"))))
6740 (gnus-run-hooks 'gnus-ps-print-hook)
6742 (ps-print-buffer-with-faces filename))))
6743 (kill-buffer buffer))))))
6745 (defun gnus-summary-show-article (&optional arg)
6746 "Force re-fetching of the current article.
6747 If ARG (the prefix) is non-nil, show the raw article without any
6748 article massaging functions being run."
6751 ;; Select the article the normal way.
6752 (gnus-summary-select-article nil 'force)
6753 ;; Bind the article treatment functions to nil.
6754 (let ((gnus-have-all-headers t)
6755 gnus-article-display-hook
6756 gnus-article-prepare-hook
6760 (gnus-summary-select-article nil 'force)))
6761 (gnus-summary-goto-subject gnus-current-article)
6762 (gnus-summary-position-point))
6764 (defun gnus-summary-verbose-headers (&optional arg)
6765 "Toggle permanent full header display.
6766 If ARG is a positive number, turn header display on.
6767 If ARG is a negative number, turn header display off."
6769 (setq gnus-show-all-headers
6770 (cond ((or (not (numberp arg))
6772 (not gnus-show-all-headers))
6775 (gnus-summary-show-article))
6777 (defun gnus-summary-toggle-header (&optional arg)
6778 "Show the headers if they are hidden, or hide them if they are shown.
6779 If ARG is a positive number, show the entire header.
6780 If ARG is a negative number, hide the unwanted header lines."
6783 (set-buffer gnus-article-buffer)
6784 (let* ((buffer-read-only nil)
6785 (inhibit-point-motion-hooks t)
6786 (hidden (text-property-any
6787 (goto-char (point-min)) (search-forward "\n\n")
6790 (goto-char (point-min))
6791 (when (search-forward "\n\n" nil t)
6792 (delete-region (point-min) (1- (point))))
6793 (goto-char (point-min))
6795 (set-buffer gnus-original-article-buffer)
6796 (goto-char (point-min))
6797 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
6798 (insert-buffer-substring gnus-original-article-buffer 1 e)
6799 (let ((article-inhibit-hiding t))
6800 (gnus-run-hooks 'gnus-article-display-hook))
6801 (when (or (not hidden) (and (numberp arg) (< arg 0)))
6802 (gnus-article-hide-headers)))))
6804 (defun gnus-summary-show-all-headers ()
6805 "Make all header lines visible."
6807 (gnus-article-show-all-headers))
6809 (defun gnus-summary-toggle-mime (&optional arg)
6810 "Toggle MIME processing.
6811 If ARG is a positive number, turn MIME processing on."
6813 (setq gnus-show-mime
6814 (if (null arg) (not gnus-show-mime)
6815 (> (prefix-numeric-value arg) 0)))
6816 (gnus-summary-select-article t 'force))
6818 (defun gnus-summary-caesar-message (&optional arg)
6819 "Caesar rotate the current article by 13.
6820 The numerical prefix specifies how many places to rotate each letter
6823 (gnus-summary-select-article)
6824 (let ((mail-header-separator ""))
6825 (gnus-eval-in-buffer-window gnus-article-buffer
6828 (let ((start (window-start))
6830 (message-caesar-buffer-body arg)
6831 (set-window-start (get-buffer-window (current-buffer)) start))))))
6833 (defun gnus-summary-stop-page-breaking ()
6834 "Stop page breaking in the current article."
6836 (gnus-summary-select-article)
6837 (gnus-eval-in-buffer-window gnus-article-buffer
6839 (when (gnus-visual-p 'page-marker)
6840 (let ((buffer-read-only nil))
6841 (gnus-remove-text-with-property 'gnus-prev)
6842 (gnus-remove-text-with-property 'gnus-next))
6843 (setq gnus-page-broken nil))))
6845 (defun gnus-summary-move-article (&optional n to-newsgroup
6846 select-method action)
6847 "Move the current article to a different newsgroup.
6848 If N is a positive number, move the N next articles.
6849 If N is a negative number, move the N previous articles.
6850 If N is nil and any articles have been marked with the process mark,
6851 move those articles instead.
6852 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
6853 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
6854 re-spool using this method.
6856 For this function to work, both the current newsgroup and the
6857 newsgroup that you want to move to have to support the `request-move'
6858 and `request-accept' functions."
6861 (setq action 'move))
6862 ;; Disable marking as read.
6863 (let (gnus-mark-article-hook)
6864 (save-window-excursion
6865 (gnus-summary-select-article)))
6866 ;; Check whether the source group supports the required functions.
6867 (cond ((and (eq action 'move)
6868 (not (gnus-check-backend-function
6869 'request-move-article gnus-newsgroup-name)))
6870 (error "The current group does not support article moving"))
6871 ((and (eq action 'crosspost)
6872 (not (gnus-check-backend-function
6873 'request-replace-article gnus-newsgroup-name)))
6874 (error "The current group does not support article editing")))
6875 (let ((articles (gnus-summary-work-articles n))
6876 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
6877 (names '((move "Move" "Moving")
6878 (copy "Copy" "Copying")
6879 (crosspost "Crosspost" "Crossposting")))
6880 (copy-buf (save-excursion
6881 (nnheader-set-temp-buffer " *copy article*")))
6882 art-group to-method new-xref article to-groups)
6883 (unless (assq action names)
6884 (error "Unknown action %s" action))
6885 ;; Read the newsgroup name.
6886 (when (and (not to-newsgroup)
6887 (not select-method))
6889 (gnus-read-move-group-name
6890 (cadr (assq action names))
6891 (symbol-value (intern (format "gnus-current-%s-group" action)))
6893 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
6894 (setq to-method (or select-method
6895 (gnus-group-name-to-method to-newsgroup)))
6896 ;; Check the method we are to move this article to...
6897 (unless (gnus-check-backend-function
6898 'request-accept-article (car to-method))
6899 (error "%s does not support article copying" (car to-method)))
6900 (unless (gnus-check-server to-method)
6901 (error "Can't open server %s" (car to-method)))
6902 (gnus-message 6 "%s to %s: %s..."
6903 (caddr (assq action names))
6904 (or (car select-method) to-newsgroup) articles)
6906 (setq article (pop articles))
6910 ;; Move the article.
6912 ;; Remove this article from future suppression.
6913 (gnus-dup-unsuppress-article article)
6914 (gnus-request-move-article
6915 article ; Article to move
6916 gnus-newsgroup-name ; From newsgroup
6917 (nth 1 (gnus-find-method-for-group
6918 gnus-newsgroup-name)) ; Server
6919 (list 'gnus-request-accept-article
6920 to-newsgroup (list 'quote select-method)
6921 (not articles)) ; Accept form
6922 (not articles))) ; Only save nov last time
6923 ;; Copy the article.
6926 (set-buffer copy-buf)
6927 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
6928 (gnus-request-accept-article
6929 to-newsgroup select-method (not articles)))))
6930 ;; Crosspost the article.
6931 ((eq action 'crosspost)
6932 (let ((xref (message-tokenize-header
6933 (mail-header-xref (gnus-summary-article-header article))
6935 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
6938 (setq xref (list (system-name))))
6941 (mapconcat 'identity
6942 (delete "Xref:" (delete new-xref xref))
6946 (set-buffer copy-buf)
6947 ;; First put the article in the destination group.
6948 (gnus-request-article-this-buffer article gnus-newsgroup-name)
6949 (when (consp (setq art-group
6950 (gnus-request-accept-article
6951 to-newsgroup select-method (not articles))))
6952 (setq new-xref (concat new-xref " " (car art-group)
6953 ":" (cdr art-group)))
6954 ;; Now we have the new Xrefs header, so we insert
6955 ;; it and replace the new article.
6956 (nnheader-replace-header "Xref" new-xref)
6957 (gnus-request-replace-article
6958 (cdr art-group) to-newsgroup (current-buffer))
6962 (gnus-message 1 "Couldn't %s article %s"
6963 (cadr (assq action names)) article))
6964 ((and (eq art-group 'junk)
6966 (gnus-summary-mark-article article gnus-canceled-mark)
6967 (gnus-message 4 "Deleted article %s" article))
6971 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
6973 (gnus-group-prefixed-name
6976 (gnus-find-method-for-group to-newsgroup)))
6977 gnus-newsrc-hashtb)))
6978 (info (nth 2 entry))
6979 (to-group (gnus-info-group info)))
6980 ;; Update the group that has been moved to.
6982 (memq action '(move copy)))
6983 (unless (member to-group to-groups)
6984 (push to-group to-groups))
6986 (unless (memq article gnus-newsgroup-unreads)
6988 info (gnus-add-to-range (gnus-info-read info)
6989 (list (cdr art-group)))))
6991 ;; Copy any marks over to the new group.
6992 (let ((marks gnus-article-mark-lists)
6993 (to-article (cdr art-group)))
6995 ;; See whether the article is to be put in the cache.
6996 (when gnus-use-cache
6997 (gnus-cache-possibly-enter-article
6999 (let ((header (copy-sequence
7000 (gnus-summary-article-header article))))
7001 (mail-header-set-number header to-article)
7003 (memq article gnus-newsgroup-marked)
7004 (memq article gnus-newsgroup-dormant)
7005 (memq article gnus-newsgroup-unreads)))
7007 (when (and (equal to-group gnus-newsgroup-name)
7008 (not (memq article gnus-newsgroup-unreads)))
7009 ;; Mark this article as read in this group.
7010 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
7011 (setcdr (gnus-active to-group) to-article)
7012 (setcdr gnus-newsgroup-active to-article))
7015 (when (memq article (symbol-value
7016 (intern (format "gnus-newsgroup-%s"
7018 ;; If the other group is the same as this group,
7019 ;; then we have to add the mark to the list.
7020 (when (equal to-group gnus-newsgroup-name)
7021 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
7024 (intern (format "gnus-newsgroup-%s"
7026 ;; Copy the marks to other group.
7027 (gnus-add-marked-articles
7028 to-group (cdar marks) (list to-article) info))
7029 (setq marks (cdr marks)))
7032 (concat "(gnus-group-set-info '"
7033 (gnus-prin1-to-string (gnus-get-info to-group))
7036 ;; Update the Xref header in this article to point to
7037 ;; the new crossposted article we have just created.
7038 (when (eq action 'crosspost)
7040 (set-buffer copy-buf)
7041 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7042 (nnheader-replace-header "Xref" new-xref)
7043 (gnus-request-replace-article
7044 article gnus-newsgroup-name (current-buffer)))))
7046 ;;;!!!Why is this necessary?
7047 (set-buffer gnus-summary-buffer)
7049 (gnus-summary-goto-subject article)
7050 (when (eq action 'move)
7051 (gnus-summary-mark-article article gnus-canceled-mark))))
7052 (gnus-summary-remove-process-mark article))
7053 ;; Re-activate all groups that have been moved to.
7056 (set-buffer gnus-group-buffer)
7057 (when (gnus-group-goto-group (car to-groups) t)
7058 (gnus-group-get-new-news-this-group 1 t))
7061 (gnus-kill-buffer copy-buf)
7062 (gnus-summary-position-point)
7063 (gnus-set-mode-line 'summary)))
7065 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
7066 "Move the current article to a different newsgroup.
7067 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7068 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7069 re-spool using this method."
7071 (gnus-summary-move-article n to-newsgroup select-method 'copy))
7073 (defun gnus-summary-crosspost-article (&optional n)
7074 "Crosspost the current article to some other group."
7076 (gnus-summary-move-article n nil nil 'crosspost))
7078 (defcustom gnus-summary-respool-default-method nil
7079 "Default method for respooling an article.
7080 If nil, use to the current newsgroup method."
7081 :type `(choice (gnus-select-method :value (nnml ""))
7083 :group 'gnus-summary-mail)
7085 (defun gnus-summary-respool-article (&optional n method)
7086 "Respool the current article.
7087 The article will be squeezed through the mail spooling process again,
7088 which means that it will be put in some mail newsgroup or other
7089 depending on `nnmail-split-methods'.
7090 If N is a positive number, respool the N next articles.
7091 If N is a negative number, respool the N previous articles.
7092 If N is nil and any articles have been marked with the process mark,
7093 respool those articles instead.
7095 Respooling can be done both from mail groups and \"real\" newsgroups.
7096 In the former case, the articles in question will be moved from the
7097 current group into whatever groups they are destined to. In the
7098 latter case, they will be copied into the relevant groups."
7100 (list current-prefix-arg
7101 (let* ((methods (gnus-methods-using 'respool))
7103 (symbol-name (or gnus-summary-respool-default-method
7104 (car (gnus-find-method-for-group
7105 gnus-newsgroup-name)))))
7107 (gnus-completing-read
7108 methname "What backend do you want to use when respooling?"
7109 methods nil t nil 'gnus-mail-method-history))
7112 ((zerop (length (setq ms (gnus-servers-using-backend
7114 (list (intern method) ""))
7118 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
7119 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
7122 (error "No method given for respooling"))
7123 (if (assoc (symbol-name
7124 (car (gnus-find-method-for-group gnus-newsgroup-name)))
7125 (gnus-methods-using 'respool))
7126 (gnus-summary-move-article n nil method)
7127 (gnus-summary-copy-article n nil method)))
7129 (defun gnus-summary-import-article (file)
7130 "Import an arbitrary file into a mail newsgroup."
7131 (interactive "fImport file: ")
7132 (let ((group gnus-newsgroup-name)
7133 (now (current-time))
7135 (unless (gnus-check-backend-function 'request-accept-article group)
7136 (error "%s does not support article importing" group))
7137 (or (file-readable-p file)
7138 (not (file-regular-p file))
7139 (error "Can't read %s" file))
7141 (set-buffer (get-buffer-create " *import file*"))
7142 (buffer-disable-undo (current-buffer))
7144 (insert-file-contents file)
7145 (goto-char (point-min))
7146 (unless (nnheader-article-p)
7147 ;; This doesn't look like an article, so we fudge some headers.
7148 (setq atts (file-attributes file)
7149 lines (count-lines (point-min) (point-max)))
7150 (insert "From: " (read-string "From: ") "\n"
7151 "Subject: " (read-string "Subject: ") "\n"
7152 "Date: " (timezone-make-date-arpa-standard
7153 (current-time-string (nth 5 atts))
7154 (current-time-zone now)
7155 (current-time-zone now))
7157 "Message-ID: " (message-make-message-id) "\n"
7158 "Lines: " (int-to-string lines) "\n"
7159 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
7160 (gnus-request-accept-article group nil t)
7161 (kill-buffer (current-buffer)))))
7163 (defun gnus-summary-article-posted-p ()
7164 "Say whether the current (mail) article is available from `gnus-select-method' as well.
7165 This will be the case if the article has both been mailed and posted."
7167 (let ((id (mail-header-references (gnus-summary-article-header)))
7168 (gnus-override-method
7169 (or gnus-refer-article-method gnus-select-method)))
7170 (if (gnus-request-head id "")
7171 (gnus-message 2 "The current message was found on %s"
7172 gnus-override-method)
7173 (gnus-message 2 "The current message couldn't be found on %s"
7174 gnus-override-method)
7177 (defun gnus-summary-expire-articles (&optional now)
7178 "Expire all articles that are marked as expirable in the current group."
7180 (when (gnus-check-backend-function
7181 'request-expire-articles gnus-newsgroup-name)
7182 ;; This backend supports expiry.
7183 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
7184 (expirable (if total
7186 ;; We need to update the info for
7187 ;; this group for `gnus-list-of-read-articles'
7188 ;; to give us the right answer.
7189 (gnus-run-hooks 'gnus-exit-group-hook)
7190 (gnus-summary-update-info)
7191 (gnus-list-of-read-articles gnus-newsgroup-name))
7192 (setq gnus-newsgroup-expirable
7193 (sort gnus-newsgroup-expirable '<))))
7194 (expiry-wait (if now 'immediate
7195 (gnus-group-find-parameter
7196 gnus-newsgroup-name 'expiry-wait)))
7199 ;; There are expirable articles in this group, so we run them
7200 ;; through the expiry process.
7201 (gnus-message 6 "Expiring articles...")
7202 ;; The list of articles that weren't expired is returned.
7205 (let ((nnmail-expiry-wait-function nil)
7206 (nnmail-expiry-wait expiry-wait))
7207 (setq es (gnus-request-expire-articles
7208 expirable gnus-newsgroup-name)))
7209 (setq es (gnus-request-expire-articles
7210 expirable gnus-newsgroup-name))))
7212 (setq gnus-newsgroup-expirable es))
7213 ;; We go through the old list of expirable, and mark all
7214 ;; really expired articles as nonexistent.
7215 (unless (eq es expirable) ;If nothing was expired, we don't mark.
7216 (let ((gnus-use-cache nil))
7218 (unless (memq (car expirable) es)
7219 (when (gnus-data-find (car expirable))
7220 (gnus-summary-mark-article
7221 (car expirable) gnus-canceled-mark)))
7222 (setq expirable (cdr expirable)))))
7223 (gnus-message 6 "Expiring articles...done")))))
7225 (defun gnus-summary-expire-articles-now ()
7226 "Expunge all expirable articles in the current group.
7227 This means that *all* articles that are marked as expirable will be
7228 deleted forever, right now."
7230 (or gnus-expert-user
7232 "Are you really, really, really sure you want to delete all these messages? ")
7234 (gnus-summary-expire-articles t))
7236 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
7237 (defun gnus-summary-delete-article (&optional n)
7238 "Delete the N next (mail) articles.
7239 This command actually deletes articles. This is not a marking
7240 command. The article will disappear forever from your life, never to
7242 If N is negative, delete backwards.
7243 If N is nil and articles have been marked with the process mark,
7244 delete these instead."
7246 (unless (gnus-check-backend-function 'request-expire-articles
7247 gnus-newsgroup-name)
7248 (error "The current newsgroup does not support article deletion"))
7249 ;; Compute the list of articles to delete.
7250 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
7252 (if (and gnus-novice-user
7253 (not (gnus-yes-or-no-p
7254 (format "Do you really want to delete %s forever? "
7255 (if (> (length articles) 1)
7256 (format "these %s articles" (length articles))
7259 ;; Delete the articles.
7260 (setq not-deleted (gnus-request-expire-articles
7261 articles gnus-newsgroup-name 'force))
7263 (gnus-summary-remove-process-mark (car articles))
7264 ;; The backend might not have been able to delete the article
7266 (unless (memq (car articles) not-deleted)
7267 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
7268 (setq articles (cdr articles)))
7270 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
7271 (gnus-summary-position-point)
7272 (gnus-set-mode-line 'summary)
7275 (defun gnus-summary-edit-article (&optional force)
7276 "Edit the current article.
7277 This will have permanent effect only in mail groups.
7278 If FORCE is non-nil, allow editing of articles even in read-only
7282 (set-buffer gnus-summary-buffer)
7283 (gnus-set-global-variables)
7284 (when (and (not force)
7285 (gnus-group-read-only-p))
7286 (error "The current newsgroup does not support article editing"))
7287 ;; Select article if needed.
7288 (unless (eq (gnus-summary-article-number)
7289 gnus-current-article)
7290 (gnus-summary-select-article t))
7291 (gnus-article-date-original)
7292 (gnus-article-edit-article
7293 `(lambda (no-highlight)
7294 (gnus-summary-edit-article-done
7295 ,(or (mail-header-references gnus-current-headers) "")
7296 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))))
7298 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
7300 (defun gnus-summary-edit-article-done (&optional references read-only buffer
7302 "Make edits to the current article permanent."
7304 ;; Replace the article.
7305 (let ((buf (current-buffer)))
7306 (nnheader-temp-write nil
7308 (if (and (not read-only)
7309 (not (gnus-request-replace-article
7310 (cdr gnus-article-current) (car gnus-article-current)
7312 (error "Couldn't replace article")
7313 ;; Update the summary buffer.
7315 (equal (message-tokenize-header references " ")
7316 (message-tokenize-header
7317 (or (message-fetch-field "references") "") " ")))
7318 ;; We only have to update this line.
7321 (message-narrow-to-head)
7322 (let ((head (buffer-string))
7324 (nnheader-temp-write nil
7325 (insert (format "211 %d Article retrieved.\n"
7326 (cdr gnus-article-current)))
7329 (let ((nntp-server-buffer (current-buffer)))
7330 (setq header (car (gnus-get-newsgroup-headers
7332 (set-buffer gnus-summary-buffer)
7333 gnus-newsgroup-dependencies)
7336 (set-buffer gnus-summary-buffer)
7337 (gnus-data-set-header
7338 (gnus-data-find (cdr gnus-article-current))
7340 (gnus-summary-update-article-line
7341 (cdr gnus-article-current) header))))))
7343 (set-buffer (or buffer gnus-summary-buffer))
7344 (gnus-summary-update-article (cdr gnus-article-current)))
7345 ;; Prettify the article buffer again.
7346 (unless no-highlight
7348 (set-buffer gnus-article-buffer)
7349 (gnus-run-hooks 'gnus-article-display-hook)
7350 (set-buffer gnus-original-article-buffer)
7351 (gnus-request-article
7352 (cdr gnus-article-current)
7353 (car gnus-article-current) (current-buffer))))
7354 ;; Prettify the summary buffer line.
7355 (when (gnus-visual-p 'summary-highlight 'highlight)
7356 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
7358 (defun gnus-summary-edit-wash (key)
7359 "Perform editing command KEY in the article buffer."
7363 (message "%s" (concat (this-command-keys) "- "))
7366 (gnus-summary-edit-article)
7367 (execute-kbd-macro (concat (this-command-keys) key))
7368 (gnus-article-edit-done))
7372 (defun gnus-summary-respool-query (&optional silent trace)
7373 "Query where the respool algorithm would put this article."
7375 (let (gnus-mark-article-hook)
7376 (gnus-summary-select-article)
7378 (set-buffer gnus-original-article-buffer)
7380 (message-narrow-to-head)
7381 (let ((groups (nnmail-article-group 'identity trace)))
7384 (message "This message would go to %s"
7385 (mapconcat 'car groups ", "))
7386 (message "This message would go to no groups"))
7389 (defun gnus-summary-respool-trace ()
7390 "Trace where the respool algorithm would put this article.
7391 Display a buffer showing all fancy splitting patterns which matched."
7393 (gnus-summary-respool-query nil t))
7395 ;; Summary marking commands.
7397 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
7398 "Mark articles which has the same subject as read, and then select the next.
7399 If UNMARK is positive, remove any kind of mark.
7400 If UNMARK is negative, tick articles."
7403 (setq unmark (prefix-numeric-value unmark)))
7405 (gnus-summary-mark-same-subject
7406 (gnus-summary-article-subject) unmark)))
7407 ;; Select next unread article. If auto-select-same mode, should
7408 ;; select the first unread article.
7409 (gnus-summary-next-article t (and gnus-auto-select-same
7410 (gnus-summary-article-subject)))
7411 (gnus-message 7 "%d article%s marked as %s"
7412 count (if (= count 1) " is" "s are")
7413 (if unmark "unread" "read"))))
7415 (defun gnus-summary-kill-same-subject (&optional unmark)
7416 "Mark articles which has the same subject as read.
7417 If UNMARK is positive, remove any kind of mark.
7418 If UNMARK is negative, tick articles."
7421 (setq unmark (prefix-numeric-value unmark)))
7423 (gnus-summary-mark-same-subject
7424 (gnus-summary-article-subject) unmark)))
7425 ;; If marked as read, go to next unread subject.
7427 ;; Go to next unread subject.
7428 (gnus-summary-next-subject 1 t))
7429 (gnus-message 7 "%d articles are marked as %s"
7430 count (if unmark "unread" "read"))))
7432 (defun gnus-summary-mark-same-subject (subject &optional unmark)
7433 "Mark articles with same SUBJECT as read, and return marked number.
7434 If optional argument UNMARK is positive, remove any kinds of marks.
7435 If optional argument UNMARK is negative, mark articles as unread instead."
7439 ((null unmark) ; Mark as read.
7442 (gnus-summary-mark-article-as-read gnus-killed-mark)
7443 (gnus-summary-show-thread) t)
7444 (gnus-summary-find-subject subject))
7445 (setq count (1+ count))))
7446 ((> unmark 0) ; Tick.
7449 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
7450 (gnus-summary-show-thread) t)
7451 (gnus-summary-find-subject subject))
7452 (setq count (1+ count))))
7453 (t ; Mark as unread.
7456 (gnus-summary-mark-article-as-unread gnus-unread-mark)
7457 (gnus-summary-show-thread) t)
7458 (gnus-summary-find-subject subject))
7459 (setq count (1+ count)))))
7460 (gnus-set-mode-line 'summary)
7461 ;; Return the number of marked articles.
7464 (defun gnus-summary-mark-as-processable (n &optional unmark)
7465 "Set the process mark on the next N articles.
7466 If N is negative, mark backward instead. If UNMARK is non-nil, remove
7467 the process mark instead. The difference between N and the actual
7468 number of articles marked is returned."
7470 (let ((backward (< n 0))
7475 (gnus-summary-remove-process-mark
7476 (gnus-summary-article-number))
7477 (gnus-summary-set-process-mark (gnus-summary-article-number)))
7478 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
7481 (gnus-message 7 "No more articles"))
7482 (gnus-summary-recenter)
7483 (gnus-summary-position-point)
7486 (defun gnus-summary-unmark-as-processable (n)
7487 "Remove the process mark from the next N articles.
7488 If N is negative, unmark backward instead. The difference between N and
7489 the actual number of articles unmarked is returned."
7491 (gnus-summary-mark-as-processable n t))
7493 (defun gnus-summary-unmark-all-processable ()
7494 "Remove the process mark from all articles."
7497 (while gnus-newsgroup-processable
7498 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
7499 (gnus-summary-position-point))
7501 (defun gnus-summary-mark-as-expirable (n)
7502 "Mark N articles forward as expirable.
7503 If N is negative, mark backward instead. The difference between N and
7504 the actual number of articles marked is returned."
7506 (gnus-summary-mark-forward n gnus-expirable-mark))
7508 (defun gnus-summary-mark-article-as-replied (article)
7509 "Mark ARTICLE replied and update the summary line."
7510 (push article gnus-newsgroup-replied)
7511 (let ((buffer-read-only nil))
7512 (when (gnus-summary-goto-subject article)
7513 (gnus-summary-update-secondary-mark article))))
7515 (defun gnus-summary-set-bookmark (article)
7516 "Set a bookmark in current article."
7517 (interactive (list (gnus-summary-article-number)))
7518 (when (or (not (get-buffer gnus-article-buffer))
7519 (not gnus-current-article)
7520 (not gnus-article-current)
7521 (not (equal gnus-newsgroup-name (car gnus-article-current))))
7522 (error "No current article selected"))
7523 ;; Remove old bookmark, if one exists.
7524 (let ((old (assq article gnus-newsgroup-bookmarks)))
7526 (setq gnus-newsgroup-bookmarks
7527 (delq old gnus-newsgroup-bookmarks))))
7528 ;; Set the new bookmark, which is on the form
7529 ;; (article-number . line-number-in-body).
7533 (set-buffer gnus-article-buffer)
7537 (goto-char (point-min))
7538 (search-forward "\n\n" nil t)
7541 gnus-newsgroup-bookmarks)
7542 (gnus-message 6 "A bookmark has been added to the current article."))
7544 (defun gnus-summary-remove-bookmark (article)
7545 "Remove the bookmark from the current article."
7546 (interactive (list (gnus-summary-article-number)))
7547 ;; Remove old bookmark, if one exists.
7548 (let ((old (assq article gnus-newsgroup-bookmarks)))
7551 (setq gnus-newsgroup-bookmarks
7552 (delq old gnus-newsgroup-bookmarks))
7553 (gnus-message 6 "Removed bookmark."))
7554 (gnus-message 6 "No bookmark in current article."))))
7556 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
7557 (defun gnus-summary-mark-as-dormant (n)
7558 "Mark N articles forward as dormant.
7559 If N is negative, mark backward instead. The difference between N and
7560 the actual number of articles marked is returned."
7562 (gnus-summary-mark-forward n gnus-dormant-mark))
7564 (defun gnus-summary-set-process-mark (article)
7565 "Set the process mark on ARTICLE and update the summary line."
7566 (setq gnus-newsgroup-processable
7568 (delq article gnus-newsgroup-processable)))
7569 (when (gnus-summary-goto-subject article)
7570 (gnus-summary-show-thread)
7571 (gnus-summary-update-secondary-mark article)))
7573 (defun gnus-summary-remove-process-mark (article)
7574 "Remove the process mark from ARTICLE and update the summary line."
7575 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
7576 (when (gnus-summary-goto-subject article)
7577 (gnus-summary-show-thread)
7578 (gnus-summary-update-secondary-mark article)))
7580 (defun gnus-summary-set-saved-mark (article)
7581 "Set the process mark on ARTICLE and update the summary line."
7582 (push article gnus-newsgroup-saved)
7583 (when (gnus-summary-goto-subject article)
7584 (gnus-summary-update-secondary-mark article)))
7586 (defun gnus-summary-mark-forward (n &optional mark no-expire)
7587 "Mark N articles as read forwards.
7588 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
7589 The difference between N and the actual number of articles marked is
7592 (let ((backward (< n 0))
7593 (gnus-summary-goto-unread
7594 (and gnus-summary-goto-unread
7595 (not (eq gnus-summary-goto-unread 'never))
7596 (not (memq mark (list gnus-unread-mark
7597 gnus-ticked-mark gnus-dormant-mark)))))
7599 (mark (or mark gnus-del-mark)))
7601 (gnus-summary-mark-article nil mark no-expire)
7602 (zerop (gnus-summary-next-subject
7604 (and gnus-summary-goto-unread
7605 (not (eq gnus-summary-goto-unread 'never)))
7609 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
7610 (gnus-summary-recenter)
7611 (gnus-summary-position-point)
7612 (gnus-set-mode-line 'summary)
7615 (defun gnus-summary-mark-article-as-read (mark)
7616 "Mark the current article quickly as read with MARK."
7617 (let ((article (gnus-summary-article-number)))
7618 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7619 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7620 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7621 (push (cons article mark) gnus-newsgroup-reads)
7622 ;; Possibly remove from cache, if that is used.
7623 (when gnus-use-cache
7624 (gnus-cache-enter-remove-article article))
7625 ;; Allow the backend to change the mark.
7626 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7627 ;; Check for auto-expiry.
7628 (when (and gnus-newsgroup-auto-expire
7629 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
7630 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
7631 (= mark gnus-ancient-mark)
7632 (= mark gnus-read-mark) (= mark gnus-souped-mark)
7633 (= mark gnus-duplicate-mark)))
7634 (setq mark gnus-expirable-mark)
7635 (push article gnus-newsgroup-expirable))
7636 ;; Set the mark in the buffer.
7637 (gnus-summary-update-mark mark 'unread)
7640 (defun gnus-summary-mark-article-as-unread (mark)
7641 "Mark the current article quickly as unread with MARK."
7642 (let* ((article (gnus-summary-article-number))
7643 (old-mark (gnus-summary-article-mark article)))
7644 (if (eq mark old-mark)
7648 (gnus-error 1 "Can't mark negative article numbers")
7650 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7651 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7652 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
7653 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
7654 (cond ((= mark gnus-ticked-mark)
7655 (push article gnus-newsgroup-marked))
7656 ((= mark gnus-dormant-mark)
7657 (push article gnus-newsgroup-dormant))
7659 (push article gnus-newsgroup-unreads)))
7660 (gnus-pull article gnus-newsgroup-reads)
7662 ;; See whether the article is to be put in the cache.
7664 (vectorp (gnus-summary-article-header article))
7666 (gnus-cache-possibly-enter-article
7667 gnus-newsgroup-name article
7668 (gnus-summary-article-header article)
7669 (= mark gnus-ticked-mark)
7670 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
7673 (gnus-summary-update-mark mark 'unread)
7676 (defun gnus-summary-mark-article (&optional article mark no-expire)
7677 "Mark ARTICLE with MARK. MARK can be any character.
7678 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
7679 `??' (dormant) and `?E' (expirable).
7680 If MARK is nil, then the default character `?D' is used.
7681 If ARTICLE is nil, then the article on the current line will be
7683 ;; The mark might be a string.
7684 (when (stringp mark)
7685 (setq mark (aref mark 0)))
7686 ;; If no mark is given, then we check auto-expiring.
7687 (and (not no-expire)
7688 gnus-newsgroup-auto-expire
7690 (and (gnus-characterp mark)
7691 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
7692 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
7693 (= mark gnus-read-mark) (= mark gnus-souped-mark)
7694 (= mark gnus-duplicate-mark))))
7695 (setq mark gnus-expirable-mark))
7696 (let* ((mark (or mark gnus-del-mark))
7697 (article (or article (gnus-summary-article-number)))
7698 (old-mark (gnus-summary-article-mark article)))
7699 (if (eq mark old-mark)
7702 (error "No article on current line"))
7703 (if (not (if (or (= mark gnus-unread-mark)
7704 (= mark gnus-ticked-mark)
7705 (= mark gnus-dormant-mark))
7706 (gnus-mark-article-as-unread article mark)
7707 (gnus-mark-article-as-read article mark)))
7709 ;; See whether the article is to be put in the cache.
7711 (not (= mark gnus-canceled-mark))
7712 (vectorp (gnus-summary-article-header article))
7714 (gnus-cache-possibly-enter-article
7715 gnus-newsgroup-name article
7716 (gnus-summary-article-header article)
7717 (= mark gnus-ticked-mark)
7718 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
7720 (when (gnus-summary-goto-subject article nil t)
7721 (let ((buffer-read-only nil))
7722 (gnus-summary-show-thread)
7724 (gnus-summary-update-mark mark 'unread)
7727 (defun gnus-summary-update-secondary-mark (article)
7728 "Update the secondary (read, process, cache) mark."
7729 (gnus-summary-update-mark
7730 (cond ((memq article gnus-newsgroup-processable)
7732 ((memq article gnus-newsgroup-cached)
7734 ((memq article gnus-newsgroup-replied)
7736 ((memq article gnus-newsgroup-saved)
7738 (t gnus-unread-mark))
7740 (when (gnus-visual-p 'summary-highlight 'highlight)
7741 (gnus-run-hooks 'gnus-summary-update-hook))
7744 (defun gnus-summary-update-mark (mark type)
7745 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
7746 (buffer-read-only nil))
7747 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
7748 (when (looking-at "\r")
7751 (<= (+ forward (point)) (point-max)))
7752 ;; Go to the right position on the line.
7753 (goto-char (+ forward (point)))
7754 ;; Replace the old mark with the new mark.
7755 (subst-char-in-region (point) (1+ (point)) (following-char) mark)
7756 ;; Optionally update the marks by some user rule.
7757 (when (eq type 'unread)
7759 (gnus-data-find (gnus-summary-article-number)) mark)
7760 (gnus-summary-update-line (eq mark gnus-unread-mark))))))
7762 (defun gnus-mark-article-as-read (article &optional mark)
7763 "Enter ARTICLE in the pertinent lists and remove it from others."
7764 ;; Make the article expirable.
7765 (let ((mark (or mark gnus-del-mark)))
7766 (if (= mark gnus-expirable-mark)
7767 (push article gnus-newsgroup-expirable)
7768 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
7769 ;; Remove from unread and marked lists.
7770 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7771 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7772 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7773 (push (cons article mark) gnus-newsgroup-reads)
7774 ;; Possibly remove from cache, if that is used.
7775 (when gnus-use-cache
7776 (gnus-cache-enter-remove-article article))
7779 (defun gnus-mark-article-as-unread (article &optional mark)
7780 "Enter ARTICLE in the pertinent lists and remove it from others."
7781 (let ((mark (or mark gnus-ticked-mark)))
7784 (gnus-error 1 "Can't mark negative article numbers")
7786 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
7787 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
7788 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
7789 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7791 ;; Unsuppress duplicates?
7792 (when gnus-suppress-duplicates
7793 (gnus-dup-unsuppress-article article))
7795 (cond ((= mark gnus-ticked-mark)
7796 (push article gnus-newsgroup-marked))
7797 ((= mark gnus-dormant-mark)
7798 (push article gnus-newsgroup-dormant))
7800 (push article gnus-newsgroup-unreads)))
7801 (gnus-pull article gnus-newsgroup-reads)
7804 (defalias 'gnus-summary-mark-as-unread-forward
7805 'gnus-summary-tick-article-forward)
7806 (make-obsolete 'gnus-summary-mark-as-unread-forward
7807 'gnus-summary-tick-article-forward)
7808 (defun gnus-summary-tick-article-forward (n)
7809 "Tick N articles forwards.
7810 If N is negative, tick backwards instead.
7811 The difference between N and the number of articles ticked is returned."
7813 (gnus-summary-mark-forward n gnus-ticked-mark))
7815 (defalias 'gnus-summary-mark-as-unread-backward
7816 'gnus-summary-tick-article-backward)
7817 (make-obsolete 'gnus-summary-mark-as-unread-backward
7818 'gnus-summary-tick-article-backward)
7819 (defun gnus-summary-tick-article-backward (n)
7820 "Tick N articles backwards.
7821 The difference between N and the number of articles ticked is returned."
7823 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
7825 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
7826 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
7827 (defun gnus-summary-tick-article (&optional article clear-mark)
7828 "Mark current article as unread.
7829 Optional 1st argument ARTICLE specifies article number to be marked as unread.
7830 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
7832 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
7835 (defun gnus-summary-mark-as-read-forward (n)
7836 "Mark N articles as read forwards.
7837 If N is negative, mark backwards instead.
7838 The difference between N and the actual number of articles marked is
7841 (gnus-summary-mark-forward n gnus-del-mark t))
7843 (defun gnus-summary-mark-as-read-backward (n)
7844 "Mark the N articles as read backwards.
7845 The difference between N and the actual number of articles marked is
7848 (gnus-summary-mark-forward (- n) gnus-del-mark t))
7850 (defun gnus-summary-mark-as-read (&optional article mark)
7851 "Mark current article as read.
7852 ARTICLE specifies the article to be marked as read.
7853 MARK specifies a string to be inserted at the beginning of the line."
7854 (gnus-summary-mark-article article mark))
7856 (defun gnus-summary-clear-mark-forward (n)
7857 "Clear marks from N articles forward.
7858 If N is negative, clear backward instead.
7859 The difference between N and the number of marks cleared is returned."
7861 (gnus-summary-mark-forward n gnus-unread-mark))
7863 (defun gnus-summary-clear-mark-backward (n)
7864 "Clear marks from N articles backward.
7865 The difference between N and the number of marks cleared is returned."
7867 (gnus-summary-mark-forward (- n) gnus-unread-mark))
7869 (defun gnus-summary-mark-unread-as-read ()
7870 "Intended to be used by `gnus-summary-mark-article-hook'."
7871 (when (memq gnus-current-article gnus-newsgroup-unreads)
7872 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
7874 (defun gnus-summary-mark-read-and-unread-as-read ()
7875 "Intended to be used by `gnus-summary-mark-article-hook'."
7876 (let ((mark (gnus-summary-article-mark)))
7877 (when (or (gnus-unread-mark-p mark)
7878 (gnus-read-mark-p mark))
7879 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
7881 (defun gnus-summary-mark-region-as-read (point mark all)
7882 "Mark all unread articles between point and mark as read.
7883 If given a prefix, mark all articles between point and mark as read,
7884 even ticked and dormant ones."
7885 (interactive "r\nP")
7894 (memq (setq article (gnus-summary-article-number))
7895 gnus-newsgroup-unreads))
7896 (gnus-summary-mark-article article gnus-del-mark))
7898 (gnus-summary-find-next))))))
7900 (defun gnus-summary-mark-below (score mark)
7901 "Mark articles with score less than SCORE with MARK."
7902 (interactive "P\ncMark: ")
7903 (setq score (if score
7904 (prefix-numeric-value score)
7905 (or gnus-summary-default-score 0)))
7907 (set-buffer gnus-summary-buffer)
7908 (goto-char (point-min))
7911 (and (< (gnus-summary-article-score) score)
7912 (gnus-summary-mark-article nil mark))
7913 (gnus-summary-find-next)))))
7915 (defun gnus-summary-kill-below (&optional score)
7916 "Mark articles with score below SCORE as read."
7918 (gnus-summary-mark-below score gnus-killed-mark))
7920 (defun gnus-summary-clear-above (&optional score)
7921 "Clear all marks from articles with score above SCORE."
7923 (gnus-summary-mark-above score gnus-unread-mark))
7925 (defun gnus-summary-tick-above (&optional score)
7926 "Tick all articles with score above SCORE."
7928 (gnus-summary-mark-above score gnus-ticked-mark))
7930 (defun gnus-summary-mark-above (score mark)
7931 "Mark articles with score over SCORE with MARK."
7932 (interactive "P\ncMark: ")
7933 (setq score (if score
7934 (prefix-numeric-value score)
7935 (or gnus-summary-default-score 0)))
7937 (set-buffer gnus-summary-buffer)
7938 (goto-char (point-min))
7940 (when (> (gnus-summary-article-score) score)
7941 (gnus-summary-mark-article nil mark))
7943 (gnus-summary-find-next)))))
7945 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
7946 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
7947 (defun gnus-summary-limit-include-expunged (&optional no-error)
7948 "Display all the hidden articles that were expunged for low scores."
7950 (let ((buffer-read-only nil))
7951 (let ((scored gnus-newsgroup-scored)
7954 (unless (gnus-summary-goto-subject (caar scored))
7955 (and (setq h (gnus-summary-article-header (caar scored)))
7956 (< (cdar scored) gnus-summary-expunge-below)
7958 (setq scored (cdr scored)))
7960 (when (not no-error)
7961 (error "No expunged articles hidden"))
7962 (goto-char (point-min))
7963 (gnus-summary-prepare-unthreaded (nreverse headers))
7964 (goto-char (point-min))
7965 (gnus-summary-position-point)
7968 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
7969 "Mark all unread articles in this newsgroup as read.
7970 If prefix argument ALL is non-nil, ticked and dormant articles will
7971 also be marked as read.
7972 If QUIETLY is non-nil, no questions will be asked.
7973 If TO-HERE is non-nil, it should be a point in the buffer. All
7974 articles before this point will be marked as read.
7975 Note that this function will only catch up the unread article
7976 in the current summary buffer limitation.
7977 The number of articles marked as read is returned."
7982 (not gnus-interactive-catchup) ;Without confirmation?
7986 "Mark absolutely all articles as read? "
7987 "Mark all unread articles as read? ")))
7989 (not gnus-newsgroup-adaptive)
7990 (not gnus-newsgroup-auto-expire)
7991 (not gnus-suppress-duplicates)
7992 (or (not gnus-use-cache)
7993 (eq gnus-use-cache 'passive)))
7996 (setq gnus-newsgroup-marked nil
7997 gnus-newsgroup-dormant nil))
7998 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
7999 ;; We actually mark all articles as canceled, which we
8000 ;; have to do when using auto-expiry or adaptive scoring.
8001 (gnus-summary-show-all-threads)
8002 (when (gnus-summary-first-subject (not all) t)
8004 (if to-here (< (point) to-here) t)
8005 (gnus-summary-mark-article-as-read gnus-catchup-mark)
8006 (gnus-summary-find-next (not all) nil nil t))))
8007 (gnus-set-mode-line 'summary))
8009 (gnus-summary-position-point)))
8011 (defun gnus-summary-catchup-to-here (&optional all)
8012 "Mark all unticked articles before the current one as read.
8013 If ALL is non-nil, also mark ticked and dormant articles as read."
8016 (gnus-save-hidden-threads
8017 (let ((beg (point)))
8018 ;; We check that there are unread articles.
8019 (when (or all (gnus-summary-find-prev))
8020 (gnus-summary-catchup all t beg)))))
8021 (gnus-summary-position-point))
8023 (defun gnus-summary-catchup-all (&optional quietly)
8024 "Mark all articles in this newsgroup as read."
8026 (gnus-summary-catchup t quietly))
8028 (defun gnus-summary-catchup-and-exit (&optional all quietly)
8029 "Mark all articles not marked as unread in this newsgroup as read, then exit.
8030 If prefix argument ALL is non-nil, all articles are marked as read."
8032 (when (gnus-summary-catchup all quietly nil 'fast)
8033 ;; Select next newsgroup or exit.
8034 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
8035 (eq gnus-auto-select-next 'quietly))
8036 (gnus-summary-next-group nil)
8037 (gnus-summary-exit))))
8039 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
8040 "Mark all articles in this newsgroup as read, and then exit."
8042 (gnus-summary-catchup-and-exit t quietly))
8044 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
8045 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
8046 "Mark all articles in this group as read and select the next group.
8047 If given a prefix, mark all articles, unread as well as ticked, as
8051 (gnus-summary-catchup all))
8052 (gnus-summary-next-article t nil nil t))
8054 ;; Thread-based commands.
8056 (defun gnus-summary-articles-in-thread (&optional article)
8057 "Return a list of all articles in the current thread.
8058 If ARTICLE is non-nil, return all articles in the thread that starts
8060 (let* ((article (or article (gnus-summary-article-number)))
8061 (data (gnus-data-find-list article))
8062 (top-level (gnus-data-level (car data)))
8064 (cond ((null gnus-thread-operation-ignore-subject)
8065 (gnus-simplify-subject-re
8066 (mail-header-subject (gnus-data-header (car data)))))
8067 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
8068 (gnus-simplify-subject-fuzzy
8069 (mail-header-subject (gnus-data-header (car data)))))
8071 (end-point (save-excursion
8072 (if (gnus-summary-go-to-next-thread)
8073 (point) (point-max))))
8076 (< (gnus-data-pos (car data)) end-point))
8077 (when (or (not top-subject)
8078 (string= top-subject
8079 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
8080 (gnus-simplify-subject-fuzzy
8081 (mail-header-subject
8082 (gnus-data-header (car data))))
8083 (gnus-simplify-subject-re
8084 (mail-header-subject
8085 (gnus-data-header (car data)))))))
8086 (push (gnus-data-number (car data)) articles))
8087 (unless (and (setq data (cdr data))
8088 (> (gnus-data-level (car data)) top-level))
8090 ;; Return the list of articles.
8091 (nreverse articles)))
8093 (defun gnus-summary-rethread-current ()
8094 "Rethread the thread the current article is part of."
8096 (let* ((gnus-show-threads t)
8097 (article (gnus-summary-article-number))
8098 (id (mail-header-id (gnus-summary-article-header)))
8099 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
8101 (error "No article on the current line"))
8102 (gnus-rebuild-thread id)
8103 (gnus-summary-goto-subject article)))
8105 (defun gnus-summary-reparent-thread ()
8106 "Make the current article child of the marked (or previous) article.
8108 Note that the re-threading will only work if `gnus-thread-ignore-subject'
8109 is non-nil or the Subject: of both articles are the same."
8111 (unless (not (gnus-group-read-only-p))
8112 (error "The current newsgroup does not support article editing"))
8113 (unless (<= (length gnus-newsgroup-processable) 1)
8114 (error "No more than one article may be marked"))
8115 (save-window-excursion
8116 (let ((gnus-article-buffer " *reparent*")
8117 (current-article (gnus-summary-article-number))
8118 ;; First grab the marked article, otherwise one line up.
8119 (parent-article (if (not (null gnus-newsgroup-processable))
8120 (car gnus-newsgroup-processable)
8122 (if (eq (forward-line -1) 0)
8123 (gnus-summary-article-number)
8124 (error "Beginning of summary buffer"))))))
8125 (unless (not (eq current-article parent-article))
8126 (error "An article may not be self-referential"))
8127 (let ((message-id (mail-header-id
8128 (gnus-summary-article-header parent-article))))
8129 (unless (and message-id (not (equal message-id "")))
8130 (error "No message-id in desired parent"))
8131 ;; We don't want the article to be marked as read.
8132 (let (gnus-mark-article-hook)
8133 (gnus-summary-select-article t t nil current-article))
8134 (set-buffer gnus-original-article-buffer)
8135 (let ((buf (format "%s" (buffer-string))))
8136 (nnheader-temp-write nil
8138 (goto-char (point-min))
8139 (if (re-search-forward "^References: " nil t)
8141 (re-search-forward "^[^ \t]" nil t)
8144 (insert " " message-id))
8145 (insert "References: " message-id "\n"))
8146 (unless (gnus-request-replace-article
8147 current-article (car gnus-article-current)
8149 (error "Couldn't replace article"))))
8150 (set-buffer gnus-summary-buffer)
8151 (gnus-summary-unmark-all-processable)
8152 (gnus-summary-update-article current-article)
8153 (gnus-summary-rethread-current)
8154 (gnus-message 3 "Article %d is now the child of article %d"
8155 current-article parent-article)))))
8157 (defun gnus-summary-toggle-threads (&optional arg)
8158 "Toggle showing conversation threads.
8159 If ARG is positive number, turn showing conversation threads on."
8161 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
8162 (setq gnus-show-threads
8163 (if (null arg) (not gnus-show-threads)
8164 (> (prefix-numeric-value arg) 0)))
8165 (gnus-summary-prepare)
8166 (gnus-summary-goto-subject current)
8167 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
8168 (gnus-summary-position-point)))
8170 (defun gnus-summary-show-all-threads ()
8174 (let ((buffer-read-only nil))
8175 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
8176 (gnus-summary-position-point))
8178 (defun gnus-summary-show-thread ()
8179 "Show thread subtrees.
8180 Returns nil if no thread was there to be shown."
8182 (let ((buffer-read-only nil)
8184 ;; first goto end then to beg, to have point at beg after let
8185 (end (progn (end-of-line) (point)))
8186 (beg (progn (beginning-of-line) (point))))
8188 ;; Any hidden lines here?
8189 (search-forward "\r" end t)
8190 (subst-char-in-region beg end ?\^M ?\n t)
8192 (gnus-summary-position-point))))
8194 (defun gnus-summary-hide-all-threads ()
8195 "Hide all thread subtrees."
8198 (goto-char (point-min))
8199 (gnus-summary-hide-thread)
8200 (while (zerop (gnus-summary-next-thread 1 t))
8201 (gnus-summary-hide-thread)))
8202 (gnus-summary-position-point))
8204 (defun gnus-summary-hide-thread ()
8205 "Hide thread subtrees.
8206 Returns nil if no threads were there to be hidden."
8208 (let ((buffer-read-only nil)
8210 (article (gnus-summary-article-number)))
8212 ;; Go forward until either the buffer ends or the subthread
8214 (when (and (not (eobp))
8215 (or (zerop (gnus-summary-next-thread 1 t))
8216 (goto-char (point-max))))
8218 (if (and (> (point) start)
8219 (search-backward "\n" start t))
8221 (subst-char-in-region start (point) ?\n ?\^M)
8222 (gnus-summary-goto-subject article))
8225 ;;(gnus-summary-position-point)
8228 (defun gnus-summary-go-to-next-thread (&optional previous)
8229 "Go to the same level (or less) next thread.
8230 If PREVIOUS is non-nil, go to previous thread instead.
8231 Return the article number moved to, or nil if moving was impossible."
8232 (let ((level (gnus-summary-thread-level))
8233 (way (if previous -1 1))
8236 (while (and (not (eobp))
8237 (< level (gnus-summary-thread-level)))
8245 (gnus-summary-article-number)
8248 (defun gnus-summary-next-thread (n &optional silent)
8249 "Go to the same level next N'th thread.
8250 If N is negative, search backward instead.
8251 Returns the difference between N and the number of skips actually
8254 If SILENT, don't output messages."
8256 (let ((backward (< n 0))
8259 (gnus-summary-go-to-next-thread backward))
8262 (gnus-summary-position-point))
8263 (when (and (not silent) (/= 0 n))
8264 (gnus-message 7 "No more threads"))
8267 (defun gnus-summary-prev-thread (n)
8268 "Go to the same level previous N'th thread.
8269 Returns the difference between N and the number of skips actually
8272 (gnus-summary-next-thread (- n)))
8274 (defun gnus-summary-go-down-thread ()
8275 "Go down one level in the current thread."
8276 (let ((children (gnus-summary-article-children)))
8278 (gnus-summary-goto-subject (car children)))))
8280 (defun gnus-summary-go-up-thread ()
8281 "Go up one level in the current thread."
8282 (let ((parent (gnus-summary-article-parent)))
8284 (gnus-summary-goto-subject parent))))
8286 (defun gnus-summary-down-thread (n)
8287 "Go down thread N steps.
8288 If N is negative, go up instead.
8289 Returns the difference between N and how many steps down that were
8295 (if up (gnus-summary-go-up-thread)
8296 (gnus-summary-go-down-thread)))
8298 (gnus-summary-position-point)
8300 (gnus-message 7 "Can't go further"))
8303 (defun gnus-summary-up-thread (n)
8304 "Go up thread N steps.
8305 If N is negative, go up instead.
8306 Returns the difference between N and how many steps down that were
8309 (gnus-summary-down-thread (- n)))
8311 (defun gnus-summary-top-thread ()
8312 "Go to the top of the thread."
8314 (while (gnus-summary-go-up-thread))
8315 (gnus-summary-article-number))
8317 (defun gnus-summary-kill-thread (&optional unmark)
8318 "Mark articles under current thread as read.
8319 If the prefix argument is positive, remove any kinds of marks.
8320 If the prefix argument is negative, tick articles instead."
8323 (setq unmark (prefix-numeric-value unmark)))
8324 (let ((articles (gnus-summary-articles-in-thread)))
8326 ;; Expand the thread.
8327 (gnus-summary-show-thread)
8328 ;; Mark all the articles.
8330 (gnus-summary-goto-subject (car articles))
8331 (cond ((null unmark)
8332 (gnus-summary-mark-article-as-read gnus-killed-mark))
8334 (gnus-summary-mark-article-as-unread gnus-unread-mark))
8336 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
8337 (setq articles (cdr articles))))
8338 ;; Hide killed subtrees.
8340 gnus-thread-hide-killed
8341 (gnus-summary-hide-thread))
8342 ;; If marked as read, go to next unread subject.
8344 ;; Go to next unread subject.
8345 (gnus-summary-next-subject 1 t)))
8346 (gnus-set-mode-line 'summary))
8348 ;; Summary sorting commands
8350 (defun gnus-summary-sort-by-number (&optional reverse)
8351 "Sort the summary buffer by article number.
8352 Argument REVERSE means reverse order."
8354 (gnus-summary-sort 'number reverse))
8356 (defun gnus-summary-sort-by-author (&optional reverse)
8357 "Sort the summary buffer by author name alphabetically.
8358 If case-fold-search is non-nil, case of letters is ignored.
8359 Argument REVERSE means reverse order."
8361 (gnus-summary-sort 'author reverse))
8363 (defun gnus-summary-sort-by-subject (&optional reverse)
8364 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
8365 If case-fold-search is non-nil, case of letters is ignored.
8366 Argument REVERSE means reverse order."
8368 (gnus-summary-sort 'subject reverse))
8370 (defun gnus-summary-sort-by-date (&optional reverse)
8371 "Sort the summary buffer by date.
8372 Argument REVERSE means reverse order."
8374 (gnus-summary-sort 'date reverse))
8376 (defun gnus-summary-sort-by-score (&optional reverse)
8377 "Sort the summary buffer by score.
8378 Argument REVERSE means reverse order."
8380 (gnus-summary-sort 'score reverse))
8382 (defun gnus-summary-sort-by-lines (&optional reverse)
8383 "Sort the summary buffer by article length.
8384 Argument REVERSE means reverse order."
8386 (gnus-summary-sort 'lines reverse))
8388 (defun gnus-summary-sort (predicate reverse)
8389 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
8390 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
8391 (article (intern (format "gnus-article-sort-by-%s" predicate)))
8392 (gnus-thread-sort-functions
8398 (gnus-article-sort-functions
8403 (,article t2 t1)))))
8405 (gnus-summary-prepare-hook nil))
8406 ;; We do the sorting by regenerating the threads.
8407 (gnus-summary-prepare)
8408 ;; Hide subthreads if needed.
8409 (when (and gnus-show-threads gnus-thread-hide-subtree)
8410 (gnus-summary-hide-all-threads))))
8412 ;; Summary saving commands.
8414 (defun gnus-summary-save-article (&optional n not-saved)
8415 "Save the current article using the default saver function.
8416 If N is a positive number, save the N next articles.
8417 If N is a negative number, save the N previous articles.
8418 If N is nil and any articles have been marked with the process mark,
8419 save those articles instead.
8420 The variable `gnus-default-article-saver' specifies the saver function."
8422 (let* ((articles (gnus-summary-work-articles n))
8423 (save-buffer (save-excursion
8424 (nnheader-set-temp-buffer " *Gnus Save*")))
8425 (num (length articles))
8426 header article file)
8428 (setq header (gnus-summary-article-header
8429 (setq article (pop articles))))
8430 (if (not (vectorp header))
8431 ;; This is a pseudo-article.
8432 (if (assq 'name header)
8433 (gnus-copy-file (cdr (assq 'name header)))
8434 (gnus-message 1 "Article %d is unsaveable" article))
8435 ;; This is a real article.
8436 (save-window-excursion
8437 (gnus-summary-select-article t nil nil article))
8439 (set-buffer save-buffer)
8441 (insert-buffer-substring gnus-original-article-buffer))
8442 (setq file (gnus-article-save save-buffer file num))
8443 (gnus-summary-remove-process-mark article)
8445 (gnus-summary-set-saved-mark article))))
8446 (gnus-kill-buffer save-buffer)
8447 (gnus-summary-position-point)
8448 (gnus-set-mode-line 'summary)
8451 (defun gnus-summary-pipe-output (&optional arg)
8452 "Pipe the current article to a subprocess.
8453 If N is a positive number, pipe the N next articles.
8454 If N is a negative number, pipe the N previous articles.
8455 If N is nil and any articles have been marked with the process mark,
8456 pipe those articles instead."
8458 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
8459 (gnus-summary-save-article arg t))
8460 (gnus-configure-windows 'pipe))
8462 (defun gnus-summary-save-article-mail (&optional arg)
8463 "Append the current article to an mail file.
8464 If N is a positive number, save the N next articles.
8465 If N is a negative number, save the N previous articles.
8466 If N is nil and any articles have been marked with the process mark,
8467 save those articles instead."
8469 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
8470 (gnus-summary-save-article arg)))
8472 (defun gnus-summary-save-article-rmail (&optional arg)
8473 "Append the current article to an rmail file.
8474 If N is a positive number, save the N next articles.
8475 If N is a negative number, save the N previous articles.
8476 If N is nil and any articles have been marked with the process mark,
8477 save those articles instead."
8479 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
8480 (gnus-summary-save-article arg)))
8482 (defun gnus-summary-save-article-file (&optional arg)
8483 "Append the current article to a file.
8484 If N is a positive number, save the N next articles.
8485 If N is a negative number, save the N previous articles.
8486 If N is nil and any articles have been marked with the process mark,
8487 save those articles instead."
8489 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
8490 (gnus-summary-save-article arg)))
8492 (defun gnus-summary-write-article-file (&optional arg)
8493 "Write the current article to a file, deleting the previous file.
8494 If N is a positive number, save the N next articles.
8495 If N is a negative number, save the N previous articles.
8496 If N is nil and any articles have been marked with the process mark,
8497 save those articles instead."
8499 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
8500 (gnus-summary-save-article arg)))
8502 (defun gnus-summary-save-article-body-file (&optional arg)
8503 "Append the current article body to a file.
8504 If N is a positive number, save the N next articles.
8505 If N is a negative number, save the N previous articles.
8506 If N is nil and any articles have been marked with the process mark,
8507 save those articles instead."
8509 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
8510 (gnus-summary-save-article arg)))
8512 (defun gnus-summary-pipe-message (program)
8513 "Pipe the current article through PROGRAM."
8514 (interactive "sProgram: ")
8515 (gnus-summary-select-article)
8516 (let ((mail-header-separator "")
8517 (art-buf (get-buffer gnus-article-buffer)))
8518 (gnus-eval-in-buffer-window gnus-article-buffer
8521 (let ((start (window-start))
8523 (message-pipe-buffer-body program)
8524 (set-window-start (get-buffer-window (current-buffer)) start))))))
8526 (defun gnus-get-split-value (methods)
8527 "Return a value based on the split METHODS."
8528 (let (split-name method result match)
8531 (set-buffer gnus-original-article-buffer)
8533 (nnheader-narrow-to-headers)
8535 (goto-char (point-min))
8536 (setq method (pop methods))
8537 (setq match (car method))
8540 ;; Regular expression.
8542 (re-search-forward match nil t)))
8543 ((gnus-functionp match)
8547 (setq result (funcall match gnus-newsgroup-name))))
8552 (setq result (eval match)))))
8553 (setq split-name (append (cdr method) split-name))
8554 (cond ((stringp result)
8555 (push (expand-file-name
8556 result gnus-article-save-directory)
8559 (setq split-name (append result split-name)))))))))
8562 (defun gnus-valid-move-group-p (group)
8567 (car (gnus-find-method-for-group
8568 (symbol-name group))))
8569 gnus-valid-select-methods))))
8571 (defun gnus-read-move-group-name (prompt default articles prefix)
8572 "Read a group name."
8573 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
8574 (minibuffer-confirm-incomplete nil) ; XEmacs
8578 (if (> (length articles) 1)
8579 (format "these %d articles" (length articles))
8584 (gnus-completing-read default prom
8586 'gnus-valid-move-group-p
8588 'gnus-group-history))
8589 ((= 1 (length split-name))
8590 (gnus-completing-read (car split-name) prom
8592 'gnus-valid-move-group-p
8594 'gnus-group-history))
8596 (gnus-completing-read nil prom
8597 (mapcar (lambda (el) (list el))
8598 (nreverse split-name))
8600 'gnus-group-history)))))
8602 (if (or (string= to-newsgroup "")
8603 (string= to-newsgroup prefix))
8604 (setq to-newsgroup default))
8605 (unless to-newsgroup
8606 (error "No group name entered"))
8607 (or (gnus-active to-newsgroup)
8608 (gnus-activate-group to-newsgroup)
8609 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
8611 (or (and (gnus-request-create-group
8612 to-newsgroup (gnus-group-name-to-method to-newsgroup))
8613 (gnus-activate-group to-newsgroup nil nil
8614 (gnus-group-name-to-method
8616 (error "Couldn't create group %s" to-newsgroup)))
8617 (error "No such group: %s" to-newsgroup)))
8620 ;; Summary extract commands
8622 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
8623 (let ((buffer-read-only nil)
8624 (article (gnus-summary-article-number))
8626 (unless (gnus-summary-goto-subject article)
8627 (error "No such article: %d" article))
8628 (gnus-summary-position-point)
8629 ;; If all commands are to be bunched up on one line, we collect
8631 (unless gnus-view-pseudos-separately
8632 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
8635 (setq action (cdr (assq 'action (car ps))))
8636 (setq files (list (cdr (assq 'name (car ps)))))
8637 (while (and ps (cdr ps)
8638 (string= (or action "1")
8639 (or (cdr (assq 'action (cadr ps))) "2")))
8640 (push (cdr (assq 'name (cadr ps))) files)
8641 (setcdr ps (cddr ps)))
8643 (when (not (string-match "%s" action))
8646 (when (assq 'execute (car ps))
8647 (setcdr (assq 'execute (car ps))
8648 (funcall (if (string-match "%s" action)
8655 (gnus-quote-arg-for-sh-or-csh f)))
8657 (setq ps (cdr ps)))))
8658 (if (and gnus-view-pseudos (not not-view))
8660 (when (assq 'execute (car pslist))
8661 (gnus-execute-command (cdr (assq 'execute (car pslist)))
8662 (eq gnus-view-pseudos 'not-confirm)))
8663 (setq pslist (cdr pslist)))
8666 (setq after-article (or (cdr (assq 'article (car pslist)))
8667 (gnus-summary-article-number)))
8668 (gnus-summary-goto-subject after-article)
8671 (insert " " (file-name-nondirectory
8672 (cdr (assq 'name (car pslist))))
8673 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
8675 (forward-line -1) ; back to `b'
8676 (gnus-add-text-properties
8677 b (1- e) (list 'gnus-number gnus-reffed-article-number
8678 gnus-mouse-face-prop gnus-mouse-face))
8680 after-article gnus-reffed-article-number
8681 gnus-unread-mark b (car pslist) 0 (- e b))
8682 (push gnus-reffed-article-number gnus-newsgroup-unreads)
8683 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
8684 (setq pslist (cdr pslist)))))))
8686 (defun gnus-pseudos< (p1 p2)
8687 (let ((c1 (cdr (assq 'action p1)))
8688 (c2 (cdr (assq 'action p2))))
8689 (and c1 c2 (string< c1 c2))))
8691 (defun gnus-request-pseudo-article (props)
8692 (cond ((assq 'execute props)
8693 (gnus-execute-command (cdr (assq 'execute props)))))
8694 (let ((gnus-current-article (gnus-summary-article-number)))
8695 (gnus-run-hooks 'gnus-mark-article-hook)))
8697 (defun gnus-execute-command (command &optional automatic)
8699 (gnus-article-setup-buffer)
8700 (set-buffer gnus-article-buffer)
8701 (setq buffer-read-only nil)
8702 (let ((command (if automatic command
8703 (read-string "Command: " (cons command 0)))))
8705 (insert "$ " command "\n\n")
8706 (if gnus-view-pseudo-asynchronously
8707 (start-process "gnus-execute" (current-buffer) shell-file-name
8708 shell-command-switch command)
8709 (call-process shell-file-name nil t nil
8710 shell-command-switch command)))))
8712 ;; Summary kill commands.
8714 (defun gnus-summary-edit-global-kill (article)
8715 "Edit the \"global\" kill file."
8716 (interactive (list (gnus-summary-article-number)))
8717 (gnus-group-edit-global-kill article))
8719 (defun gnus-summary-edit-local-kill ()
8720 "Edit a local kill file applied to the current newsgroup."
8722 (setq gnus-current-headers (gnus-summary-article-header))
8723 (gnus-group-edit-local-kill
8724 (gnus-summary-article-number) gnus-newsgroup-name))
8728 (defun gnus-read-header (id &optional header)
8729 "Read the headers of article ID and enter them into the Gnus system."
8730 (let ((group gnus-newsgroup-name)
8731 (gnus-override-method
8732 (and (gnus-news-group-p gnus-newsgroup-name)
8733 gnus-refer-article-method))
8735 ;; First we check to see whether the header in question is already
8738 ;; This is a Message-ID.
8739 (setq header (or header (gnus-id-to-header id)))
8740 ;; This is an article number.
8741 (setq header (or header (gnus-summary-article-header id))))
8743 (not (gnus-summary-article-sparse-p (mail-header-number header))))
8744 ;; We have found the header.
8746 ;; If this is a sparse article, we have to nix out its
8747 ;; previous entry in the thread hashtb.
8749 (gnus-summary-article-sparse-p (mail-header-number header)))
8750 (let* ((parent (gnus-parent-id (mail-header-references header)))
8751 (thread (and parent (gnus-id-to-thread parent))))
8753 (delq (assq header thread) thread))))
8754 ;; We have to really fetch the header to this article.
8756 (set-buffer nntp-server-buffer)
8757 (when (setq where (gnus-request-head id group))
8758 (nnheader-fold-continuation-lines)
8759 (goto-char (point-max))
8761 (goto-char (point-min))
8765 ((cdr where) (cdr where))
8766 (header (mail-header-number header))
8767 (t gnus-reffed-article-number))
8769 (insert " Article retrieved.\n"))
8771 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
8772 () ; Malformed head.
8773 (unless (gnus-summary-article-sparse-p (mail-header-number header))
8774 (when (and (stringp id)
8775 (not (string= (gnus-group-real-name group)
8777 ;; If we fetched by Message-ID and the article came
8778 ;; from a different group, we fudge some bogus article
8779 ;; numbers for this article.
8780 (mail-header-set-number header gnus-reffed-article-number))
8782 (set-buffer gnus-summary-buffer)
8783 (decf gnus-reffed-article-number)
8784 (gnus-remove-header (mail-header-number header))
8785 (push header gnus-newsgroup-headers)
8786 (setq gnus-current-headers header)
8787 (push (mail-header-number header) gnus-newsgroup-limit)))
8790 (defun gnus-remove-header (number)
8791 "Remove header NUMBER from `gnus-newsgroup-headers'."
8792 (if (and gnus-newsgroup-headers
8793 (= number (mail-header-number (car gnus-newsgroup-headers))))
8794 (pop gnus-newsgroup-headers)
8795 (let ((headers gnus-newsgroup-headers))
8796 (while (and (cdr headers)
8797 (not (= number (mail-header-number (cadr headers)))))
8800 (setcdr headers (cddr headers))))))
8803 ;;; summary highlights
8806 (defun gnus-highlight-selected-summary ()
8807 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
8808 ;; Highlight selected article in summary buffer
8809 (when gnus-summary-selected-face
8811 (let* ((beg (progn (beginning-of-line) (point)))
8812 (end (progn (end-of-line) (point)))
8813 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
8814 (from (if (get-text-property beg gnus-mouse-face-prop)
8816 (or (next-single-property-change
8817 beg gnus-mouse-face-prop nil end)
8822 (or (next-single-property-change
8823 from gnus-mouse-face-prop nil end)
8825 ;; If no mouse-face prop on line we will have to = from = end,
8826 ;; so we highlight the entire line instead.
8827 (when (= (+ to 2) from)
8830 (if gnus-newsgroup-selected-overlay
8831 ;; Move old overlay.
8833 gnus-newsgroup-selected-overlay from to (current-buffer))
8834 ;; Create new overlay.
8836 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
8837 'face gnus-summary-selected-face))))))
8839 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
8840 (defun gnus-summary-highlight-line ()
8841 "Highlight current line according to `gnus-summary-highlight'."
8842 (let* ((list gnus-summary-highlight)
8844 (end (progn (end-of-line) (point)))
8845 ;; now find out where the line starts and leave point there.
8846 (beg (progn (beginning-of-line) (point)))
8847 (article (gnus-summary-article-number))
8848 (score (or (cdr (assq (or article gnus-current-article)
8849 gnus-newsgroup-scored))
8850 gnus-summary-default-score 0))
8851 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
8852 (inhibit-read-only t))
8853 ;; Eval the cars of the lists until we find a match.
8854 (let ((default gnus-summary-default-score))
8856 (not (eval (caar list))))
8857 (setq list (cdr list))))
8858 (let ((face (cdar list)))
8859 (unless (eq face (get-text-property beg 'face))
8860 (gnus-put-text-property-excluding-characters-with-faces
8862 (setq face (if (boundp face) (symbol-value face) face)))
8863 (when gnus-summary-highlight-line-function
8864 (funcall gnus-summary-highlight-line-function article face))))
8867 (defun gnus-update-read-articles (group unread &optional compute)
8868 "Update the list of read articles in GROUP."
8869 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
8870 (entry (gnus-gethash group gnus-newsrc-hashtb))
8871 (info (nth 2 entry))
8873 (unread (sort (copy-sequence unread) '<))
8875 (if (or (not info) (not active))
8876 ;; There is no info on this group if it was, in fact,
8877 ;; killed. Gnus stores no information on killed groups, so
8878 ;; there's nothing to be done.
8879 ;; One could store the information somewhere temporarily,
8880 ;; perhaps... Hmmm...
8882 ;; Remove any negative articles numbers.
8883 (while (and unread (< (car unread) 0))
8884 (setq unread (cdr unread)))
8885 ;; Remove any expired article numbers
8886 (while (and unread (< (car unread) (car active)))
8887 (setq unread (cdr unread)))
8888 ;; Compute the ranges of read articles by looking at the list of
8891 (when (/= (car unread) prev)
8892 (push (if (= prev (1- (car unread))) prev
8893 (cons prev (1- (car unread))))
8895 (setq prev (1+ (car unread)))
8896 (setq unread (cdr unread)))
8897 (when (<= prev (cdr active))
8898 (push (cons prev (cdr active)) read))
8900 (if (> (length read) 1) (nreverse read) read)
8902 (set-buffer gnus-group-buffer)
8905 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
8906 (gnus-info-set-read ',info ',(gnus-info-read info))
8907 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
8908 (gnus-group-update-group ,group t))))
8909 ;; Enter this list into the group info.
8911 info (if (> (length read) 1) (nreverse read) read))
8912 ;; Set the number of unread articles in gnus-newsrc-hashtb.
8913 (gnus-get-unread-articles-in-group info (gnus-active group))
8916 (defun gnus-offer-save-summaries ()
8917 "Offer to save all active summary buffers."
8919 (let ((buflist (buffer-list))
8921 ;; Go through all buffers and find all summaries.
8923 (and (setq bufname (buffer-name (car buflist)))
8924 (string-match "Summary" bufname)
8926 (set-buffer bufname)
8927 ;; We check that this is, indeed, a summary buffer.
8928 (and (eq major-mode 'gnus-summary-mode)
8929 ;; Also make sure this isn't bogus.
8930 gnus-newsgroup-prepared
8931 ;; Also make sure that this isn't a dead summary buffer.
8932 (not gnus-dead-summary-mode)))
8933 (push bufname buffers))
8934 (setq buflist (cdr buflist)))
8935 ;; Go through all these summary buffers and offer to save them.
8938 "Update summary buffer %s? "
8940 (switch-to-buffer buf)
8941 (gnus-summary-exit))
8948 (run-hooks 'gnus-sum-load-hook)
8950 ;;; gnus-sum.el ends here