1 ;;; gnus-sum.el --- summary mode commands for Semi-gnus
2 ;; Copyright (C) 1996,97,98 Free Software Foundation, Inc.
4 ;; Author: Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
5 ;; MORIOKA Tomohiko <morioka@jaist.ac.jp>
6 ;; Keywords: mail, news, MIME
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
29 (eval-when-compile (require 'cl))
39 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
40 (autoload 'gnus-set-summary-default-charset "gnus-i18n" nil t)
42 (defcustom gnus-kill-summary-on-exit t
43 "*If non-nil, kill the summary buffer when you exit from it.
44 If nil, the summary will become a \"*Dead Summary*\" buffer, and
45 it will be killed sometime later."
46 :group 'gnus-summary-exit
49 (defcustom gnus-fetch-old-headers nil
50 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
51 If an unread article in the group refers to an older, already read (or
52 just marked as read) article, the old article will not normally be
53 displayed in the Summary buffer. If this variable is non-nil, Gnus
54 will attempt to grab the headers to the old articles, and thereby
55 build complete threads. If it has the value `some', only enough
56 headers to connect otherwise loose threads will be displayed. This
57 variable can also be a number. In that case, no more than that number
58 of old headers will be fetched. If it has the value `invisible', all
59 old headers will be fetched, but none will be displayed.
61 The server has to support NOV for any of this to work."
63 :type '(choice (const :tag "off" nil)
66 (sexp :menu-tag "other" t)))
68 (defcustom gnus-refer-thread-limit 200
69 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
70 If t, fetch all the available old headers."
73 (sexp :menu-tag "other" t)))
75 (defcustom gnus-summary-make-false-root 'adopt
76 "*nil means that Gnus won't gather loose threads.
77 If the root of a thread has expired or been read in a previous
78 session, the information necessary to build a complete thread has been
79 lost. Instead of having many small sub-threads from this original thread
80 scattered all over the summary buffer, Gnus can gather them.
82 If non-nil, Gnus will try to gather all loose sub-threads from an
83 original thread into one large thread.
85 If this variable is non-nil, it should be one of `none', `adopt',
88 If this variable is `none', Gnus will not make a false root, but just
89 present the sub-threads after another.
90 If this variable is `dummy', Gnus will create a dummy root that will
91 have all the sub-threads as children.
92 If this variable is `adopt', Gnus will make one of the \"children\"
93 the parent and mark all the step-children as such.
94 If this variable is `empty', the \"children\" are printed with empty
95 subject fields. (Or rather, they will be printed with a string
96 given by the `gnus-summary-same-subject' variable.)"
98 :type '(choice (const :tag "off" nil)
104 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
105 "*A regexp to match subjects to be excluded from loose thread gathering.
106 As loose thread gathering is done on subjects only, that means that
107 there can be many false gatherings performed. By rooting out certain
108 common subjects, gathering might become saner."
112 (defcustom gnus-summary-gather-subject-limit nil
113 "*Maximum length of subject comparisons when gathering loose threads.
114 Use nil to compare full subjects. Setting this variable to a low
115 number will help gather threads that have been corrupted by
116 newsreaders chopping off subject lines, but it might also mean that
117 unrelated articles that have subject that happen to begin with the
118 same few characters will be incorrectly gathered.
120 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
123 :type '(choice (const :tag "off" nil)
125 (sexp :menu-tag "on" t)))
127 (defcustom gnus-simplify-subject-functions nil
128 "*List of functions taking a string argument that simplify subjects.
129 The functions are applied recursively."
131 :type '(repeat (list 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 t
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
514 %U Number of unread articles in the group
515 %e Number of unselected articles in the group
516 %Z A string with unread/unselected article counts
517 %g Shortish group name
518 %S Subject of the current article
520 %s Current score file name
521 %d Number of dormant articles
522 %r Number of articles that have been marked as read in this session
523 %E Number of articles expunged by the score files"
524 :group 'gnus-summary-format
527 (defcustom gnus-summary-mark-below 0
528 "*Mark all articles with a score below this variable as read.
529 This variable is local to each summary buffer and usually set by the
531 :group 'gnus-score-default
534 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
535 "*List of functions used for sorting articles in the summary buffer.
536 This variable is only used when not using a threaded display."
537 :group 'gnus-summary-sort
538 :type '(repeat (choice (function-item gnus-article-sort-by-number)
539 (function-item gnus-article-sort-by-author)
540 (function-item gnus-article-sort-by-subject)
541 (function-item gnus-article-sort-by-date)
542 (function-item gnus-article-sort-by-score)
543 (function :tag "other"))))
545 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
546 "*List of functions used for sorting threads in the summary buffer.
547 By default, threads are sorted by article number.
549 Each function takes two threads and return non-nil if the first thread
550 should be sorted before the other. If you use more than one function,
551 the primary sort function should be the last. You should probably
552 always include `gnus-thread-sort-by-number' in the list of sorting
553 functions -- preferably first.
555 Ready-made functions include `gnus-thread-sort-by-number',
556 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
557 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
558 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function')."
559 :group 'gnus-summary-sort
560 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
561 (function-item gnus-thread-sort-by-author)
562 (function-item gnus-thread-sort-by-subject)
563 (function-item gnus-thread-sort-by-date)
564 (function-item gnus-thread-sort-by-score)
565 (function-item gnus-thread-sort-by-total-score)
566 (function :tag "other"))))
568 (defcustom gnus-thread-score-function '+
569 "*Function used for calculating the total score of a thread.
571 The function is called with the scores of the article and each
572 subthread and should then return the score of the thread.
574 Some functions you can use are `+', `max', or `min'."
575 :group 'gnus-summary-sort
578 (defcustom gnus-summary-expunge-below nil
579 "*All articles that have a score less than this variable will be expunged.
580 This variable is local to the summary buffers."
581 :group 'gnus-score-default
582 :type '(choice (const :tag "off" nil)
585 (defcustom gnus-thread-expunge-below nil
586 "*All threads that have a total score less than this variable will be expunged.
587 See `gnus-thread-score-function' for en explanation of what a
590 This variable is local to the summary buffers."
591 :group 'gnus-treading
592 :group 'gnus-score-default
593 :type '(choice (const :tag "off" nil)
596 (defcustom gnus-summary-mode-hook nil
597 "*A hook for Gnus summary mode.
598 This hook is run before any variables are set in the summary buffer."
599 :group 'gnus-summary-various
602 (defcustom gnus-summary-menu-hook nil
603 "*Hook run after the creation of the summary mode menu."
604 :group 'gnus-summary-visual
607 (defcustom gnus-summary-exit-hook nil
608 "*A hook called on exit from the summary buffer.
609 It will be called with point in the group buffer."
610 :group 'gnus-summary-exit
613 (defcustom gnus-summary-prepare-hook nil
614 "*A hook called after the summary buffer has been generated.
615 If you want to modify the summary buffer, you can use this hook."
616 :group 'gnus-summary-various
619 (defcustom gnus-summary-prepared-hook nil
620 "*A hook called as the last thing after the summary buffer has been generated."
621 :group 'gnus-summary-various
624 (defcustom gnus-summary-generate-hook nil
625 "*A hook run just before generating the summary buffer.
626 This hook is commonly used to customize threading variables and the
628 :group 'gnus-summary-various
631 (defcustom gnus-select-group-hook nil
632 "*A hook called when a newsgroup is selected.
634 If you'd like to simplify subjects like the
635 `gnus-summary-next-same-subject' command does, you can use the
638 (setq gnus-select-group-hook
641 (mapcar (lambda (header)
642 (mail-header-set-subject
644 (gnus-simplify-subject
645 (mail-header-subject header) 're-only)))
646 gnus-newsgroup-headers))))"
647 :group 'gnus-group-select
650 (defcustom gnus-select-article-hook nil
651 "*A hook called when an article is selected."
652 :group 'gnus-summary-choose
655 (defcustom gnus-visual-mark-article-hook
656 (list 'gnus-highlight-selected-summary)
657 "*Hook run after selecting an article in the summary buffer.
658 It is meant to be used for highlighting the article in some way. It
659 is not run if `gnus-visual' is nil."
660 :group 'gnus-summary-visual
663 ;; 1997/5/4 by MORIOKA Tomohiko <morioka@jaist.ac.jp>
664 (defcustom gnus-structured-field-decoder
667 (eword-decode-structured-field-body
668 (std11-unfold-string string) 'must-unfold)
670 "*Function to decode non-ASCII characters in structured field for summary."
674 (defcustom gnus-unstructured-field-decoder
677 (eword-decode-unstructured-field-body
678 (std11-unfold-string string) 'must-unfold)
680 "*Function to decode non-ASCII characters in unstructured field for summary."
684 (defcustom gnus-parse-headers-hook
685 '(gnus-set-summary-default-charset)
686 "*A hook called before parsing the headers."
690 (defcustom gnus-exit-group-hook nil
691 "*A hook called when exiting (not quitting) summary mode."
695 (defcustom gnus-summary-update-hook
696 (list 'gnus-summary-highlight-line)
697 "*A hook called when a summary line is changed.
698 The hook will not be called if `gnus-visual' is nil.
700 The default function `gnus-summary-highlight-line' will
701 highlight the line according to the `gnus-summary-highlight'
703 :group 'gnus-summary-visual
706 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
707 "*A hook called when an article is selected for the first time.
708 The hook is intended to mark an article as read (or unread)
709 automatically when it is selected."
710 :group 'gnus-summary-choose
713 (defcustom gnus-group-no-more-groups-hook nil
714 "*A hook run when returning to group mode having no more (unread) groups."
715 :group 'gnus-group-select
718 (defcustom gnus-ps-print-hook nil
719 "*A hook run before ps-printing something from Gnus."
723 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
724 "*Face used for highlighting the current article in the summary buffer."
725 :group 'gnus-summary-visual
728 (defcustom gnus-summary-highlight
729 '(((= mark gnus-canceled-mark)
730 . gnus-summary-cancelled-face)
731 ((and (> score default)
732 (or (= mark gnus-dormant-mark)
733 (= mark gnus-ticked-mark)))
734 . gnus-summary-high-ticked-face)
735 ((and (< score default)
736 (or (= mark gnus-dormant-mark)
737 (= mark gnus-ticked-mark)))
738 . gnus-summary-low-ticked-face)
739 ((or (= mark gnus-dormant-mark)
740 (= mark gnus-ticked-mark))
741 . gnus-summary-normal-ticked-face)
742 ((and (> score default) (= mark gnus-ancient-mark))
743 . gnus-summary-high-ancient-face)
744 ((and (< score default) (= mark gnus-ancient-mark))
745 . gnus-summary-low-ancient-face)
746 ((= mark gnus-ancient-mark)
747 . gnus-summary-normal-ancient-face)
748 ((and (> score default) (= mark gnus-unread-mark))
749 . gnus-summary-high-unread-face)
750 ((and (< score default) (= mark gnus-unread-mark))
751 . gnus-summary-low-unread-face)
752 ((memq mark (list gnus-unread-mark gnus-downloadable-mark
753 gnus-undownloaded-mark))
754 . gnus-summary-normal-unread-face)
756 . gnus-summary-high-read-face)
758 . gnus-summary-low-read-face)
760 . gnus-summary-normal-read-face))
761 "*Controls the highlighting of summary buffer lines.
763 A list of (FORM . FACE) pairs. When deciding how a a particular
764 summary line should be displayed, each form is evaluated. The content
765 of the face field after the first true form is used. You can change
766 how those summary lines are displayed, by editing the face field.
768 You can use the following variables in the FORM field.
770 score: The articles score
771 default: The default article score.
772 below: The score below which articles are automatically marked as read.
773 mark: The articles mark."
774 :group 'gnus-summary-visual
775 :type '(repeat (cons (sexp :tag "Form" nil)
778 (defcustom gnus-alter-header-function nil
779 "*Function called to allow alteration of article header structures.
780 The function is called with one parameter, the article header vector,
781 which it may alter in any way.")
783 ;;; Internal variables
785 (defvar gnus-scores-exclude-files nil)
786 (defvar gnus-page-broken nil)
788 (defvar gnus-original-article nil)
789 (defvar gnus-article-internal-prepare-hook nil)
790 (defvar gnus-newsgroup-process-stack nil)
792 (defvar gnus-thread-indent-array nil)
793 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
795 ;; Avoid highlighting in kill files.
796 (defvar gnus-summary-inhibit-highlight nil)
797 (defvar gnus-newsgroup-selected-overlay nil)
798 (defvar gnus-inhibit-limiting nil)
799 (defvar gnus-newsgroup-adaptive-score-file nil)
800 (defvar gnus-current-score-file nil)
801 (defvar gnus-current-move-group nil)
802 (defvar gnus-current-copy-group nil)
803 (defvar gnus-current-crosspost-group nil)
805 (defvar gnus-newsgroup-dependencies nil)
806 (defvar gnus-newsgroup-adaptive nil)
807 (defvar gnus-summary-display-article-function nil)
808 (defvar gnus-summary-highlight-line-function nil
809 "Function called after highlighting a summary line.")
811 (defvar gnus-summary-line-format-alist
812 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
813 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
814 (?s gnus-tmp-subject-or-nil ?s)
815 (?n gnus-tmp-name ?s)
816 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
818 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
820 (?F gnus-tmp-from ?s)
821 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
822 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
823 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
824 (?o (gnus-date-iso8601 gnus-tmp-header) ?s)
825 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
826 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
827 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
828 (?L gnus-tmp-lines ?d)
829 (?I gnus-tmp-indentation ?s)
830 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
831 (?R gnus-tmp-replied ?c)
832 (?\[ gnus-tmp-opening-bracket ?c)
833 (?\] gnus-tmp-closing-bracket ?c)
834 (?\> (make-string gnus-tmp-level ? ) ?s)
835 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
836 (?i gnus-tmp-score ?d)
837 (?z gnus-tmp-score-char ?c)
838 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
839 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
840 (?U gnus-tmp-unread ?c)
841 (?t (gnus-summary-number-of-articles-in-thread
842 (and (boundp 'thread) (car thread)) gnus-tmp-level)
844 (?e (gnus-summary-number-of-articles-in-thread
845 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
847 (?u gnus-tmp-user-defined ?s)
848 (?P (gnus-pick-line-number) ?d))
849 "An alist of format specifications that can appear in summary lines,
850 and what variables they correspond with, along with the type of the
851 variable (string, integer, character, etc).")
853 (defvar gnus-summary-dummy-line-format-alist
854 `((?S gnus-tmp-subject ?s)
855 (?N gnus-tmp-number ?d)
856 (?u gnus-tmp-user-defined ?s)))
858 (defvar gnus-summary-mode-line-format-alist
859 `((?G gnus-tmp-group-name ?s)
860 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
861 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
862 (?A gnus-tmp-article-number ?d)
863 (?Z gnus-tmp-unread-and-unselected ?s)
865 (?U gnus-tmp-unread-and-unticked ?d)
866 (?S gnus-tmp-subject ?s)
867 (?e gnus-tmp-unselected ?d)
868 (?u gnus-tmp-user-defined ?s)
869 (?d (length gnus-newsgroup-dormant) ?d)
870 (?t (length gnus-newsgroup-marked) ?d)
871 (?r (length gnus-newsgroup-reads) ?d)
872 (?E gnus-newsgroup-expunged-tally ?d)
873 (?s (gnus-current-score-file-nondirectory) ?s)))
875 (defvar gnus-last-search-regexp nil
876 "Default regexp for article search command.")
878 (defvar gnus-last-shell-command nil
879 "Default shell command on article.")
881 (defvar gnus-newsgroup-begin nil)
882 (defvar gnus-newsgroup-end nil)
883 (defvar gnus-newsgroup-last-rmail nil)
884 (defvar gnus-newsgroup-last-mail nil)
885 (defvar gnus-newsgroup-last-folder nil)
886 (defvar gnus-newsgroup-last-file nil)
887 (defvar gnus-newsgroup-auto-expire nil)
888 (defvar gnus-newsgroup-active nil)
890 (defvar gnus-newsgroup-data nil)
891 (defvar gnus-newsgroup-data-reverse nil)
892 (defvar gnus-newsgroup-limit nil)
893 (defvar gnus-newsgroup-limits nil)
895 (defvar gnus-newsgroup-unreads nil
896 "List of unread articles in the current newsgroup.")
898 (defvar gnus-newsgroup-unselected nil
899 "List of unselected unread articles in the current newsgroup.")
901 (defvar gnus-newsgroup-reads nil
902 "Alist of read articles and article marks in the current newsgroup.")
904 (defvar gnus-newsgroup-expunged-tally nil)
906 (defvar gnus-newsgroup-marked nil
907 "List of ticked articles in the current newsgroup (a subset of unread art).")
909 (defvar gnus-newsgroup-killed nil
910 "List of ranges of articles that have been through the scoring process.")
912 (defvar gnus-newsgroup-cached nil
913 "List of articles that come from the article cache.")
915 (defvar gnus-newsgroup-saved nil
916 "List of articles that have been saved.")
918 (defvar gnus-newsgroup-kill-headers nil)
920 (defvar gnus-newsgroup-replied nil
921 "List of articles that have been replied to in the current newsgroup.")
923 (defvar gnus-newsgroup-expirable nil
924 "List of articles in the current newsgroup that can be expired.")
926 (defvar gnus-newsgroup-processable nil
927 "List of articles in the current newsgroup that can be processed.")
929 (defvar gnus-newsgroup-downloadable nil
930 "List of articles in the current newsgroup that can be processed.")
932 (defvar gnus-newsgroup-undownloaded nil
933 "List of articles in the current newsgroup that haven't been downloaded..")
935 (defvar gnus-newsgroup-unsendable nil
936 "List of articles in the current newsgroup that won't be sent.")
938 (defvar gnus-newsgroup-bookmarks nil
939 "List of articles in the current newsgroup that have bookmarks.")
941 (defvar gnus-newsgroup-dormant nil
942 "List of dormant articles in the current newsgroup.")
944 (defvar gnus-newsgroup-scored nil
945 "List of scored articles in the current newsgroup.")
947 (defvar gnus-newsgroup-headers nil
948 "List of article headers in the current newsgroup.")
950 (defvar gnus-newsgroup-threads nil)
952 (defvar gnus-newsgroup-prepared nil
953 "Whether the current group has been prepared properly.")
955 (defvar gnus-newsgroup-ancient nil
956 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
958 (defvar gnus-newsgroup-sparse nil)
960 (defvar gnus-current-article nil)
961 (defvar gnus-article-current nil)
962 (defvar gnus-current-headers nil)
963 (defvar gnus-have-all-headers nil)
964 (defvar gnus-last-article nil)
965 (defvar gnus-newsgroup-history nil)
967 (defconst gnus-summary-local-variables
968 '(gnus-newsgroup-name
969 gnus-newsgroup-begin gnus-newsgroup-end
970 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
971 gnus-newsgroup-last-folder gnus-newsgroup-last-file
972 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
973 gnus-newsgroup-unselected gnus-newsgroup-marked
974 gnus-newsgroup-reads gnus-newsgroup-saved
975 gnus-newsgroup-replied gnus-newsgroup-expirable
976 gnus-newsgroup-processable gnus-newsgroup-killed
977 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
978 gnus-newsgroup-unsendable
979 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
980 gnus-newsgroup-headers gnus-newsgroup-threads
981 gnus-newsgroup-prepared gnus-summary-highlight-line-function
982 gnus-current-article gnus-current-headers gnus-have-all-headers
983 gnus-last-article gnus-article-internal-prepare-hook
984 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
985 gnus-newsgroup-scored gnus-newsgroup-kill-headers
986 gnus-thread-expunge-below
987 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
988 (gnus-summary-mark-below . global)
989 gnus-newsgroup-active gnus-scores-exclude-files
990 gnus-newsgroup-history gnus-newsgroup-ancient
991 gnus-newsgroup-sparse gnus-newsgroup-process-stack
992 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
993 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
994 (gnus-newsgroup-expunged-tally . 0)
995 gnus-cache-removable-articles gnus-newsgroup-cached
996 gnus-newsgroup-data gnus-newsgroup-data-reverse
997 gnus-newsgroup-limit gnus-newsgroup-limits)
998 "Variables that are buffer-local to the summary buffers.")
1000 ;; Byte-compiler warning.
1001 (defvar gnus-article-mode-map)
1003 ;; Subject simplification.
1005 (defun gnus-simplify-whitespace (str)
1006 "Remove excessive whitespace."
1009 (while (string-match "[ \t][ \t]+" mystr)
1010 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1012 (substring mystr (match-end 0)))))
1014 (when (string-match "^[ \t]+" mystr)
1015 (setq mystr (substring mystr (match-end 0))))
1017 (when (string-match "[ \t]+$" mystr)
1018 (setq mystr (substring mystr 0 (match-beginning 0))))
1021 (defsubst gnus-simplify-subject-re (subject)
1022 "Remove \"Re:\" from subject lines."
1023 (if (string-match "^[Rr][Ee]: *" subject)
1024 (substring subject (match-end 0))
1027 (defun gnus-simplify-subject (subject &optional re-only)
1028 "Remove `Re:' and words in parentheses.
1029 If RE-ONLY is non-nil, strip leading `Re:'s only."
1030 (let ((case-fold-search t)) ;Ignore case.
1031 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1032 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1033 (setq subject (substring subject (match-end 0))))
1034 ;; Remove uninteresting prefixes.
1035 (when (and (not re-only)
1036 gnus-simplify-ignored-prefixes
1037 (string-match gnus-simplify-ignored-prefixes subject))
1038 (setq subject (substring subject (match-end 0))))
1039 ;; Remove words in parentheses from end.
1041 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1042 (setq subject (substring subject 0 (match-beginning 0)))))
1043 ;; Return subject string.
1046 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1048 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1049 (goto-char (point-min))
1050 (while (re-search-forward regexp nil t)
1051 (replace-match (or newtext ""))))
1053 (defun gnus-simplify-buffer-fuzzy ()
1054 "Simplify string in the buffer fuzzily.
1055 The string in the accessible portion of the current buffer is simplified.
1056 It is assumed to be a single-line subject.
1057 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1058 matter is removed. Additional things can be deleted by setting
1059 gnus-simplify-subject-fuzzy-regexp."
1060 (let ((case-fold-search t)
1062 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1064 (while (not (eq modified-tick (buffer-modified-tick)))
1065 (setq modified-tick (buffer-modified-tick))
1067 ((listp gnus-simplify-subject-fuzzy-regexp)
1068 (mapcar 'gnus-simplify-buffer-fuzzy-step
1069 gnus-simplify-subject-fuzzy-regexp))
1070 (gnus-simplify-subject-fuzzy-regexp
1071 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1072 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1073 (gnus-simplify-buffer-fuzzy-step
1074 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1075 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1077 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1078 (gnus-simplify-buffer-fuzzy-step " +" " ")
1079 (gnus-simplify-buffer-fuzzy-step " $")
1080 (gnus-simplify-buffer-fuzzy-step "^ +")))
1082 (defun gnus-simplify-subject-fuzzy (subject)
1083 "Simplify a subject string fuzzily.
1084 See `gnus-simplify-buffer-fuzzy' for details."
1086 (gnus-set-work-buffer)
1087 (let ((case-fold-search t))
1088 ;; Remove uninteresting prefixes.
1089 (when (and gnus-simplify-ignored-prefixes
1090 (string-match gnus-simplify-ignored-prefixes subject))
1091 (setq subject (substring subject (match-end 0))))
1093 (inline (gnus-simplify-buffer-fuzzy))
1096 (defsubst gnus-simplify-subject-fully (subject)
1097 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1099 (gnus-simplify-subject-functions
1100 (gnus-map-function gnus-simplify-subject-functions subject))
1101 ((null gnus-summary-gather-subject-limit)
1102 (gnus-simplify-subject-re subject))
1103 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1104 (gnus-simplify-subject-fuzzy subject))
1105 ((numberp gnus-summary-gather-subject-limit)
1106 (gnus-limit-string (gnus-simplify-subject-re subject)
1107 gnus-summary-gather-subject-limit))
1111 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1112 "Check whether two subjects are equal.
1113 If optional argument simple-first is t, first argument is already
1116 ((null simple-first)
1117 (equal (gnus-simplify-subject-fully s1)
1118 (gnus-simplify-subject-fully s2)))
1121 (gnus-simplify-subject-fully s2)))))
1123 (defun gnus-summary-bubble-group ()
1124 "Increase the score of the current group.
1125 This is a handy function to add to `gnus-summary-exit-hook' to
1126 increase the score of each group you read."
1127 (gnus-group-add-score gnus-newsgroup-name))
1131 ;;; Gnus summary mode
1134 (put 'gnus-summary-mode 'mode-class 'special)
1137 ;; Non-orthogonal keys
1139 (gnus-define-keys gnus-summary-mode-map
1140 " " gnus-summary-next-page
1141 "\177" gnus-summary-prev-page
1142 [delete] gnus-summary-prev-page
1143 [backspace] gnus-summary-prev-page
1144 "\r" gnus-summary-scroll-up
1145 "\e\r" gnus-summary-scroll-down
1146 "n" gnus-summary-next-unread-article
1147 "p" gnus-summary-prev-unread-article
1148 "N" gnus-summary-next-article
1149 "P" gnus-summary-prev-article
1150 "\M-\C-n" gnus-summary-next-same-subject
1151 "\M-\C-p" gnus-summary-prev-same-subject
1152 "\M-n" gnus-summary-next-unread-subject
1153 "\M-p" gnus-summary-prev-unread-subject
1154 "." gnus-summary-first-unread-article
1155 "," gnus-summary-best-unread-article
1156 "\M-s" gnus-summary-search-article-forward
1157 "\M-r" gnus-summary-search-article-backward
1158 "<" gnus-summary-beginning-of-article
1159 ">" gnus-summary-end-of-article
1160 "j" gnus-summary-goto-article
1161 "^" gnus-summary-refer-parent-article
1162 "\M-^" gnus-summary-refer-article
1163 "u" gnus-summary-tick-article-forward
1164 "!" gnus-summary-tick-article-forward
1165 "U" gnus-summary-tick-article-backward
1166 "d" gnus-summary-mark-as-read-forward
1167 "D" gnus-summary-mark-as-read-backward
1168 "E" gnus-summary-mark-as-expirable
1169 "\M-u" gnus-summary-clear-mark-forward
1170 "\M-U" gnus-summary-clear-mark-backward
1171 "k" gnus-summary-kill-same-subject-and-select
1172 "\C-k" gnus-summary-kill-same-subject
1173 "\M-\C-k" gnus-summary-kill-thread
1174 "\M-\C-l" gnus-summary-lower-thread
1175 "e" gnus-summary-edit-article
1176 "#" gnus-summary-mark-as-processable
1177 "\M-#" gnus-summary-unmark-as-processable
1178 "\M-\C-t" gnus-summary-toggle-threads
1179 "\M-\C-s" gnus-summary-show-thread
1180 "\M-\C-h" gnus-summary-hide-thread
1181 "\M-\C-f" gnus-summary-next-thread
1182 "\M-\C-b" gnus-summary-prev-thread
1183 "\M-\C-u" gnus-summary-up-thread
1184 "\M-\C-d" gnus-summary-down-thread
1185 "&" gnus-summary-execute-command
1186 "c" gnus-summary-catchup-and-exit
1187 "\C-w" gnus-summary-mark-region-as-read
1188 "\C-t" gnus-summary-toggle-truncation
1189 "?" gnus-summary-mark-as-dormant
1190 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1191 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1192 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1193 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1194 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1195 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1196 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1197 "=" gnus-summary-expand-window
1198 "\C-x\C-s" gnus-summary-reselect-current-group
1199 "\M-g" gnus-summary-rescan-group
1200 "w" gnus-summary-stop-page-breaking
1201 "\C-c\C-r" gnus-summary-caesar-message
1202 "\M-t" gnus-summary-toggle-mime
1203 "f" gnus-summary-followup
1204 "F" gnus-summary-followup-with-original
1205 "C" gnus-summary-cancel-article
1206 "r" gnus-summary-reply
1207 "R" gnus-summary-reply-with-original
1208 "\C-c\C-f" gnus-summary-mail-forward
1209 "o" gnus-summary-save-article
1210 "\C-o" gnus-summary-save-article-mail
1211 "|" gnus-summary-pipe-output
1212 "\M-k" gnus-summary-edit-local-kill
1213 "\M-K" gnus-summary-edit-global-kill
1215 "\C-c\C-d" gnus-summary-describe-group
1216 "q" gnus-summary-exit
1217 "Q" gnus-summary-exit-no-update
1218 "\C-c\C-i" gnus-info-find-node
1219 gnus-mouse-2 gnus-mouse-pick-article
1220 "m" gnus-summary-mail-other-window
1221 "a" gnus-summary-post-news
1222 "x" gnus-summary-limit-to-unread
1223 "s" gnus-summary-isearch-article
1224 "t" gnus-article-hide-headers
1225 "g" gnus-summary-show-article
1226 "l" gnus-summary-goto-last-article
1227 "v" gnus-summary-preview-mime-message
1228 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1229 "\C-d" gnus-summary-enter-digest-group
1230 "\M-\C-d" gnus-summary-read-document
1231 "\M-\C-e" gnus-summary-edit-parameters
1233 "*" gnus-cache-enter-article
1234 "\M-*" gnus-cache-remove-article
1235 "\M-&" gnus-summary-universal-argument
1236 "\C-l" gnus-recenter
1237 "I" gnus-summary-increase-score
1238 "L" gnus-summary-lower-score
1239 "\M-i" gnus-symbolic-argument
1240 "h" gnus-summary-select-article-buffer
1242 "V" gnus-summary-score-map
1243 "X" gnus-uu-extract-map
1244 "S" gnus-summary-send-map)
1246 ;; Sort of orthogonal keymap
1247 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1248 "t" gnus-summary-tick-article-forward
1249 "!" gnus-summary-tick-article-forward
1250 "d" gnus-summary-mark-as-read-forward
1251 "r" gnus-summary-mark-as-read-forward
1252 "c" gnus-summary-clear-mark-forward
1253 " " gnus-summary-clear-mark-forward
1254 "e" gnus-summary-mark-as-expirable
1255 "x" gnus-summary-mark-as-expirable
1256 "?" gnus-summary-mark-as-dormant
1257 "b" gnus-summary-set-bookmark
1258 "B" gnus-summary-remove-bookmark
1259 "#" gnus-summary-mark-as-processable
1260 "\M-#" gnus-summary-unmark-as-processable
1261 "S" gnus-summary-limit-include-expunged
1262 "C" gnus-summary-catchup
1263 "H" gnus-summary-catchup-to-here
1264 "\C-c" gnus-summary-catchup-all
1265 "k" gnus-summary-kill-same-subject-and-select
1266 "K" gnus-summary-kill-same-subject
1267 "P" gnus-uu-mark-map)
1269 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1270 "c" gnus-summary-clear-above
1271 "u" gnus-summary-tick-above
1272 "m" gnus-summary-mark-above
1273 "k" gnus-summary-kill-below)
1275 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1276 "/" gnus-summary-limit-to-subject
1277 "n" gnus-summary-limit-to-articles
1278 "w" gnus-summary-pop-limit
1279 "s" gnus-summary-limit-to-subject
1280 "a" gnus-summary-limit-to-author
1281 "u" gnus-summary-limit-to-unread
1282 "m" gnus-summary-limit-to-marks
1283 "v" gnus-summary-limit-to-score
1284 "*" gnus-summary-limit-include-cached
1285 "D" gnus-summary-limit-include-dormant
1286 "T" gnus-summary-limit-include-thread
1287 "d" gnus-summary-limit-exclude-dormant
1288 "t" gnus-summary-limit-to-age
1289 "E" gnus-summary-limit-include-expunged
1290 "c" gnus-summary-limit-exclude-childless-dormant
1291 "C" gnus-summary-limit-mark-excluded-as-read)
1293 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1294 "n" gnus-summary-next-unread-article
1295 "p" gnus-summary-prev-unread-article
1296 "N" gnus-summary-next-article
1297 "P" gnus-summary-prev-article
1298 "\C-n" gnus-summary-next-same-subject
1299 "\C-p" gnus-summary-prev-same-subject
1300 "\M-n" gnus-summary-next-unread-subject
1301 "\M-p" gnus-summary-prev-unread-subject
1302 "f" gnus-summary-first-unread-article
1303 "b" gnus-summary-best-unread-article
1304 "j" gnus-summary-goto-article
1305 "g" gnus-summary-goto-subject
1306 "l" gnus-summary-goto-last-article
1307 "o" gnus-summary-pop-article)
1309 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1310 "k" gnus-summary-kill-thread
1311 "l" gnus-summary-lower-thread
1312 "i" gnus-summary-raise-thread
1313 "T" gnus-summary-toggle-threads
1314 "t" gnus-summary-rethread-current
1315 "^" gnus-summary-reparent-thread
1316 "s" gnus-summary-show-thread
1317 "S" gnus-summary-show-all-threads
1318 "h" gnus-summary-hide-thread
1319 "H" gnus-summary-hide-all-threads
1320 "n" gnus-summary-next-thread
1321 "p" gnus-summary-prev-thread
1322 "u" gnus-summary-up-thread
1323 "o" gnus-summary-top-thread
1324 "d" gnus-summary-down-thread
1325 "#" gnus-uu-mark-thread
1326 "\M-#" gnus-uu-unmark-thread)
1328 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1329 "g" gnus-summary-prepare
1330 "c" gnus-summary-insert-cached-articles)
1332 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1333 "c" gnus-summary-catchup-and-exit
1334 "C" gnus-summary-catchup-all-and-exit
1335 "E" gnus-summary-exit-no-update
1336 "Q" gnus-summary-exit
1337 "Z" gnus-summary-exit
1338 "n" gnus-summary-catchup-and-goto-next-group
1339 "R" gnus-summary-reselect-current-group
1340 "G" gnus-summary-rescan-group
1341 "N" gnus-summary-next-group
1342 "s" gnus-summary-save-newsrc
1343 "P" gnus-summary-prev-group)
1345 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1346 " " gnus-summary-next-page
1347 "n" gnus-summary-next-page
1348 "\177" gnus-summary-prev-page
1349 [delete] gnus-summary-prev-page
1350 "p" gnus-summary-prev-page
1351 "\r" gnus-summary-scroll-up
1352 "<" gnus-summary-beginning-of-article
1353 ">" gnus-summary-end-of-article
1354 "b" gnus-summary-beginning-of-article
1355 "e" gnus-summary-end-of-article
1356 "^" gnus-summary-refer-parent-article
1357 "r" gnus-summary-refer-parent-article
1358 "R" gnus-summary-refer-references
1359 "T" gnus-summary-refer-thread
1360 "g" gnus-summary-show-article
1361 "s" gnus-summary-isearch-article
1362 "P" gnus-summary-print-article)
1364 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1365 "b" gnus-article-add-buttons
1366 "B" gnus-article-add-buttons-to-head
1367 "o" gnus-article-treat-overstrike
1368 "e" gnus-article-emphasize
1369 "w" gnus-article-fill-cited-article
1370 "c" gnus-article-remove-cr
1371 "q" gnus-article-de-quoted-unreadable
1372 "f" gnus-article-display-x-face
1373 "l" gnus-summary-stop-page-breaking
1374 "r" gnus-summary-caesar-message
1375 "t" gnus-article-hide-headers
1376 "v" gnus-summary-verbose-headers
1377 "m" gnus-summary-toggle-mime
1378 "h" gnus-article-treat-html
1379 "d" gnus-article-treat-dumbquotes)
1381 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1382 "a" gnus-article-hide
1383 "h" gnus-article-hide-headers
1384 "b" gnus-article-hide-boring-headers
1385 "s" gnus-article-hide-signature
1386 "c" gnus-article-hide-citation
1387 "p" gnus-article-hide-pgp
1388 "P" gnus-article-hide-pem
1389 "\C-c" gnus-article-hide-citation-maybe)
1391 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1392 "a" gnus-article-highlight
1393 "h" gnus-article-highlight-headers
1394 "c" gnus-article-highlight-citation
1395 "s" gnus-article-highlight-signature)
1397 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1398 "z" gnus-article-date-ut
1399 "u" gnus-article-date-ut
1400 "l" gnus-article-date-local
1401 "e" gnus-article-date-lapsed
1402 "o" gnus-article-date-original
1403 "i" gnus-article-date-iso8601
1404 "s" gnus-article-date-user)
1406 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1407 "t" gnus-article-remove-trailing-blank-lines
1408 "l" gnus-article-strip-leading-blank-lines
1409 "m" gnus-article-strip-multiple-blank-lines
1410 "a" gnus-article-strip-blank-lines
1411 "A" gnus-article-strip-all-blank-lines
1412 "s" gnus-article-strip-leading-space)
1414 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1416 "f" gnus-summary-fetch-faq
1417 "d" gnus-summary-describe-group
1418 "h" gnus-summary-describe-briefly
1419 "i" gnus-info-find-node)
1421 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1422 "e" gnus-summary-expire-articles
1423 "\M-\C-e" gnus-summary-expire-articles-now
1424 "\177" gnus-summary-delete-article
1425 [delete] gnus-summary-delete-article
1426 "m" gnus-summary-move-article
1427 "r" gnus-summary-respool-article
1428 "w" gnus-summary-edit-article
1429 "c" gnus-summary-copy-article
1430 "B" gnus-summary-crosspost-article
1431 "q" gnus-summary-respool-query
1432 "i" gnus-summary-import-article
1433 "p" gnus-summary-article-posted-p)
1435 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1436 "o" gnus-summary-save-article
1437 "m" gnus-summary-save-article-mail
1438 "F" gnus-summary-write-article-file
1439 "r" gnus-summary-save-article-rmail
1440 "f" gnus-summary-save-article-file
1441 "b" gnus-summary-save-article-body-file
1442 "h" gnus-summary-save-article-folder
1443 "v" gnus-summary-save-article-vm
1444 "p" gnus-summary-pipe-output
1445 "s" gnus-soup-add-article))
1447 (defun gnus-summary-make-menu-bar ()
1448 (gnus-turn-off-edit-menu 'summary)
1450 (unless (boundp 'gnus-summary-misc-menu)
1453 gnus-summary-kill-menu gnus-summary-mode-map ""
1458 ["Enter score..." gnus-summary-score-entry t]
1459 ["Customize" gnus-score-customize t])
1460 (gnus-make-score-map 'increase)
1461 (gnus-make-score-map 'lower)
1463 ["Kill below" gnus-summary-kill-below t]
1464 ["Mark above" gnus-summary-mark-above t]
1465 ["Tick above" gnus-summary-tick-above t]
1466 ["Clear above" gnus-summary-clear-above t])
1467 ["Current score" gnus-summary-current-score t]
1468 ["Set score" gnus-summary-set-score t]
1469 ["Switch current score file..." gnus-score-change-score-file t]
1470 ["Set mark below..." gnus-score-set-mark-below t]
1471 ["Set expunge below..." gnus-score-set-expunge-below t]
1472 ["Edit current score file" gnus-score-edit-current-scores t]
1473 ["Edit score file" gnus-score-edit-file t]
1474 ["Trace score" gnus-score-find-trace t]
1475 ["Find words" gnus-score-find-favourite-words t]
1476 ["Rescore buffer" gnus-summary-rescore t]
1477 ["Increase score..." gnus-summary-increase-score t]
1478 ["Lower score..." gnus-summary-lower-score t]))))
1481 ["Ask" (gnus-score-set-default 'gnus-score-default-header nil)
1483 :selected (null gnus-score-default-header)]
1484 ["From" (gnus-score-set-default 'gnus-score-default-header 'a)
1486 :selected (eq gnus-score-default-header 'a)]
1487 ["Subject" (gnus-score-set-default 'gnus-score-default-header 's)
1489 :selected (eq gnus-score-default-header 's)]
1491 (gnus-score-set-default 'gnus-score-default-header 'b)
1493 :selected (eq gnus-score-default-header 'b )]
1495 (gnus-score-set-default 'gnus-score-default-header 'h)
1497 :selected (eq gnus-score-default-header 'h )]
1498 ["Message-ID" (gnus-score-set-default 'gnus-score-default-header 'i)
1500 :selected (eq gnus-score-default-header 'i )]
1501 ["Thread" (gnus-score-set-default 'gnus-score-default-header 't)
1503 :selected (eq gnus-score-default-header 't )]
1505 (gnus-score-set-default 'gnus-score-default-header 'x)
1507 :selected (eq gnus-score-default-header 'x )]
1508 ["Lines" (gnus-score-set-default 'gnus-score-default-header 'l)
1510 :selected (eq gnus-score-default-header 'l )]
1511 ["Date" (gnus-score-set-default 'gnus-score-default-header 'd)
1513 :selected (eq gnus-score-default-header 'd )]
1514 ["Followups to author"
1515 (gnus-score-set-default 'gnus-score-default-header 'f)
1517 :selected (eq gnus-score-default-header 'f )])
1519 ["Ask" (gnus-score-set-default 'gnus-score-default-type nil)
1521 :selected (null gnus-score-default-type)]
1522 ;; The `:active' key is commented out in the following,
1523 ;; because the GNU Emacs hack to support radio buttons use
1524 ;; active to indicate which button is selected.
1525 ["Substring" (gnus-score-set-default 'gnus-score-default-type 's)
1527 ;; :active (not (memq gnus-score-default-header '(l d)))
1528 :selected (eq gnus-score-default-type 's)]
1529 ["Regexp" (gnus-score-set-default 'gnus-score-default-type 'r)
1531 ;; :active (not (memq gnus-score-default-header '(l d)))
1532 :selected (eq gnus-score-default-type 'r)]
1533 ["Exact" (gnus-score-set-default 'gnus-score-default-type 'e)
1535 ;; :active (not (memq gnus-score-default-header '(l d)))
1536 :selected (eq gnus-score-default-type 'e)]
1537 ["Fuzzy" (gnus-score-set-default 'gnus-score-default-type 'f)
1539 ;; :active (not (memq gnus-score-default-header '(l d)))
1540 :selected (eq gnus-score-default-type 'f)]
1541 ["Before date" (gnus-score-set-default 'gnus-score-default-type 'b)
1543 ;; :active (eq (gnus-score-default-header 'd))
1544 :selected (eq gnus-score-default-type 'b)]
1545 ["At date" (gnus-score-set-default 'gnus-score-default-type 'n)
1547 ;; :active (eq (gnus-score-default-header 'd))
1548 :selected (eq gnus-score-default-type 'n)]
1549 ["After date" (gnus-score-set-default 'gnus-score-default-type 'a)
1551 ;; :active (eq (gnus-score-default-header 'd))
1552 :selected (eq gnus-score-default-type 'a)]
1554 (gnus-score-set-default 'gnus-score-default-type '<)
1556 ;; :active (eq (gnus-score-default-header 'l))
1557 :selected (eq gnus-score-default-type '<)]
1559 (gnus-score-set-default 'gnus-score-default-type '=)
1561 ;; :active (eq (gnus-score-default-header 'l))
1562 :selected (eq gnus-score-default-type '=)]
1563 ["Greater than number"
1564 (gnus-score-set-default 'gnus-score-default-type '>)
1566 ;; :active (eq (gnus-score-default-header 'l))
1567 :selected (eq gnus-score-default-type '>)])
1568 ["Default fold" gnus-score-default-fold-toggle
1570 :selected gnus-score-default-fold]
1572 ["Ask" (gnus-score-set-default 'gnus-score-default-duration nil)
1574 :selected (null gnus-score-default-duration)]
1576 (gnus-score-set-default 'gnus-score-default-duration 'p)
1578 :selected (eq gnus-score-default-duration 'p)]
1580 (gnus-score-set-default 'gnus-score-default-duration 't)
1582 :selected (eq gnus-score-default-duration 't)]
1584 (gnus-score-set-default 'gnus-score-default-duration 'i)
1586 :selected (eq gnus-score-default-duration 'i)]))
1589 gnus-summary-article-menu gnus-summary-mode-map ""
1592 ["All" gnus-article-hide t]
1593 ["Headers" gnus-article-hide-headers t]
1594 ["Signature" gnus-article-hide-signature t]
1595 ["Citation" gnus-article-hide-citation t]
1596 ["PGP" gnus-article-hide-pgp t]
1597 ["Boring headers" gnus-article-hide-boring-headers t])
1599 ["All" gnus-article-highlight t]
1600 ["Headers" gnus-article-highlight-headers t]
1601 ["Signature" gnus-article-highlight-signature t]
1602 ["Citation" gnus-article-highlight-citation t])
1604 ["Local" gnus-article-date-local t]
1605 ["ISO8601" gnus-article-date-iso8601 t]
1606 ["UT" gnus-article-date-ut t]
1607 ["Original" gnus-article-date-original t]
1608 ["Lapsed" gnus-article-date-lapsed t]
1609 ["User-defined" gnus-article-date-user t])
1612 ["Leading" gnus-article-strip-leading-blank-lines t]
1613 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1614 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1615 ["All of the above" gnus-article-strip-blank-lines t]
1616 ["All" gnus-article-strip-all-blank-lines t]
1617 ["Leading space" gnus-article-strip-leading-space t])
1618 ["Overstrike" gnus-article-treat-overstrike t]
1619 ["Dumb quotes" gnus-article-treat-dumbquotes t]
1620 ["Emphasis" gnus-article-emphasize t]
1621 ["Word wrap" gnus-article-fill-cited-article t]
1622 ["CR" gnus-article-remove-cr t]
1623 ["Show X-Face" gnus-article-display-x-face t]
1624 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
1625 ["UnHTMLize" gnus-article-treat-html t]
1626 ["Rot 13" gnus-summary-caesar-message t]
1627 ["Unix pipe" gnus-summary-pipe-message t]
1628 ["Add buttons" gnus-article-add-buttons t]
1629 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1630 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1631 ["Toggle MIME" gnus-summary-toggle-mime t]
1632 ["Verbose header" gnus-summary-verbose-headers t]
1633 ["Toggle header" gnus-summary-toggle-header t])
1635 ["Save in default format" gnus-summary-save-article t]
1636 ["Save in file" gnus-summary-save-article-file t]
1637 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1638 ["Save in MH folder" gnus-summary-save-article-folder t]
1639 ["Save in VM folder" gnus-summary-save-article-vm t]
1640 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1641 ["Save body in file" gnus-summary-save-article-body-file t]
1642 ["Pipe through a filter" gnus-summary-pipe-output t]
1643 ["Add to SOUP packet" gnus-soup-add-article t]
1644 ["Print" gnus-summary-print-article t])
1646 ["Respool article..." gnus-summary-respool-article t]
1647 ["Move article..." gnus-summary-move-article
1648 (gnus-check-backend-function
1649 'request-move-article gnus-newsgroup-name)]
1650 ["Copy article..." gnus-summary-copy-article t]
1651 ["Crosspost article..." gnus-summary-crosspost-article
1652 (gnus-check-backend-function
1653 'request-replace-article gnus-newsgroup-name)]
1654 ["Import file..." gnus-summary-import-article t]
1655 ["Check if posted" gnus-summary-article-posted-p t]
1656 ["Edit article" gnus-summary-edit-article
1657 (not (gnus-group-read-only-p))]
1658 ["Delete article" gnus-summary-delete-article
1659 (gnus-check-backend-function
1660 'request-expire-articles gnus-newsgroup-name)]
1661 ["Query respool" gnus-summary-respool-query t]
1662 ["Delete expirable articles" gnus-summary-expire-articles-now
1663 (gnus-check-backend-function
1664 'request-expire-articles gnus-newsgroup-name)])
1666 ["Uudecode" gnus-uu-decode-uu t]
1667 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1668 ["Unshar" gnus-uu-decode-unshar t]
1669 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1670 ["Save" gnus-uu-decode-save t]
1671 ["Binhex" gnus-uu-decode-binhex t]
1672 ["Postscript" gnus-uu-decode-postscript t])
1674 ["Enter article" gnus-cache-enter-article t]
1675 ["Remove article" gnus-cache-remove-article t])
1676 ["Select article buffer" gnus-summary-select-article-buffer t]
1677 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1678 ["Isearch article..." gnus-summary-isearch-article t]
1679 ["Beginning of the article" gnus-summary-beginning-of-article t]
1680 ["End of the article" gnus-summary-end-of-article t]
1681 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1682 ["Fetch referenced articles" gnus-summary-refer-references t]
1683 ["Fetch current thread" gnus-summary-refer-thread t]
1684 ["Fetch article with id..." gnus-summary-refer-article t]
1685 ["Redisplay" gnus-summary-show-article t]))
1688 gnus-summary-thread-menu gnus-summary-mode-map ""
1690 ["Toggle threading" gnus-summary-toggle-threads t]
1691 ["Hide threads" gnus-summary-hide-all-threads t]
1692 ["Show threads" gnus-summary-show-all-threads t]
1693 ["Hide thread" gnus-summary-hide-thread t]
1694 ["Show thread" gnus-summary-show-thread t]
1695 ["Go to next thread" gnus-summary-next-thread t]
1696 ["Go to previous thread" gnus-summary-prev-thread t]
1697 ["Go down thread" gnus-summary-down-thread t]
1698 ["Go up thread" gnus-summary-up-thread t]
1699 ["Top of thread" gnus-summary-top-thread t]
1700 ["Mark thread as read" gnus-summary-kill-thread t]
1701 ["Lower thread score" gnus-summary-lower-thread t]
1702 ["Raise thread score" gnus-summary-raise-thread t]
1703 ["Rethread current" gnus-summary-rethread-current t]
1707 gnus-summary-post-menu gnus-summary-mode-map ""
1709 ["Post an article" gnus-summary-post-news t]
1710 ["Followup" gnus-summary-followup t]
1711 ["Followup and yank" gnus-summary-followup-with-original t]
1712 ["Supersede article" gnus-summary-supersede-article t]
1713 ["Cancel article" gnus-summary-cancel-article t]
1714 ["Reply" gnus-summary-reply t]
1715 ["Reply and yank" gnus-summary-reply-with-original t]
1716 ["Wide reply" gnus-summary-wide-reply t]
1717 ["Wide reply and yank" gnus-summary-wide-reply-with-original t]
1718 ["Mail forward" gnus-summary-mail-forward t]
1719 ["Post forward" gnus-summary-post-forward t]
1720 ["Digest and mail" gnus-uu-digest-mail-forward t]
1721 ["Digest and post" gnus-uu-digest-post-forward t]
1722 ["Resend message" gnus-summary-resend-message t]
1723 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
1724 ["Send a mail" gnus-summary-mail-other-window t]
1725 ["Uuencode and post" gnus-uu-post-news t]
1726 ["Followup via news" gnus-summary-followup-to-mail t]
1727 ["Followup via news and yank"
1728 gnus-summary-followup-to-mail-with-original t]
1730 ;;["Send" gnus-summary-send-draft t]
1731 ;;["Send bounced" gnus-resend-bounced-mail t])
1735 gnus-summary-misc-menu gnus-summary-mode-map ""
1738 ["Mark as read" gnus-summary-mark-as-read-forward t]
1739 ["Mark same subject and select"
1740 gnus-summary-kill-same-subject-and-select t]
1741 ["Mark same subject" gnus-summary-kill-same-subject t]
1742 ["Catchup" gnus-summary-catchup t]
1743 ["Catchup all" gnus-summary-catchup-all t]
1744 ["Catchup to here" gnus-summary-catchup-to-here t]
1745 ["Catchup region" gnus-summary-mark-region-as-read t]
1746 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
1748 ["Tick" gnus-summary-tick-article-forward t]
1749 ["Mark as dormant" gnus-summary-mark-as-dormant t]
1750 ["Remove marks" gnus-summary-clear-mark-forward t]
1751 ["Set expirable mark" gnus-summary-mark-as-expirable t]
1752 ["Set bookmark" gnus-summary-set-bookmark t]
1753 ["Remove bookmark" gnus-summary-remove-bookmark t])
1755 ["Marks..." gnus-summary-limit-to-marks t]
1756 ["Subject..." gnus-summary-limit-to-subject t]
1757 ["Author..." gnus-summary-limit-to-author t]
1758 ["Age..." gnus-summary-limit-to-age t]
1759 ["Score" gnus-summary-limit-to-score t]
1760 ["Unread" gnus-summary-limit-to-unread t]
1761 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
1762 ["Articles" gnus-summary-limit-to-articles t]
1763 ["Pop limit" gnus-summary-pop-limit t]
1764 ["Show dormant" gnus-summary-limit-include-dormant t]
1765 ["Hide childless dormant"
1766 gnus-summary-limit-exclude-childless-dormant t]
1767 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
1768 ["Show expunged" gnus-summary-show-all-expunged t])
1770 ["Set mark" gnus-summary-mark-as-processable t]
1771 ["Remove mark" gnus-summary-unmark-as-processable t]
1772 ["Remove all marks" gnus-summary-unmark-all-processable t]
1773 ["Mark above" gnus-uu-mark-over t]
1774 ["Mark series" gnus-uu-mark-series t]
1775 ["Mark region" gnus-uu-mark-region t]
1776 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
1777 ["Mark all" gnus-uu-mark-all t]
1778 ["Mark buffer" gnus-uu-mark-buffer t]
1779 ["Mark sparse" gnus-uu-mark-sparse t]
1780 ["Mark thread" gnus-uu-mark-thread t]
1781 ["Unmark thread" gnus-uu-unmark-thread t]
1782 ("Process Mark Sets"
1783 ["Kill" gnus-summary-kill-process-mark t]
1784 ["Yank" gnus-summary-yank-process-mark
1785 gnus-newsgroup-process-stack]
1786 ["Save" gnus-summary-save-process-mark t]))
1788 ["Page forward" gnus-summary-next-page t]
1789 ["Page backward" gnus-summary-prev-page t]
1790 ["Line forward" gnus-summary-scroll-up t])
1792 ["Next unread article" gnus-summary-next-unread-article t]
1793 ["Previous unread article" gnus-summary-prev-unread-article t]
1794 ["Next article" gnus-summary-next-article t]
1795 ["Previous article" gnus-summary-prev-article t]
1796 ["Next unread subject" gnus-summary-next-unread-subject t]
1797 ["Previous unread subject" gnus-summary-prev-unread-subject t]
1798 ["Next article same subject" gnus-summary-next-same-subject t]
1799 ["Previous article same subject" gnus-summary-prev-same-subject t]
1800 ["First unread article" gnus-summary-first-unread-article t]
1801 ["Best unread article" gnus-summary-best-unread-article t]
1802 ["Go to subject number..." gnus-summary-goto-subject t]
1803 ["Go to article number..." gnus-summary-goto-article t]
1804 ["Go to the last article" gnus-summary-goto-last-article t]
1805 ["Pop article off history" gnus-summary-pop-article t])
1807 ["Sort by number" gnus-summary-sort-by-number t]
1808 ["Sort by author" gnus-summary-sort-by-author t]
1809 ["Sort by subject" gnus-summary-sort-by-subject t]
1810 ["Sort by date" gnus-summary-sort-by-date t]
1811 ["Sort by score" gnus-summary-sort-by-score t]
1812 ["Sort by lines" gnus-summary-sort-by-lines t])
1814 ["Fetch group FAQ" gnus-summary-fetch-faq t]
1815 ["Describe group" gnus-summary-describe-group t]
1816 ["Read manual" gnus-info-find-node t])
1818 ["Pick and read" gnus-pick-mode t]
1819 ["Binary" gnus-binary-mode t])
1821 ["Regenerate" gnus-summary-prepare t]
1822 ["Insert cached articles" gnus-summary-insert-cached-articles t]
1823 ["Toggle threading" gnus-summary-toggle-threads t])
1824 ["Filter articles..." gnus-summary-execute-command t]
1825 ["Run command on subjects..." gnus-summary-universal-argument t]
1826 ["Search articles forward..." gnus-summary-search-article-forward t]
1827 ["Search articles backward..." gnus-summary-search-article-backward t]
1828 ["Toggle line truncation" gnus-summary-toggle-truncation t]
1829 ["Expand window" gnus-summary-expand-window t]
1830 ["Expire expirable articles" gnus-summary-expire-articles
1831 (gnus-check-backend-function
1832 'request-expire-articles gnus-newsgroup-name)]
1833 ["Edit local kill file" gnus-summary-edit-local-kill t]
1834 ["Edit main kill file" gnus-summary-edit-global-kill t]
1835 ["Edit group parameters" gnus-summary-edit-parameters t]
1837 ["Catchup and exit" gnus-summary-catchup-and-exit t]
1838 ["Catchup all and exit" gnus-summary-catchup-and-exit t]
1839 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
1840 ["Exit group" gnus-summary-exit t]
1841 ["Exit group without updating" gnus-summary-exit-no-update t]
1842 ["Exit and goto next group" gnus-summary-next-group t]
1843 ["Exit and goto prev group" gnus-summary-prev-group t]
1844 ["Reselect group" gnus-summary-reselect-current-group t]
1845 ["Rescan group" gnus-summary-rescan-group t]
1846 ["Update dribble" gnus-summary-save-newsrc t])))
1848 (gnus-run-hooks 'gnus-summary-menu-hook)))
1850 (defun gnus-score-set-default (var value)
1851 "A version of set that updates the GNU Emacs menu-bar."
1853 ;; It is the message that forces the active status to be updated.
1856 (defun gnus-make-score-map (type)
1857 "Make a summary score map of type TYPE."
1860 (let ((headers '(("author" "from" string)
1861 ("subject" "subject" string)
1862 ("article body" "body" string)
1863 ("article head" "head" string)
1864 ("xref" "xref" string)
1865 ("lines" "lines" number)
1866 ("followups to author" "followup" string)))
1867 (types '((number ("less than" <)
1870 (string ("substring" s)
1874 (perms '(("temporary" (current-time-string))
1882 (if (eq type 'lower)
1887 (setq header (car headers))
1893 (let ((ts (cdr (assoc (nth 2 header) types)))
1909 'gnus-summary-score-entry
1911 (if (or (string= (nth 1 header)
1913 (string= (nth 1 header)
1916 (list 'gnus-summary-header
1918 (list 'quote (nth 1 (car ts)))
1919 (list 'gnus-score-default nil)
1925 (list (nreverse outp))))
1928 (list (nreverse outt))))
1930 (setq headers (cdr headers)))
1931 (list (nreverse outh))))))))
1935 (defun gnus-summary-mode (&optional group)
1936 "Major mode for reading articles.
1938 All normal editing commands are switched off.
1939 \\<gnus-summary-mode-map>
1940 Each line in this buffer represents one article. To read an
1941 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
1942 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
1945 You can also post articles and send mail from this buffer. To
1946 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
1947 of an article, type `\\[gnus-summary-reply]'.
1949 There are approx. one gazillion commands you can execute in this
1950 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
1952 The following commands are available:
1954 \\{gnus-summary-mode-map}"
1956 (when (gnus-visual-p 'summary-menu 'menu)
1957 (gnus-summary-make-menu-bar))
1958 (kill-all-local-variables)
1959 (gnus-summary-make-local-variables)
1960 (gnus-make-thread-indent-array)
1961 (gnus-simplify-mode-line)
1962 (setq major-mode 'gnus-summary-mode)
1963 (setq mode-name "Summary")
1964 (make-local-variable 'minor-mode-alist)
1965 (use-local-map gnus-summary-mode-map)
1966 (buffer-disable-undo (current-buffer))
1967 (setq buffer-read-only t) ;Disable modification
1968 (setq truncate-lines t)
1969 (setq selective-display t)
1970 (setq selective-display-ellipses t) ;Display `...'
1971 (gnus-summary-set-display-table)
1972 (gnus-set-default-directory)
1973 (setq gnus-newsgroup-name group)
1974 (make-local-variable 'gnus-summary-line-format)
1975 (make-local-variable 'gnus-summary-line-format-spec)
1976 (make-local-variable 'gnus-summary-dummy-line-format)
1977 (make-local-variable 'gnus-summary-dummy-line-format-spec)
1978 (make-local-variable 'gnus-summary-mark-positions)
1979 (make-local-hook 'post-command-hook)
1980 (add-hook 'post-command-hook 'gnus-clear-inboxes-moved nil t)
1981 (make-local-hook 'pre-command-hook)
1982 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
1983 (gnus-run-hooks 'gnus-summary-mode-hook)
1984 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
1985 (gnus-update-summary-mark-positions))
1987 (defun gnus-summary-make-local-variables ()
1988 "Make all the local summary buffer variables."
1989 (let ((locals gnus-summary-local-variables)
1991 (while (setq local (pop locals))
1994 (if (eq (cdr local) 'global)
1995 ;; Copy the global value of the variable.
1996 (setq global (symbol-value (car local)))
1997 ;; Use the value from the list.
1998 (setq global (eval (cdr local))))
1999 (make-local-variable (car local))
2000 (set (car local) global))
2001 ;; Simple nil-valued local variable.
2002 (make-local-variable local)
2005 (defun gnus-summary-clear-local-variables ()
2006 (let ((locals gnus-summary-local-variables))
2008 (if (consp (car locals))
2009 (and (vectorp (caar locals))
2010 (set (caar locals) nil))
2011 (and (vectorp (car locals))
2012 (set (car locals) nil)))
2013 (setq locals (cdr locals)))))
2015 ;; Summary data functions.
2017 (defmacro gnus-data-number (data)
2020 (defmacro gnus-data-set-number (data number)
2021 `(setcar ,data ,number))
2023 (defmacro gnus-data-mark (data)
2026 (defmacro gnus-data-set-mark (data mark)
2027 `(setcar (nthcdr 1 ,data) ,mark))
2029 (defmacro gnus-data-pos (data)
2032 (defmacro gnus-data-set-pos (data pos)
2033 `(setcar (nthcdr 2 ,data) ,pos))
2035 (defmacro gnus-data-header (data)
2038 (defmacro gnus-data-set-header (data header)
2039 `(setf (nth 3 ,data) ,header))
2041 (defmacro gnus-data-level (data)
2044 (defmacro gnus-data-unread-p (data)
2045 `(= (nth 1 ,data) gnus-unread-mark))
2047 (defmacro gnus-data-read-p (data)
2048 `(/= (nth 1 ,data) gnus-unread-mark))
2050 (defmacro gnus-data-pseudo-p (data)
2051 `(consp (nth 3 ,data)))
2053 (defmacro gnus-data-find (number)
2054 `(assq ,number gnus-newsgroup-data))
2056 (defmacro gnus-data-find-list (number &optional data)
2057 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2058 (memq (assq ,number bdata)
2061 (defmacro gnus-data-make (number mark pos header level)
2062 `(list ,number ,mark ,pos ,header ,level))
2064 (defun gnus-data-enter (after-article number mark pos header level offset)
2065 (let ((data (gnus-data-find-list after-article)))
2067 (error "No such article: %d" after-article))
2068 (setcdr data (cons (gnus-data-make number mark pos header level)
2070 (setq gnus-newsgroup-data-reverse nil)
2071 (gnus-data-update-list (cddr data) offset)))
2073 (defun gnus-data-enter-list (after-article list &optional offset)
2075 (let ((data (and after-article (gnus-data-find-list after-article)))
2077 (or data (not after-article) (error "No such article: %d" after-article))
2078 ;; Find the last element in the list to be spliced into the main
2081 (setq list (cdr list)))
2084 (setcdr list gnus-newsgroup-data)
2085 (setq gnus-newsgroup-data ilist)
2087 (gnus-data-update-list (cdr list) offset)))
2088 (setcdr list (cdr data))
2091 (gnus-data-update-list (cdr list) offset)))
2092 (setq gnus-newsgroup-data-reverse nil))))
2094 (defun gnus-data-remove (article &optional offset)
2095 (let ((data gnus-newsgroup-data))
2096 (if (= (gnus-data-number (car data)) article)
2098 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2099 gnus-newsgroup-data-reverse nil)
2101 (gnus-data-update-list gnus-newsgroup-data offset)))
2103 (when (= (gnus-data-number (cadr data)) article)
2104 (setcdr data (cddr data))
2106 (gnus-data-update-list (cdr data) offset))
2108 gnus-newsgroup-data-reverse nil))
2109 (setq data (cdr data))))))
2111 (defmacro gnus-data-list (backward)
2113 (or gnus-newsgroup-data-reverse
2114 (setq gnus-newsgroup-data-reverse
2115 (reverse gnus-newsgroup-data)))
2116 gnus-newsgroup-data))
2118 (defun gnus-data-update-list (data offset)
2119 "Add OFFSET to the POS of all data entries in DATA."
2121 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2122 (setq data (cdr data))))
2124 (defun gnus-data-compute-positions ()
2125 "Compute the positions of all articles."
2126 (let ((data gnus-newsgroup-data)
2129 (when (setq pos (text-property-any
2130 (point-min) (point-max)
2131 'gnus-number (gnus-data-number (car data))))
2132 (gnus-data-set-pos (car data) (+ pos 3)))
2133 (setq data (cdr data)))))
2135 (defun gnus-summary-article-pseudo-p (article)
2136 "Say whether this article is a pseudo article or not."
2137 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2139 (defmacro gnus-summary-article-sparse-p (article)
2140 "Say whether this article is a sparse article or not."
2141 `(memq ,article gnus-newsgroup-sparse))
2143 (defmacro gnus-summary-article-ancient-p (article)
2144 "Say whether this article is a sparse article or not."
2145 `(memq ,article gnus-newsgroup-ancient))
2147 (defun gnus-article-parent-p (number)
2148 "Say whether this article is a parent or not."
2149 (let ((data (gnus-data-find-list number)))
2150 (and (cdr data) ; There has to be an article after...
2151 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2152 (gnus-data-level (nth 1 data))))))
2154 (defun gnus-article-children (number)
2155 "Return a list of all children to NUMBER."
2156 (let* ((data (gnus-data-find-list number))
2157 (level (gnus-data-level (car data)))
2159 (setq data (cdr data))
2161 (= (gnus-data-level (car data)) (1+ level)))
2162 (push (gnus-data-number (car data)) children)
2163 (setq data (cdr data)))
2166 (defmacro gnus-summary-skip-intangible ()
2167 "If the current article is intangible, then jump to a different article."
2168 '(let ((to (get-text-property (point) 'gnus-intangible)))
2169 (and to (gnus-summary-goto-subject to))))
2171 (defmacro gnus-summary-article-intangible-p ()
2172 "Say whether this article is intangible or not."
2173 '(get-text-property (point) 'gnus-intangible))
2175 (defun gnus-article-read-p (article)
2176 "Say whether ARTICLE is read or not."
2177 (not (or (memq article gnus-newsgroup-marked)
2178 (memq article gnus-newsgroup-unreads)
2179 (memq article gnus-newsgroup-unselected)
2180 (memq article gnus-newsgroup-dormant))))
2182 ;; Some summary mode macros.
2184 (defmacro gnus-summary-article-number ()
2185 "The article number of the article on the current line.
2186 If there isn's an article number here, then we return the current
2189 (gnus-summary-skip-intangible)
2190 (or (get-text-property (point) 'gnus-number)
2191 (gnus-summary-last-subject))))
2193 (defmacro gnus-summary-article-header (&optional number)
2194 "Return the header of article NUMBER."
2195 `(gnus-data-header (gnus-data-find
2196 ,(or number '(gnus-summary-article-number)))))
2198 (defmacro gnus-summary-thread-level (&optional number)
2199 "Return the level of thread that starts with article NUMBER."
2200 `(if (and (eq gnus-summary-make-false-root 'dummy)
2201 (get-text-property (point) 'gnus-intangible))
2203 (gnus-data-level (gnus-data-find
2204 ,(or number '(gnus-summary-article-number))))))
2206 (defmacro gnus-summary-article-mark (&optional number)
2207 "Return the mark of article NUMBER."
2208 `(gnus-data-mark (gnus-data-find
2209 ,(or number '(gnus-summary-article-number)))))
2211 (defmacro gnus-summary-article-pos (&optional number)
2212 "Return the position of the line of article NUMBER."
2213 `(gnus-data-pos (gnus-data-find
2214 ,(or number '(gnus-summary-article-number)))))
2216 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2217 (defmacro gnus-summary-article-subject (&optional number)
2218 "Return current subject string or nil if nothing."
2221 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2222 '(gnus-data-header (assq (gnus-summary-article-number)
2223 gnus-newsgroup-data)))))
2226 (mail-header-subject headers))))
2228 (defmacro gnus-summary-article-score (&optional number)
2229 "Return current article score."
2230 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2231 gnus-newsgroup-scored))
2232 gnus-summary-default-score 0))
2234 (defun gnus-summary-article-children (&optional number)
2235 "Return a list of article numbers that are children of article NUMBER."
2236 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2237 (level (gnus-data-level (car data)))
2239 (while (and (setq data (cdr data))
2240 (> (setq l (gnus-data-level (car data))) level))
2241 (and (= (1+ level) l)
2242 (push (gnus-data-number (car data))
2244 (nreverse children)))
2246 (defun gnus-summary-article-parent (&optional number)
2247 "Return the article number of the parent of article NUMBER."
2248 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2249 (gnus-data-list t)))
2250 (level (gnus-data-level (car data))))
2252 () ; This is a root.
2253 ;; We search until we find an article with a level less than
2254 ;; this one. That function has to be the parent.
2255 (while (and (setq data (cdr data))
2256 (not (< (gnus-data-level (car data)) level))))
2257 (and data (gnus-data-number (car data))))))
2259 (defun gnus-unread-mark-p (mark)
2260 "Say whether MARK is the unread mark."
2261 (= mark gnus-unread-mark))
2263 (defun gnus-read-mark-p (mark)
2264 "Say whether MARK is one of the marks that mark as read.
2265 This is all marks except unread, ticked, dormant, and expirable."
2266 (not (or (= mark gnus-unread-mark)
2267 (= mark gnus-ticked-mark)
2268 (= mark gnus-dormant-mark)
2269 (= mark gnus-expirable-mark))))
2271 (defmacro gnus-article-mark (number)
2272 "Return the MARK of article NUMBER.
2273 This macro should only be used when computing the mark the \"first\"
2274 time; i.e., when generating the summary lines. After that,
2275 `gnus-summary-article-mark' should be used to examine the
2278 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2279 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2280 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2281 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2282 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2283 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2284 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2285 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2286 gnus-ancient-mark))))
2288 ;; Saving hidden threads.
2290 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2291 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2293 (defmacro gnus-save-hidden-threads (&rest forms)
2294 "Save hidden threads, eval FORMS, and restore the hidden threads."
2295 (let ((config (make-symbol "config")))
2296 `(let ((,config (gnus-hidden-threads-configuration)))
2300 (gnus-restore-hidden-threads-configuration ,config)))))
2302 (defun gnus-hidden-threads-configuration ()
2303 "Return the current hidden threads configuration."
2306 (goto-char (point-min))
2307 (while (search-forward "\r" nil t)
2308 (push (1- (point)) config))
2311 (defun gnus-restore-hidden-threads-configuration (config)
2312 "Restore hidden threads configuration from CONFIG."
2313 (let (point buffer-read-only)
2314 (while (setq point (pop config))
2315 (when (and (< point (point-max))
2317 (= (following-char) ?\n))
2318 (subst-char-in-region point (1+ point) ?\n ?\r)))))
2320 ;; Various summary mode internalish functions.
2322 (defun gnus-mouse-pick-article (e)
2325 (gnus-summary-next-page nil t))
2327 (defun gnus-summary-set-display-table ()
2328 ;; Change the display table. Odd characters have a tendency to mess
2329 ;; up nicely formatted displays - we make all possible glyphs
2330 ;; display only a single character.
2332 ;; We start from the standard display table, if any.
2333 (let ((table (or (copy-sequence standard-display-table)
2334 (make-display-table)))
2336 ;; Nix out all the control chars...
2337 (while (>= (setq i (1- i)) 0)
2338 (aset table i [??]))
2339 ;; ... but not newline and cr, of course. (cr is necessary for the
2340 ;; selective display).
2341 (aset table ?\n nil)
2342 (aset table ?\r nil)
2343 ;; We keep TAB as well.
2344 (aset table ?\t nil)
2345 ;; We nix out any glyphs over 126 that are not set already.
2347 (while (>= (setq i (1- i)) 127)
2348 ;; Only modify if the entry is nil.
2349 (unless (aref table i)
2350 (aset table i [??]))))
2351 (setq buffer-display-table table)))
2353 (defun gnus-summary-setup-buffer (group)
2354 "Initialize summary buffer."
2355 (let ((buffer (concat "*Summary " group "*")))
2356 (if (get-buffer buffer)
2359 (setq gnus-summary-buffer (current-buffer))
2360 (not gnus-newsgroup-prepared))
2361 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2362 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
2363 (gnus-add-current-to-buffer-list)
2364 (gnus-summary-mode group)
2366 (gnus-carpal-setup-buffer 'summary))
2367 (unless gnus-single-article-buffer
2368 (make-local-variable 'gnus-article-buffer)
2369 (make-local-variable 'gnus-article-current)
2370 (make-local-variable 'gnus-original-article-buffer))
2371 (setq gnus-newsgroup-name group)
2374 (defun gnus-set-global-variables ()
2375 ;; Set the global equivalents of the summary buffer-local variables
2376 ;; to the latest values they had. These reflect the summary buffer
2377 ;; that was in action when the last article was fetched.
2378 (when (eq major-mode 'gnus-summary-mode)
2379 (setq gnus-summary-buffer (current-buffer))
2380 (let ((name gnus-newsgroup-name)
2381 (marked gnus-newsgroup-marked)
2382 (unread gnus-newsgroup-unreads)
2383 (headers gnus-current-headers)
2384 (data gnus-newsgroup-data)
2385 (summary gnus-summary-buffer)
2386 (article-buffer gnus-article-buffer)
2387 (original gnus-original-article-buffer)
2388 (gac gnus-article-current)
2389 (reffed gnus-reffed-article-number)
2390 (score-file gnus-current-score-file))
2392 (set-buffer gnus-group-buffer)
2393 (setq gnus-newsgroup-name name
2394 gnus-newsgroup-marked marked
2395 gnus-newsgroup-unreads unread
2396 gnus-current-headers headers
2397 gnus-newsgroup-data data
2398 gnus-article-current gac
2399 gnus-summary-buffer summary
2400 gnus-article-buffer article-buffer
2401 gnus-original-article-buffer original
2402 gnus-reffed-article-number reffed
2403 gnus-current-score-file score-file)
2404 ;; The article buffer also has local variables.
2405 (when (gnus-buffer-live-p gnus-article-buffer)
2406 (set-buffer gnus-article-buffer)
2407 (setq gnus-summary-buffer summary))))))
2409 (defun gnus-summary-article-unread-p (article)
2410 "Say whether ARTICLE is unread or not."
2411 (memq article gnus-newsgroup-unreads))
2413 (defun gnus-summary-first-article-p (&optional article)
2414 "Return whether ARTICLE is the first article in the buffer."
2415 (if (not (setq article (or article (gnus-summary-article-number))))
2417 (eq article (caar gnus-newsgroup-data))))
2419 (defun gnus-summary-last-article-p (&optional article)
2420 "Return whether ARTICLE is the last article in the buffer."
2421 (if (not (setq article (or article (gnus-summary-article-number))))
2422 t ; All non-existent numbers are the last article. :-)
2423 (not (cdr (gnus-data-find-list article)))))
2425 (defun gnus-make-thread-indent-array ()
2427 (unless (and gnus-thread-indent-array
2428 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2429 (setq gnus-thread-indent-array (make-vector 201 "")
2430 gnus-thread-indent-array-level gnus-thread-indent-level)
2432 (aset gnus-thread-indent-array n
2433 (make-string (* n gnus-thread-indent-level) ? ))
2436 (defun gnus-update-summary-mark-positions ()
2437 "Compute where the summary marks are to go."
2439 (when (and gnus-summary-buffer
2440 (get-buffer gnus-summary-buffer)
2441 (buffer-name (get-buffer gnus-summary-buffer)))
2442 (set-buffer gnus-summary-buffer))
2443 (let ((gnus-replied-mark 129)
2444 (gnus-score-below-mark 130)
2445 (gnus-score-over-mark 130)
2446 (gnus-download-mark 131)
2447 (spec gnus-summary-line-format-spec)
2448 thread gnus-visual pos)
2450 (gnus-set-work-buffer)
2451 (let ((gnus-summary-line-format-spec spec)
2452 (gnus-newsgroup-downloadable '((0 . t))))
2453 (gnus-summary-insert-line
2454 [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
2455 (goto-char (point-min))
2456 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2458 (goto-char (point-min))
2459 (push (cons 'replied (and (search-forward "\201" nil t)
2462 (goto-char (point-min))
2463 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2465 (goto-char (point-min))
2466 (push (cons 'download
2467 (and (search-forward "\203" nil t) (- (point) 2)))
2469 (setq gnus-summary-mark-positions pos))))
2471 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2472 "Insert a dummy root in the summary buffer."
2474 (gnus-add-text-properties
2475 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2476 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2478 (defun gnus-summary-insert-line (gnus-tmp-header
2479 gnus-tmp-level gnus-tmp-current
2480 gnus-tmp-unread gnus-tmp-replied
2481 gnus-tmp-expirable gnus-tmp-subject-or-nil
2482 &optional gnus-tmp-dummy gnus-tmp-score
2484 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2485 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2486 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2487 (gnus-tmp-score-char
2488 (if (or (null gnus-summary-default-score)
2489 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2490 gnus-summary-zcore-fuzz))
2492 (if (< gnus-tmp-score gnus-summary-default-score)
2493 gnus-score-below-mark gnus-score-over-mark)))
2495 (cond (gnus-tmp-process gnus-process-mark)
2496 ((memq gnus-tmp-current gnus-newsgroup-cached)
2498 (gnus-tmp-replied gnus-replied-mark)
2499 ((memq gnus-tmp-current gnus-newsgroup-saved)
2501 (t gnus-unread-mark)))
2502 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2505 ((string-match "<[^>]+> *$" gnus-tmp-from)
2506 (let ((beg (match-beginning 0)))
2507 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
2508 (substring gnus-tmp-from (1+ (match-beginning 0))
2509 (1- (match-end 0))))
2510 (substring gnus-tmp-from 0 beg))))
2511 ((string-match "(.+)" gnus-tmp-from)
2512 (substring gnus-tmp-from
2513 (1+ (match-beginning 0)) (1- (match-end 0))))
2515 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2516 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2517 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2518 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
2519 (buffer-read-only nil))
2520 (when (string= gnus-tmp-name "")
2521 (setq gnus-tmp-name gnus-tmp-from))
2522 (unless (numberp gnus-tmp-lines)
2523 (setq gnus-tmp-lines 0))
2524 (gnus-put-text-property
2526 (progn (eval gnus-summary-line-format-spec) (point))
2527 'gnus-number gnus-tmp-number)
2528 (when (gnus-visual-p 'summary-highlight 'highlight)
2530 (gnus-run-hooks 'gnus-summary-update-hook)
2533 (defun gnus-summary-update-line (&optional dont-update)
2534 ;; Update summary line after change.
2535 (when (and gnus-summary-default-score
2536 (not gnus-summary-inhibit-highlight))
2537 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
2538 (article (gnus-summary-article-number))
2539 (score (gnus-summary-article-score article)))
2541 (if (and gnus-summary-mark-below
2542 (< (gnus-summary-article-score)
2543 gnus-summary-mark-below))
2544 ;; This article has a low score, so we mark it as read.
2545 (when (memq article gnus-newsgroup-unreads)
2546 (gnus-summary-mark-article-as-read gnus-low-score-mark))
2547 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
2548 ;; This article was previously marked as read on account
2549 ;; of a low score, but now it has risen, so we mark it as
2551 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
2552 (gnus-summary-update-mark
2553 (if (or (null gnus-summary-default-score)
2554 (<= (abs (- score gnus-summary-default-score))
2555 gnus-summary-zcore-fuzz))
2557 (if (< score gnus-summary-default-score)
2558 gnus-score-below-mark gnus-score-over-mark))
2560 ;; Do visual highlighting.
2561 (when (gnus-visual-p 'summary-highlight 'highlight)
2562 (gnus-run-hooks 'gnus-summary-update-hook)))))
2564 (defvar gnus-tmp-new-adopts nil)
2566 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
2567 "Return the number of articles in THREAD.
2568 This may be 0 in some cases -- if none of the articles in
2569 the thread are to be displayed."
2571 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
2573 ((not (listp thread))
2575 ((and (consp thread) (cdr thread))
2578 'gnus-summary-number-of-articles-in-thread (cdr thread))))
2581 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
2584 (when (and level (zerop level) gnus-tmp-new-adopts)
2587 'gnus-summary-number-of-articles-in-thread
2588 gnus-tmp-new-adopts))))
2590 (if (> number 1) gnus-not-empty-thread-mark
2591 gnus-empty-thread-mark)
2594 (defun gnus-summary-set-local-parameters (group)
2595 "Go through the local params of GROUP and set all variable specs in that list."
2596 (let ((params (gnus-group-find-parameter group))
2599 (setq elem (car params)
2600 params (cdr params))
2601 (and (consp elem) ; Has to be a cons.
2602 (consp (cdr elem)) ; The cdr has to be a list.
2603 (symbolp (car elem)) ; Has to be a symbol in there.
2604 (not (memq (car elem)
2605 '(quit-config to-address to-list to-group)))
2606 (ignore-errors ; So we set it.
2607 (make-local-variable (car elem))
2608 (set (car elem) (eval (nth 1 elem))))))))
2610 (defun gnus-summary-read-group (group &optional show-all no-article
2611 kill-buffer no-display)
2612 "Start reading news in newsgroup GROUP.
2613 If SHOW-ALL is non-nil, already read articles are also listed.
2614 If NO-ARTICLE is non-nil, no article is selected initially.
2615 If NO-DISPLAY, don't generate a summary buffer."
2619 (let ((gnus-auto-select-next nil))
2620 (or (gnus-summary-read-group-1
2621 group show-all no-article
2622 kill-buffer no-display)
2623 (setq show-all nil)))))
2624 (eq gnus-auto-select-next 'quietly))
2625 (set-buffer gnus-group-buffer)
2626 (if (not (equal group (gnus-group-group-name)))
2627 (setq group (gnus-group-group-name))
2631 (defun gnus-summary-read-group-1 (group show-all no-article
2632 kill-buffer no-display)
2633 ;; Killed foreign groups can't be entered.
2634 (when (and (not (gnus-group-native-p group))
2635 (not (gnus-gethash group gnus-newsrc-hashtb)))
2636 (error "Dead non-native groups can't be entered"))
2637 (gnus-message 5 "Retrieving newsgroup: %s..." group)
2638 (let* ((new-group (gnus-summary-setup-buffer group))
2639 (quit-config (gnus-group-quit-config group))
2640 (did-select (and new-group (gnus-select-newsgroup group show-all))))
2642 ;; This summary buffer exists already, so we just select it.
2644 (gnus-set-global-variables)
2646 (gnus-kill-or-deaden-summary kill-buffer))
2647 (gnus-configure-windows 'summary 'force)
2648 (gnus-set-mode-line 'summary)
2649 (gnus-summary-position-point)
2652 ;; We couldn't select this group.
2654 (when (and (eq major-mode 'gnus-summary-mode)
2655 (not (equal (current-buffer) kill-buffer)))
2656 (kill-buffer (current-buffer))
2657 (if (not quit-config)
2659 ;; Update the info -- marks might need to be removed,
2661 (gnus-summary-update-info)
2662 (set-buffer gnus-group-buffer)
2663 (gnus-group-jump-to-group group)
2664 (gnus-group-next-unread-group 1))
2665 (gnus-handle-ephemeral-exit quit-config)))
2666 (gnus-message 3 "Can't select group")
2668 ;; The user did a `C-g' while prompting for number of articles,
2669 ;; so we exit this group.
2670 ((eq did-select 'quit)
2671 (and (eq major-mode 'gnus-summary-mode)
2672 (not (equal (current-buffer) kill-buffer))
2673 (kill-buffer (current-buffer)))
2675 (gnus-kill-or-deaden-summary kill-buffer))
2676 (if (not quit-config)
2678 (set-buffer gnus-group-buffer)
2679 (gnus-group-jump-to-group group)
2680 (gnus-group-next-unread-group 1)
2681 (gnus-configure-windows 'group 'force))
2682 (gnus-handle-ephemeral-exit quit-config))
2683 ;; Finally signal the quit.
2685 ;; The group was successfully selected.
2687 (gnus-set-global-variables)
2688 ;; Save the active value in effect when the group was entered.
2689 (setq gnus-newsgroup-active
2691 (gnus-active gnus-newsgroup-name)))
2692 ;; You can change the summary buffer in some way with this hook.
2693 (gnus-run-hooks 'gnus-select-group-hook)
2694 ;; Set any local variables in the group parameters.
2695 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2696 (gnus-update-format-specifications
2697 nil 'summary 'summary-mode 'summary-dummy)
2698 ;; Do score processing.
2699 (when gnus-use-scoring
2700 (gnus-possibly-score-headers))
2701 ;; Check whether to fill in the gaps in the threads.
2702 (when gnus-build-sparse-threads
2703 (gnus-build-sparse-threads))
2704 ;; Find the initial limit.
2705 (if gnus-show-threads
2707 (let ((gnus-newsgroup-dormant nil))
2708 (gnus-summary-initial-limit show-all))
2709 (gnus-summary-initial-limit show-all))
2710 (setq gnus-newsgroup-limit
2712 (lambda (header) (mail-header-number header))
2713 gnus-newsgroup-headers)))
2714 ;; Generate the summary buffer.
2716 (gnus-summary-prepare))
2717 (when gnus-use-trees
2718 (gnus-tree-open group)
2719 (setq gnus-summary-highlight-line-function
2720 'gnus-tree-highlight-article))
2721 ;; If the summary buffer is empty, but there are some low-scored
2722 ;; articles or some excluded dormants, we include these in the
2724 (when (and (zerop (buffer-size))
2726 (cond (gnus-newsgroup-dormant
2727 (gnus-summary-limit-include-dormant))
2728 ((and gnus-newsgroup-scored show-all)
2729 (gnus-summary-limit-include-expunged t))))
2730 ;; Function `gnus-apply-kill-file' must be called in this hook.
2731 (gnus-run-hooks 'gnus-apply-kill-hook)
2732 (if (and (zerop (buffer-size))
2735 ;; This newsgroup is empty.
2736 (gnus-summary-catchup-and-exit nil t)
2737 (gnus-message 6 "No unread news")
2739 (gnus-kill-or-deaden-summary kill-buffer))
2740 ;; Return nil from this function.
2742 ;; Hide conversation thread subtrees. We cannot do this in
2743 ;; gnus-summary-prepare-hook since kill processing may not
2744 ;; work with hidden articles.
2745 (and gnus-show-threads
2746 gnus-thread-hide-subtree
2747 (gnus-summary-hide-all-threads))
2749 (gnus-kill-or-deaden-summary kill-buffer))
2750 ;; Show first unread article if requested.
2751 (if (and (not no-article)
2753 gnus-newsgroup-unreads
2754 gnus-auto-select-first)
2755 (unless (if (eq gnus-auto-select-first 'best)
2756 (gnus-summary-best-unread-article)
2757 (gnus-summary-first-unread-article))
2758 (gnus-configure-windows 'summary))
2759 ;; Don't select any articles, just move point to the first
2760 ;; article in the group.
2761 (goto-char (point-min))
2762 (gnus-summary-position-point)
2763 (gnus-configure-windows 'summary 'force)
2764 (gnus-set-mode-line 'summary))
2765 (when (get-buffer-window gnus-group-buffer t)
2766 ;; Gotta use windows, because recenter does weird stuff if
2767 ;; the current buffer ain't the displayed window.
2768 (let ((owin (selected-window)))
2769 (select-window (get-buffer-window gnus-group-buffer t))
2770 (when (gnus-group-goto-group group)
2772 (select-window owin)))
2773 ;; Mark this buffer as "prepared".
2774 (setq gnus-newsgroup-prepared t)
2775 (gnus-run-hooks 'gnus-summary-prepared-hook)
2778 (defun gnus-summary-prepare ()
2779 "Generate the summary buffer."
2781 (let ((buffer-read-only nil))
2783 (setq gnus-newsgroup-data nil
2784 gnus-newsgroup-data-reverse nil)
2785 (gnus-run-hooks 'gnus-summary-generate-hook)
2786 ;; Generate the buffer, either with threads or without.
2787 (when gnus-newsgroup-headers
2788 (gnus-summary-prepare-threads
2789 (if gnus-show-threads
2790 (gnus-sort-gathered-threads
2791 (funcall gnus-summary-thread-gathering-function
2793 (gnus-cut-threads (gnus-make-threads)))))
2794 ;; Unthreaded display.
2795 (gnus-sort-articles gnus-newsgroup-headers))))
2796 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
2797 ;; Call hooks for modifying summary buffer.
2798 (goto-char (point-min))
2799 (gnus-run-hooks 'gnus-summary-prepare-hook)))
2801 (defsubst gnus-general-simplify-subject (subject)
2802 "Simply subject by the same rules as gnus-gather-threads-by-subject."
2805 ;; Truncate the subject.
2806 (gnus-simplify-subject-functions
2807 (gnus-map-function gnus-simplify-subject-functions subject))
2808 ((numberp gnus-summary-gather-subject-limit)
2809 (setq subject (gnus-simplify-subject-re subject))
2810 (if (> (length subject) gnus-summary-gather-subject-limit)
2811 (substring subject 0 gnus-summary-gather-subject-limit)
2813 ;; Fuzzily simplify it.
2814 ((eq 'fuzzy gnus-summary-gather-subject-limit)
2815 (gnus-simplify-subject-fuzzy subject))
2816 ;; Just remove the leading "Re:".
2818 (gnus-simplify-subject-re subject))))
2820 (if (and gnus-summary-gather-exclude-subject
2821 (string-match gnus-summary-gather-exclude-subject subject))
2822 nil ; This article shouldn't be gathered
2825 (defun gnus-summary-simplify-subject-query ()
2826 "Query where the respool algorithm would put this article."
2828 (gnus-summary-select-article)
2829 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
2831 (defun gnus-gather-threads-by-subject (threads)
2832 "Gather threads by looking at Subject headers."
2833 (if (not gnus-summary-make-false-root)
2835 (let ((hashtb (gnus-make-hashtable 1024))
2838 subject hthread whole-subject)
2840 (setq subject (gnus-general-simplify-subject
2841 (setq whole-subject (mail-header-subject
2844 (if (setq hthread (gnus-gethash subject hashtb))
2846 ;; We enter a dummy root into the thread, if we
2847 ;; haven't done that already.
2848 (unless (stringp (caar hthread))
2849 (setcar hthread (list whole-subject (car hthread))))
2850 ;; We add this new gathered thread to this gathered
2852 (setcdr (car hthread)
2853 (nconc (cdar hthread) (list (car threads))))
2854 ;; Remove it from the list of threads.
2855 (setcdr prev (cdr threads))
2856 (setq threads prev))
2857 ;; Enter this thread into the hash table.
2858 (gnus-sethash subject threads hashtb)))
2860 (setq threads (cdr threads)))
2863 (defun gnus-gather-threads-by-references (threads)
2864 "Gather threads by looking at References headers."
2865 (let ((idhashtb (gnus-make-hashtable 1024))
2866 (thhashtb (gnus-make-hashtable 1024))
2869 ids references id gthread gid entered ref)
2871 (when (setq references (mail-header-references (caar threads)))
2872 (setq id (mail-header-id (caar threads))
2873 ids (gnus-split-references references)
2875 (while (setq ref (pop ids))
2876 (setq ids (delete ref ids))
2877 (if (not (setq gid (gnus-gethash ref idhashtb)))
2879 (gnus-sethash ref id idhashtb)
2880 (gnus-sethash id threads thhashtb))
2881 (setq gthread (gnus-gethash gid thhashtb))
2883 ;; We enter a dummy root into the thread, if we
2884 ;; haven't done that already.
2885 (unless (stringp (caar gthread))
2886 (setcar gthread (list (mail-header-subject (caar gthread))
2888 ;; We add this new gathered thread to this gathered
2890 (setcdr (car gthread)
2891 (nconc (cdar gthread) (list (car threads)))))
2892 ;; Add it into the thread hash table.
2893 (gnus-sethash id gthread thhashtb)
2895 ;; Remove it from the list of threads.
2896 (setcdr prev (cdr threads))
2897 (setq threads prev))))
2899 (setq threads (cdr threads)))
2902 (defun gnus-sort-gathered-threads (threads)
2903 "Sort subtreads inside each gathered thread by article number."
2904 (let ((result threads))
2906 (when (stringp (caar threads))
2907 (setcdr (car threads)
2908 (sort (cdar threads) 'gnus-thread-sort-by-number)))
2909 (setq threads (cdr threads)))
2912 (defun gnus-thread-loop-p (root thread)
2913 "Say whether ROOT is in THREAD."
2914 (let ((stack (list thread))
2917 (while (setq thread (pop stack))
2918 (setq th (cdr thread))
2920 (not (eq (caar th) root)))
2923 ;; We have found a loop.
2925 (setcdr thread (delq (car th) (cdr thread)))
2926 (if (boundp (setq ref-dep (intern "none"
2927 gnus-newsgroup-dependencies)))
2928 (setcdr (symbol-value ref-dep)
2929 (nconc (cdr (symbol-value ref-dep))
2931 (set ref-dep (list nil (car th))))
2934 ;; Push all the subthreads onto the stack.
2935 (push (cdr thread) stack)))
2938 (defun gnus-make-threads ()
2939 "Go through the dependency hashtb and find the roots. Return all threads."
2941 (while (catch 'infloop
2944 ;; Deal with self-referencing References loops.
2945 (when (and (car (symbol-value refs))
2952 (car (symbol-value refs)) thread))
2953 (cdr (symbol-value refs)))))))
2956 (unless (car (symbol-value refs))
2957 ;; These threads do not refer back to any other articles,
2958 ;; so they're roots.
2959 (setq threads (append (cdr (symbol-value refs)) threads))))
2960 gnus-newsgroup-dependencies)))
2963 (defun gnus-build-sparse-threads ()
2964 (let ((headers gnus-newsgroup-headers)
2965 (deps gnus-newsgroup-dependencies)
2966 header references generation relations
2967 cthread subject child end pthread relation new-child)
2968 ;; First we create an alist of generations/relations, where
2969 ;; generations is how much we trust the relation, and the relation
2971 (gnus-message 7 "Making sparse threads...")
2973 (nnheader-set-temp-buffer " *gnus sparse threads*")
2974 (while (setq header (pop headers))
2975 (when (and (setq references (mail-header-references header))
2976 (not (string= references "")))
2978 (setq child (mail-header-id header)
2979 subject (mail-header-subject header))
2981 (while (search-backward ">" nil t)
2982 (setq end (1+ (point)))
2983 (when (search-backward "<" nil t)
2984 (unless (string= (setq new-child (buffer-substring (point) end))
2986 (push (list (incf generation)
2987 child (setq child new-child)
2990 (push (list (1+ generation) child nil subject) relations)
2992 (kill-buffer (current-buffer)))
2993 ;; Sort over trustworthiness.
2994 (setq relations (sort relations 'car-less-than-car))
2995 (while (setq relation (pop relations))
2996 (when (if (boundp (setq cthread (intern (cadr relation) deps)))
2997 (unless (car (symbol-value cthread))
2998 ;; Make this article the parent of these threads.
2999 (setcar (symbol-value cthread)
3000 (vector gnus-reffed-article-number
3004 (or (caddr relation) "") 0 0 "")))
3005 (set cthread (list (vector gnus-reffed-article-number
3007 "" "" (cadr relation)
3008 (or (caddr relation) "") 0 0 ""))))
3009 (push gnus-reffed-article-number gnus-newsgroup-limit)
3010 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3011 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3012 gnus-newsgroup-reads)
3013 (decf gnus-reffed-article-number)
3014 ;; Make this new thread the child of its parent.
3015 (if (boundp (setq pthread (intern (or (caddr relation) "none") deps)))
3016 (setcdr (symbol-value pthread)
3017 (nconc (cdr (symbol-value pthread))
3018 (list (symbol-value cthread))))
3019 (set pthread (list nil (symbol-value cthread))))))
3020 (gnus-message 7 "Making sparse threads...done")))
3022 (defun gnus-build-old-threads ()
3023 ;; Look at all the articles that refer back to old articles, and
3024 ;; fetch the headers for the articles that aren't there. This will
3025 ;; build complete threads - if the roots haven't been expired by the
3030 (when (not (car (symbol-value refs)))
3031 (setq heads (cdr (symbol-value refs)))
3033 (if (memq (mail-header-number (caar heads))
3034 gnus-newsgroup-dormant)
3035 (setq heads (cdr heads))
3036 (setq id (symbol-name refs))
3037 (while (and (setq id (gnus-build-get-header id))
3038 (not (car (gnus-gethash
3039 id gnus-newsgroup-dependencies)))))
3040 (setq heads nil)))))
3041 gnus-newsgroup-dependencies)))
3043 (defun gnus-build-get-header (id)
3044 ;; Look through the buffer of NOV lines and find the header to
3045 ;; ID. Enter this line into the dependencies hash table, and return
3046 ;; the id of the parent article (if any).
3047 (let ((deps gnus-newsgroup-dependencies)
3051 (set-buffer nntp-server-buffer)
3052 (let ((case-fold-search nil))
3053 (goto-char (point-min))
3054 (while (and (not found)
3055 (search-forward id nil t))
3057 (setq found (looking-at
3058 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3059 (regexp-quote id))))
3060 (or found (beginning-of-line 2)))
3064 (setq header (gnus-nov-parse-line
3065 (read (current-buffer)) deps))
3066 (gnus-parent-id (mail-header-references header))))))
3068 (let ((number (mail-header-number header)))
3069 (push number gnus-newsgroup-limit)
3070 (push header gnus-newsgroup-headers)
3071 (if (memq number gnus-newsgroup-unselected)
3073 (push number gnus-newsgroup-unreads)
3074 (setq gnus-newsgroup-unselected
3075 (delq number gnus-newsgroup-unselected)))
3076 (push number gnus-newsgroup-ancient)))))))
3078 (defun gnus-build-all-threads ()
3079 "Read all the headers."
3080 (let ((deps gnus-newsgroup-dependencies)
3081 (gnus-summary-ignore-duplicates t)
3082 found header article)
3084 (set-buffer nntp-server-buffer)
3085 (let ((case-fold-search nil))
3086 (goto-char (point-min))
3089 (setq article (read (current-buffer)))
3090 (setq header (gnus-nov-parse-line article deps)))
3092 (push header gnus-newsgroup-headers)
3093 (if (memq (setq article (mail-header-number header))
3094 gnus-newsgroup-unselected)
3096 (push article gnus-newsgroup-unreads)
3097 (setq gnus-newsgroup-unselected
3098 (delq article gnus-newsgroup-unselected)))
3099 (push article gnus-newsgroup-ancient))
3100 (forward-line 1)))))))
3102 (defun gnus-summary-update-article-line (article header)
3103 "Update the line for ARTICLE using HEADERS."
3104 (let* ((id (mail-header-id header))
3105 (thread (gnus-id-to-thread id)))
3107 (error "Article in no thread"))
3108 ;; Update the thread.
3109 (setcar thread header)
3110 (gnus-summary-goto-subject article)
3111 (let* ((datal (gnus-data-find-list article))
3113 (length (when (cdr datal)
3114 (- (gnus-data-pos data)
3115 (gnus-data-pos (cadr datal)))))
3116 (buffer-read-only nil)
3117 (level (gnus-summary-thread-level)))
3119 (gnus-summary-insert-line
3120 header level nil (gnus-article-mark article)
3121 (memq article gnus-newsgroup-replied)
3122 (memq article gnus-newsgroup-expirable)
3123 ;; Only insert the Subject string when it's different
3124 ;; from the previous Subject string.
3125 (if (gnus-subject-equal
3127 (mail-header-subject
3130 (gnus-data-find-list
3132 (gnus-data-list t)))))
3133 ;; Error on the side of excessive subjects.
3135 (mail-header-subject header))
3137 (mail-header-subject header))
3138 nil (cdr (assq article gnus-newsgroup-scored))
3139 (memq article gnus-newsgroup-processable))
3141 (gnus-data-update-list
3142 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3144 (defun gnus-summary-update-article (article &optional iheader)
3145 "Update ARTICLE in the summary buffer."
3146 (set-buffer gnus-summary-buffer)
3147 (let* ((header (or iheader (gnus-summary-article-header article)))
3148 (id (mail-header-id header))
3149 (data (gnus-data-find article))
3150 (thread (gnus-id-to-thread id))
3151 (references (mail-header-references header))
3155 (when (and references
3156 (not (equal "" references)))
3159 (buffer-read-only nil)
3161 (number (mail-header-number header))
3164 ;; !!! Should this be in or not?
3166 (setcar thread nil))
3168 (delq thread parent))
3169 (if (gnus-summary-insert-subject id header iheader)
3170 ;; Set the (possibly) new article number in the data structure.
3171 (gnus-data-set-number data (gnus-id-to-article id))
3175 (defun gnus-rebuild-thread (id)
3176 "Rebuild the thread containing ID."
3177 (let ((buffer-read-only nil)
3178 old-pos current thread data)
3179 (if (not gnus-show-threads)
3180 (setq thread (list (car (gnus-id-to-thread id))))
3181 ;; Get the thread this article is part of.
3182 (setq thread (gnus-remove-thread id)))
3183 (setq old-pos (gnus-point-at-bol))
3184 (setq current (save-excursion
3185 (and (zerop (forward-line -1))
3186 (gnus-summary-article-number))))
3187 ;; If this is a gathered thread, we have to go some re-gathering.
3188 (when (stringp (car thread))
3189 (let ((subject (car thread))
3191 (setq thread (cdr thread))
3193 (unless (memq (setq thr (gnus-id-to-thread
3195 (mail-header-id (caar thread)))))
3198 (setq thread (cdr thread)))
3199 ;; We now have all (unique) roots.
3200 (if (= (length roots) 1)
3201 ;; All the loose roots are now one solid root.
3202 (setq thread (car roots))
3203 (setq thread (cons subject (gnus-sort-threads roots))))))
3205 ;; We then insert this thread into the summary buffer.
3206 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3207 (if gnus-show-threads
3208 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3209 (gnus-summary-prepare-unthreaded thread))
3210 (setq data (nreverse gnus-newsgroup-data))
3211 (setq threads gnus-newsgroup-threads))
3212 ;; We splice the new data into the data structure.
3213 (gnus-data-enter-list current data (- (point) old-pos))
3214 (setq gnus-newsgroup-threads (nconc threads gnus-newsgroup-threads)))))
3216 (defun gnus-number-to-header (number)
3217 "Return the header for article NUMBER."
3218 (let ((headers gnus-newsgroup-headers))
3220 (not (= number (mail-header-number (car headers)))))
3225 (defun gnus-parent-headers (headers &optional generation)
3226 "Return the headers of the GENERATIONeth parent of HEADERS."
3228 (setq generation 1))
3231 (while (and parent headers (not (zerop generation)))
3232 (setq references (mail-header-references headers))
3233 (when (and references
3234 (setq parent (gnus-parent-id references))
3235 (setq headers (car (gnus-id-to-thread parent))))
3239 (defun gnus-id-to-thread (id)
3240 "Return the (sub-)thread where ID appears."
3241 (gnus-gethash id gnus-newsgroup-dependencies))
3243 (defun gnus-id-to-article (id)
3244 "Return the article number of ID."
3245 (let ((thread (gnus-id-to-thread id)))
3248 (mail-header-number (car thread)))))
3250 (defun gnus-id-to-header (id)
3251 "Return the article headers of ID."
3252 (car (gnus-id-to-thread id)))
3254 (defun gnus-article-displayed-root-p (article)
3255 "Say whether ARTICLE is a root(ish) article."
3256 (let ((level (gnus-summary-thread-level article))
3257 (refs (mail-header-references (gnus-summary-article-header article)))
3263 ((null (gnus-parent-id refs)) t)
3265 (null (setq particle (gnus-id-to-article
3266 (gnus-parent-id refs))))
3267 (null (gnus-summary-thread-level particle)))))))
3269 (defun gnus-root-id (id)
3270 "Return the id of the root of the thread where ID appears."
3272 (while (and id (setq prev (car (gnus-gethash
3273 id gnus-newsgroup-dependencies))))
3275 id (gnus-parent-id (mail-header-references prev))))
3278 (defun gnus-articles-in-thread (thread)
3279 "Return the list of articles in THREAD."
3280 (cons (mail-header-number (car thread))
3281 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
3283 (defun gnus-remove-thread (id &optional dont-remove)
3284 "Remove the thread that has ID in it."
3285 (let ((dep gnus-newsgroup-dependencies)
3286 headers thread last-id)
3287 ;; First go up in this thread until we find the root.
3288 (setq last-id (gnus-root-id id))
3289 (setq headers (list (car (gnus-id-to-thread last-id))
3290 (caadr (gnus-id-to-thread last-id))))
3291 ;; We have now found the real root of this thread. It might have
3292 ;; been gathered into some loose thread, so we have to search
3293 ;; through the threads to find the thread we wanted.
3294 (let ((threads gnus-newsgroup-threads)
3297 (setq sub (car threads))
3298 (if (stringp (car sub))
3299 ;; This is a gathered thread, so we look at the roots
3300 ;; below it to find whether this article is in this
3303 (setq sub (cdr sub))
3305 (when (member (caar sub) headers)
3306 (setq thread (car threads)
3309 (setq sub (cdr sub))))
3310 ;; It's an ordinary thread, so we check it.
3311 (when (eq (car sub) (car headers))
3314 (setq threads (cdr threads)))
3315 ;; If this article is in no thread, then it's a root.
3318 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
3319 (setq thread (gnus-gethash last-id dep)))
3322 thread ; We return this thread.
3324 (if (stringp (car thread))
3326 ;; If we use dummy roots, then we have to remove the
3327 ;; dummy root as well.
3328 (when (eq gnus-summary-make-false-root 'dummy)
3330 (gnus-data-compute-positions))
3331 (setq thread (cdr thread))
3333 (gnus-remove-thread-1 (car thread))
3334 (setq thread (cdr thread))))
3335 (gnus-remove-thread-1 thread))))))))
3337 (defun gnus-remove-thread-1 (thread)
3338 "Remove the thread THREAD recursively."
3339 (let ((number (mail-header-number (pop thread)))
3341 (setq thread (reverse thread))
3343 (gnus-remove-thread-1 (pop thread)))
3344 (when (setq d (gnus-data-find number))
3345 (goto-char (gnus-data-pos d))
3348 (- (gnus-point-at-bol)
3350 (1+ (gnus-point-at-eol))
3351 (gnus-delete-line)))))))
3353 (defun gnus-sort-threads (threads)
3355 (if (not gnus-thread-sort-functions)
3357 (gnus-message 7 "Sorting threads...")
3359 (sort threads (gnus-make-sort-function gnus-thread-sort-functions))
3360 (gnus-message 7 "Sorting threads...done"))))
3362 (defun gnus-sort-articles (articles)
3364 (when gnus-article-sort-functions
3365 (gnus-message 7 "Sorting articles...")
3367 (setq gnus-newsgroup-headers
3368 (sort articles (gnus-make-sort-function
3369 gnus-article-sort-functions)))
3370 (gnus-message 7 "Sorting articles...done"))))
3372 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3373 (defmacro gnus-thread-header (thread)
3374 ;; Return header of first article in THREAD.
3375 ;; Note that THREAD must never, ever be anything else than a variable -
3376 ;; using some other form will lead to serious barfage.
3377 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
3378 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
3379 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
3382 (defsubst gnus-article-sort-by-number (h1 h2)
3383 "Sort articles by article number."
3384 (< (mail-header-number h1)
3385 (mail-header-number h2)))
3387 (defun gnus-thread-sort-by-number (h1 h2)
3388 "Sort threads by root article number."
3389 (gnus-article-sort-by-number
3390 (gnus-thread-header h1) (gnus-thread-header h2)))
3392 (defsubst gnus-article-sort-by-lines (h1 h2)
3393 "Sort articles by article Lines header."
3394 (< (mail-header-lines h1)
3395 (mail-header-lines h2)))
3397 (defun gnus-thread-sort-by-lines (h1 h2)
3398 "Sort threads by root article Lines header."
3399 (gnus-article-sort-by-lines
3400 (gnus-thread-header h1) (gnus-thread-header h2)))
3402 (defsubst gnus-article-sort-by-author (h1 h2)
3403 "Sort articles by root author."
3405 (let ((extract (funcall
3406 gnus-extract-address-components
3407 (mail-header-from h1))))
3408 (or (car extract) (cadr extract) ""))
3409 (let ((extract (funcall
3410 gnus-extract-address-components
3411 (mail-header-from h2))))
3412 (or (car extract) (cadr extract) ""))))
3414 (defun gnus-thread-sort-by-author (h1 h2)
3415 "Sort threads by root author."
3416 (gnus-article-sort-by-author
3417 (gnus-thread-header h1) (gnus-thread-header h2)))
3419 (defsubst gnus-article-sort-by-subject (h1 h2)
3420 "Sort articles by root subject."
3422 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
3423 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
3425 (defun gnus-thread-sort-by-subject (h1 h2)
3426 "Sort threads by root subject."
3427 (gnus-article-sort-by-subject
3428 (gnus-thread-header h1) (gnus-thread-header h2)))
3430 (defsubst gnus-article-sort-by-date (h1 h2)
3431 "Sort articles by root article date."
3433 (gnus-date-get-time (mail-header-date h1))
3434 (gnus-date-get-time (mail-header-date h2))))
3436 (defun gnus-thread-sort-by-date (h1 h2)
3437 "Sort threads by root article date."
3438 (gnus-article-sort-by-date
3439 (gnus-thread-header h1) (gnus-thread-header h2)))
3441 (defsubst gnus-article-sort-by-score (h1 h2)
3442 "Sort articles by root article score.
3443 Unscored articles will be counted as having a score of zero."
3444 (> (or (cdr (assq (mail-header-number h1)
3445 gnus-newsgroup-scored))
3446 gnus-summary-default-score 0)
3447 (or (cdr (assq (mail-header-number h2)
3448 gnus-newsgroup-scored))
3449 gnus-summary-default-score 0)))
3451 (defun gnus-thread-sort-by-score (h1 h2)
3452 "Sort threads by root article score."
3453 (gnus-article-sort-by-score
3454 (gnus-thread-header h1) (gnus-thread-header h2)))
3456 (defun gnus-thread-sort-by-total-score (h1 h2)
3457 "Sort threads by the sum of all scores in the thread.
3458 Unscored articles will be counted as having a score of zero."
3459 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
3461 (defun gnus-thread-total-score (thread)
3462 ;; This function find the total score of THREAD.
3463 (cond ((null thread)
3466 (if (stringp (car thread))
3467 (apply gnus-thread-score-function 0
3468 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
3469 (gnus-thread-total-score-1 thread)))
3471 (gnus-thread-total-score-1 (list thread)))))
3473 (defun gnus-thread-total-score-1 (root)
3474 ;; This function find the total score of the thread below ROOT.
3475 (setq root (car root))
3476 (apply gnus-thread-score-function
3478 (mapcar 'gnus-thread-total-score
3479 (cdr (gnus-gethash (mail-header-id root)
3480 gnus-newsgroup-dependencies)))
3481 (when (> (mail-header-number root) 0)
3482 (list (or (cdr (assq (mail-header-number root)
3483 gnus-newsgroup-scored))
3484 gnus-summary-default-score 0))))
3485 (list gnus-summary-default-score)
3488 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
3489 (defvar gnus-tmp-prev-subject nil)
3490 (defvar gnus-tmp-false-parent nil)
3491 (defvar gnus-tmp-root-expunged nil)
3492 (defvar gnus-tmp-dummy-line nil)
3494 (defun gnus-summary-prepare-threads (threads)
3495 "Prepare summary buffer from THREADS and indentation LEVEL.
3496 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
3497 or a straight list of headers."
3498 (gnus-message 7 "Generating summary...")
3500 (setq gnus-newsgroup-threads threads)
3503 (let ((gnus-tmp-level 0)
3504 (default-score (or gnus-summary-default-score 0))
3505 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
3506 thread number subject stack state gnus-tmp-gathered beg-match
3507 new-roots gnus-tmp-new-adopts thread-end
3508 gnus-tmp-header gnus-tmp-unread
3509 gnus-tmp-replied gnus-tmp-subject-or-nil
3510 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
3511 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
3512 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
3514 (setq gnus-tmp-prev-subject nil)
3516 (if (vectorp (car threads))
3517 ;; If this is a straight (sic) list of headers, then a
3518 ;; threaded summary display isn't required, so we just create
3519 ;; an unthreaded one.
3520 (gnus-summary-prepare-unthreaded threads)
3522 ;; Do the threaded display.
3524 (while (or threads stack gnus-tmp-new-adopts new-roots)
3526 (if (and (= gnus-tmp-level 0)
3527 (not (setq gnus-tmp-dummy-line nil))
3530 (not gnus-tmp-false-parent)
3531 (or gnus-tmp-new-adopts new-roots))
3532 (if gnus-tmp-new-adopts
3533 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
3534 thread (list (car gnus-tmp-new-adopts))
3535 gnus-tmp-header (caar thread)
3536 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
3538 (setq thread (list (car new-roots))
3539 gnus-tmp-header (caar thread)
3540 new-roots (cdr new-roots))))
3543 ;; If there are some threads, we do them before the
3544 ;; threads on the stack.
3545 (setq thread threads
3546 gnus-tmp-header (caar thread))
3547 ;; There were no current threads, so we pop something off
3549 (setq state (car stack)
3550 gnus-tmp-level (car state)
3553 gnus-tmp-header (caar thread))))
3555 (setq gnus-tmp-false-parent nil)
3556 (setq gnus-tmp-root-expunged nil)
3557 (setq thread-end nil)
3559 (if (stringp gnus-tmp-header)
3560 ;; The header is a dummy root.
3562 ((eq gnus-summary-make-false-root 'adopt)
3563 ;; We let the first article adopt the rest.
3564 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
3566 (setq gnus-tmp-gathered
3568 (lambda (h) (mail-header-number (car h)))
3571 (setq thread (cons (list (caar thread)
3574 (setq gnus-tmp-level -1
3575 gnus-tmp-false-parent t))
3576 ((eq gnus-summary-make-false-root 'empty)
3577 ;; We print adopted articles with empty subject fields.
3578 (setq gnus-tmp-gathered
3580 (lambda (h) (mail-header-number (car h)))
3583 (setq gnus-tmp-level -1))
3584 ((eq gnus-summary-make-false-root 'dummy)
3585 ;; We remember that we probably want to output a dummy
3587 (setq gnus-tmp-dummy-line gnus-tmp-header)
3588 (setq gnus-tmp-prev-subject gnus-tmp-header))
3590 ;; We do not make a root for the gathered
3591 ;; sub-threads at all.
3592 (setq gnus-tmp-level -1)))
3594 (setq number (mail-header-number gnus-tmp-header)
3595 subject (mail-header-subject gnus-tmp-header))
3598 ;; If the thread has changed subject, we might want to make
3599 ;; this subthread into a root.
3600 ((and (null gnus-thread-ignore-subject)
3601 (not (zerop gnus-tmp-level))
3602 gnus-tmp-prev-subject
3604 (gnus-subject-equal gnus-tmp-prev-subject subject))))
3605 (setq new-roots (nconc new-roots (list (car thread)))
3607 gnus-tmp-header nil))
3608 ;; If the article lies outside the current limit,
3609 ;; then we do not display it.
3610 ((not (memq number gnus-newsgroup-limit))
3611 (setq gnus-tmp-gathered
3613 (lambda (h) (mail-header-number (car h)))
3616 (setq gnus-tmp-new-adopts (if (cdar thread)
3617 (append gnus-tmp-new-adopts
3619 gnus-tmp-new-adopts)
3621 gnus-tmp-header nil)
3622 (when (zerop gnus-tmp-level)
3623 (setq gnus-tmp-root-expunged t)))
3624 ;; Perhaps this article is to be marked as read?
3625 ((and gnus-summary-mark-below
3626 (< (or (cdr (assq number gnus-newsgroup-scored))
3628 gnus-summary-mark-below)
3629 ;; Don't touch sparse articles.
3630 (not (gnus-summary-article-sparse-p number))
3631 (not (gnus-summary-article-ancient-p number)))
3632 (setq gnus-newsgroup-unreads
3633 (delq number gnus-newsgroup-unreads))
3634 (if gnus-newsgroup-auto-expire
3635 (push number gnus-newsgroup-expirable)
3636 (push (cons number gnus-low-score-mark)
3637 gnus-newsgroup-reads))))
3639 (when gnus-tmp-header
3640 ;; We may have an old dummy line to output before this
3642 (when gnus-tmp-dummy-line
3643 (gnus-summary-insert-dummy-line
3644 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
3645 (setq gnus-tmp-dummy-line nil))
3647 ;; Compute the mark.
3648 (setq gnus-tmp-unread (gnus-article-mark number))
3650 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
3651 gnus-tmp-header gnus-tmp-level)
3652 gnus-newsgroup-data)
3654 ;; Actually insert the line.
3656 gnus-tmp-subject-or-nil
3658 ((and gnus-thread-ignore-subject
3659 gnus-tmp-prev-subject
3660 (not (inline (gnus-subject-equal
3661 gnus-tmp-prev-subject subject))))
3663 ((zerop gnus-tmp-level)
3664 (if (and (eq gnus-summary-make-false-root 'empty)
3665 (memq number gnus-tmp-gathered)
3666 gnus-tmp-prev-subject
3667 (inline (gnus-subject-equal
3668 gnus-tmp-prev-subject subject)))
3669 gnus-summary-same-subject
3671 (t gnus-summary-same-subject)))
3672 (if (and (eq gnus-summary-make-false-root 'adopt)
3673 (= gnus-tmp-level 1)
3674 (memq number gnus-tmp-gathered))
3675 (setq gnus-tmp-opening-bracket ?\<
3676 gnus-tmp-closing-bracket ?\>)
3677 (setq gnus-tmp-opening-bracket ?\[
3678 gnus-tmp-closing-bracket ?\]))
3680 gnus-tmp-indentation
3681 (aref gnus-thread-indent-array gnus-tmp-level)
3682 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
3683 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
3684 gnus-summary-default-score 0)
3686 (if (or (null gnus-summary-default-score)
3687 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3688 gnus-summary-zcore-fuzz))
3690 (if (< gnus-tmp-score gnus-summary-default-score)
3691 gnus-score-below-mark gnus-score-over-mark))
3693 (cond ((memq number gnus-newsgroup-processable)
3695 ((memq number gnus-newsgroup-cached)
3697 ((memq number gnus-newsgroup-replied)
3699 ((memq number gnus-newsgroup-saved)
3701 (t gnus-unread-mark))
3702 gnus-tmp-from (mail-header-from gnus-tmp-header)
3705 ((string-match "<[^>]+> *$" gnus-tmp-from)
3706 (setq beg-match (match-beginning 0))
3707 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
3708 (substring gnus-tmp-from (1+ (match-beginning 0))
3709 (1- (match-end 0))))
3710 (substring gnus-tmp-from 0 beg-match)))
3711 ((string-match "(.+)" gnus-tmp-from)
3712 (substring gnus-tmp-from
3713 (1+ (match-beginning 0)) (1- (match-end 0))))
3715 (when (string= gnus-tmp-name "")
3716 (setq gnus-tmp-name gnus-tmp-from))
3717 (unless (numberp gnus-tmp-lines)
3718 (setq gnus-tmp-lines 0))
3719 (gnus-put-text-property
3721 (progn (eval gnus-summary-line-format-spec) (point))
3722 'gnus-number number)
3725 (gnus-run-hooks 'gnus-summary-update-hook)
3728 (setq gnus-tmp-prev-subject subject)))
3730 (when (nth 1 thread)
3731 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
3732 (incf gnus-tmp-level)
3733 (setq threads (if thread-end nil (cdar thread)))
3735 (setq gnus-tmp-level 0)))))
3736 (gnus-message 7 "Generating summary...done"))
3738 (defun gnus-summary-prepare-unthreaded (headers)
3739 "Generate an unthreaded summary buffer based on HEADERS."
3740 (let (header number mark)
3745 ;; We may have to root out some bad articles...
3746 (when (memq (setq number (mail-header-number
3747 (setq header (pop headers))))
3748 gnus-newsgroup-limit)
3749 ;; Mark article as read when it has a low score.
3750 (when (and gnus-summary-mark-below
3751 (< (or (cdr (assq number gnus-newsgroup-scored))
3752 gnus-summary-default-score 0)
3753 gnus-summary-mark-below)
3754 (not (gnus-summary-article-ancient-p number)))
3755 (setq gnus-newsgroup-unreads
3756 (delq number gnus-newsgroup-unreads))
3757 (if gnus-newsgroup-auto-expire
3758 (push number gnus-newsgroup-expirable)
3759 (push (cons number gnus-low-score-mark)
3760 gnus-newsgroup-reads)))
3762 (setq mark (gnus-article-mark number))
3763 (push (gnus-data-make number mark (1+ (point)) header 0)
3764 gnus-newsgroup-data)
3765 (gnus-summary-insert-line
3767 mark (memq number gnus-newsgroup-replied)
3768 (memq number gnus-newsgroup-expirable)
3769 (mail-header-subject header) nil
3770 (cdr (assq number gnus-newsgroup-scored))
3771 (memq number gnus-newsgroup-processable))))))
3773 (defun gnus-select-newsgroup (group &optional read-all)
3774 "Select newsgroup GROUP.
3775 If READ-ALL is non-nil, all articles in the group are selected."
3776 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
3777 ;;!!! Dirty hack; should be removed.
3778 (gnus-summary-ignore-duplicates
3779 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
3781 gnus-summary-ignore-duplicates))
3782 (info (nth 2 entry))
3783 articles fetched-articles cached)
3785 (unless (gnus-check-server
3786 (setq gnus-current-select-method
3787 (gnus-find-method-for-group group)))
3788 (error "Couldn't open server"))
3790 (or (and entry (not (eq (car entry) t))) ; Either it's active...
3791 (gnus-activate-group group) ; Or we can activate it...
3792 (progn ; Or we bug out.
3793 (when (equal major-mode 'gnus-summary-mode)
3794 (kill-buffer (current-buffer)))
3795 (error "Couldn't request group %s: %s"
3796 group (gnus-status-message group))))
3798 (unless (gnus-request-group group t)
3799 (when (equal major-mode 'gnus-summary-mode)
3800 (kill-buffer (current-buffer)))
3801 (error "Couldn't request group %s: %s"
3802 group (gnus-status-message group)))
3804 (setq gnus-newsgroup-name group)
3805 (setq gnus-newsgroup-unselected nil)
3806 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
3808 ;; Adjust and set lists of article marks.
3810 (gnus-adjust-marked-articles info))
3812 ;; Kludge to avoid having cached articles nixed out in virtual groups.
3813 (when (gnus-virtual-group-p group)
3814 (setq cached gnus-newsgroup-cached))
3816 (setq gnus-newsgroup-unreads
3817 (gnus-set-difference
3818 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
3819 gnus-newsgroup-dormant))
3821 (setq gnus-newsgroup-processable nil)
3823 (gnus-update-read-articles group gnus-newsgroup-unreads)
3824 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
3825 (gnus-group-update-group group))
3827 (setq articles (gnus-articles-to-read group read-all))
3831 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
3833 ((eq articles 0) nil)
3835 ;; Init the dependencies hash table.
3836 (setq gnus-newsgroup-dependencies
3837 (gnus-make-hashtable (length articles)))
3838 ;; Retrieve the headers and read them in.
3839 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
3840 (setq gnus-newsgroup-headers
3842 (setq gnus-headers-retrieved-by
3843 (gnus-retrieve-headers
3844 articles gnus-newsgroup-name
3845 ;; We might want to fetch old headers, but
3846 ;; not if there is only 1 article.
3847 (and gnus-fetch-old-headers
3849 (not (eq gnus-fetch-old-headers 'some))
3850 (not (numberp gnus-fetch-old-headers)))
3851 (> (length articles) 1))))))
3852 (gnus-get-newsgroup-headers-xover
3853 articles nil nil gnus-newsgroup-name t)
3854 (gnus-get-newsgroup-headers)))
3855 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
3857 ;; Kludge to avoid having cached articles nixed out in virtual groups.
3859 (setq gnus-newsgroup-cached cached))
3861 ;; Suppress duplicates?
3862 (when gnus-suppress-duplicates
3863 (gnus-dup-suppress-articles))
3865 ;; Set the initial limit.
3866 (setq gnus-newsgroup-limit (copy-sequence articles))
3867 ;; Remove canceled articles from the list of unread articles.
3868 (setq gnus-newsgroup-unreads
3869 (gnus-set-sorted-intersection
3870 gnus-newsgroup-unreads
3871 (setq fetched-articles
3872 (mapcar (lambda (headers) (mail-header-number headers))
3873 gnus-newsgroup-headers))))
3874 ;; Removed marked articles that do not exist.
3875 (gnus-update-missing-marks
3876 (gnus-sorted-complement fetched-articles articles))
3877 ;; Let the Gnus agent mark articles as read.
3879 (gnus-agent-get-undownloaded-list))
3880 ;; We might want to build some more threads first.
3881 (when (and gnus-fetch-old-headers
3882 (eq gnus-headers-retrieved-by 'nov))
3883 (if (eq gnus-fetch-old-headers 'invisible)
3884 (gnus-build-all-threads)
3885 (gnus-build-old-threads)))
3886 ;; Check whether auto-expire is to be done in this group.
3887 (setq gnus-newsgroup-auto-expire
3888 (gnus-group-auto-expirable-p group))
3889 ;; Set up the article buffer now, if necessary.
3890 (unless gnus-single-article-buffer
3891 (gnus-article-setup-buffer))
3892 ;; First and last article in this newsgroup.
3893 (when gnus-newsgroup-headers
3894 (setq gnus-newsgroup-begin
3895 (mail-header-number (car gnus-newsgroup-headers))
3898 (gnus-last-element gnus-newsgroup-headers))))
3899 ;; GROUP is successfully selected.
3900 (or gnus-newsgroup-headers t)))))
3902 (defun gnus-articles-to-read (group &optional read-all)
3903 ;; Find out what articles the user wants to read.
3905 ;; Select all articles if `read-all' is non-nil, or if there
3906 ;; are no unread articles.
3908 (and (zerop (length gnus-newsgroup-marked))
3909 (zerop (length gnus-newsgroup-unreads)))
3910 (eq (gnus-group-find-parameter group 'display)
3912 (gnus-uncompress-range (gnus-active group))
3913 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
3914 (copy-sequence gnus-newsgroup-unreads))
3916 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
3917 (scored (length scored-list))
3918 (number (length articles))
3919 (marked (+ (length gnus-newsgroup-marked)
3920 (length gnus-newsgroup-dormant)))
3928 ((and (or (<= scored marked) (= scored number))
3929 (numberp gnus-large-newsgroup)
3930 (> number gnus-large-newsgroup))
3934 "How many articles from %s (default %d): "
3935 (gnus-limit-string gnus-newsgroup-name 35)
3937 (if (string-match "^[ \t]*$" input) number input)))
3938 ((and (> scored marked) (< scored number)
3939 (> (- scored number) 20))
3942 (format "%s %s (%d scored, %d total): "
3943 "How many articles from"
3944 group scored number))))
3945 (if (string-match "^[ \t]*$" input)
3949 (setq select (if (stringp select) (string-to-number select) select))
3950 (if (or (null select) (zerop select))
3952 (if (and (not (zerop scored)) (<= (abs select) scored))
3954 (setq articles (sort scored-list '<))
3955 (setq number (length articles)))
3956 (setq articles (copy-sequence articles)))
3958 (when (< (abs select) number)
3960 ;; Select the N oldest articles.
3961 (setcdr (nthcdr (1- (abs select)) articles) nil)
3962 ;; Select the N most recent articles.
3963 (setq articles (nthcdr (- number select) articles))))
3964 (setq gnus-newsgroup-unselected
3965 (gnus-sorted-intersection
3966 gnus-newsgroup-unreads
3967 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
3970 (defun gnus-killed-articles (killed articles)
3973 (when (inline (gnus-member-of-range (car articles) killed))
3974 (push (car articles) out))
3975 (setq articles (cdr articles)))
3978 (defun gnus-uncompress-marks (marks)
3979 "Uncompress the mark ranges in MARKS."
3980 (let ((uncompressed '(score bookmark))
3983 (if (memq (caar marks) uncompressed)
3984 (push (car marks) out)
3985 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
3986 (setq marks (cdr marks)))
3989 (defun gnus-adjust-marked-articles (info)
3990 "Set all article lists and remove all marks that are no longer legal."
3991 (let* ((marked-lists (gnus-info-marks info))
3992 (active (gnus-active (gnus-info-group info)))
3995 (types gnus-article-mark-lists)
3996 (uncompressed '(score bookmark killed))
3997 marks var articles article mark)
4000 (setq marks (pop marked-lists))
4001 (set (setq var (intern (format "gnus-newsgroup-%s"
4002 (car (rassq (setq mark (car marks))
4004 (if (memq (car marks) uncompressed) (cdr marks)
4005 (gnus-uncompress-range (cdr marks))))
4007 (setq articles (symbol-value var))
4009 ;; All articles have to be subsets of the active articles.
4011 ;; Adjust "simple" lists.
4012 ((memq mark '(tick dormant expire reply save))
4014 (when (or (< (setq article (pop articles)) min) (> article max))
4015 (set var (delq article (symbol-value var))))))
4017 ((memq mark uncompressed)
4018 (when (not (listp (cdr (symbol-value var))))
4019 (set var (list (symbol-value var))))
4020 (when (not (listp (cdr articles)))
4021 (setq articles (list articles)))
4023 (when (or (not (consp (setq article (pop articles))))
4024 (< (car article) min)
4025 (> (car article) max))
4026 (set var (delq article (symbol-value var))))))))))
4028 (defun gnus-update-missing-marks (missing)
4029 "Go through the list of MISSING articles and remove them from the mark lists."
4031 (let ((types gnus-article-mark-lists)
4033 ;; Go through all types.
4035 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
4036 (when (symbol-value var)
4037 ;; This list has articles. So we delete all missing articles
4041 (set var (delq (pop m) (symbol-value var)))))))))
4043 (defun gnus-update-marks ()
4044 "Enter the various lists of marked articles into the newsgroup info list."
4045 (let ((types gnus-article-mark-lists)
4046 (info (gnus-get-info gnus-newsgroup-name))
4047 (uncompressed '(score bookmark killed))
4048 type list newmarked symbol)
4050 ;; Add all marks lists that are non-nil to the list of marks lists.
4051 (while (setq type (pop types))
4052 (when (setq list (symbol-value
4054 (intern (format "gnus-newsgroup-%s"
4057 ;; Get rid of the entries of the articles that have the
4059 (when (and (eq (cdr type) 'score)
4063 (prev (cons nil list))
4066 (if (or (not (consp (car arts)))
4067 (= (cdar arts) gnus-summary-default-score))
4068 (setcdr prev (cdr arts))
4070 (setq arts (cdr arts)))
4071 (setq list (cdr all))))
4073 (push (cons (cdr type)
4074 (if (memq (cdr type) uncompressed) list
4075 (gnus-compress-sequence
4076 (set symbol (sort list '<)) t)))
4079 ;; Enter these new marks into the info of the group.
4081 (setcar (nthcdr 3 info) newmarked)
4082 ;; Add the marks lists to the end of the info.
4084 (setcdr (nthcdr 2 info) (list newmarked))))
4086 ;; Cut off the end of the info if there's nothing else there.
4090 (when (nthcdr (decf i) info)
4091 (setcdr (nthcdr i info) nil)))))))
4093 (defun gnus-set-mode-line (where)
4094 "This function sets the mode line of the article or summary buffers.
4095 If WHERE is `summary', the summary mode line format will be used."
4096 ;; Is this mode line one we keep updated?
4097 (when (memq where gnus-updated-mode-lines)
4100 ;; We evaluate this in the summary buffer since these
4101 ;; variables are buffer-local to that buffer.
4102 (set-buffer gnus-summary-buffer)
4103 ;; We bind all these variables that are used in the `eval' form
4105 (let* ((mformat (symbol-value
4107 (format "gnus-%s-mode-line-format-spec" where))))
4108 (gnus-tmp-group-name gnus-newsgroup-name)
4109 (gnus-tmp-article-number (or gnus-current-article 0))
4110 (gnus-tmp-unread gnus-newsgroup-unreads)
4111 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
4112 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
4113 (gnus-tmp-unread-and-unselected
4114 (cond ((and (zerop gnus-tmp-unread-and-unticked)
4115 (zerop gnus-tmp-unselected))
4117 ((zerop gnus-tmp-unselected)
4118 (format "{%d more}" gnus-tmp-unread-and-unticked))
4119 (t (format "{%d(+%d) more}"
4120 gnus-tmp-unread-and-unticked
4121 gnus-tmp-unselected))))
4123 (if (and gnus-current-headers
4124 (vectorp gnus-current-headers))
4125 (gnus-mode-string-quote
4126 (mail-header-subject gnus-current-headers))
4128 bufname-length max-len
4129 gnus-tmp-header);; passed as argument to any user-format-funcs
4130 (setq mode-string (eval mformat))
4131 (setq bufname-length (if (string-match "%b" mode-string)
4134 (if (eq where 'summary)
4136 (get-buffer gnus-article-buffer))))
4139 (setq max-len (max 4 (if gnus-mode-non-string-length
4141 gnus-mode-non-string-length
4143 (length mode-string))))
4144 ;; We might have to chop a bit of the string off...
4145 (when (> (length mode-string) max-len)
4147 (concat (gnus-truncate-string mode-string (- max-len 3))
4149 ;; Pad the mode string a bit.
4150 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
4151 ;; Update the mode line.
4152 (setq mode-line-buffer-identification
4153 (gnus-mode-line-buffer-identification (list mode-string)))
4154 (set-buffer-modified-p t))))
4156 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
4157 "Go through the HEADERS list and add all Xrefs to a hash table.
4158 The resulting hash table is returned, or nil if no Xrefs were found."
4159 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
4160 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
4161 (xref-hashtb (gnus-make-hashtable))
4162 start group entry number xrefs header)
4164 (setq header (pop headers))
4165 (when (and (setq xrefs (mail-header-xref header))
4166 (not (memq (setq number (mail-header-number header))
4169 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
4170 (setq start (match-end 0))
4171 (setq group (if prefix
4172 (concat prefix (substring xrefs (match-beginning 1)
4174 (substring xrefs (match-beginning 1) (match-end 1))))
4176 (string-to-int (substring xrefs (match-beginning 2)
4178 (if (setq entry (gnus-gethash group xref-hashtb))
4179 (setcdr entry (cons number (cdr entry)))
4180 (gnus-sethash group (cons number nil) xref-hashtb)))))
4181 (and start xref-hashtb)))
4183 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
4184 "Look through all the headers and mark the Xrefs as read."
4185 (let ((virtual (gnus-virtual-group-p from-newsgroup))
4186 name entry info xref-hashtb idlist method nth4)
4188 (set-buffer gnus-group-buffer)
4189 (when (setq xref-hashtb
4190 (gnus-create-xref-hashtb from-newsgroup headers unreads))
4193 (unless (string= from-newsgroup (setq name (symbol-name group)))
4194 (setq idlist (symbol-value group))
4195 ;; Dead groups are not updated.
4197 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
4199 (when (stringp (setq nth4 (gnus-info-method info)))
4200 (setq nth4 (gnus-server-to-method nth4))))
4201 ;; Only do the xrefs if the group has the same
4202 ;; select method as the group we have just read.
4203 (or (gnus-methods-equal-p
4204 nth4 (gnus-find-method-for-group from-newsgroup))
4206 (equal nth4 (setq method (gnus-find-method-for-group
4208 (and (equal (car nth4) (car method))
4209 (equal (nth 1 nth4) (nth 1 method))))
4210 gnus-use-cross-reference
4211 (or (not (eq gnus-use-cross-reference t))
4213 ;; Only do cross-references on subscribed
4214 ;; groups, if that is what is wanted.
4215 (<= (gnus-info-level info) gnus-level-subscribed))
4216 (gnus-group-make-articles-read name idlist))))
4219 (defun gnus-compute-read-articles (group articles)
4220 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4221 (info (nth 2 entry))
4222 (active (gnus-active group))
4225 ;; First peel off all illegal article numbers.
4227 (let ((ids articles)
4229 (while (setq id (pop ids))
4230 (when (and first (> id (cdr active)))
4231 ;; We'll end up in this situation in one particular
4232 ;; obscure situation. If you re-scan a group and get
4233 ;; a new article that is cross-posted to a different
4234 ;; group that has not been re-scanned, you might get
4235 ;; crossposted article that has a higher number than
4236 ;; Gnus believes possible. So we re-activate this
4237 ;; group as well. This might mean doing the
4238 ;; crossposting thingy will *increase* the number
4239 ;; of articles in some groups. Tsk, tsk.
4240 (setq active (or (gnus-activate-group group) active)))
4241 (when (or (> id (cdr active))
4242 (< id (car active)))
4243 (setq articles (delq id articles))))))
4244 ;; If the read list is nil, we init it.
4246 (null (gnus-info-read info))
4248 (setq ninfo (cons 1 (1- (car active))))
4249 (setq ninfo (gnus-info-read info)))
4250 ;; Then we add the read articles to the range.
4252 ninfo (setq articles (sort articles '<))))))
4254 (defun gnus-group-make-articles-read (group articles)
4255 "Update the info of GROUP to say that ARTICLES are read."
4257 (entry (gnus-gethash group gnus-newsrc-hashtb))
4258 (info (nth 2 entry))
4259 (active (gnus-active group))
4262 (setq range (gnus-compute-read-articles group articles))
4264 (set-buffer gnus-group-buffer)
4267 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
4268 (gnus-info-set-read ',info ',(gnus-info-read info))
4269 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
4270 (gnus-group-update-group ,group t))))
4271 ;; Add the read articles to the range.
4272 (gnus-info-set-read info range)
4273 ;; Then we have to re-compute how many unread
4274 ;; articles there are in this group.
4278 (setq num (- (1+ (cdr active)) (car active))))
4279 ((not (listp (cdr range)))
4280 (setq num (- (cdr active) (- (1+ (cdr range))
4284 (if (numberp (car range))
4286 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
4287 (setq range (cdr range)))
4288 (setq num (- (cdr active) num))))
4289 ;; Update the number of unread articles.
4291 ;; Update the group buffer.
4292 (gnus-group-update-group group t)))))
4294 (defun gnus-methods-equal-p (m1 m2)
4295 (let ((m1 (or m1 gnus-select-method))
4296 (m2 (or m2 gnus-select-method)))
4298 (and (eq (car m1) (car m2))
4299 (or (not (memq 'address (assoc (symbol-name (car m1))
4300 gnus-valid-select-methods)))
4301 (equal (nth 1 m1) (nth 1 m2)))))))
4303 (defvar gnus-newsgroup-none-id 0)
4305 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
4306 (let ((cur nntp-server-buffer)
4309 (save-excursion (set-buffer gnus-summary-buffer)
4310 gnus-newsgroup-dependencies)))
4311 headers id id-dep ref-dep end ref)
4313 (set-buffer nntp-server-buffer)
4314 ;; Translate all TAB characters into SPACE characters.
4315 (subst-char-in-region (point-min) (point-max) ?\t ? t)
4316 (gnus-run-hooks 'gnus-parse-headers-hook)
4317 (let ((case-fold-search t)
4318 in-reply-to header p lines)
4319 (goto-char (point-min))
4320 ;; Search to the beginning of the next header. Error messages
4321 ;; do not begin with 2 or 3.
4322 (while (re-search-forward "^[23][0-9]+ " nil t)
4325 ;; This implementation of this function, with nine
4326 ;; search-forwards instead of the one re-search-forward and
4327 ;; a case (which basically was the old function) is actually
4328 ;; about twice as fast, even though it looks messier. You
4329 ;; can't have everything, I guess. Speed and elegance
4330 ;; doesn't always go hand in hand.
4339 (narrow-to-region (point)
4340 (or (and (search-forward "\n.\n" nil t)
4346 (if (search-forward "\nsubject: " nil t)
4348 gnus-unstructured-field-decoder (nnheader-header-value))
4353 (if (search-forward "\nfrom: " nil t)
4355 gnus-structured-field-decoder (nnheader-header-value))
4360 (if (search-forward "\ndate: " nil t)
4361 (nnheader-header-value) ""))
4365 (setq id (if (search-forward "\nmessage-id:" nil t)
4367 (1- (or (search-forward "<" nil t) (point)))
4368 (or (search-forward ">" nil t) (point)))
4369 ;; If there was no message-id, we just fake one
4370 ;; to make subsequent routines simpler.
4371 (nnheader-generate-fake-message-id))))
4375 (if (search-forward "\nreferences: " nil t)
4379 (nnheader-header-value)
4384 (search-backward ">" end t)
4387 (search-backward "<" end t)
4389 ;; Get the references from the in-reply-to header if there
4390 ;; were no references and the in-reply-to header looks
4392 (if (and (search-forward "\nin-reply-to: " nil t)
4393 (setq in-reply-to (nnheader-header-value))
4394 (string-match "<[^>]+>" in-reply-to))
4396 (setq ref (substring in-reply-to (match-beginning 0)
4398 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
4399 (setq ref2 (substring in-reply-to (match-beginning 0)
4401 (when (> (length ref2) (length ref))
4409 (if (search-forward "\nlines: " nil t)
4410 (if (numberp (setq lines (ignore-errors (read cur))))
4416 (and (search-forward "\nxref: " nil t)
4417 (nnheader-header-value)))))
4418 (when (equal id ref)
4421 (when gnus-alter-header-function
4422 (funcall gnus-alter-header-function header)
4423 (setq id (mail-header-id header)
4424 ref (gnus-parent-id (mail-header-references header))))
4426 ;; We do the threading while we read the headers. The
4427 ;; message-id and the last reference are both entered into
4428 ;; the same hash table. Some tippy-toeing around has to be
4429 ;; done in case an article has arrived before the article
4430 ;; which it refers to.
4431 (if (boundp (setq id-dep (intern id dependencies)))
4432 (if (and (car (symbol-value id-dep))
4434 ;; An article with this Message-ID has already been seen.
4435 (if gnus-summary-ignore-duplicates
4436 ;; We ignore this one, except we add
4437 ;; any additional Xrefs (in case the two articles
4438 ;; came from different servers).
4440 (mail-header-set-xref
4441 (car (symbol-value id-dep))
4442 (concat (or (mail-header-xref
4443 (car (symbol-value id-dep)))
4445 (or (mail-header-xref header) "")))
4447 ;; We rename the Message-ID.
4449 (setq id-dep (intern (setq id (nnmail-message-id))
4452 (mail-header-set-id header id))
4453 (setcar (symbol-value id-dep) header))
4454 (set id-dep (list header)))
4456 (if (boundp (setq ref-dep (intern (or ref "none") dependencies)))
4457 (setcdr (symbol-value ref-dep)
4458 (nconc (cdr (symbol-value ref-dep))
4459 (list (symbol-value id-dep))))
4460 (set ref-dep (list nil (symbol-value id-dep))))
4461 (push header headers))
4462 (goto-char (point-max))
4464 (nreverse headers)))))
4466 ;; The following macros and functions were written by Felix Lee
4467 ;; <flee@cse.psu.edu>.
4469 (defmacro gnus-nov-read-integer ()
4471 (if (= (following-char) ?\t)
4473 (let ((num (ignore-errors (read buffer))))
4474 (if (numberp num) num 0)))
4476 (search-forward "\t" eol 'move))))
4478 (defmacro gnus-nov-skip-field ()
4479 '(search-forward "\t" eol 'move))
4481 (defmacro gnus-nov-field ()
4482 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
4484 ;; (defvar gnus-nov-none-counter 0)
4486 ;; This function has to be called with point after the article number
4487 ;; on the beginning of the line.
4488 (defun gnus-nov-parse-line (number dependencies &optional force-new)
4489 (let ((eol (gnus-point-at-eol))
4490 (buffer (current-buffer))
4491 header ref id id-dep ref-dep)
4493 ;; overview: [num subject from date id refs chars lines misc]
4496 (narrow-to-region (point) eol)
4504 gnus-unstructured-field-decoder (gnus-nov-field)) ; subject
4506 gnus-structured-field-decoder (gnus-nov-field)) ; from
4507 (gnus-nov-field) ; date
4508 (setq id (or (gnus-nov-field)
4509 (nnheader-generate-fake-message-id))) ; id
4511 (let ((beg (point)))
4512 (search-forward "\t" eol)
4513 (if (search-backward ">" beg t)
4517 (or (search-backward "<" beg t) beg)))
4520 (gnus-nov-field)) ; refs
4521 (gnus-nov-read-integer) ; chars
4522 (gnus-nov-read-integer) ; lines
4523 (if (= (following-char) ?\n)
4525 (gnus-nov-field))))) ; misc
4529 (when gnus-alter-header-function
4530 (funcall gnus-alter-header-function header)
4531 (setq id (mail-header-id header)
4532 ref (gnus-parent-id (mail-header-references header))))
4534 ;; We build the thread tree.
4535 (when (equal id ref)
4536 ;; This article refers back to itself. Naughty, naughty.
4538 (if (boundp (setq id-dep (intern id dependencies)))
4539 (if (and (car (symbol-value id-dep))
4541 ;; An article with this Message-ID has already been seen.
4542 (if gnus-summary-ignore-duplicates
4543 ;; We ignore this one, except we add any additional
4544 ;; Xrefs (in case the two articles came from different
4547 (mail-header-set-xref
4548 (car (symbol-value id-dep))
4549 (concat (or (mail-header-xref
4550 (car (symbol-value id-dep)))
4552 (or (mail-header-xref header) "")))
4554 ;; We rename the Message-ID.
4556 (setq id-dep (intern (setq id (nnmail-message-id))
4559 (mail-header-set-id header id))
4560 (setcar (symbol-value id-dep) header))
4561 (set id-dep (list header)))
4563 (if (boundp (setq ref-dep (intern (or ref "none") dependencies)))
4564 (setcdr (symbol-value ref-dep)
4565 (nconc (cdr (symbol-value ref-dep))
4566 (list (symbol-value id-dep))))
4567 (set ref-dep (list nil (symbol-value id-dep)))))
4570 ;; Goes through the xover lines and returns a list of vectors
4571 (defun gnus-get-newsgroup-headers-xover (sequence &optional
4572 force-new dependencies
4573 group also-fetch-heads)
4574 "Parse the news overview data in the server buffer, and return a
4575 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
4576 ;; Get the Xref when the users reads the articles since most/some
4577 ;; NNTP servers do not include Xrefs when using XOVER.
4578 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
4579 (let ((cur nntp-server-buffer)
4580 (dependencies (or dependencies gnus-newsgroup-dependencies))
4581 number headers header)
4583 (set-buffer nntp-server-buffer)
4584 ;; Allow the user to mangle the headers before parsing them.
4585 (gnus-run-hooks 'gnus-parse-headers-hook)
4586 (goto-char (point-min))
4589 (while (and sequence (not (eobp)))
4590 (setq number (read cur))
4591 (while (and sequence
4592 (< (car sequence) number))
4593 (setq sequence (cdr sequence)))
4595 (eq number (car sequence))
4597 (setq sequence (cdr sequence))
4598 (setq header (inline
4599 (gnus-nov-parse-line
4600 number dependencies force-new))))
4601 (push header headers))
4604 (gnus-error 4 "Strange nov line (%d)"
4605 (count-lines (point-min) (point)))))
4607 ;; A common bug in inn is that if you have posted an article and
4608 ;; then retrieves the active file, it will answer correctly --
4609 ;; the new article is included. However, a NOV entry for the
4610 ;; article may not have been generated yet, so this may fail.
4611 ;; We work around this problem by retrieving the last few
4612 ;; headers using HEAD.
4613 (if (or (not also-fetch-heads)
4615 ;; We (probably) got all the headers.
4617 (let ((gnus-nov-is-evil t))
4620 (when (gnus-retrieve-headers sequence group)
4621 (gnus-get-newsgroup-headers))))))))
4623 (defun gnus-article-get-xrefs ()
4624 "Fill in the Xref value in `gnus-current-headers', if necessary.
4625 This is meant to be called in `gnus-article-internal-prepare-hook'."
4626 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
4627 gnus-current-headers)))
4628 (or (not gnus-use-cross-reference)
4630 (and (mail-header-xref headers)
4631 (not (string= (mail-header-xref headers) "")))
4632 (let ((case-fold-search t)
4635 (nnheader-narrow-to-headers)
4636 (goto-char (point-min))
4637 (when (or (and (eq (downcase (following-char)) ?x)
4638 (looking-at "Xref:"))
4639 (search-forward "\nXref:" nil t))
4640 (goto-char (1+ (match-end 0)))
4641 (setq xref (buffer-substring (point)
4642 (progn (end-of-line) (point))))
4643 (mail-header-set-xref headers xref)))))))
4645 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
4646 "Find article ID and insert the summary line for that article."
4647 (let ((header (if (and old-header use-old-header)
4648 old-header (gnus-read-header id)))
4649 (number (and (numberp id) id))
4652 ;; Rebuild the thread that this article is part of and go to the
4653 ;; article we have fetched.
4654 (when (and (not gnus-show-threads)
4656 (when (setq d (gnus-data-find (mail-header-number old-header)))
4657 (goto-char (gnus-data-pos d))
4660 (- (gnus-point-at-bol)
4662 (1+ (gnus-point-at-eol))
4663 (gnus-delete-line))))))
4665 (mail-header-set-number header (mail-header-number old-header)))
4666 (setq gnus-newsgroup-sparse
4667 (delq (setq number (mail-header-number header))
4668 gnus-newsgroup-sparse))
4669 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
4670 (gnus-rebuild-thread (mail-header-id header))
4671 (gnus-summary-goto-subject number nil t))
4672 (when (and (numberp number)
4674 ;; We have to update the boundaries even if we can't fetch the
4675 ;; article if ID is a number -- so that the next `P' or `N'
4676 ;; command will fetch the previous (or next) article even
4677 ;; if the one we tried to fetch this time has been canceled.
4678 (when (> number gnus-newsgroup-end)
4679 (setq gnus-newsgroup-end number))
4680 (when (< number gnus-newsgroup-begin)
4681 (setq gnus-newsgroup-begin number))
4682 (setq gnus-newsgroup-unselected
4683 (delq number gnus-newsgroup-unselected)))
4684 ;; Report back a success?
4685 (and header (mail-header-number header))))
4687 ;;; Process/prefix in the summary buffer
4689 (defun gnus-summary-work-articles (n)
4690 "Return a list of articles to be worked upon. The prefix argument,
4691 the list of process marked articles, and the current article will be
4692 taken into consideration."
4694 (set-buffer gnus-summary-buffer)
4697 ;; A numerical prefix has been given.
4698 (setq n (prefix-numeric-value n))
4699 (let ((backward (< n 0))
4700 (n (abs (prefix-numeric-value n)))
4705 (push (setq article (gnus-summary-article-number))
4708 (gnus-summary-find-prev nil article)
4709 (gnus-summary-find-next nil article)))
4711 (nreverse articles)))
4712 ((and (gnus-region-active-p) (mark))
4713 (message "region active")
4714 ;; Work on the region between point and mark.
4715 (let ((max (max (point) (mark)))
4718 (goto-char (min (point) (mark)))
4721 (push (setq article (gnus-summary-article-number)) articles)
4722 (gnus-summary-find-next nil article)
4724 (nreverse articles))))
4725 (gnus-newsgroup-processable
4726 ;; There are process-marked articles present.
4727 ;; Save current state.
4728 (gnus-summary-save-process-mark)
4730 (reverse gnus-newsgroup-processable))
4732 ;; Just return the current article.
4733 (list (gnus-summary-article-number))))))
4735 (defun gnus-summary-save-process-mark ()
4736 "Push the current set of process marked articles on the stack."
4738 (push (copy-sequence gnus-newsgroup-processable)
4739 gnus-newsgroup-process-stack))
4741 (defun gnus-summary-kill-process-mark ()
4742 "Push the current set of process marked articles on the stack and unmark."
4744 (gnus-summary-save-process-mark)
4745 (gnus-summary-unmark-all-processable))
4747 (defun gnus-summary-yank-process-mark ()
4748 "Pop the last process mark state off the stack and restore it."
4750 (unless gnus-newsgroup-process-stack
4751 (error "Empty mark stack"))
4752 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
4754 (defun gnus-summary-process-mark-set (set)
4755 "Make SET into the current process marked articles."
4756 (gnus-summary-unmark-all-processable)
4758 (gnus-summary-set-process-mark (pop set))))
4760 ;;; Searching and stuff
4762 (defun gnus-summary-search-group (&optional backward use-level)
4763 "Search for next unread newsgroup.
4764 If optional argument BACKWARD is non-nil, search backward instead."
4766 (set-buffer gnus-group-buffer)
4767 (when (gnus-group-search-forward
4768 backward nil (if use-level (gnus-group-group-level) nil))
4769 (gnus-group-group-name))))
4771 (defun gnus-summary-best-group (&optional exclude-group)
4772 "Find the name of the best unread group.
4773 If EXCLUDE-GROUP, do not go to this group."
4775 (set-buffer gnus-group-buffer)
4777 (gnus-group-best-unread-group exclude-group))))
4779 (defun gnus-summary-find-next (&optional unread article backward)
4780 (if backward (gnus-summary-find-prev)
4781 (let* ((dummy (gnus-summary-article-intangible-p))
4782 (article (or article (gnus-summary-article-number)))
4783 (arts (gnus-data-find-list article))
4785 (when (and (not dummy)
4786 (or (not gnus-summary-check-current)
4788 (not (gnus-data-unread-p (car arts)))))
4789 (setq arts (cdr arts)))
4794 (when (gnus-data-unread-p (car arts))
4795 (setq result (car arts)
4797 (setq arts (cdr arts)))
4800 (goto-char (gnus-data-pos result))
4801 (gnus-data-number result)))))
4803 (defun gnus-summary-find-prev (&optional unread article)
4804 (let* ((eobp (eobp))
4805 (article (or article (gnus-summary-article-number)))
4806 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
4808 (when (and (not eobp)
4809 (or (not gnus-summary-check-current)
4811 (not (gnus-data-unread-p (car arts)))))
4812 (setq arts (cdr arts)))
4817 (when (gnus-data-unread-p (car arts))
4818 (setq result (car arts)
4820 (setq arts (cdr arts)))
4823 (goto-char (gnus-data-pos result))
4824 (gnus-data-number result))))
4826 (defun gnus-summary-find-subject (subject &optional unread backward article)
4827 (let* ((simp-subject (gnus-simplify-subject-fully subject))
4828 (article (or article (gnus-summary-article-number)))
4829 (articles (gnus-data-list backward))
4830 (arts (gnus-data-find-list article articles))
4832 (when (or (not gnus-summary-check-current)
4834 (not (gnus-data-unread-p (car arts))))
4835 (setq arts (cdr arts)))
4837 (and (or (not unread)
4838 (gnus-data-unread-p (car arts)))
4839 (vectorp (gnus-data-header (car arts)))
4841 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
4842 (setq result (car arts)
4844 (setq arts (cdr arts)))
4846 (goto-char (gnus-data-pos result))
4847 (gnus-data-number result))))
4849 (defun gnus-summary-search-forward (&optional unread subject backward)
4850 "Search forward for an article.
4851 If UNREAD, look for unread articles. If SUBJECT, look for
4852 articles with that subject. If BACKWARD, search backward instead."
4853 (cond (subject (gnus-summary-find-subject subject unread backward))
4854 (backward (gnus-summary-find-prev unread))
4855 (t (gnus-summary-find-next unread))))
4857 (defun gnus-recenter (&optional n)
4858 "Center point in window and redisplay frame.
4859 Also do horizontal recentering."
4861 (when (and gnus-auto-center-summary
4862 (not (eq gnus-auto-center-summary 'vertical)))
4863 (gnus-horizontal-recenter))
4866 (defun gnus-summary-recenter ()
4867 "Center point in the summary window.
4868 If `gnus-auto-center-summary' is nil, or the article buffer isn't
4869 displayed, no centering will be performed."
4870 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
4871 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
4872 (let* ((top (cond ((< (window-height) 4) 0)
4873 ((< (window-height) 7) 1)
4875 (height (1- (window-height)))
4876 (bottom (save-excursion (goto-char (point-max))
4877 (forward-line (- height))
4879 (window (get-buffer-window (current-buffer))))
4880 ;; The user has to want it.
4881 (when gnus-auto-center-summary
4882 (when (get-buffer-window gnus-article-buffer)
4883 ;; Only do recentering when the article buffer is displayed,
4884 ;; Set the window start to either `bottom', which is the biggest
4885 ;; possible valid number, or the second line from the top,
4886 ;; whichever is the least.
4888 window (min bottom (save-excursion
4889 (forward-line (- top)) (point)))))
4890 ;; Do horizontal recentering while we're at it.
4891 (when (and (get-buffer-window (current-buffer) t)
4892 (not (eq gnus-auto-center-summary 'vertical)))
4893 (let ((selected (selected-window)))
4894 (select-window (get-buffer-window (current-buffer) t))
4895 (gnus-summary-position-point)
4896 (gnus-horizontal-recenter)
4897 (select-window selected))))))
4899 (defun gnus-summary-jump-to-group (newsgroup)
4900 "Move point to NEWSGROUP in group mode buffer."
4901 ;; Keep update point of group mode buffer if visible.
4902 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
4903 (save-window-excursion
4904 ;; Take care of tree window mode.
4905 (when (get-buffer-window gnus-group-buffer)
4906 (pop-to-buffer gnus-group-buffer))
4907 (gnus-group-jump-to-group newsgroup))
4909 ;; Take care of tree window mode.
4910 (if (get-buffer-window gnus-group-buffer)
4911 (pop-to-buffer gnus-group-buffer)
4912 (set-buffer gnus-group-buffer))
4913 (gnus-group-jump-to-group newsgroup))))
4915 ;; This function returns a list of article numbers based on the
4916 ;; difference between the ranges of read articles in this group and
4917 ;; the range of active articles.
4918 (defun gnus-list-of-unread-articles (group)
4919 (let* ((read (gnus-info-read (gnus-get-info group)))
4920 (active (or (gnus-active group) (gnus-activate-group group)))
4923 ;; If none are read, then all are unread.
4925 (setq first (car active))
4926 ;; If the range of read articles is a single range, then the
4927 ;; first unread article is the article after the last read
4928 ;; article. Sounds logical, doesn't it?
4929 (if (not (listp (cdr read)))
4930 (setq first (1+ (cdr read)))
4931 ;; `read' is a list of ranges.
4932 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
4938 (while (< first nlast)
4940 (setq first (1+ first))))
4941 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
4942 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
4943 (setq read (cdr read)))))
4944 ;; And add the last unread articles.
4945 (while (<= first last)
4947 (setq first (1+ first)))
4948 ;; Return the list of unread articles.
4949 (delq 0 (nreverse unread))))
4951 (defun gnus-list-of-read-articles (group)
4952 "Return a list of unread, unticked and non-dormant articles."
4953 (let* ((info (gnus-get-info group))
4954 (marked (gnus-info-marks info))
4955 (active (gnus-active group)))
4957 (gnus-set-difference
4958 (gnus-sorted-complement
4959 (gnus-uncompress-range active)
4960 (gnus-list-of-unread-articles group))
4962 (gnus-uncompress-range (cdr (assq 'dormant marked)))
4963 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
4965 ;; Various summary commands
4967 (defun gnus-summary-select-article-buffer ()
4968 "Reconfigure windows to show article buffer."
4970 (if (not (gnus-buffer-live-p gnus-article-buffer))
4971 (error "There is no article buffer for this summary buffer")
4972 (gnus-configure-windows 'article)
4973 (select-window (get-buffer-window gnus-article-buffer))))
4975 (defun gnus-summary-universal-argument (arg)
4976 "Perform any operation on all articles that are process/prefixed."
4978 (let ((articles (gnus-summary-work-articles arg))
4985 (substitute-command-keys
4986 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
4989 (gnus-error 1 "Undefined key")
4992 (gnus-summary-goto-subject (setq article (pop articles)))
4993 (let (gnus-newsgroup-processable)
4994 (command-execute func))
4995 (gnus-summary-remove-process-mark article)))))
4996 (gnus-summary-position-point))
4998 (defun gnus-summary-toggle-truncation (&optional arg)
4999 "Toggle truncation of summary lines.
5000 With arg, turn line truncation on iff arg is positive."
5002 (setq truncate-lines
5003 (if (null arg) (not truncate-lines)
5004 (> (prefix-numeric-value arg) 0)))
5007 (defun gnus-summary-reselect-current-group (&optional all rescan)
5008 "Exit and then reselect the current newsgroup.
5009 The prefix argument ALL means to select all articles."
5011 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
5012 (error "Ephemeral groups can't be reselected"))
5013 (let ((current-subject (gnus-summary-article-number))
5014 (group gnus-newsgroup-name))
5015 (setq gnus-newsgroup-begin nil)
5017 ;; We have to adjust the point of group mode buffer because
5018 ;; point was moved to the next unread newsgroup by exiting.
5019 (gnus-summary-jump-to-group group)
5022 (gnus-group-get-new-news-this-group 1)))
5023 (gnus-group-read-group all t)
5024 (gnus-summary-goto-subject current-subject nil t)))
5026 (defun gnus-summary-rescan-group (&optional all)
5027 "Exit the newsgroup, ask for new articles, and select the newsgroup."
5029 (gnus-summary-reselect-current-group all t))
5031 (defun gnus-summary-update-info (&optional non-destructive)
5033 (let ((group gnus-newsgroup-name))
5035 (when gnus-newsgroup-kill-headers
5036 (setq gnus-newsgroup-killed
5037 (gnus-compress-sequence
5039 (gnus-set-sorted-intersection
5040 (gnus-uncompress-range gnus-newsgroup-killed)
5041 (setq gnus-newsgroup-unselected
5042 (sort gnus-newsgroup-unselected '<)))
5043 (setq gnus-newsgroup-unreads
5044 (sort gnus-newsgroup-unreads '<)))
5046 (unless (listp (cdr gnus-newsgroup-killed))
5047 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
5048 (let ((headers gnus-newsgroup-headers))
5049 (when (and (not gnus-save-score)
5050 (not non-destructive))
5051 (setq gnus-newsgroup-scored nil))
5052 ;; Set the new ranges of read articles.
5054 (set-buffer gnus-group-buffer)
5055 (gnus-undo-force-boundary))
5056 (gnus-update-read-articles
5057 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
5058 ;; Set the current article marks.
5060 ;; Do the cross-ref thing.
5061 (when gnus-use-cross-reference
5062 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
5063 ;; Do not switch windows but change the buffer to work.
5064 (set-buffer gnus-group-buffer)
5065 (unless (gnus-ephemeral-group-p group)
5066 (gnus-group-update-group group)))))))
5068 (defun gnus-summary-save-newsrc (&optional force)
5069 "Save the current number of read/marked articles in the dribble buffer.
5070 The dribble buffer will then be saved.
5071 If FORCE (the prefix), also save the .newsrc file(s)."
5073 (gnus-summary-update-info t)
5075 (gnus-save-newsrc-file)
5076 (gnus-dribble-save)))
5078 (defun gnus-summary-exit (&optional temporary)
5079 "Exit reading current newsgroup, and then return to group selection mode.
5080 gnus-exit-group-hook is called with no arguments if that value is non-nil."
5082 (gnus-kill-save-kill-buffer)
5083 (let* ((group gnus-newsgroup-name)
5084 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
5087 (buf (current-buffer)))
5088 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
5089 ;; If we have several article buffers, we kill them at exit.
5090 (unless gnus-single-article-buffer
5091 (gnus-kill-buffer gnus-original-article-buffer)
5092 (setq gnus-article-current nil))
5093 (when gnus-use-cache
5094 (gnus-cache-possibly-remove-articles)
5095 (gnus-cache-save-buffers))
5096 (gnus-async-prefetch-remove-group group)
5097 (when gnus-suppress-duplicates
5098 (gnus-dup-enter-articles))
5099 (when gnus-use-trees
5100 (gnus-tree-close group))
5101 ;; Remove entries for this group.
5102 (nnmail-purge-split-history group)
5103 ;; Make all changes in this group permanent.
5105 (gnus-run-hooks 'gnus-exit-group-hook)
5106 (gnus-summary-update-info)
5107 ;; Do adaptive scoring, and possibly save score files.
5108 (when gnus-newsgroup-adaptive
5109 (gnus-score-adaptive))
5110 (when gnus-use-scoring
5112 (gnus-close-group group)
5113 ;; Make sure where we were, and go to next newsgroup.
5114 (set-buffer gnus-group-buffer)
5116 (gnus-group-jump-to-group group))
5117 (gnus-run-hooks 'gnus-summary-exit-hook)
5118 (unless (or quit-config
5119 ;; If this group has disappeared from the summary
5120 ;; buffer, don't skip forwards.
5121 (not (string= group (gnus-group-group-name))))
5122 (gnus-group-next-unread-group 1))
5123 (setq group-point (point))
5126 ;; If we have several article buffers, we kill them at exit.
5127 (unless gnus-single-article-buffer
5128 (gnus-kill-buffer gnus-article-buffer)
5129 (gnus-kill-buffer gnus-original-article-buffer)
5130 (setq gnus-article-current nil))
5132 (if (not gnus-kill-summary-on-exit)
5133 (gnus-deaden-summary)
5134 ;; We set all buffer-local variables to nil. It is unclear why
5135 ;; this is needed, but if we don't, buffer-local variables are
5136 ;; not garbage-collected, it seems. This would the lead to en
5137 ;; ever-growing Emacs.
5138 (gnus-summary-clear-local-variables)
5139 (when (get-buffer gnus-article-buffer)
5140 (bury-buffer gnus-article-buffer))
5141 ;; We clear the global counterparts of the buffer-local
5142 ;; variables as well, just to be on the safe side.
5143 (set-buffer gnus-group-buffer)
5144 (gnus-summary-clear-local-variables)
5145 ;; Return to group mode buffer.
5146 (when (eq mode 'gnus-summary-mode)
5147 (gnus-kill-buffer buf)))
5148 (setq gnus-current-select-method gnus-select-method)
5149 (pop-to-buffer gnus-group-buffer)
5150 ;; Clear the current group name.
5151 (if (not quit-config)
5153 (goto-char group-point)
5154 (gnus-configure-windows 'group 'force))
5155 (gnus-handle-ephemeral-exit quit-config))
5157 (setq gnus-newsgroup-name nil)))))
5159 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
5160 (defun gnus-summary-exit-no-update (&optional no-questions)
5161 "Quit reading current newsgroup without updating read article info."
5163 (let* ((group gnus-newsgroup-name)
5164 (quit-config (gnus-group-quit-config group)))
5165 (when (or no-questions
5167 (gnus-y-or-n-p "Discard changes to this group and exit? "))
5168 ;; If we have several article buffers, we kill them at exit.
5169 (unless gnus-single-article-buffer
5170 (gnus-kill-buffer gnus-article-buffer)
5171 (gnus-kill-buffer gnus-original-article-buffer)
5172 (setq gnus-article-current nil))
5173 (if (not gnus-kill-summary-on-exit)
5174 (gnus-deaden-summary)
5175 (gnus-close-group group)
5176 (gnus-summary-clear-local-variables)
5177 (set-buffer gnus-group-buffer)
5178 (gnus-summary-clear-local-variables)
5179 (when (get-buffer gnus-summary-buffer)
5180 (kill-buffer gnus-summary-buffer)))
5181 (unless gnus-single-article-buffer
5182 (setq gnus-article-current nil))
5183 (when gnus-use-trees
5184 (gnus-tree-close group))
5185 (gnus-async-prefetch-remove-group group)
5186 (when (get-buffer gnus-article-buffer)
5187 (bury-buffer gnus-article-buffer))
5188 ;; Return to the group buffer.
5189 (gnus-configure-windows 'group 'force)
5190 ;; Clear the current group name.
5191 (setq gnus-newsgroup-name nil)
5192 (when (equal (gnus-group-group-name) group)
5193 (gnus-group-next-unread-group 1))
5195 (gnus-handle-ephemeral-exit quit-config)))))
5197 (defun gnus-handle-ephemeral-exit (quit-config)
5198 "Handle movement when leaving an ephemeral group. The state
5199 which existed when entering the ephemeral is reset."
5200 (if (not (buffer-name (car quit-config)))
5201 (gnus-configure-windows 'group 'force)
5202 (set-buffer (car quit-config))
5203 (cond ((eq major-mode 'gnus-summary-mode)
5204 (gnus-set-global-variables))
5205 ((eq major-mode 'gnus-article-mode)
5207 ;; The `gnus-summary-buffer' variable may point
5208 ;; to the old summary buffer when using a single
5210 (unless (gnus-buffer-live-p gnus-summary-buffer)
5211 (set-buffer gnus-group-buffer))
5212 (set-buffer gnus-summary-buffer)
5213 (gnus-set-global-variables))))
5214 (if (or (eq (cdr quit-config) 'article)
5215 (eq (cdr quit-config) 'pick))
5217 ;; The current article may be from the ephemeral group
5218 ;; thus it is best that we reload this article
5219 (gnus-summary-show-article)
5220 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
5221 (gnus-configure-windows 'pick 'force)
5222 (gnus-configure-windows (cdr quit-config) 'force)))
5223 (gnus-configure-windows (cdr quit-config) 'force))
5224 (when (eq major-mode 'gnus-summary-mode)
5225 (gnus-summary-next-subject 1 nil t)
5226 (gnus-summary-recenter)
5227 (gnus-summary-position-point))))
5229 (defun gnus-summary-preview-mime-message (arg)
5230 "MIME decode and play this message."
5232 (let ((gnus-break-pages nil))
5233 (gnus-summary-select-article t t)
5235 (pop-to-buffer gnus-original-article-buffer t)
5236 (let (buffer-read-only)
5237 (if (text-property-any (point-min) (point-max) 'invisible t)
5238 (remove-text-properties (point-min) (point-max)
5239 gnus-hidden-properties)
5241 (mime-view-mode nil nil nil gnus-original-article-buffer
5242 gnus-article-buffer)
5245 (defun gnus-summary-scroll-down ()
5246 "Scroll down one line current article."
5248 (gnus-summary-scroll-up -1)
5253 (defvar gnus-dead-summary-mode-map nil)
5255 (unless gnus-dead-summary-mode-map
5256 (setq gnus-dead-summary-mode-map (make-keymap))
5257 (suppress-keymap gnus-dead-summary-mode-map)
5258 (substitute-key-definition
5259 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
5260 (let ((keys '("\C-d" "\r" "\177" [delete])))
5262 (define-key gnus-dead-summary-mode-map
5263 (pop keys) 'gnus-summary-wake-up-the-dead))))
5265 (defvar gnus-dead-summary-mode nil
5266 "Minor mode for Gnus summary buffers.")
5268 (defun gnus-dead-summary-mode (&optional arg)
5269 "Minor mode for Gnus summary buffers."
5271 (when (eq major-mode 'gnus-summary-mode)
5272 (make-local-variable 'gnus-dead-summary-mode)
5273 (setq gnus-dead-summary-mode
5274 (if (null arg) (not gnus-dead-summary-mode)
5275 (> (prefix-numeric-value arg) 0)))
5276 (when gnus-dead-summary-mode
5277 (gnus-add-minor-mode
5278 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
5280 (defun gnus-deaden-summary ()
5281 "Make the current summary buffer into a dead summary buffer."
5282 ;; Kill any previous dead summary buffer.
5283 (when (and gnus-dead-summary
5284 (buffer-name gnus-dead-summary))
5286 (set-buffer gnus-dead-summary)
5287 (when gnus-dead-summary-mode
5288 (kill-buffer (current-buffer)))))
5289 ;; Make this the current dead summary.
5290 (setq gnus-dead-summary (current-buffer))
5291 (gnus-dead-summary-mode 1)
5292 (let ((name (buffer-name)))
5293 (when (string-match "Summary" name)
5295 (concat (substring name 0 (match-beginning 0)) "Dead "
5296 (substring name (match-beginning 0)))
5299 (defun gnus-kill-or-deaden-summary (buffer)
5300 "Kill or deaden the summary BUFFER."
5302 (when (and (buffer-name buffer)
5303 (not gnus-single-article-buffer))
5306 (gnus-kill-buffer gnus-article-buffer)
5307 (gnus-kill-buffer gnus-original-article-buffer)))
5308 (cond (gnus-kill-summary-on-exit
5309 (when (and gnus-use-trees
5310 (and (get-buffer buffer)
5311 (buffer-name (get-buffer buffer))))
5313 (set-buffer (get-buffer buffer))
5314 (gnus-tree-close gnus-newsgroup-name)))
5315 (gnus-kill-buffer buffer))
5316 ((and (get-buffer buffer)
5317 (buffer-name (get-buffer buffer)))
5320 (gnus-deaden-summary))))))
5322 (defun gnus-summary-wake-up-the-dead (&rest args)
5323 "Wake up the dead summary buffer."
5325 (gnus-dead-summary-mode -1)
5326 (let ((name (buffer-name)))
5327 (when (string-match "Dead " name)
5329 (concat (substring name 0 (match-beginning 0))
5330 (substring name (match-end 0)))
5332 (gnus-message 3 "This dead summary is now alive again"))
5334 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
5335 (defun gnus-summary-fetch-faq (&optional faq-dir)
5336 "Fetch the FAQ for the current group.
5337 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
5341 (when current-prefix-arg
5343 "Faq dir: " (and (listp gnus-group-faq-directory)
5344 (mapcar (lambda (file) (list file))
5345 gnus-group-faq-directory))))))
5346 (let (gnus-faq-buffer)
5347 (when (setq gnus-faq-buffer
5348 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
5349 (gnus-configure-windows 'summary-faq))))
5351 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
5352 (defun gnus-summary-describe-group (&optional force)
5353 "Describe the current newsgroup."
5355 (gnus-group-describe-group force gnus-newsgroup-name))
5357 (defun gnus-summary-describe-briefly ()
5358 "Describe summary mode commands briefly."
5361 (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")))
5363 ;; Walking around group mode buffer from summary mode.
5365 (defun gnus-summary-next-group (&optional no-article target-group backward)
5366 "Exit current newsgroup and then select next unread newsgroup.
5367 If prefix argument NO-ARTICLE is non-nil, no article is selected
5368 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
5369 previous group instead."
5371 ;; Stop pre-fetching.
5372 (gnus-async-halt-prefetch)
5373 (let ((current-group gnus-newsgroup-name)
5374 (current-buffer (current-buffer))
5376 ;; First we semi-exit this group to update Xrefs and all variables.
5377 ;; We can't do a real exit, because the window conf must remain
5378 ;; the same in case the user is prompted for info, and we don't
5379 ;; want the window conf to change before that...
5380 (gnus-summary-exit t)
5381 (while (not entered)
5382 ;; Then we find what group we are supposed to enter.
5383 (set-buffer gnus-group-buffer)
5384 (gnus-group-jump-to-group current-group)
5387 (if (eq gnus-keep-same-level 'best)
5388 (gnus-summary-best-group gnus-newsgroup-name)
5389 (gnus-summary-search-group backward gnus-keep-same-level))))
5390 (if (not target-group)
5391 ;; There are no further groups, so we return to the group
5394 (gnus-message 5 "Returning to the group buffer")
5396 (when (gnus-buffer-live-p current-buffer)
5397 (set-buffer current-buffer)
5398 (gnus-summary-exit))
5399 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
5400 ;; We try to enter the target group.
5401 (gnus-group-jump-to-group target-group)
5402 (let ((unreads (gnus-group-group-unread)))
5403 (if (and (or (eq t unreads)
5404 (and unreads (not (zerop unreads))))
5405 (gnus-summary-read-group
5406 target-group nil no-article
5407 (and (buffer-name current-buffer) current-buffer)))
5409 (setq current-group target-group
5410 target-group nil)))))))
5412 (defun gnus-summary-prev-group (&optional no-article)
5413 "Exit current newsgroup and then select previous unread newsgroup.
5414 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
5416 (gnus-summary-next-group no-article nil t))
5418 ;; Walking around summary lines.
5420 (defun gnus-summary-first-subject (&optional unread)
5421 "Go to the first unread subject.
5422 If UNREAD is non-nil, go to the first unread article.
5423 Returns the article selected or nil if there are no unread articles."
5428 ((null gnus-newsgroup-data)
5429 (gnus-message 3 "No articles in the group")
5431 ;; Pick the first article.
5433 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
5434 (gnus-data-number (car gnus-newsgroup-data)))
5435 ;; No unread articles.
5436 ((null gnus-newsgroup-unreads)
5437 (gnus-message 3 "No more unread articles")
5439 ;; Find the first unread article.
5441 (let ((data gnus-newsgroup-data))
5443 (not (gnus-data-unread-p (car data))))
5444 (setq data (cdr data)))
5446 (goto-char (gnus-data-pos (car data)))
5447 (gnus-data-number (car data))))))
5448 (gnus-summary-position-point)))
5450 (defun gnus-summary-next-subject (n &optional unread dont-display)
5451 "Go to next N'th summary line.
5452 If N is negative, go to the previous N'th subject line.
5453 If UNREAD is non-nil, only unread articles are selected.
5454 The difference between N and the actual number of steps taken is
5457 (let ((backward (< n 0))
5461 (gnus-summary-find-prev unread)
5462 (gnus-summary-find-next unread)))
5465 (gnus-message 7 "No more%s articles"
5466 (if unread " unread" "")))
5467 (unless dont-display
5468 (gnus-summary-recenter)
5469 (gnus-summary-position-point))
5472 (defun gnus-summary-next-unread-subject (n)
5473 "Go to next N'th unread summary line."
5475 (gnus-summary-next-subject n t))
5477 (defun gnus-summary-prev-subject (n &optional unread)
5478 "Go to previous N'th summary line.
5479 If optional argument UNREAD is non-nil, only unread article is selected."
5481 (gnus-summary-next-subject (- n) unread))
5483 (defun gnus-summary-prev-unread-subject (n)
5484 "Go to previous N'th unread summary line."
5486 (gnus-summary-next-subject (- n) t))
5488 (defun gnus-summary-goto-subject (article &optional force silent)
5489 "Go the subject line of ARTICLE.
5490 If FORCE, also allow jumping to articles not currently shown."
5491 (interactive "nArticle number: ")
5493 (data (gnus-data-find article)))
5494 ;; We read in the article if we have to.
5497 (gnus-summary-insert-subject article (and (vectorp force) force) t)
5498 (setq data (gnus-data-find article)))
5503 (gnus-message 3 "Can't find article %d" article))
5505 (goto-char (gnus-data-pos data))
5508 ;; Walking around summary lines with displaying articles.
5510 (defun gnus-summary-expand-window (&optional arg)
5511 "Make the summary buffer take up the entire Emacs frame.
5512 Given a prefix, will force an `article' buffer configuration."
5515 (gnus-configure-windows 'article 'force)
5516 (gnus-configure-windows 'summary 'force)))
5518 (defun gnus-summary-display-article (article &optional all-header)
5519 "Display ARTICLE in article buffer."
5520 (gnus-set-global-variables)
5524 (if gnus-summary-display-article-function
5525 (funcall gnus-summary-display-article-function article all-header)
5526 (gnus-article-prepare article all-header))
5527 (gnus-run-hooks 'gnus-select-article-hook)
5528 (when (and gnus-current-article
5529 (not (zerop gnus-current-article)))
5530 (gnus-summary-goto-subject gnus-current-article))
5531 (gnus-summary-recenter)
5532 (when (and gnus-use-trees gnus-show-threads)
5533 (gnus-possibly-generate-tree article)
5534 (gnus-highlight-selected-tree article))
5535 ;; Successfully display article.
5536 (gnus-article-set-window-start
5537 (cdr (assq article gnus-newsgroup-bookmarks))))))
5539 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
5540 "Select the current article.
5541 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
5542 non-nil, the article will be re-fetched even if it already present in
5543 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
5545 ;; Make sure we are in the summary buffer to work around bbdb bug.
5546 (unless (eq major-mode 'gnus-summary-mode)
5547 (set-buffer gnus-summary-buffer))
5548 (let ((article (or article (gnus-summary-article-number)))
5549 (all-headers (not (not all-headers))) ;Must be T or NIL.
5550 gnus-summary-display-article-function
5553 (gnus-summary-article-pseudo-p article)
5554 (error "This is a pseudo-article"))
5557 (set-buffer gnus-summary-buffer)
5558 (if (or (and gnus-single-article-buffer
5559 (or (null gnus-current-article)
5560 (null gnus-article-current)
5561 (null (get-buffer gnus-article-buffer))
5562 (not (eq article (cdr gnus-article-current)))
5563 (not (equal (car gnus-article-current)
5564 gnus-newsgroup-name))))
5565 (and (not gnus-single-article-buffer)
5566 (or (null gnus-current-article)
5567 (not (eq gnus-current-article article))))
5569 ;; The requested article is different from the current article.
5571 (gnus-summary-display-article article all-headers)
5573 (when (or all-headers gnus-show-all-headers)
5574 (gnus-article-show-all-headers))
5577 (gnus-article-set-window-start
5578 (cdr (assq article gnus-newsgroup-bookmarks)))))))
5580 (defun gnus-summary-set-current-mark (&optional current-mark)
5581 "Obsolete function."
5584 (defun gnus-summary-next-article (&optional unread subject backward push)
5585 "Select the next article.
5586 If UNREAD, only unread articles are selected.
5587 If SUBJECT, only articles with SUBJECT are selected.
5588 If BACKWARD, the previous article is selected instead of the next."
5591 ;; Is there such an article?
5592 ((and (gnus-summary-search-forward unread subject backward)
5593 (or (gnus-summary-display-article (gnus-summary-article-number))
5594 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
5595 (gnus-summary-position-point))
5596 ;; If not, we try the first unread, if that is wanted.
5598 gnus-auto-select-same
5599 (gnus-summary-first-unread-article))
5600 (gnus-summary-position-point)
5601 (gnus-message 6 "Wrapped"))
5602 ;; Try to get next/previous article not displayed in this group.
5603 ((and gnus-auto-extend-newsgroup
5604 (not unread) (not subject))
5605 (gnus-summary-goto-article
5606 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
5608 ;; Go to next/previous group.
5610 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
5611 (gnus-summary-jump-to-group gnus-newsgroup-name))
5612 (let ((cmd last-command-char)
5615 (set-buffer gnus-group-buffer)
5618 (if (eq gnus-keep-same-level 'best)
5619 (gnus-summary-best-group gnus-newsgroup-name)
5620 (gnus-summary-search-group backward gnus-keep-same-level))))
5621 ;; For some reason, the group window gets selected. We change
5623 (select-window (get-buffer-window (current-buffer)))
5624 ;; Select next unread newsgroup automagically.
5626 ((or (not gnus-auto-select-next)
5628 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
5629 ((or (eq gnus-auto-select-next 'quietly)
5630 (and (eq gnus-auto-select-next 'slightly-quietly)
5632 (and (eq gnus-auto-select-next 'almost-quietly)
5633 (gnus-summary-last-article-p)))
5635 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
5637 (gnus-message 7 "No more%s articles (%s)..."
5638 (if unread " unread" "")
5639 (if group (concat "selecting " group)
5641 (gnus-summary-next-group nil group backward)))
5643 (when (gnus-key-press-event-p last-input-event)
5644 (gnus-summary-walk-group-buffer
5645 gnus-newsgroup-name cmd unread backward point))))))))
5647 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
5648 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
5649 (?\C-p (gnus-group-prev-unread-group 1))))
5650 (cursor-in-echo-area t)
5651 keve key group ended)
5653 (set-buffer gnus-group-buffer)
5656 (if (eq gnus-keep-same-level 'best)
5657 (gnus-summary-best-group gnus-newsgroup-name)
5658 (gnus-summary-search-group backward gnus-keep-same-level))))
5661 5 "No more%s articles%s" (if unread " unread" "")
5663 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
5664 (format " (Type %s for %s [%s])"
5665 (single-key-description cmd) group
5666 (car (gnus-gethash group gnus-newsrc-hashtb)))
5667 (format " (Type %s to exit %s)"
5668 (single-key-description cmd)
5669 gnus-newsgroup-name)))
5670 ;; Confirm auto selection.
5671 (setq key (car (setq keve (gnus-read-event-char))))
5674 ((assq key keystrokes)
5675 (let ((obuf (current-buffer)))
5676 (switch-to-buffer gnus-group-buffer)
5678 (gnus-group-jump-to-group group))
5679 (eval (cadr (assq key keystrokes)))
5680 (setq group (gnus-group-group-name))
5681 (switch-to-buffer obuf))
5685 (gnus-ephemeral-group-p gnus-newsgroup-name))
5687 (gnus-summary-next-group nil group backward)))
5689 (push (cdr keve) unread-command-events))))))
5691 (defun gnus-summary-next-unread-article ()
5692 "Select unread article after current one."
5694 (gnus-summary-next-article
5695 (or (not (eq gnus-summary-goto-unread 'never))
5696 (gnus-summary-last-article-p (gnus-summary-article-number)))
5697 (and gnus-auto-select-same
5698 (gnus-summary-article-subject))))
5700 (defun gnus-summary-prev-article (&optional unread subject)
5701 "Select the article after the current one.
5702 If UNREAD is non-nil, only unread articles are selected."
5704 (gnus-summary-next-article unread subject t))
5706 (defun gnus-summary-prev-unread-article ()
5707 "Select unread article before current one."
5709 (gnus-summary-prev-article
5710 (or (not (eq gnus-summary-goto-unread 'never))
5711 (gnus-summary-first-article-p (gnus-summary-article-number)))
5712 (and gnus-auto-select-same
5713 (gnus-summary-article-subject))))
5715 (defun gnus-summary-next-page (&optional lines circular)
5716 "Show next page of the selected article.
5717 If at the end of the current article, select the next article.
5718 LINES says how many lines should be scrolled up.
5720 If CIRCULAR is non-nil, go to the start of the article instead of
5721 selecting the next article when reaching the end of the current
5724 (setq gnus-summary-buffer (current-buffer))
5725 (gnus-set-global-variables)
5726 (let ((article (gnus-summary-article-number))
5727 (article-window (get-buffer-window gnus-article-buffer t))
5729 (gnus-configure-windows 'article)
5730 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
5731 (if (and (eq gnus-summary-goto-unread 'never)
5732 (not (gnus-summary-last-article-p article)))
5733 (gnus-summary-next-article)
5734 (gnus-summary-next-unread-article))
5735 (if (or (null gnus-current-article)
5736 (null gnus-article-current)
5737 (/= article (cdr gnus-article-current))
5738 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5739 ;; Selected subject is different from current article's.
5740 (gnus-summary-display-article article)
5741 (when article-window
5742 (gnus-eval-in-buffer-window gnus-article-buffer
5743 (setq endp (gnus-article-next-page lines)))
5746 (gnus-summary-beginning-of-article))
5748 (gnus-message 3 "End of message"))
5750 (if (and (eq gnus-summary-goto-unread 'never)
5751 (not (gnus-summary-last-article-p article)))
5752 (gnus-summary-next-article)
5753 (gnus-summary-next-unread-article))))))))
5754 (gnus-summary-recenter)
5755 (gnus-summary-position-point)))
5757 (defun gnus-summary-prev-page (&optional lines move)
5758 "Show previous page of selected article.
5759 Argument LINES specifies lines to be scrolled down.
5760 If MOVE, move to the previous unread article if point is at
5761 the beginning of the buffer."
5763 (let ((article (gnus-summary-article-number))
5764 (article-window (get-buffer-window gnus-article-buffer t))
5766 (gnus-configure-windows 'article)
5767 (if (or (null gnus-current-article)
5768 (null gnus-article-current)
5769 (/= article (cdr gnus-article-current))
5770 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5771 ;; Selected subject is different from current article's.
5772 (gnus-summary-display-article article)
5773 (gnus-summary-recenter)
5774 (when article-window
5775 (gnus-eval-in-buffer-window gnus-article-buffer
5776 (setq endp (gnus-article-prev-page lines)))
5777 (when (and move endp)
5779 (gnus-message 3 "Beginning of message"))
5781 (if (and (eq gnus-summary-goto-unread 'never)
5782 (not (gnus-summary-first-article-p article)))
5783 (gnus-summary-prev-article)
5784 (gnus-summary-prev-unread-article))))))))
5785 (gnus-summary-position-point))
5787 (defun gnus-summary-prev-page-or-article (&optional lines)
5788 "Show previous page of selected article.
5789 Argument LINES specifies lines to be scrolled down.
5790 If at the beginning of the article, go to the next article."
5792 (gnus-summary-prev-page lines t))
5794 (defun gnus-summary-scroll-up (lines)
5795 "Scroll up (or down) one line current article.
5796 Argument LINES specifies lines to be scrolled up (or down if negative)."
5798 (gnus-configure-windows 'article)
5799 (gnus-summary-show-thread)
5800 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
5801 (gnus-eval-in-buffer-window gnus-article-buffer
5803 (when (gnus-article-next-page lines)
5804 (gnus-message 3 "End of message")))
5806 (gnus-article-prev-page (- lines))))))
5807 (gnus-summary-recenter)
5808 (gnus-summary-position-point))
5810 (defun gnus-summary-next-same-subject ()
5811 "Select next article which has the same subject as current one."
5813 (gnus-summary-next-article nil (gnus-summary-article-subject)))
5815 (defun gnus-summary-prev-same-subject ()
5816 "Select previous article which has the same subject as current one."
5818 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
5820 (defun gnus-summary-next-unread-same-subject ()
5821 "Select next unread article which has the same subject as current one."
5823 (gnus-summary-next-article t (gnus-summary-article-subject)))
5825 (defun gnus-summary-prev-unread-same-subject ()
5826 "Select previous unread article which has the same subject as current one."
5828 (gnus-summary-prev-article t (gnus-summary-article-subject)))
5830 (defun gnus-summary-first-unread-article ()
5831 "Select the first unread article.
5832 Return nil if there are no unread articles."
5835 (when (gnus-summary-first-subject t)
5836 (gnus-summary-show-thread)
5837 (gnus-summary-first-subject t)
5838 (gnus-summary-display-article (gnus-summary-article-number)))
5839 (gnus-summary-position-point)))
5841 (defun gnus-summary-first-article ()
5842 "Select the first article.
5843 Return nil if there are no articles."
5846 (when (gnus-summary-first-subject)
5847 (gnus-summary-show-thread)
5848 (gnus-summary-first-subject)
5849 (gnus-summary-display-article (gnus-summary-article-number)))
5850 (gnus-summary-position-point)))
5852 (defun gnus-summary-best-unread-article ()
5853 "Select the unread article with the highest score."
5855 (let ((best -1000000)
5856 (data gnus-newsgroup-data)
5859 (and (gnus-data-unread-p (car data))
5861 (gnus-summary-article-score (gnus-data-number (car data))))
5864 article (gnus-data-number (car data))))
5865 (setq data (cdr data)))
5868 (gnus-summary-goto-article article)
5869 (error "No unread articles"))
5870 (gnus-summary-position-point))))
5872 (defun gnus-summary-last-subject ()
5873 "Go to the last displayed subject line in the group."
5874 (let ((article (gnus-data-number (car (gnus-data-list t)))))
5876 (gnus-summary-goto-subject article))))
5878 (defun gnus-summary-goto-article (article &optional all-headers force)
5879 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
5880 If ALL-HEADERS is non-nil, no header lines are hidden."
5884 "Article number or Message-ID: "
5885 (mapcar (lambda (number) (list (int-to-string number)))
5886 gnus-newsgroup-limit))
5890 (if (and (stringp article)
5891 (string-match "@" article))
5892 (gnus-summary-refer-article article)
5893 (when (stringp article)
5894 (setq article (string-to-number article)))
5895 (if (gnus-summary-goto-subject article force)
5896 (gnus-summary-display-article article all-headers)
5897 (gnus-message 4 "Couldn't go to article %s" article) nil))
5898 (gnus-summary-position-point)))
5900 (defun gnus-summary-goto-last-article ()
5901 "Go to the previously read article."
5904 (when gnus-last-article
5905 (gnus-summary-goto-article gnus-last-article nil t))
5906 (gnus-summary-position-point)))
5908 (defun gnus-summary-pop-article (number)
5909 "Pop one article off the history and go to the previous.
5910 NUMBER articles will be popped off."
5913 (setq gnus-newsgroup-history
5914 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
5916 (gnus-summary-goto-article (car to) nil t)
5917 (error "Article history empty")))
5918 (gnus-summary-position-point))
5920 ;; Summary commands and functions for limiting the summary buffer.
5922 (defun gnus-summary-limit-to-articles (n)
5923 "Limit the summary buffer to the next N articles.
5924 If not given a prefix, use the process marked articles instead."
5927 (let ((articles (gnus-summary-work-articles n)))
5928 (setq gnus-newsgroup-processable nil)
5929 (gnus-summary-limit articles))
5930 (gnus-summary-position-point)))
5932 (defun gnus-summary-pop-limit (&optional total)
5933 "Restore the previous limit.
5934 If given a prefix, remove all limits."
5937 (setq gnus-newsgroup-limits
5938 (list (mapcar (lambda (h) (mail-header-number h))
5939 gnus-newsgroup-headers))))
5940 (unless gnus-newsgroup-limits
5941 (error "No limit to pop"))
5943 (gnus-summary-limit nil 'pop)
5944 (gnus-summary-position-point)))
5946 (defun gnus-summary-limit-to-subject (subject &optional header)
5947 "Limit the summary buffer to articles that have subjects that match a regexp."
5948 (interactive "sLimit to subject (regexp): ")
5950 (setq header "subject"))
5951 (when (not (equal "" subject))
5953 (let ((articles (gnus-summary-find-matching
5954 (or header "subject") subject 'all)))
5956 (error "Found no matches for \"%s\"" subject))
5957 (gnus-summary-limit articles))
5958 (gnus-summary-position-point))))
5960 (defun gnus-summary-limit-to-author (from)
5961 "Limit the summary buffer to articles that have authors that match a regexp."
5962 (interactive "sLimit to author (regexp): ")
5963 (gnus-summary-limit-to-subject from "from"))
5965 (defun gnus-summary-limit-to-age (age &optional younger-p)
5966 "Limit the summary buffer to articles that are older than (or equal) AGE days.
5967 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
5968 articles that are younger than AGE days."
5969 (interactive "nTime in days: \nP")
5971 (let ((data gnus-newsgroup-data)
5972 (cutoff (nnmail-days-to-time age))
5973 articles d date is-younger)
5974 (while (setq d (pop data))
5975 (when (and (vectorp (gnus-data-header d))
5976 (setq date (mail-header-date (gnus-data-header d))))
5977 (setq is-younger (nnmail-time-less
5978 (nnmail-time-since (nnmail-date-to-time date))
5980 (when (if younger-p is-younger (not is-younger))
5981 (push (gnus-data-number d) articles))))
5982 (gnus-summary-limit (nreverse articles)))
5983 (gnus-summary-position-point)))
5985 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
5987 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
5989 (defun gnus-summary-limit-to-unread (&optional all)
5990 "Limit the summary buffer to articles that are not marked as read.
5991 If ALL is non-nil, limit strictly to unread articles."
5994 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
5995 (gnus-summary-limit-to-marks
5996 ;; Concat all the marks that say that an article is read and have
5998 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
5999 gnus-killed-mark gnus-kill-file-mark
6000 gnus-low-score-mark gnus-expirable-mark
6001 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
6002 gnus-duplicate-mark gnus-souped-mark)
6005 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
6006 (make-obsolete 'gnus-summary-delete-marked-with
6007 'gnus-summary-limit-exlude-marks)
6009 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
6010 "Exclude articles that are marked with MARKS (e.g. \"DK\").
6011 If REVERSE, limit the summary buffer to articles that are marked
6012 with MARKS. MARKS can either be a string of marks or a list of marks.
6013 Returns how many articles were removed."
6014 (interactive "sMarks: ")
6015 (gnus-summary-limit-to-marks marks t))
6017 (defun gnus-summary-limit-to-marks (marks &optional reverse)
6018 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
6019 If REVERSE (the prefix), limit the summary buffer to articles that are
6020 not marked with MARKS. MARKS can either be a string of marks or a
6022 Returns how many articles were removed."
6023 (interactive "sMarks: \nP")
6025 (let ((data gnus-newsgroup-data)
6026 (marks (if (listp marks) marks
6027 (append marks nil))) ; Transform to list.
6030 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
6031 (memq (gnus-data-mark (car data)) marks))
6032 (push (gnus-data-number (car data)) articles))
6033 (setq data (cdr data)))
6034 (gnus-summary-limit articles))
6035 (gnus-summary-position-point)))
6037 (defun gnus-summary-limit-to-score (&optional score)
6038 "Limit to articles with score at or above SCORE."
6040 (setq score (if score
6041 (prefix-numeric-value score)
6042 (or gnus-summary-default-score 0)))
6043 (let ((data gnus-newsgroup-data)
6046 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
6048 (push (gnus-data-number (car data)) articles))
6049 (setq data (cdr data)))
6051 (gnus-summary-limit articles)
6052 (gnus-summary-position-point))))
6054 (defun gnus-summary-limit-include-thread (id)
6055 "Display all the hidden articles that in the current thread."
6056 (interactive (list (mail-header-id (gnus-summary-article-header))))
6057 (let ((articles (gnus-articles-in-thread
6058 (gnus-id-to-thread (gnus-root-id id)))))
6060 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
6061 (gnus-summary-position-point))))
6063 (defun gnus-summary-limit-include-dormant ()
6064 "Display all the hidden articles that are marked as dormant.
6065 Note that this command only works on a subset of the articles currently
6066 fetched for this group."
6068 (unless gnus-newsgroup-dormant
6069 (error "There are no dormant articles in this group"))
6071 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
6072 (gnus-summary-position-point)))
6074 (defun gnus-summary-limit-exclude-dormant ()
6075 "Hide all dormant articles."
6078 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
6079 (gnus-summary-position-point)))
6081 (defun gnus-summary-limit-exclude-childless-dormant ()
6082 "Hide all dormant articles that have no children."
6084 (let ((data (gnus-data-list t))
6085 articles d children)
6086 ;; Find all articles that are either not dormant or have
6088 (while (setq d (pop data))
6089 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
6091 (gnus-article-children (gnus-data-number d)))
6094 (when (memq (car children) articles)
6099 (push (gnus-data-number d) articles)))
6102 (gnus-summary-limit articles)
6103 (gnus-summary-position-point))))
6105 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
6106 "Mark all unread excluded articles as read.
6107 If ALL, mark even excluded ticked and dormants as read."
6109 (let ((articles (gnus-sorted-complement
6111 (mapcar (lambda (h) (mail-header-number h))
6112 gnus-newsgroup-headers)
6114 (sort gnus-newsgroup-limit '<)))
6116 (setq gnus-newsgroup-unreads gnus-newsgroup-limit)
6118 (setq gnus-newsgroup-dormant nil
6119 gnus-newsgroup-marked nil
6120 gnus-newsgroup-reads
6122 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
6123 gnus-newsgroup-reads))
6124 (while (setq article (pop articles))
6125 (unless (or (memq article gnus-newsgroup-dormant)
6126 (memq article gnus-newsgroup-marked))
6127 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
6129 (defun gnus-summary-limit (articles &optional pop)
6131 ;; We pop the previous limit off the stack and use that.
6132 (setq articles (car gnus-newsgroup-limits)
6133 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
6134 ;; We use the new limit, so we push the old limit on the stack.
6135 (push gnus-newsgroup-limit gnus-newsgroup-limits))
6137 (setq gnus-newsgroup-limit articles)
6138 (let ((total (length gnus-newsgroup-data))
6139 (data (gnus-data-find-list (gnus-summary-article-number)))
6140 (gnus-summary-mark-below nil) ; Inhibit this.
6142 ;; This will do all the work of generating the new summary buffer
6143 ;; according to the new limit.
6144 (gnus-summary-prepare)
6145 ;; Hide any threads, possibly.
6146 (and gnus-show-threads
6147 gnus-thread-hide-subtree
6148 (gnus-summary-hide-all-threads))
6149 ;; Try to return to the article you were at, or one in the
6152 ;; We try to find some article after the current one.
6154 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
6157 (setq data (cdr data))))
6159 ;; If there is no data, that means that we were after the last
6160 ;; article. The same goes when we can't find any articles
6161 ;; after the current one.
6162 (goto-char (point-max))
6163 (gnus-summary-find-prev))
6164 ;; We return how many articles were removed from the summary
6165 ;; buffer as a result of the new limit.
6166 (- total (length gnus-newsgroup-data))))
6168 (defsubst gnus-invisible-cut-children (threads)
6171 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
6176 (defsubst gnus-cut-thread (thread)
6177 "Go forwards in the thread until we find an article that we want to display."
6178 (when (or (eq gnus-fetch-old-headers 'some)
6179 (eq gnus-fetch-old-headers 'invisible)
6180 (eq gnus-build-sparse-threads 'some)
6181 (eq gnus-build-sparse-threads 'more))
6182 ;; Deal with old-fetched headers and sparse threads.
6186 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
6187 (gnus-summary-article-ancient-p
6188 (mail-header-number (car thread))))
6189 (if (or (<= (length (cdr thread)) 1)
6190 (eq gnus-fetch-old-headers 'invisible))
6191 (setq gnus-newsgroup-limit
6192 (delq (mail-header-number (car thread))
6193 gnus-newsgroup-limit)
6194 thread (cadr thread))
6195 (when (gnus-invisible-cut-children (cdr thread))
6196 (let ((th (cdr thread)))
6198 (if (memq (mail-header-number (caar th))
6199 gnus-newsgroup-limit)
6200 (setq thread (car th)
6202 (setq th (cdr th))))))))))
6205 (defun gnus-cut-threads (threads)
6206 "Cut off all uninteresting articles from the beginning of threads."
6207 (when (or (eq gnus-fetch-old-headers 'some)
6208 (eq gnus-fetch-old-headers 'invisible)
6209 (eq gnus-build-sparse-threads 'some)
6210 (eq gnus-build-sparse-threads 'more))
6213 (setcar th (gnus-cut-thread (car th)))
6214 (setq th (cdr th)))))
6215 ;; Remove nixed out threads.
6218 (defun gnus-summary-initial-limit (&optional show-if-empty)
6219 "Figure out what the initial limit is supposed to be on group entry.
6220 This entails weeding out unwanted dormants, low-scored articles,
6221 fetch-old-headers verbiage, and so on."
6222 ;; Most groups have nothing to remove.
6223 (if (or gnus-inhibit-limiting
6224 (and (null gnus-newsgroup-dormant)
6225 (not (eq gnus-fetch-old-headers 'some))
6226 (not (eq gnus-fetch-old-headers 'invisible))
6227 (null gnus-summary-expunge-below)
6228 (not (eq gnus-build-sparse-threads 'some))
6229 (not (eq gnus-build-sparse-threads 'more))
6230 (null gnus-thread-expunge-below)
6231 (not gnus-use-nocem)))
6233 (push gnus-newsgroup-limit gnus-newsgroup-limits)
6234 (setq gnus-newsgroup-limit nil)
6237 (unless (car (symbol-value node))
6238 ;; These threads have no parents -- they are roots.
6239 (let ((nodes (cdr (symbol-value node)))
6242 (if (and gnus-thread-expunge-below
6243 (< (gnus-thread-total-score (car nodes))
6244 gnus-thread-expunge-below))
6245 (gnus-expunge-thread (pop nodes))
6246 (setq thread (pop nodes))
6247 (gnus-summary-limit-children thread))))))
6248 gnus-newsgroup-dependencies)
6249 ;; If this limitation resulted in an empty group, we might
6250 ;; pop the previous limit and use it instead.
6251 (when (and (not gnus-newsgroup-limit)
6253 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
6254 gnus-newsgroup-limit))
6256 (defun gnus-summary-limit-children (thread)
6257 "Return 1 if this subthread is visible and 0 if it is not."
6258 ;; First we get the number of visible children to this thread. This
6259 ;; is done by recursing down the thread using this function, so this
6260 ;; will really go down to a leaf article first, before slowly
6261 ;; working its way up towards the root.
6265 (apply '+ (mapcar 'gnus-summary-limit-children
6268 (number (mail-header-number (car thread)))
6271 (not (memq number gnus-newsgroup-marked))
6273 ;; If this article is dormant and has absolutely no visible
6274 ;; children, then this article isn't visible.
6275 (and (memq number gnus-newsgroup-dormant)
6277 ;; If this is "fetch-old-headered" and there is no
6278 ;; visible children, then we don't want this article.
6279 (and (eq gnus-fetch-old-headers 'some)
6280 (gnus-summary-article-ancient-p number)
6282 ;; If this is "fetch-old-headered" and `invisible', then
6283 ;; we don't want this article.
6284 (and (eq gnus-fetch-old-headers 'invisible)
6285 (gnus-summary-article-ancient-p number))
6286 ;; If this is a sparsely inserted article with no children,
6287 ;; we don't want it.
6288 (and (eq gnus-build-sparse-threads 'some)
6289 (gnus-summary-article-sparse-p number)
6291 ;; If we use expunging, and this article is really
6292 ;; low-scored, then we don't want this article.
6293 (when (and gnus-summary-expunge-below
6295 (or (cdr (assq number gnus-newsgroup-scored))
6296 gnus-summary-default-score))
6297 gnus-summary-expunge-below))
6298 ;; We increase the expunge-tally here, but that has
6299 ;; nothing to do with the limits, really.
6300 (incf gnus-newsgroup-expunged-tally)
6301 ;; We also mark as read here, if that's wanted.
6302 (when (and gnus-summary-mark-below
6303 (< score gnus-summary-mark-below))
6304 (setq gnus-newsgroup-unreads
6305 (delq number gnus-newsgroup-unreads))
6306 (if gnus-newsgroup-auto-expire
6307 (push number gnus-newsgroup-expirable)
6308 (push (cons number gnus-low-score-mark)
6309 gnus-newsgroup-reads)))
6311 ;; Check NoCeM things.
6312 (if (and gnus-use-nocem
6313 (gnus-nocem-unwanted-article-p
6314 (mail-header-id (car thread))))
6316 (setq gnus-newsgroup-unreads
6317 (delq number gnus-newsgroup-unreads))
6319 ;; Nope, invisible article.
6321 ;; Ok, this article is to be visible, so we add it to the limit
6323 (push number gnus-newsgroup-limit)
6326 (defun gnus-expunge-thread (thread)
6327 "Mark all articles in THREAD as read."
6328 (let* ((number (mail-header-number (car thread))))
6329 (incf gnus-newsgroup-expunged-tally)
6330 ;; We also mark as read here, if that's wanted.
6331 (setq gnus-newsgroup-unreads
6332 (delq number gnus-newsgroup-unreads))
6333 (if gnus-newsgroup-auto-expire
6334 (push number gnus-newsgroup-expirable)
6335 (push (cons number gnus-low-score-mark)
6336 gnus-newsgroup-reads)))
6337 ;; Go recursively through all subthreads.
6338 (mapcar 'gnus-expunge-thread (cdr thread)))
6340 ;; Summary article oriented commands
6342 (defun gnus-summary-refer-parent-article (n)
6343 "Refer parent article N times.
6344 If N is negative, go to ancestor -N instead.
6345 The difference between N and the number of articles fetched is returned."
6349 (when (not (natnump n))
6354 (setq header (gnus-summary-article-header))
6355 (if (and (eq (mail-header-number header)
6356 (cdr gnus-article-current))
6357 (equal gnus-newsgroup-name
6358 (car gnus-article-current)))
6359 ;; If we try to find the parent of the currently
6360 ;; displayed article, then we take a look at the actual
6361 ;; References header, since this is slightly more
6362 ;; reliable than the References field we got from the
6365 (set-buffer gnus-original-article-buffer)
6366 (nnheader-narrow-to-headers)
6367 (unless (setq ref (message-fetch-field "references"))
6368 (setq ref (message-fetch-field "in-reply-to")))
6371 ;; It's not the current article, so we take a bet on
6372 ;; the value we got from the server.
6373 (mail-header-references header)))
6375 (not (equal ref "")))
6376 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
6377 (gnus-message 1 "Couldn't find parent"))
6378 (gnus-message 1 "No references in article %d"
6379 (gnus-summary-article-number))
6382 (gnus-summary-position-point)
6385 (defun gnus-summary-refer-references ()
6386 "Fetch all articles mentioned in the References header.
6387 Return the number of articles fetched."
6389 (let ((ref (mail-header-references (gnus-summary-article-header)))
6390 (current (gnus-summary-article-number))
6394 (error "No References in the current article")
6395 ;; For each Message-ID in the References header...
6396 (while (string-match "<[^>]*>" ref)
6398 ;; ... fetch that article.
6399 (gnus-summary-refer-article
6400 (prog1 (match-string 0 ref)
6401 (setq ref (substring ref (match-end 0))))))
6402 (gnus-summary-goto-subject current)
6403 (gnus-summary-position-point)
6406 (defun gnus-summary-refer-thread (&optional limit)
6407 "Fetch all articles in the current thread.
6408 If LIMIT (the numerical prefix), fetch that many old headers instead
6409 of what's specified by the `gnus-refer-thread-limit' variable."
6411 (let ((id (mail-header-id (gnus-summary-article-header)))
6412 (limit (if limit (prefix-numeric-value limit)
6413 gnus-refer-thread-limit))
6415 ;; We want to fetch LIMIT *old* headers, but we also have to
6416 ;; re-fetch all the headers in the current buffer, because many of
6417 ;; them may be undisplayed. So we adjust LIMIT.
6418 (when (numberp limit)
6419 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
6420 (unless (eq gnus-fetch-old-headers 'invisible)
6421 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
6422 ;; Retrieve the headers and read them in.
6423 (if (eq (gnus-retrieve-headers
6424 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
6426 (gnus-build-all-threads)
6427 (error "Can't fetch thread from backends that don't support NOV"))
6428 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
6429 (gnus-summary-limit-include-thread id)))
6431 (defun gnus-summary-refer-article (message-id &optional arg)
6432 "Fetch an article specified by MESSAGE-ID.
6433 If ARG (the prefix), fetch the article using `gnus-refer-article-method'
6434 or `gnus-select-method', no matter what backend the article comes from."
6435 (interactive "sMessage-ID: \nP")
6436 (when (and (stringp message-id)
6437 (not (zerop (length message-id))))
6438 ;; Construct the correct Message-ID if necessary.
6439 ;; Suggested by tale@pawl.rpi.edu.
6440 (unless (string-match "^<" message-id)
6441 (setq message-id (concat "<" message-id)))
6442 (unless (string-match ">$" message-id)
6443 (setq message-id (concat message-id ">")))
6444 (let* ((header (gnus-id-to-header message-id))
6446 (gnus-summary-article-sparse-p
6447 (mail-header-number header))
6448 (memq (mail-header-number header)
6449 gnus-newsgroup-limit)))
6452 ;; If the article is present in the buffer we just go to it.
6454 (or (not (gnus-summary-article-sparse-p
6455 (mail-header-number header)))
6458 (gnus-summary-goto-article
6459 (mail-header-number header) nil t)
6461 (gnus-summary-update-article (mail-header-number header)))))
6463 ;; We fetch the article
6464 (let ((gnus-override-method
6465 (cond ((gnus-news-group-p gnus-newsgroup-name)
6466 gnus-refer-article-method)
6468 (or gnus-refer-article-method gnus-select-method))
6471 ;; Start the special refer-article method, if necessary.
6472 (when (and gnus-refer-article-method
6473 (gnus-news-group-p gnus-newsgroup-name))
6474 (gnus-check-server gnus-refer-article-method))
6475 ;; Fetch the header, and display the article.
6476 (if (setq number (gnus-summary-insert-subject message-id))
6477 (gnus-summary-select-article nil nil nil number)
6478 (gnus-message 3 "Couldn't fetch article %s" message-id))))))))
6480 (defun gnus-summary-edit-parameters ()
6481 "Edit the group parameters of the current group."
6482 (gnus-group-edit-group gnus-newsgroup-name 'params))
6484 (defun gnus-summary-enter-digest-group (&optional force)
6485 "Enter an nndoc group based on the current article.
6486 If FORCE, force a digest interpretation. If not, try
6487 to guess what the document format is."
6489 (let ((conf gnus-current-window-configuration))
6491 (gnus-summary-select-article))
6492 (setq gnus-current-window-configuration conf)
6493 (let* ((name (format "%s-%d"
6494 (gnus-group-prefixed-name
6495 gnus-newsgroup-name (list 'nndoc ""))
6497 (set-buffer gnus-summary-buffer)
6498 gnus-current-article)))
6499 (ogroup gnus-newsgroup-name)
6500 (params (append (gnus-info-params (gnus-get-info ogroup))
6501 (list (cons 'to-group ogroup))
6502 (list (cons 'save-article-group ogroup))))
6503 (case-fold-search t)
6504 (buf (current-buffer))
6507 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
6508 (insert-buffer-substring gnus-original-article-buffer)
6509 ;; Remove lines that may lead nndoc to misinterpret the
6512 (goto-char (point-min))
6513 (or (search-forward "\n\n" nil t) (point)))
6514 (goto-char (point-min))
6515 (delete-matching-lines "^\\(Path\\):\\|^From ")
6518 (if (gnus-group-read-ephemeral-group
6519 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
6521 ,(if force 'digest 'guess))) t)
6522 ;; Make all postings to this group go to the parent group.
6523 (nconc (gnus-info-params (gnus-get-info name))
6525 ;; Couldn't select this doc group.
6526 (switch-to-buffer buf)
6527 (gnus-set-global-variables)
6528 (gnus-configure-windows 'summary)
6529 (gnus-message 3 "Article couldn't be entered?"))
6530 (kill-buffer dig)))))
6532 (defun gnus-summary-read-document (n)
6533 "Open a new group based on the current article(s).
6534 This will allow you to read digests and other similar
6535 documents as newsgroups.
6536 Obeys the standard process/prefix convention."
6538 (let* ((articles (gnus-summary-work-articles n))
6539 (ogroup gnus-newsgroup-name)
6540 (params (append (gnus-info-params (gnus-get-info ogroup))
6541 (list (cons 'to-group ogroup))))
6542 article group egroup groups vgroup)
6543 (while (setq article (pop articles))
6544 (setq group (format "%s-%d" gnus-newsgroup-name article))
6545 (gnus-summary-remove-process-mark article)
6546 (when (gnus-summary-display-article article)
6548 (nnheader-temp-write nil
6549 (insert-buffer-substring gnus-original-article-buffer)
6550 ;; Remove some headers that may lead nndoc to make
6552 (message-narrow-to-head)
6553 (goto-char (point-min))
6554 (delete-matching-lines "^\\(Path\\):\\|^From ")
6557 (gnus-group-read-ephemeral-group
6558 group `(nndoc ,group (nndoc-address ,(current-buffer))
6559 (nndoc-article-type guess))
6562 ;; Make all postings to this group go to the parent group.
6563 (nconc (gnus-info-params (gnus-get-info egroup))
6565 (push egroup groups))
6566 ;; Couldn't select this doc group.
6567 (gnus-error 3 "Article couldn't be entered"))))))
6568 ;; Now we have selected all the documents.
6571 (error "None of the articles could be interpreted as documents"))
6572 ((gnus-group-read-ephemeral-group
6573 (setq vgroup (format
6574 "nnvirtual:%s-%s" gnus-newsgroup-name
6575 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
6576 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
6578 (cons (current-buffer) 'summary)))
6580 (error "Couldn't select virtual nndoc group")))))
6582 (defun gnus-summary-isearch-article (&optional regexp-p)
6583 "Do incremental search forward on the current article.
6584 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
6586 (gnus-summary-select-article)
6587 (gnus-configure-windows 'article)
6588 (gnus-eval-in-buffer-window gnus-article-buffer
6591 (isearch-forward regexp-p))))
6593 (defun gnus-summary-search-article-forward (regexp &optional backward)
6594 "Search for an article containing REGEXP forward.
6595 If BACKWARD, search backward instead."
6598 (format "Search article %s (regexp%s): "
6599 (if current-prefix-arg "backward" "forward")
6600 (if gnus-last-search-regexp
6601 (concat ", default " gnus-last-search-regexp)
6603 current-prefix-arg))
6604 (if (string-equal regexp "")
6605 (setq regexp (or gnus-last-search-regexp ""))
6606 (setq gnus-last-search-regexp regexp))
6607 (if (gnus-summary-search-article regexp backward)
6608 (gnus-summary-show-thread)
6609 (error "Search failed: \"%s\"" regexp)))
6611 (defun gnus-summary-search-article-backward (regexp)
6612 "Search for an article containing REGEXP backward."
6615 (format "Search article backward (regexp%s): "
6616 (if gnus-last-search-regexp
6617 (concat ", default " gnus-last-search-regexp)
6619 (gnus-summary-search-article-forward regexp 'backward))
6621 (defun gnus-summary-search-article (regexp &optional backward)
6622 "Search for an article containing REGEXP.
6623 Optional argument BACKWARD means do search for backward.
6624 `gnus-select-article-hook' is not called during the search."
6625 ;; We have to require this here to make sure that the following
6626 ;; dynamic binding isn't shadowed by autoloading.
6627 (require 'gnus-async)
6628 (let ((gnus-select-article-hook nil) ;Disable hook.
6629 (gnus-article-display-hook nil)
6630 (gnus-mark-article-hook nil) ;Inhibit marking as read.
6631 (gnus-use-article-prefetch nil)
6632 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
6633 (gnus-use-trees nil) ;Inhibit updating tree buffer.
6634 (sum (current-buffer))
6637 (gnus-save-hidden-threads
6638 (gnus-summary-select-article)
6639 (set-buffer gnus-article-buffer)
6643 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
6645 (re-search-backward regexp nil t)
6646 (re-search-forward regexp nil t))
6647 ;; We found the regexp.
6652 (get-buffer-window (current-buffer))
6656 (setq point (point)))
6657 ;; We didn't find it, so we go to the next article.
6660 (while (eq found 'not)
6661 (if (not (if backward (gnus-summary-find-prev)
6662 (gnus-summary-find-next)))
6663 ;; No more articles.
6665 ;; Select the next article and adjust point.
6666 (unless (gnus-summary-article-sparse-p
6667 (gnus-summary-article-number))
6669 (gnus-summary-select-article)
6670 (set-buffer gnus-article-buffer)
6672 (goto-char (if backward (point-max) (point-min))))))))
6673 (gnus-message 7 ""))
6674 ;; Return whether we found the regexp.
6675 (when (eq found 'found)
6677 (gnus-summary-show-thread)
6678 (gnus-summary-goto-subject gnus-current-article)
6679 (gnus-summary-position-point)
6682 (defun gnus-summary-find-matching (header regexp &optional backward unread
6684 "Return a list of all articles that match REGEXP on HEADER.
6685 The search stars on the current article and goes forwards unless
6686 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
6687 If UNREAD is non-nil, only unread articles will
6688 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
6689 in the comparisons."
6690 (let ((data (if (eq backward 'all) gnus-newsgroup-data
6691 (gnus-data-find-list
6692 (gnus-summary-article-number) (gnus-data-list backward))))
6693 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
6694 (case-fold-search (not not-case-fold))
6696 (unless (fboundp (intern (concat "mail-header-" header)))
6697 (error "%s is not a valid header" header))
6700 (and (or (not unread) ; We want all articles...
6701 (gnus-data-unread-p d)) ; Or just unreads.
6702 (vectorp (gnus-data-header d)) ; It's not a pseudo.
6703 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
6704 (push (gnus-data-number d) articles)) ; Success!
6705 (setq data (cdr data)))
6706 (nreverse articles)))
6708 (defun gnus-summary-execute-command (header regexp command &optional backward)
6709 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
6710 If HEADER is an empty string (or nil), the match is done on the entire
6711 article. If BACKWARD (the prefix) is non-nil, search backward instead."
6713 (list (let ((completion-ignore-case t))
6716 (mapcar (lambda (string) (list string))
6717 '("Number" "Subject" "From" "Lines" "Date"
6718 "Message-ID" "Xref" "References" "Body"))
6719 nil 'require-match))
6720 (read-string "Regexp: ")
6721 (read-key-sequence "Command: ")
6722 current-prefix-arg))
6723 (when (equal header "Body")
6725 ;; Hidden thread subtrees must be searched as well.
6726 (gnus-summary-show-all-threads)
6727 ;; We don't want to change current point nor window configuration.
6729 (save-window-excursion
6730 (gnus-message 6 "Executing %s..." (key-description command))
6731 ;; We'd like to execute COMMAND interactively so as to give arguments.
6732 (gnus-execute header regexp
6733 `(call-interactively ',(key-binding command))
6735 (gnus-message 6 "Executing %s...done" (key-description command)))))
6737 (defun gnus-summary-beginning-of-article ()
6738 "Scroll the article back to the beginning."
6740 (gnus-summary-select-article)
6741 (gnus-configure-windows 'article)
6742 (gnus-eval-in-buffer-window gnus-article-buffer
6744 (goto-char (point-min))
6745 (when gnus-page-broken
6746 (gnus-narrow-to-page))))
6748 (defun gnus-summary-end-of-article ()
6749 "Scroll to the end of the article."
6751 (gnus-summary-select-article)
6752 (gnus-configure-windows 'article)
6753 (gnus-eval-in-buffer-window gnus-article-buffer
6755 (goto-char (point-max))
6757 (when gnus-page-broken
6758 (gnus-narrow-to-page))))
6760 (defun gnus-summary-print-article (&optional filename n)
6761 "Generate and print a PostScript image of the N next (mail) articles.
6763 If N is negative, print the N previous articles. If N is nil and articles
6764 have been marked with the process mark, print these instead.
6766 If the optional second argument FILENAME is nil, send the image to the
6767 printer. If FILENAME is a string, save the PostScript image in a file with
6768 that name. If FILENAME is a number, prompt the user for the name of the file
6770 (interactive (list (ps-print-preprint current-prefix-arg)
6771 current-prefix-arg))
6772 (dolist (article (gnus-summary-work-articles n))
6773 (gnus-summary-select-article nil nil 'pseudo article)
6774 (gnus-eval-in-buffer-window gnus-article-buffer
6775 (let ((buffer (generate-new-buffer " *print*")))
6778 (copy-to-buffer buffer (point-min) (point-max))
6780 (gnus-article-delete-invisible-text)
6781 (let ((ps-left-header
6784 (mail-header-subject gnus-current-headers) ")")
6786 (mail-header-from gnus-current-headers) ")")))
6789 "/pagenumberstring load"
6791 (mail-header-date gnus-current-headers) ")"))))
6792 (gnus-run-hooks 'gnus-ps-print-hook)
6793 (ps-print-buffer-with-faces filename)))
6794 (kill-buffer buffer))))))
6796 (defun gnus-summary-show-article (&optional arg)
6797 "Force re-fetching of the current article.
6798 If ARG (the prefix) is non-nil, show the raw article without any
6799 article massaging functions being run."
6802 ;; Select the article the normal way.
6803 (gnus-summary-select-article nil 'force)
6804 ;; Bind the article treatment functions to nil.
6805 (let ((gnus-have-all-headers t)
6806 gnus-article-display-hook
6807 gnus-article-prepare-hook
6811 (gnus-summary-select-article nil 'force)))
6812 (gnus-summary-goto-subject gnus-current-article)
6813 (gnus-summary-position-point))
6815 (defun gnus-summary-verbose-headers (&optional arg)
6816 "Toggle permanent full header display.
6817 If ARG is a positive number, turn header display on.
6818 If ARG is a negative number, turn header display off."
6820 (setq gnus-show-all-headers
6821 (cond ((or (not (numberp arg))
6823 (not gnus-show-all-headers))
6826 (gnus-summary-show-article))
6828 (defun gnus-summary-toggle-header (&optional arg)
6829 "Show the headers if they are hidden, or hide them if they are shown.
6830 If ARG is a positive number, show the entire header.
6831 If ARG is a negative number, hide the unwanted header lines."
6834 (set-buffer gnus-article-buffer)
6835 (let* ((buffer-read-only nil)
6836 (inhibit-point-motion-hooks t)
6837 (hidden (text-property-any
6838 (goto-char (point-min)) (search-forward "\n\n")
6841 (goto-char (point-min))
6842 (when (search-forward "\n\n" nil t)
6843 (delete-region (point-min) (1- (point))))
6844 (goto-char (point-min))
6846 (set-buffer gnus-original-article-buffer)
6847 (goto-char (point-min))
6848 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
6849 (insert-buffer-substring gnus-original-article-buffer 1 e)
6850 (let ((article-inhibit-hiding t))
6851 (gnus-run-hooks 'gnus-article-display-hook))
6852 (when (or (not hidden) (and (numberp arg) (< arg 0)))
6853 (gnus-article-hide-headers)))))
6855 (defun gnus-summary-show-all-headers ()
6856 "Make all header lines visible."
6858 (gnus-article-show-all-headers))
6860 (defun gnus-summary-toggle-mime (&optional arg)
6861 "Toggle MIME processing.
6862 If ARG is a positive number, turn MIME processing on."
6864 (setq gnus-show-mime
6865 (if (null arg) (not gnus-show-mime)
6866 (> (prefix-numeric-value arg) 0)))
6867 (gnus-summary-select-article t 'force))
6869 (defun gnus-summary-caesar-message (&optional arg)
6870 "Caesar rotate the current article by 13.
6871 The numerical prefix specifies how many places to rotate each letter
6874 (gnus-summary-select-article)
6875 (let ((mail-header-separator ""))
6876 (gnus-eval-in-buffer-window gnus-article-buffer
6879 (let ((start (window-start))
6881 (message-caesar-buffer-body arg)
6882 (set-window-start (get-buffer-window (current-buffer)) start))))))
6884 (defun gnus-summary-stop-page-breaking ()
6885 "Stop page breaking in the current article."
6887 (gnus-summary-select-article)
6888 (gnus-eval-in-buffer-window gnus-article-buffer
6890 (when (gnus-visual-p 'page-marker)
6891 (let ((buffer-read-only nil))
6892 (gnus-remove-text-with-property 'gnus-prev)
6893 (gnus-remove-text-with-property 'gnus-next)))))
6895 (defun gnus-summary-move-article (&optional n to-newsgroup
6896 select-method action)
6897 "Move the current article to a different newsgroup.
6898 If N is a positive number, move the N next articles.
6899 If N is a negative number, move the N previous articles.
6900 If N is nil and any articles have been marked with the process mark,
6901 move those articles instead.
6902 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
6903 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
6904 re-spool using this method.
6906 For this function to work, both the current newsgroup and the
6907 newsgroup that you want to move to have to support the `request-move'
6908 and `request-accept' functions."
6911 (setq action 'move))
6912 ;; Disable marking as read.
6913 (let (gnus-mark-article-hook)
6914 (save-window-excursion
6915 (gnus-summary-select-article)))
6916 ;; Check whether the source group supports the required functions.
6917 (cond ((and (eq action 'move)
6918 (not (gnus-check-backend-function
6919 'request-move-article gnus-newsgroup-name)))
6920 (error "The current group does not support article moving"))
6921 ((and (eq action 'crosspost)
6922 (not (gnus-check-backend-function
6923 'request-replace-article gnus-newsgroup-name)))
6924 (error "The current group does not support article editing")))
6925 (let ((articles (gnus-summary-work-articles n))
6926 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
6927 (names '((move "Move" "Moving")
6928 (copy "Copy" "Copying")
6929 (crosspost "Crosspost" "Crossposting")))
6930 (copy-buf (save-excursion
6931 (nnheader-set-temp-buffer " *copy article*")))
6932 art-group to-method new-xref article to-groups)
6933 (unless (assq action names)
6934 (error "Unknown action %s" action))
6935 ;; Read the newsgroup name.
6936 (when (and (not to-newsgroup)
6937 (not select-method))
6939 (gnus-read-move-group-name
6940 (cadr (assq action names))
6941 (symbol-value (intern (format "gnus-current-%s-group" action)))
6943 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
6944 (setq to-method (or select-method
6945 (gnus-group-name-to-method to-newsgroup)))
6946 ;; Check the method we are to move this article to...
6947 (unless (gnus-check-backend-function
6948 'request-accept-article (car to-method))
6949 (error "%s does not support article copying" (car to-method)))
6950 (unless (gnus-check-server to-method)
6951 (error "Can't open server %s" (car to-method)))
6952 (gnus-message 6 "%s to %s: %s..."
6953 (caddr (assq action names))
6954 (or (car select-method) to-newsgroup) articles)
6956 (setq article (pop articles))
6960 ;; Move the article.
6962 ;; Remove this article from future suppression.
6963 (gnus-dup-unsuppress-article article)
6964 (gnus-request-move-article
6965 article ; Article to move
6966 gnus-newsgroup-name ; From newsgroup
6967 (nth 1 (gnus-find-method-for-group
6968 gnus-newsgroup-name)) ; Server
6969 (list 'gnus-request-accept-article
6970 to-newsgroup (list 'quote select-method)
6971 (not articles)) ; Accept form
6972 (not articles))) ; Only save nov last time
6973 ;; Copy the article.
6976 (set-buffer copy-buf)
6977 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
6978 (gnus-request-accept-article
6979 to-newsgroup select-method (not articles)))))
6980 ;; Crosspost the article.
6981 ((eq action 'crosspost)
6982 (let ((xref (message-tokenize-header
6983 (mail-header-xref (gnus-summary-article-header article))
6985 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
6988 (setq xref (list (system-name))))
6991 (mapconcat 'identity
6992 (delete "Xref:" (delete new-xref xref))
6996 (set-buffer copy-buf)
6997 ;; First put the article in the destination group.
6998 (gnus-request-article-this-buffer article gnus-newsgroup-name)
6999 (when (consp (setq art-group
7000 (gnus-request-accept-article
7001 to-newsgroup select-method (not articles))))
7002 (setq new-xref (concat new-xref " " (car art-group)
7003 ":" (cdr art-group)))
7004 ;; Now we have the new Xrefs header, so we insert
7005 ;; it and replace the new article.
7006 (nnheader-replace-header "Xref" new-xref)
7007 (gnus-request-replace-article
7008 (cdr art-group) to-newsgroup (current-buffer))
7012 (gnus-message 1 "Couldn't %s article %s"
7013 (cadr (assq action names)) article))
7014 ((and (eq art-group 'junk)
7016 (gnus-summary-mark-article article gnus-canceled-mark)
7017 (gnus-message 4 "Deleted article %s" article))
7021 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
7023 (gnus-group-prefixed-name
7026 (gnus-find-method-for-group to-newsgroup)))
7027 gnus-newsrc-hashtb)))
7028 (info (nth 2 entry))
7029 (to-group (gnus-info-group info)))
7030 ;; Update the group that has been moved to.
7032 (memq action '(move copy)))
7033 (unless (member to-group to-groups)
7034 (push to-group to-groups))
7036 (unless (memq article gnus-newsgroup-unreads)
7038 info (gnus-add-to-range (gnus-info-read info)
7039 (list (cdr art-group)))))
7041 ;; Copy any marks over to the new group.
7042 (let ((marks gnus-article-mark-lists)
7043 (to-article (cdr art-group)))
7045 ;; See whether the article is to be put in the cache.
7046 (when gnus-use-cache
7047 (gnus-cache-possibly-enter-article
7049 (let ((header (copy-sequence
7050 (gnus-summary-article-header article))))
7051 (mail-header-set-number header to-article)
7053 (memq article gnus-newsgroup-marked)
7054 (memq article gnus-newsgroup-dormant)
7055 (memq article gnus-newsgroup-unreads)))
7057 (when (and (equal to-group gnus-newsgroup-name)
7058 (not (memq article gnus-newsgroup-unreads)))
7059 ;; Mark this article as read in this group.
7060 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
7061 (setcdr (gnus-active to-group) to-article)
7062 (setcdr gnus-newsgroup-active to-article))
7065 (when (memq article (symbol-value
7066 (intern (format "gnus-newsgroup-%s"
7068 ;; If the other group is the same as this group,
7069 ;; then we have to add the mark to the list.
7070 (when (equal to-group gnus-newsgroup-name)
7071 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
7074 (intern (format "gnus-newsgroup-%s"
7076 ;; Copy the marks to other group.
7077 (gnus-add-marked-articles
7078 to-group (cdar marks) (list to-article) info))
7079 (setq marks (cdr marks)))
7082 (concat "(gnus-group-set-info '"
7083 (gnus-prin1-to-string (gnus-get-info to-group))
7086 ;; Update the Xref header in this article to point to
7087 ;; the new crossposted article we have just created.
7088 (when (eq action 'crosspost)
7090 (set-buffer copy-buf)
7091 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7092 (nnheader-replace-header "Xref" new-xref)
7093 (gnus-request-replace-article
7094 article gnus-newsgroup-name (current-buffer)))))
7096 ;;;!!!Why is this necessary?
7097 (set-buffer gnus-summary-buffer)
7099 (gnus-summary-goto-subject article)
7100 (when (eq action 'move)
7101 (gnus-summary-mark-article article gnus-canceled-mark))))
7102 (gnus-summary-remove-process-mark article))
7103 ;; Re-activate all groups that have been moved to.
7106 (set-buffer gnus-group-buffer)
7107 (when (gnus-group-goto-group (car to-groups) t)
7108 (gnus-group-get-new-news-this-group 1 t))
7111 (gnus-kill-buffer copy-buf)
7112 (gnus-summary-position-point)
7113 (gnus-set-mode-line 'summary)))
7115 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
7116 "Move the current article to a different newsgroup.
7117 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7118 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7119 re-spool using this method."
7121 (gnus-summary-move-article n to-newsgroup select-method 'copy))
7123 (defun gnus-summary-crosspost-article (&optional n)
7124 "Crosspost the current article to some other group."
7126 (gnus-summary-move-article n nil nil 'crosspost))
7128 (defcustom gnus-summary-respool-default-method nil
7129 "*Default method for respooling an article.
7130 If nil, use to the current newsgroup method."
7131 :type `(choice (gnus-select-method :value (nnml ""))
7133 :group 'gnus-summary-mail)
7135 (defun gnus-summary-respool-article (&optional n method)
7136 "Respool the current article.
7137 The article will be squeezed through the mail spooling process again,
7138 which means that it will be put in some mail newsgroup or other
7139 depending on `nnmail-split-methods'.
7140 If N is a positive number, respool the N next articles.
7141 If N is a negative number, respool the N previous articles.
7142 If N is nil and any articles have been marked with the process mark,
7143 respool those articles instead.
7145 Respooling can be done both from mail groups and \"real\" newsgroups.
7146 In the former case, the articles in question will be moved from the
7147 current group into whatever groups they are destined to. In the
7148 latter case, they will be copied into the relevant groups."
7150 (list current-prefix-arg
7151 (let* ((methods (gnus-methods-using 'respool))
7153 (symbol-name (or gnus-summary-respool-default-method
7154 (car (gnus-find-method-for-group
7155 gnus-newsgroup-name)))))
7157 (gnus-completing-read
7158 methname "What backend do you want to use when respooling?"
7159 methods nil t nil 'gnus-mail-method-history))
7162 ((zerop (length (setq ms (gnus-servers-using-backend
7164 (list (intern method) ""))
7168 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
7169 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
7172 (error "No method given for respooling"))
7173 (if (assoc (symbol-name
7174 (car (gnus-find-method-for-group gnus-newsgroup-name)))
7175 (gnus-methods-using 'respool))
7176 (gnus-summary-move-article n nil method)
7177 (gnus-summary-copy-article n nil method)))
7179 (defun gnus-summary-import-article (file)
7180 "Import a random file into a mail newsgroup."
7181 (interactive "fImport file: ")
7182 (let ((group gnus-newsgroup-name)
7183 (now (current-time))
7185 (unless (gnus-check-backend-function 'request-accept-article group)
7186 (error "%s does not support article importing" group))
7187 (or (file-readable-p file)
7188 (not (file-regular-p file))
7189 (error "Can't read %s" file))
7191 (set-buffer (get-buffer-create " *import file*"))
7192 (buffer-disable-undo (current-buffer))
7194 (insert-file-contents file)
7195 (goto-char (point-min))
7196 (unless (nnheader-article-p)
7197 ;; This doesn't look like an article, so we fudge some headers.
7198 (setq atts (file-attributes file)
7199 lines (count-lines (point-min) (point-max)))
7200 (insert "From: " (read-string "From: ") "\n"
7201 "Subject: " (read-string "Subject: ") "\n"
7202 "Date: " (timezone-make-date-arpa-standard
7203 (current-time-string (nth 5 atts))
7204 (current-time-zone now)
7205 (current-time-zone now))
7207 "Message-ID: " (message-make-message-id) "\n"
7208 "Lines: " (int-to-string lines) "\n"
7209 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
7210 (gnus-request-accept-article group nil t)
7211 (kill-buffer (current-buffer)))))
7213 (defun gnus-summary-article-posted-p ()
7214 "Say whether the current (mail) article is available from `gnus-select-method' as well.
7215 This will be the case if the article has both been mailed and posted."
7217 (let ((id (mail-header-references (gnus-summary-article-header)))
7218 (gnus-override-method
7219 (or gnus-refer-article-method gnus-select-method)))
7220 (if (gnus-request-head id "")
7221 (gnus-message 2 "The current message was found on %s"
7222 gnus-override-method)
7223 (gnus-message 2 "The current message couldn't be found on %s"
7224 gnus-override-method)
7227 (defun gnus-summary-expire-articles (&optional now)
7228 "Expire all articles that are marked as expirable in the current group."
7230 (when (gnus-check-backend-function
7231 'request-expire-articles gnus-newsgroup-name)
7232 ;; This backend supports expiry.
7233 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
7234 (expirable (if total
7236 ;; We need to update the info for
7237 ;; this group for `gnus-list-of-read-articles'
7238 ;; to give us the right answer.
7239 (gnus-run-hooks 'gnus-exit-group-hook)
7240 (gnus-summary-update-info)
7241 (gnus-list-of-read-articles gnus-newsgroup-name))
7242 (setq gnus-newsgroup-expirable
7243 (sort gnus-newsgroup-expirable '<))))
7244 (expiry-wait (if now 'immediate
7245 (gnus-group-find-parameter
7246 gnus-newsgroup-name 'expiry-wait)))
7249 ;; There are expirable articles in this group, so we run them
7250 ;; through the expiry process.
7251 (gnus-message 6 "Expiring articles...")
7252 ;; The list of articles that weren't expired is returned.
7255 (let ((nnmail-expiry-wait-function nil)
7256 (nnmail-expiry-wait expiry-wait))
7257 (setq es (gnus-request-expire-articles
7258 expirable gnus-newsgroup-name)))
7259 (setq es (gnus-request-expire-articles
7260 expirable gnus-newsgroup-name))))
7262 (setq gnus-newsgroup-expirable es))
7263 ;; We go through the old list of expirable, and mark all
7264 ;; really expired articles as nonexistent.
7265 (unless (eq es expirable) ;If nothing was expired, we don't mark.
7266 (let ((gnus-use-cache nil))
7268 (unless (memq (car expirable) es)
7269 (when (gnus-data-find (car expirable))
7270 (gnus-summary-mark-article
7271 (car expirable) gnus-canceled-mark)))
7272 (setq expirable (cdr expirable)))))
7273 (gnus-message 6 "Expiring articles...done")))))
7275 (defun gnus-summary-expire-articles-now ()
7276 "Expunge all expirable articles in the current group.
7277 This means that *all* articles that are marked as expirable will be
7278 deleted forever, right now."
7280 (unless gnus-expert-user
7282 "Are you really, really, really sure you want to delete all these messages? ")
7284 (gnus-summary-expire-articles t))
7286 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
7287 (defun gnus-summary-delete-article (&optional n)
7288 "Delete the N next (mail) articles.
7289 This command actually deletes articles. This is not a marking
7290 command. The article will disappear forever from your life, never to
7292 If N is negative, delete backwards.
7293 If N is nil and articles have been marked with the process mark,
7294 delete these instead."
7296 (unless (gnus-check-backend-function 'request-expire-articles
7297 gnus-newsgroup-name)
7298 (error "The current newsgroup does not support article deletion"))
7299 ;; Compute the list of articles to delete.
7300 (let ((articles (gnus-summary-work-articles n))
7302 (if (and gnus-novice-user
7303 (not (gnus-yes-or-no-p
7304 (format "Do you really want to delete %s forever? "
7305 (if (> (length articles) 1)
7306 (format "these %s articles" (length articles))
7309 ;; Delete the articles.
7310 (setq not-deleted (gnus-request-expire-articles
7311 articles gnus-newsgroup-name 'force))
7313 (gnus-summary-remove-process-mark (car articles))
7314 ;; The backend might not have been able to delete the article
7316 (unless (memq (car articles) not-deleted)
7317 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
7318 (setq articles (cdr articles)))
7320 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
7321 (gnus-summary-position-point)
7322 (gnus-set-mode-line 'summary)
7325 (defun gnus-summary-edit-article (&optional force)
7326 "Edit the current article.
7327 This will have permanent effect only in mail groups.
7328 If FORCE is non-nil, allow editing of articles even in read-only
7332 (set-buffer gnus-summary-buffer)
7333 (gnus-set-global-variables)
7334 (when (and (not force)
7335 (gnus-group-read-only-p))
7336 (error "The current newsgroup does not support article editing"))
7337 ;; Select article if needed.
7338 (unless (eq (gnus-summary-article-number)
7339 gnus-current-article)
7340 (gnus-summary-select-article t))
7341 (gnus-article-date-original)
7342 (gnus-article-edit-article
7343 `(lambda (no-highlight)
7344 (gnus-summary-edit-article-done
7345 ,(or (mail-header-references gnus-current-headers) "")
7346 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))))
7348 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
7350 (defun gnus-summary-edit-article-done (&optional references read-only buffer
7352 "Make edits to the current article permanent."
7354 ;; Replace the article.
7355 (if (and (not read-only)
7356 (not (gnus-request-replace-article
7357 (cdr gnus-article-current) (car gnus-article-current)
7359 (error "Couldn't replace article")
7360 ;; Update the summary buffer.
7362 (equal (message-tokenize-header references " ")
7363 (message-tokenize-header
7364 (or (message-fetch-field "references") "") " ")))
7365 ;; We only have to update this line.
7368 (message-narrow-to-head)
7369 (let ((head (buffer-string))
7371 (nnheader-temp-write nil
7372 (insert (format "211 %d Article retrieved.\n"
7373 (cdr gnus-article-current)))
7376 (let ((nntp-server-buffer (current-buffer)))
7377 (setq header (car (gnus-get-newsgroup-headers
7379 (set-buffer gnus-summary-buffer)
7380 gnus-newsgroup-dependencies)
7383 (set-buffer gnus-summary-buffer)
7384 (gnus-data-set-header
7385 (gnus-data-find (cdr gnus-article-current))
7387 (gnus-summary-update-article-line
7388 (cdr gnus-article-current) header))))))
7390 (set-buffer (or buffer gnus-summary-buffer))
7391 (gnus-summary-update-article (cdr gnus-article-current)))
7392 ;; Prettify the article buffer again.
7393 (unless no-highlight
7395 (set-buffer gnus-article-buffer)
7396 (gnus-run-hooks 'gnus-article-display-hook)
7397 (set-buffer gnus-original-article-buffer)
7398 (gnus-request-article
7399 (cdr gnus-article-current)
7400 (car gnus-article-current) (current-buffer))))
7401 ;; Prettify the summary buffer line.
7402 (when (gnus-visual-p 'summary-highlight 'highlight)
7403 (gnus-run-hooks 'gnus-visual-mark-article-hook))))
7405 (defun gnus-summary-edit-wash (key)
7406 "Perform editing command in the article buffer."
7410 (message "%s" (concat (this-command-keys) "- "))
7413 (gnus-summary-edit-article)
7414 (execute-kbd-macro (concat (this-command-keys) key))
7415 (gnus-article-edit-done))
7419 (defun gnus-summary-respool-query (&optional silent)
7420 "Query where the respool algorithm would put this article."
7422 (let (gnus-mark-article-hook)
7423 (gnus-summary-select-article)
7425 (set-buffer gnus-original-article-buffer)
7427 (message-narrow-to-head)
7428 (let ((groups (nnmail-article-group 'identity)))
7431 (message "This message would go to %s"
7432 (mapconcat 'car groups ", "))
7433 (message "This message would go to no groups"))
7436 ;; Summary marking commands.
7438 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
7439 "Mark articles which has the same subject as read, and then select the next.
7440 If UNMARK is positive, remove any kind of mark.
7441 If UNMARK is negative, tick articles."
7444 (setq unmark (prefix-numeric-value unmark)))
7446 (gnus-summary-mark-same-subject
7447 (gnus-summary-article-subject) unmark)))
7448 ;; Select next unread article. If auto-select-same mode, should
7449 ;; select the first unread article.
7450 (gnus-summary-next-article t (and gnus-auto-select-same
7451 (gnus-summary-article-subject)))
7452 (gnus-message 7 "%d article%s marked as %s"
7453 count (if (= count 1) " is" "s are")
7454 (if unmark "unread" "read"))))
7456 (defun gnus-summary-kill-same-subject (&optional unmark)
7457 "Mark articles which has the same subject as read.
7458 If UNMARK is positive, remove any kind of mark.
7459 If UNMARK is negative, tick articles."
7462 (setq unmark (prefix-numeric-value unmark)))
7464 (gnus-summary-mark-same-subject
7465 (gnus-summary-article-subject) unmark)))
7466 ;; If marked as read, go to next unread subject.
7468 ;; Go to next unread subject.
7469 (gnus-summary-next-subject 1 t))
7470 (gnus-message 7 "%d articles are marked as %s"
7471 count (if unmark "unread" "read"))))
7473 (defun gnus-summary-mark-same-subject (subject &optional unmark)
7474 "Mark articles with same SUBJECT as read, and return marked number.
7475 If optional argument UNMARK is positive, remove any kinds of marks.
7476 If optional argument UNMARK is negative, mark articles as unread instead."
7480 ((null unmark) ; Mark as read.
7483 (gnus-summary-mark-article-as-read gnus-killed-mark)
7484 (gnus-summary-show-thread) t)
7485 (gnus-summary-find-subject subject))
7486 (setq count (1+ count))))
7487 ((> unmark 0) ; Tick.
7490 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
7491 (gnus-summary-show-thread) t)
7492 (gnus-summary-find-subject subject))
7493 (setq count (1+ count))))
7494 (t ; Mark as unread.
7497 (gnus-summary-mark-article-as-unread gnus-unread-mark)
7498 (gnus-summary-show-thread) t)
7499 (gnus-summary-find-subject subject))
7500 (setq count (1+ count)))))
7501 (gnus-set-mode-line 'summary)
7502 ;; Return the number of marked articles.
7505 (defun gnus-summary-mark-as-processable (n &optional unmark)
7506 "Set the process mark on the next N articles.
7507 If N is negative, mark backward instead. If UNMARK is non-nil, remove
7508 the process mark instead. The difference between N and the actual
7509 number of articles marked is returned."
7511 (let ((backward (< n 0))
7516 (gnus-summary-remove-process-mark
7517 (gnus-summary-article-number))
7518 (gnus-summary-set-process-mark (gnus-summary-article-number)))
7519 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
7522 (gnus-message 7 "No more articles"))
7523 (gnus-summary-recenter)
7524 (gnus-summary-position-point)
7527 (defun gnus-summary-unmark-as-processable (n)
7528 "Remove the process mark from the next N articles.
7529 If N is negative, unmark backward instead. The difference between N and
7530 the actual number of articles unmarked is returned."
7532 (gnus-summary-mark-as-processable n t))
7534 (defun gnus-summary-unmark-all-processable ()
7535 "Remove the process mark from all articles."
7538 (while gnus-newsgroup-processable
7539 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
7540 (gnus-summary-position-point))
7542 (defun gnus-summary-mark-as-expirable (n)
7543 "Mark N articles forward as expirable.
7544 If N is negative, mark backward instead. The difference between N and
7545 the actual number of articles marked is returned."
7547 (gnus-summary-mark-forward n gnus-expirable-mark))
7549 (defun gnus-summary-mark-article-as-replied (article)
7550 "Mark ARTICLE replied and update the summary line."
7551 (push article gnus-newsgroup-replied)
7552 (let ((buffer-read-only nil))
7553 (when (gnus-summary-goto-subject article)
7554 (gnus-summary-update-secondary-mark article))))
7556 (defun gnus-summary-set-bookmark (article)
7557 "Set a bookmark in current article."
7558 (interactive (list (gnus-summary-article-number)))
7559 (when (or (not (get-buffer gnus-article-buffer))
7560 (not gnus-current-article)
7561 (not gnus-article-current)
7562 (not (equal gnus-newsgroup-name (car gnus-article-current))))
7563 (error "No current article selected"))
7564 ;; Remove old bookmark, if one exists.
7565 (let ((old (assq article gnus-newsgroup-bookmarks)))
7567 (setq gnus-newsgroup-bookmarks
7568 (delq old gnus-newsgroup-bookmarks))))
7569 ;; Set the new bookmark, which is on the form
7570 ;; (article-number . line-number-in-body).
7574 (set-buffer gnus-article-buffer)
7578 (goto-char (point-min))
7579 (search-forward "\n\n" nil t)
7582 gnus-newsgroup-bookmarks)
7583 (gnus-message 6 "A bookmark has been added to the current article."))
7585 (defun gnus-summary-remove-bookmark (article)
7586 "Remove the bookmark from the current article."
7587 (interactive (list (gnus-summary-article-number)))
7588 ;; Remove old bookmark, if one exists.
7589 (let ((old (assq article gnus-newsgroup-bookmarks)))
7592 (setq gnus-newsgroup-bookmarks
7593 (delq old gnus-newsgroup-bookmarks))
7594 (gnus-message 6 "Removed bookmark."))
7595 (gnus-message 6 "No bookmark in current article."))))
7597 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
7598 (defun gnus-summary-mark-as-dormant (n)
7599 "Mark N articles forward as dormant.
7600 If N is negative, mark backward instead. The difference between N and
7601 the actual number of articles marked is returned."
7603 (gnus-summary-mark-forward n gnus-dormant-mark))
7605 (defun gnus-summary-set-process-mark (article)
7606 "Set the process mark on ARTICLE and update the summary line."
7607 (setq gnus-newsgroup-processable
7609 (delq article gnus-newsgroup-processable)))
7610 (when (gnus-summary-goto-subject article)
7611 (gnus-summary-show-thread)
7612 (gnus-summary-update-secondary-mark article)))
7614 (defun gnus-summary-remove-process-mark (article)
7615 "Remove the process mark from ARTICLE and update the summary line."
7616 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
7617 (when (gnus-summary-goto-subject article)
7618 (gnus-summary-show-thread)
7619 (gnus-summary-update-secondary-mark article)))
7621 (defun gnus-summary-set-saved-mark (article)
7622 "Set the process mark on ARTICLE and update the summary line."
7623 (push article gnus-newsgroup-saved)
7624 (when (gnus-summary-goto-subject article)
7625 (gnus-summary-update-secondary-mark article)))
7627 (defun gnus-summary-mark-forward (n &optional mark no-expire)
7628 "Mark N articles as read forwards.
7629 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
7630 The difference between N and the actual number of articles marked is
7633 (let ((backward (< n 0))
7634 (gnus-summary-goto-unread
7635 (and gnus-summary-goto-unread
7636 (not (eq gnus-summary-goto-unread 'never))
7637 (not (memq mark (list gnus-unread-mark
7638 gnus-ticked-mark gnus-dormant-mark)))))
7640 (mark (or mark gnus-del-mark)))
7642 (gnus-summary-mark-article nil mark no-expire)
7643 (zerop (gnus-summary-next-subject
7645 (and gnus-summary-goto-unread
7646 (not (eq gnus-summary-goto-unread 'never)))
7650 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
7651 (gnus-summary-recenter)
7652 (gnus-summary-position-point)
7653 (gnus-set-mode-line 'summary)
7656 (defun gnus-summary-mark-article-as-read (mark)
7657 "Mark the current article quickly as read with MARK."
7658 (let ((article (gnus-summary-article-number)))
7659 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7660 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7661 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7662 (push (cons article mark) gnus-newsgroup-reads)
7663 ;; Possibly remove from cache, if that is used.
7664 (when gnus-use-cache
7665 (gnus-cache-enter-remove-article article))
7666 ;; Allow the backend to change the mark.
7667 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7668 ;; Check for auto-expiry.
7669 (when (and gnus-newsgroup-auto-expire
7670 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
7671 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
7672 (= mark gnus-ancient-mark)
7673 (= mark gnus-read-mark) (= mark gnus-souped-mark)
7674 (= mark gnus-duplicate-mark)))
7675 (setq mark gnus-expirable-mark)
7676 (push article gnus-newsgroup-expirable))
7677 ;; Set the mark in the buffer.
7678 (gnus-summary-update-mark mark 'unread)
7681 (defun gnus-summary-mark-article-as-unread (mark)
7682 "Mark the current article quickly as unread with MARK."
7683 (let* ((article (gnus-summary-article-number))
7684 (old-mark (gnus-summary-article-mark article)))
7685 (if (eq mark old-mark)
7689 (gnus-error 1 "Can't mark negative article numbers")
7691 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7692 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7693 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
7694 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
7695 (cond ((= mark gnus-ticked-mark)
7696 (push article gnus-newsgroup-marked))
7697 ((= mark gnus-dormant-mark)
7698 (push article gnus-newsgroup-dormant))
7700 (push article gnus-newsgroup-unreads)))
7701 (setq gnus-newsgroup-reads
7702 (delq (assq article gnus-newsgroup-reads)
7703 gnus-newsgroup-reads))
7705 ;; See whether the article is to be put in the cache.
7707 (vectorp (gnus-summary-article-header article))
7709 (gnus-cache-possibly-enter-article
7710 gnus-newsgroup-name article
7711 (gnus-summary-article-header article)
7712 (= mark gnus-ticked-mark)
7713 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
7716 (gnus-summary-update-mark mark 'unread)
7719 (defun gnus-summary-mark-article (&optional article mark no-expire)
7720 "Mark ARTICLE with MARK. MARK can be any character.
7721 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
7722 `??' (dormant) and `?E' (expirable).
7723 If MARK is nil, then the default character `?D' is used.
7724 If ARTICLE is nil, then the article on the current line will be
7726 ;; The mark might be a string.
7727 (when (stringp mark)
7728 (setq mark (aref mark 0)))
7729 ;; If no mark is given, then we check auto-expiring.
7730 (and (not no-expire)
7731 gnus-newsgroup-auto-expire
7733 (and (gnus-characterp mark)
7734 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
7735 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
7736 (= mark gnus-read-mark) (= mark gnus-souped-mark)
7737 (= mark gnus-duplicate-mark))))
7738 (setq mark gnus-expirable-mark))
7739 (let* ((mark (or mark gnus-del-mark))
7740 (article (or article (gnus-summary-article-number))))
7742 (error "No article on current line"))
7743 (if (not (if (or (= mark gnus-unread-mark)
7744 (= mark gnus-ticked-mark)
7745 (= mark gnus-dormant-mark))
7746 (gnus-mark-article-as-unread article mark)
7747 (gnus-mark-article-as-read article mark)))
7749 ;; See whether the article is to be put in the cache.
7751 (not (= mark gnus-canceled-mark))
7752 (vectorp (gnus-summary-article-header article))
7754 (gnus-cache-possibly-enter-article
7755 gnus-newsgroup-name article
7756 (gnus-summary-article-header article)
7757 (= mark gnus-ticked-mark)
7758 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
7760 (when (gnus-summary-goto-subject article nil t)
7761 (let ((buffer-read-only nil))
7762 (gnus-summary-show-thread)
7764 (gnus-summary-update-mark mark 'unread)
7767 (defun gnus-summary-update-secondary-mark (article)
7768 "Update the secondary (read, process, cache) mark."
7769 (gnus-summary-update-mark
7770 (cond ((memq article gnus-newsgroup-processable)
7772 ((memq article gnus-newsgroup-cached)
7774 ((memq article gnus-newsgroup-replied)
7776 ((memq article gnus-newsgroup-saved)
7778 (t gnus-unread-mark))
7780 (when (gnus-visual-p 'summary-highlight 'highlight)
7781 (gnus-run-hooks 'gnus-summary-update-hook))
7784 (defun gnus-summary-update-mark (mark type)
7785 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
7786 (buffer-read-only nil))
7787 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
7788 (when (looking-at "\r")
7791 (<= (+ forward (point)) (point-max)))
7792 ;; Go to the right position on the line.
7793 (goto-char (+ forward (point)))
7794 ;; Replace the old mark with the new mark.
7795 (subst-char-in-region (point) (1+ (point)) (following-char) mark)
7796 ;; Optionally update the marks by some user rule.
7797 (when (eq type 'unread)
7799 (gnus-data-find (gnus-summary-article-number)) mark)
7800 (gnus-summary-update-line (eq mark gnus-unread-mark))))))
7802 (defun gnus-mark-article-as-read (article &optional mark)
7803 "Enter ARTICLE in the pertinent lists and remove it from others."
7804 ;; Make the article expirable.
7805 (let ((mark (or mark gnus-del-mark)))
7806 (if (= mark gnus-expirable-mark)
7807 (push article gnus-newsgroup-expirable)
7808 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
7809 ;; Remove from unread and marked lists.
7810 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7811 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7812 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7813 (push (cons article mark) gnus-newsgroup-reads)
7814 ;; Possibly remove from cache, if that is used.
7815 (when gnus-use-cache
7816 (gnus-cache-enter-remove-article article))
7819 (defun gnus-mark-article-as-unread (article &optional mark)
7820 "Enter ARTICLE in the pertinent lists and remove it from others."
7821 (let ((mark (or mark gnus-ticked-mark)))
7824 (gnus-error 1 "Can't mark negative article numbers")
7826 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
7827 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
7828 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
7829 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7831 ;; Unsuppress duplicates?
7832 (when gnus-suppress-duplicates
7833 (gnus-dup-unsuppress-article article))
7835 (cond ((= mark gnus-ticked-mark)
7836 (push article gnus-newsgroup-marked))
7837 ((= mark gnus-dormant-mark)
7838 (push article gnus-newsgroup-dormant))
7840 (push article gnus-newsgroup-unreads)))
7841 (setq gnus-newsgroup-reads
7842 (delq (assq article gnus-newsgroup-reads)
7843 gnus-newsgroup-reads))
7846 (defalias 'gnus-summary-mark-as-unread-forward
7847 'gnus-summary-tick-article-forward)
7848 (make-obsolete 'gnus-summary-mark-as-unread-forward
7849 'gnus-summary-tick-article-forward)
7850 (defun gnus-summary-tick-article-forward (n)
7851 "Tick N articles forwards.
7852 If N is negative, tick backwards instead.
7853 The difference between N and the number of articles ticked is returned."
7855 (gnus-summary-mark-forward n gnus-ticked-mark))
7857 (defalias 'gnus-summary-mark-as-unread-backward
7858 'gnus-summary-tick-article-backward)
7859 (make-obsolete 'gnus-summary-mark-as-unread-backward
7860 'gnus-summary-tick-article-backward)
7861 (defun gnus-summary-tick-article-backward (n)
7862 "Tick N articles backwards.
7863 The difference between N and the number of articles ticked is returned."
7865 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
7867 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
7868 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
7869 (defun gnus-summary-tick-article (&optional article clear-mark)
7870 "Mark current article as unread.
7871 Optional 1st argument ARTICLE specifies article number to be marked as unread.
7872 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
7874 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
7877 (defun gnus-summary-mark-as-read-forward (n)
7878 "Mark N articles as read forwards.
7879 If N is negative, mark backwards instead.
7880 The difference between N and the actual number of articles marked is
7883 (gnus-summary-mark-forward n gnus-del-mark t))
7885 (defun gnus-summary-mark-as-read-backward (n)
7886 "Mark the N articles as read backwards.
7887 The difference between N and the actual number of articles marked is
7890 (gnus-summary-mark-forward (- n) gnus-del-mark t))
7892 (defun gnus-summary-mark-as-read (&optional article mark)
7893 "Mark current article as read.
7894 ARTICLE specifies the article to be marked as read.
7895 MARK specifies a string to be inserted at the beginning of the line."
7896 (gnus-summary-mark-article article mark))
7898 (defun gnus-summary-clear-mark-forward (n)
7899 "Clear marks from N articles forward.
7900 If N is negative, clear backward instead.
7901 The difference between N and the number of marks cleared is returned."
7903 (gnus-summary-mark-forward n gnus-unread-mark))
7905 (defun gnus-summary-clear-mark-backward (n)
7906 "Clear marks from N articles backward.
7907 The difference between N and the number of marks cleared is returned."
7909 (gnus-summary-mark-forward (- n) gnus-unread-mark))
7911 (defun gnus-summary-mark-unread-as-read ()
7912 "Intended to be used by `gnus-summary-mark-article-hook'."
7913 (when (memq gnus-current-article gnus-newsgroup-unreads)
7914 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
7916 (defun gnus-summary-mark-read-and-unread-as-read ()
7917 "Intended to be used by `gnus-summary-mark-article-hook'."
7918 (let ((mark (gnus-summary-article-mark)))
7919 (when (or (gnus-unread-mark-p mark)
7920 (gnus-read-mark-p mark))
7921 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
7923 (defun gnus-summary-mark-region-as-read (point mark all)
7924 "Mark all unread articles between point and mark as read.
7925 If given a prefix, mark all articles between point and mark as read,
7926 even ticked and dormant ones."
7927 (interactive "r\nP")
7936 (memq (setq article (gnus-summary-article-number))
7937 gnus-newsgroup-unreads))
7938 (gnus-summary-mark-article article gnus-del-mark))
7940 (gnus-summary-find-next))))))
7942 (defun gnus-summary-mark-below (score mark)
7943 "Mark articles with score less than SCORE with MARK."
7944 (interactive "P\ncMark: ")
7945 (setq score (if score
7946 (prefix-numeric-value score)
7947 (or gnus-summary-default-score 0)))
7949 (set-buffer gnus-summary-buffer)
7950 (goto-char (point-min))
7953 (and (< (gnus-summary-article-score) score)
7954 (gnus-summary-mark-article nil mark))
7955 (gnus-summary-find-next)))))
7957 (defun gnus-summary-kill-below (&optional score)
7958 "Mark articles with score below SCORE as read."
7960 (gnus-summary-mark-below score gnus-killed-mark))
7962 (defun gnus-summary-clear-above (&optional score)
7963 "Clear all marks from articles with score above SCORE."
7965 (gnus-summary-mark-above score gnus-unread-mark))
7967 (defun gnus-summary-tick-above (&optional score)
7968 "Tick all articles with score above SCORE."
7970 (gnus-summary-mark-above score gnus-ticked-mark))
7972 (defun gnus-summary-mark-above (score mark)
7973 "Mark articles with score over SCORE with MARK."
7974 (interactive "P\ncMark: ")
7975 (setq score (if score
7976 (prefix-numeric-value score)
7977 (or gnus-summary-default-score 0)))
7979 (set-buffer gnus-summary-buffer)
7980 (goto-char (point-min))
7982 (when (> (gnus-summary-article-score) score)
7983 (gnus-summary-mark-article nil mark))
7985 (gnus-summary-find-next)))))
7987 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
7988 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
7989 (defun gnus-summary-limit-include-expunged (&optional no-error)
7990 "Display all the hidden articles that were expunged for low scores."
7992 (let ((buffer-read-only nil))
7993 (let ((scored gnus-newsgroup-scored)
7996 (unless (gnus-summary-goto-subject (caar scored))
7997 (and (setq h (gnus-summary-article-header (caar scored)))
7998 (< (cdar scored) gnus-summary-expunge-below)
8000 (setq scored (cdr scored)))
8002 (when (not no-error)
8003 (error "No expunged articles hidden"))
8004 (goto-char (point-min))
8005 (gnus-summary-prepare-unthreaded (nreverse headers))
8006 (goto-char (point-min))
8007 (gnus-summary-position-point)
8010 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
8011 "Mark all unread articles in this newsgroup as read.
8012 If prefix argument ALL is non-nil, ticked and dormant articles will
8013 also be marked as read.
8014 If QUIETLY is non-nil, no questions will be asked.
8015 If TO-HERE is non-nil, it should be a point in the buffer. All
8016 articles before this point will be marked as read.
8017 Note that this function will only catch up the unread article
8018 in the current summary buffer limitation.
8019 The number of articles marked as read is returned."
8024 (not gnus-interactive-catchup) ;Without confirmation?
8028 "Mark absolutely all articles as read? "
8029 "Mark all unread articles as read? ")))
8031 (not gnus-newsgroup-adaptive)
8032 (not gnus-newsgroup-auto-expire)
8033 (not gnus-suppress-duplicates)
8034 (or (not gnus-use-cache)
8035 (eq gnus-use-cache 'passive)))
8038 (setq gnus-newsgroup-marked nil
8039 gnus-newsgroup-dormant nil))
8040 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
8041 ;; We actually mark all articles as canceled, which we
8042 ;; have to do when using auto-expiry or adaptive scoring.
8043 (gnus-summary-show-all-threads)
8044 (when (gnus-summary-first-subject (not all))
8046 (if to-here (< (point) to-here) t)
8047 (gnus-summary-mark-article-as-read gnus-catchup-mark)
8048 (gnus-summary-find-next (not all)))))
8049 (gnus-set-mode-line 'summary))
8051 (gnus-summary-position-point)))
8053 (defun gnus-summary-catchup-to-here (&optional all)
8054 "Mark all unticked articles before the current one as read.
8055 If ALL is non-nil, also mark ticked and dormant articles as read."
8058 (gnus-save-hidden-threads
8059 (let ((beg (point)))
8060 ;; We check that there are unread articles.
8061 (when (or all (gnus-summary-find-prev))
8062 (gnus-summary-catchup all t beg)))))
8063 (gnus-summary-position-point))
8065 (defun gnus-summary-catchup-all (&optional quietly)
8066 "Mark all articles in this newsgroup as read."
8068 (gnus-summary-catchup t quietly))
8070 (defun gnus-summary-catchup-and-exit (&optional all quietly)
8071 "Mark all articles not marked as unread in this newsgroup as read, then exit.
8072 If prefix argument ALL is non-nil, all articles are marked as read."
8074 (when (gnus-summary-catchup all quietly nil 'fast)
8075 ;; Select next newsgroup or exit.
8076 (if (eq gnus-auto-select-next 'quietly)
8077 (gnus-summary-next-group nil)
8078 (gnus-summary-exit))))
8080 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
8081 "Mark all articles in this newsgroup as read, and then exit."
8083 (gnus-summary-catchup-and-exit t quietly))
8085 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
8086 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
8087 "Mark all articles in this group as read and select the next group.
8088 If given a prefix, mark all articles, unread as well as ticked, as
8092 (gnus-summary-catchup all))
8093 (gnus-summary-next-article t nil nil t))
8095 ;; Thread-based commands.
8097 (defun gnus-summary-articles-in-thread (&optional article)
8098 "Return a list of all articles in the current thread.
8099 If ARTICLE is non-nil, return all articles in the thread that starts
8101 (let* ((article (or article (gnus-summary-article-number)))
8102 (data (gnus-data-find-list article))
8103 (top-level (gnus-data-level (car data)))
8105 (cond ((null gnus-thread-operation-ignore-subject)
8106 (gnus-simplify-subject-re
8107 (mail-header-subject (gnus-data-header (car data)))))
8108 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
8109 (gnus-simplify-subject-fuzzy
8110 (mail-header-subject (gnus-data-header (car data)))))
8112 (end-point (save-excursion
8113 (if (gnus-summary-go-to-next-thread)
8114 (point) (point-max))))
8117 (< (gnus-data-pos (car data)) end-point))
8118 (when (or (not top-subject)
8119 (string= top-subject
8120 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
8121 (gnus-simplify-subject-fuzzy
8122 (mail-header-subject
8123 (gnus-data-header (car data))))
8124 (gnus-simplify-subject-re
8125 (mail-header-subject
8126 (gnus-data-header (car data)))))))
8127 (push (gnus-data-number (car data)) articles))
8128 (unless (and (setq data (cdr data))
8129 (> (gnus-data-level (car data)) top-level))
8131 ;; Return the list of articles.
8132 (nreverse articles)))
8134 (defun gnus-summary-rethread-current ()
8135 "Rethread the thread the current article is part of."
8137 (let* ((gnus-show-threads t)
8138 (article (gnus-summary-article-number))
8139 (id (mail-header-id (gnus-summary-article-header)))
8140 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
8142 (error "No article on the current line"))
8143 (gnus-rebuild-thread id)
8144 (gnus-summary-goto-subject article)))
8146 (defun gnus-summary-reparent-thread ()
8147 "Make the current article child of the marked (or previous) article.
8149 Note that the re-threading will only work if `gnus-thread-ignore-subject'
8150 is non-nil or the Subject: of both articles are the same."
8152 (unless (not (gnus-group-read-only-p))
8153 (error "The current newsgroup does not support article editing"))
8154 (unless (<= (length gnus-newsgroup-processable) 1)
8155 (error "No more than one article may be marked"))
8156 (save-window-excursion
8157 (let ((gnus-article-buffer " *reparent*")
8158 (current-article (gnus-summary-article-number))
8159 ;; First grab the marked article, otherwise one line up.
8160 (parent-article (if (not (null gnus-newsgroup-processable))
8161 (car gnus-newsgroup-processable)
8163 (if (eq (forward-line -1) 0)
8164 (gnus-summary-article-number)
8165 (error "Beginning of summary buffer"))))))
8166 (unless (not (eq current-article parent-article))
8167 (error "An article may not be self-referential"))
8168 (let ((message-id (mail-header-id
8169 (gnus-summary-article-header parent-article))))
8170 (unless (and message-id (not (equal message-id "")))
8171 (error "No message-id in desired parent"))
8172 (gnus-summary-select-article t t nil current-article)
8173 (set-buffer gnus-original-article-buffer)
8174 (let ((buf (format "%s" (buffer-string))))
8175 (nnheader-temp-write nil
8177 (goto-char (point-min))
8178 (if (re-search-forward "^References: " nil t)
8180 (re-search-forward "^[^ \t]" nil t)
8183 (insert " " message-id))
8184 (insert "References: " message-id "\n"))
8185 (unless (gnus-request-replace-article
8186 current-article (car gnus-article-current)
8188 (error "Couldn't replace article"))))
8189 (set-buffer gnus-summary-buffer)
8190 (gnus-summary-unmark-all-processable)
8191 (gnus-summary-update-article current-article)
8192 (gnus-summary-rethread-current)
8193 (gnus-message 3 "Article %d is now the child of article %d"
8194 current-article parent-article)))))
8196 (defun gnus-summary-toggle-threads (&optional arg)
8197 "Toggle showing conversation threads.
8198 If ARG is positive number, turn showing conversation threads on."
8200 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
8201 (setq gnus-show-threads
8202 (if (null arg) (not gnus-show-threads)
8203 (> (prefix-numeric-value arg) 0)))
8204 (gnus-summary-prepare)
8205 (gnus-summary-goto-subject current)
8206 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
8207 (gnus-summary-position-point)))
8209 (defun gnus-summary-show-all-threads ()
8213 (let ((buffer-read-only nil))
8214 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
8215 (gnus-summary-position-point))
8217 (defun gnus-summary-show-thread ()
8218 "Show thread subtrees.
8219 Returns nil if no thread was there to be shown."
8221 (let ((buffer-read-only nil)
8223 ;; first goto end then to beg, to have point at beg after let
8224 (end (progn (end-of-line) (point)))
8225 (beg (progn (beginning-of-line) (point))))
8227 ;; Any hidden lines here?
8228 (search-forward "\r" end t)
8229 (subst-char-in-region beg end ?\^M ?\n t)
8231 (gnus-summary-position-point))))
8233 (defun gnus-summary-hide-all-threads ()
8234 "Hide all thread subtrees."
8237 (goto-char (point-min))
8238 (gnus-summary-hide-thread)
8239 (while (zerop (gnus-summary-next-thread 1 t))
8240 (gnus-summary-hide-thread)))
8241 (gnus-summary-position-point))
8243 (defun gnus-summary-hide-thread ()
8244 "Hide thread subtrees.
8245 Returns nil if no threads were there to be hidden."
8247 (let ((buffer-read-only nil)
8249 (article (gnus-summary-article-number)))
8251 ;; Go forward until either the buffer ends or the subthread
8253 (when (and (not (eobp))
8254 (or (zerop (gnus-summary-next-thread 1 t))
8255 (goto-char (point-max))))
8257 (if (and (> (point) start)
8258 (search-backward "\n" start t))
8260 (subst-char-in-region start (point) ?\n ?\^M)
8261 (gnus-summary-goto-subject article))
8264 ;;(gnus-summary-position-point)
8267 (defun gnus-summary-go-to-next-thread (&optional previous)
8268 "Go to the same level (or less) next thread.
8269 If PREVIOUS is non-nil, go to previous thread instead.
8270 Return the article number moved to, or nil if moving was impossible."
8271 (let ((level (gnus-summary-thread-level))
8272 (way (if previous -1 1))
8275 (while (and (not (eobp))
8276 (< level (gnus-summary-thread-level)))
8284 (gnus-summary-article-number)
8287 (defun gnus-summary-next-thread (n &optional silent)
8288 "Go to the same level next N'th thread.
8289 If N is negative, search backward instead.
8290 Returns the difference between N and the number of skips actually
8293 If SILENT, don't output messages."
8295 (let ((backward (< n 0))
8298 (gnus-summary-go-to-next-thread backward))
8301 (gnus-summary-position-point))
8302 (when (and (not silent) (/= 0 n))
8303 (gnus-message 7 "No more threads"))
8306 (defun gnus-summary-prev-thread (n)
8307 "Go to the same level previous N'th thread.
8308 Returns the difference between N and the number of skips actually
8311 (gnus-summary-next-thread (- n)))
8313 (defun gnus-summary-go-down-thread ()
8314 "Go down one level in the current thread."
8315 (let ((children (gnus-summary-article-children)))
8317 (gnus-summary-goto-subject (car children)))))
8319 (defun gnus-summary-go-up-thread ()
8320 "Go up one level in the current thread."
8321 (let ((parent (gnus-summary-article-parent)))
8323 (gnus-summary-goto-subject parent))))
8325 (defun gnus-summary-down-thread (n)
8326 "Go down thread N steps.
8327 If N is negative, go up instead.
8328 Returns the difference between N and how many steps down that were
8334 (if up (gnus-summary-go-up-thread)
8335 (gnus-summary-go-down-thread)))
8337 (gnus-summary-position-point)
8339 (gnus-message 7 "Can't go further"))
8342 (defun gnus-summary-up-thread (n)
8343 "Go up thread N steps.
8344 If N is negative, go up instead.
8345 Returns the difference between N and how many steps down that were
8348 (gnus-summary-down-thread (- n)))
8350 (defun gnus-summary-top-thread ()
8351 "Go to the top of the thread."
8353 (while (gnus-summary-go-up-thread))
8354 (gnus-summary-article-number))
8356 (defun gnus-summary-kill-thread (&optional unmark)
8357 "Mark articles under current thread as read.
8358 If the prefix argument is positive, remove any kinds of marks.
8359 If the prefix argument is negative, tick articles instead."
8362 (setq unmark (prefix-numeric-value unmark)))
8363 (let ((articles (gnus-summary-articles-in-thread)))
8365 ;; Expand the thread.
8366 (gnus-summary-show-thread)
8367 ;; Mark all the articles.
8369 (gnus-summary-goto-subject (car articles))
8370 (cond ((null unmark)
8371 (gnus-summary-mark-article-as-read gnus-killed-mark))
8373 (gnus-summary-mark-article-as-unread gnus-unread-mark))
8375 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
8376 (setq articles (cdr articles))))
8377 ;; Hide killed subtrees.
8379 gnus-thread-hide-killed
8380 (gnus-summary-hide-thread))
8381 ;; If marked as read, go to next unread subject.
8383 ;; Go to next unread subject.
8384 (gnus-summary-next-subject 1 t)))
8385 (gnus-set-mode-line 'summary))
8387 ;; Summary sorting commands
8389 (defun gnus-summary-sort-by-number (&optional reverse)
8390 "Sort the summary buffer by article number.
8391 Argument REVERSE means reverse order."
8393 (gnus-summary-sort 'number reverse))
8395 (defun gnus-summary-sort-by-author (&optional reverse)
8396 "Sort the summary buffer by author name alphabetically.
8397 If case-fold-search is non-nil, case of letters is ignored.
8398 Argument REVERSE means reverse order."
8400 (gnus-summary-sort 'author reverse))
8402 (defun gnus-summary-sort-by-subject (&optional reverse)
8403 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
8404 If case-fold-search is non-nil, case of letters is ignored.
8405 Argument REVERSE means reverse order."
8407 (gnus-summary-sort 'subject reverse))
8409 (defun gnus-summary-sort-by-date (&optional reverse)
8410 "Sort the summary buffer by date.
8411 Argument REVERSE means reverse order."
8413 (gnus-summary-sort 'date reverse))
8415 (defun gnus-summary-sort-by-score (&optional reverse)
8416 "Sort the summary buffer by score.
8417 Argument REVERSE means reverse order."
8419 (gnus-summary-sort 'score reverse))
8421 (defun gnus-summary-sort-by-lines (&optional reverse)
8422 "Sort the summary buffer by article length.
8423 Argument REVERSE means reverse order."
8425 (gnus-summary-sort 'lines reverse))
8427 (defun gnus-summary-sort (predicate reverse)
8428 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
8429 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
8430 (article (intern (format "gnus-article-sort-by-%s" predicate)))
8431 (gnus-thread-sort-functions
8437 (gnus-article-sort-functions
8442 (,article t2 t1)))))
8444 (gnus-summary-prepare-hook nil))
8445 ;; We do the sorting by regenerating the threads.
8446 (gnus-summary-prepare)
8447 ;; Hide subthreads if needed.
8448 (when (and gnus-show-threads gnus-thread-hide-subtree)
8449 (gnus-summary-hide-all-threads))))
8451 ;; Summary saving commands.
8453 (defun gnus-summary-save-article (&optional n not-saved)
8454 "Save the current article using the default saver function.
8455 If N is a positive number, save the N next articles.
8456 If N is a negative number, save the N previous articles.
8457 If N is nil and any articles have been marked with the process mark,
8458 save those articles instead.
8459 The variable `gnus-default-article-saver' specifies the saver function."
8461 (let* ((articles (gnus-summary-work-articles n))
8462 (save-buffer (save-excursion
8463 (nnheader-set-temp-buffer " *Gnus Save*")))
8464 (num (length articles))
8465 header article file)
8467 (setq header (gnus-summary-article-header
8468 (setq article (pop articles))))
8469 (if (not (vectorp header))
8470 ;; This is a pseudo-article.
8471 (if (assq 'name header)
8472 (gnus-copy-file (cdr (assq 'name header)))
8473 (gnus-message 1 "Article %d is unsaveable" article))
8474 ;; This is a real article.
8475 (save-window-excursion
8476 (gnus-summary-select-article t nil nil article))
8478 (set-buffer save-buffer)
8480 (insert-buffer-substring gnus-original-article-buffer))
8481 (setq file (gnus-article-save save-buffer file num))
8482 (gnus-summary-remove-process-mark article)
8484 (gnus-summary-set-saved-mark article))))
8485 (gnus-kill-buffer save-buffer)
8486 (gnus-summary-position-point)
8487 (gnus-set-mode-line 'summary)
8490 (defun gnus-summary-pipe-output (&optional arg)
8491 "Pipe the current article to a subprocess.
8492 If N is a positive number, pipe the N next articles.
8493 If N is a negative number, pipe the N previous articles.
8494 If N is nil and any articles have been marked with the process mark,
8495 pipe those articles instead."
8497 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
8498 (gnus-summary-save-article arg t))
8499 (gnus-configure-windows 'pipe))
8501 (defun gnus-summary-save-article-mail (&optional arg)
8502 "Append the current article to an mail file.
8503 If N is a positive number, save the N next articles.
8504 If N is a negative number, save the N previous articles.
8505 If N is nil and any articles have been marked with the process mark,
8506 save those articles instead."
8508 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
8509 (gnus-summary-save-article arg)))
8511 (defun gnus-summary-save-article-rmail (&optional arg)
8512 "Append the current article to an rmail file.
8513 If N is a positive number, save the N next articles.
8514 If N is a negative number, save the N previous articles.
8515 If N is nil and any articles have been marked with the process mark,
8516 save those articles instead."
8518 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
8519 (gnus-summary-save-article arg)))
8521 (defun gnus-summary-save-article-file (&optional arg)
8522 "Append the current article to a file.
8523 If N is a positive number, save the N next articles.
8524 If N is a negative number, save the N previous articles.
8525 If N is nil and any articles have been marked with the process mark,
8526 save those articles instead."
8528 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
8529 (gnus-summary-save-article arg)))
8531 (defun gnus-summary-write-article-file (&optional arg)
8532 "Write the current article to a file, deleting the previous file.
8533 If N is a positive number, save the N next articles.
8534 If N is a negative number, save the N previous articles.
8535 If N is nil and any articles have been marked with the process mark,
8536 save those articles instead."
8538 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
8539 (gnus-summary-save-article arg)))
8541 (defun gnus-summary-save-article-body-file (&optional arg)
8542 "Append the current article body to a file.
8543 If N is a positive number, save the N next articles.
8544 If N is a negative number, save the N previous articles.
8545 If N is nil and any articles have been marked with the process mark,
8546 save those articles instead."
8548 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
8549 (gnus-summary-save-article arg)))
8551 (defun gnus-summary-pipe-message (program)
8552 "Pipe the current article through PROGRAM."
8553 (interactive "sProgram: ")
8554 (gnus-summary-select-article)
8555 (let ((mail-header-separator "")
8556 (art-buf (get-buffer gnus-article-buffer)))
8557 (gnus-eval-in-buffer-window gnus-article-buffer
8560 (let ((start (window-start))
8562 (message-pipe-buffer-body program)
8563 (set-window-start (get-buffer-window (current-buffer)) start))))))
8565 (defun gnus-get-split-value (methods)
8566 "Return a value based on the split METHODS."
8567 (let (split-name method result match)
8570 (set-buffer gnus-original-article-buffer)
8572 (nnheader-narrow-to-headers)
8574 (goto-char (point-min))
8575 (setq method (pop methods))
8576 (setq match (car method))
8579 ;; Regular expression.
8581 (re-search-forward match nil t)))
8582 ((gnus-functionp match)
8586 (setq result (funcall match gnus-newsgroup-name))))
8591 (setq result (eval match)))))
8592 (setq split-name (append (cdr method) split-name))
8593 (cond ((stringp result)
8594 (push (expand-file-name
8595 result gnus-article-save-directory)
8598 (setq split-name (append result split-name)))))))))
8601 (defun gnus-valid-move-group-p (group)
8606 (car (gnus-find-method-for-group
8607 (symbol-name group))))
8608 gnus-valid-select-methods))))
8610 (defun gnus-read-move-group-name (prompt default articles prefix)
8611 "Read a group name."
8612 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
8613 (minibuffer-confirm-incomplete nil) ; XEmacs
8617 (if (> (length articles) 1)
8618 (format "these %d articles" (length articles))
8623 (gnus-completing-read default prom
8625 'gnus-valid-move-group-p
8627 'gnus-group-history))
8628 ((= 1 (length split-name))
8629 (gnus-completing-read (car split-name) prom
8631 'gnus-valid-move-group-p
8633 'gnus-group-history))
8635 (gnus-completing-read nil prom
8636 (mapcar (lambda (el) (list el))
8637 (nreverse split-name))
8639 'gnus-group-history)))))
8641 (if (or (string= to-newsgroup "")
8642 (string= to-newsgroup prefix))
8643 (setq to-newsgroup default))
8644 (unless to-newsgroup
8645 (error "No group name entered"))
8646 (or (gnus-active to-newsgroup)
8647 (gnus-activate-group to-newsgroup)
8648 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
8650 (or (and (gnus-request-create-group
8651 to-newsgroup (gnus-group-name-to-method to-newsgroup))
8652 (gnus-activate-group to-newsgroup nil nil
8653 (gnus-group-name-to-method
8655 (error "Couldn't create group %s" to-newsgroup)))
8656 (error "No such group: %s" to-newsgroup)))
8659 ;; Summary extract commands
8661 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
8662 (let ((buffer-read-only nil)
8663 (article (gnus-summary-article-number))
8665 (unless (gnus-summary-goto-subject article)
8666 (error "No such article: %d" article))
8667 (gnus-summary-position-point)
8668 ;; If all commands are to be bunched up on one line, we collect
8670 (unless gnus-view-pseudos-separately
8671 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
8674 (setq action (cdr (assq 'action (car ps))))
8675 (setq files (list (cdr (assq 'name (car ps)))))
8676 (while (and ps (cdr ps)
8677 (string= (or action "1")
8678 (or (cdr (assq 'action (cadr ps))) "2")))
8679 (push (cdr (assq 'name (cadr ps))) files)
8680 (setcdr ps (cddr ps)))
8682 (when (not (string-match "%s" action))
8685 (when (assq 'execute (car ps))
8686 (setcdr (assq 'execute (car ps))
8687 (funcall (if (string-match "%s" action)
8694 (gnus-quote-arg-for-sh-or-csh f)))
8696 (setq ps (cdr ps)))))
8697 (if (and gnus-view-pseudos (not not-view))
8699 (when (assq 'execute (car pslist))
8700 (gnus-execute-command (cdr (assq 'execute (car pslist)))
8701 (eq gnus-view-pseudos 'not-confirm)))
8702 (setq pslist (cdr pslist)))
8705 (setq after-article (or (cdr (assq 'article (car pslist)))
8706 (gnus-summary-article-number)))
8707 (gnus-summary-goto-subject after-article)
8710 (insert " " (file-name-nondirectory
8711 (cdr (assq 'name (car pslist))))
8712 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
8714 (forward-line -1) ; back to `b'
8715 (gnus-add-text-properties
8716 b (1- e) (list 'gnus-number gnus-reffed-article-number
8717 gnus-mouse-face-prop gnus-mouse-face))
8719 after-article gnus-reffed-article-number
8720 gnus-unread-mark b (car pslist) 0 (- e b))
8721 (push gnus-reffed-article-number gnus-newsgroup-unreads)
8722 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
8723 (setq pslist (cdr pslist)))))))
8725 (defun gnus-pseudos< (p1 p2)
8726 (let ((c1 (cdr (assq 'action p1)))
8727 (c2 (cdr (assq 'action p2))))
8728 (and c1 c2 (string< c1 c2))))
8730 (defun gnus-request-pseudo-article (props)
8731 (cond ((assq 'execute props)
8732 (gnus-execute-command (cdr (assq 'execute props)))))
8733 (let ((gnus-current-article (gnus-summary-article-number)))
8734 (gnus-run-hooks 'gnus-mark-article-hook)))
8736 (defun gnus-execute-command (command &optional automatic)
8738 (gnus-article-setup-buffer)
8739 (set-buffer gnus-article-buffer)
8740 (setq buffer-read-only nil)
8741 (let ((command (if automatic command
8742 (read-string "Command: " (cons command 0)))))
8744 (insert "$ " command "\n\n")
8745 (if gnus-view-pseudo-asynchronously
8746 (start-process "gnus-execute" (current-buffer) shell-file-name
8747 shell-command-switch command)
8748 (call-process shell-file-name nil t nil
8749 shell-command-switch command)))))
8751 ;; Summary kill commands.
8753 (defun gnus-summary-edit-global-kill (article)
8754 "Edit the \"global\" kill file."
8755 (interactive (list (gnus-summary-article-number)))
8756 (gnus-group-edit-global-kill article))
8758 (defun gnus-summary-edit-local-kill ()
8759 "Edit a local kill file applied to the current newsgroup."
8761 (setq gnus-current-headers (gnus-summary-article-header))
8762 (gnus-group-edit-local-kill
8763 (gnus-summary-article-number) gnus-newsgroup-name))
8767 (defun gnus-read-header (id &optional header)
8768 "Read the headers of article ID and enter them into the Gnus system."
8769 (let ((group gnus-newsgroup-name)
8770 (gnus-override-method
8771 (and (gnus-news-group-p gnus-newsgroup-name)
8772 gnus-refer-article-method))
8774 ;; First we check to see whether the header in question is already
8777 ;; This is a Message-ID.
8778 (setq header (or header (gnus-id-to-header id)))
8779 ;; This is an article number.
8780 (setq header (or header (gnus-summary-article-header id))))
8782 (not (gnus-summary-article-sparse-p (mail-header-number header))))
8783 ;; We have found the header.
8785 ;; If this is a sparse article, we have to nix out its
8786 ;; previous entry in the thread hashtb.
8788 (gnus-summary-article-sparse-p (mail-header-number header)))
8789 (let* ((parent (gnus-parent-id (mail-header-references header)))
8792 (gnus-gethash parent gnus-newsgroup-dependencies))))
8794 (delq (assq header thread) thread))))
8795 ;; We have to really fetch the header to this article.
8797 (set-buffer nntp-server-buffer)
8798 (when (setq where (gnus-request-head id group))
8799 (nnheader-fold-continuation-lines)
8800 (goto-char (point-max))
8802 (goto-char (point-min))
8806 ((cdr where) (cdr where))
8807 (header (mail-header-number header))
8808 (t gnus-reffed-article-number))
8810 (insert " Article retrieved.\n"))
8812 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
8813 () ; Malformed head.
8814 (unless (gnus-summary-article-sparse-p (mail-header-number header))
8815 (when (and (stringp id)
8816 (not (string= (gnus-group-real-name group)
8818 ;; If we fetched by Message-ID and the article came
8819 ;; from a different group, we fudge some bogus article
8820 ;; numbers for this article.
8821 (mail-header-set-number header gnus-reffed-article-number))
8823 (set-buffer gnus-summary-buffer)
8824 (decf gnus-reffed-article-number)
8825 (gnus-remove-header (mail-header-number header))
8826 (push header gnus-newsgroup-headers)
8827 (setq gnus-current-headers header)
8828 (push (mail-header-number header) gnus-newsgroup-limit)))
8831 (defun gnus-remove-header (number)
8832 "Remove header NUMBER from `gnus-newsgroup-headers'."
8833 (if (and gnus-newsgroup-headers
8834 (= number (mail-header-number (car gnus-newsgroup-headers))))
8835 (pop gnus-newsgroup-headers)
8836 (let ((headers gnus-newsgroup-headers))
8837 (while (and (cdr headers)
8838 (not (= number (mail-header-number (cadr headers)))))
8841 (setcdr headers (cddr headers))))))
8844 ;;; summary highlights
8847 (defun gnus-highlight-selected-summary ()
8848 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
8849 ;; Highlight selected article in summary buffer
8850 (when gnus-summary-selected-face
8852 (let* ((beg (progn (beginning-of-line) (point)))
8853 (end (progn (end-of-line) (point)))
8854 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
8855 (from (if (get-text-property beg gnus-mouse-face-prop)
8857 (or (next-single-property-change
8858 beg gnus-mouse-face-prop nil end)
8863 (or (next-single-property-change
8864 from gnus-mouse-face-prop nil end)
8866 ;; If no mouse-face prop on line we will have to = from = end,
8867 ;; so we highlight the entire line instead.
8868 (when (= (+ to 2) from)
8871 (if gnus-newsgroup-selected-overlay
8872 ;; Move old overlay.
8874 gnus-newsgroup-selected-overlay from to (current-buffer))
8875 ;; Create new overlay.
8877 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
8878 'face gnus-summary-selected-face))))))
8880 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
8881 (defun gnus-summary-highlight-line ()
8882 "Highlight current line according to `gnus-summary-highlight'."
8883 (let* ((list gnus-summary-highlight)
8885 (end (progn (end-of-line) (point)))
8886 ;; now find out where the line starts and leave point there.
8887 (beg (progn (beginning-of-line) (point)))
8888 (article (gnus-summary-article-number))
8889 (score (or (cdr (assq (or article gnus-current-article)
8890 gnus-newsgroup-scored))
8891 gnus-summary-default-score 0))
8892 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
8893 (inhibit-read-only t))
8894 ;; Eval the cars of the lists until we find a match.
8895 (let ((default gnus-summary-default-score))
8897 (not (eval (caar list))))
8898 (setq list (cdr list))))
8899 (let ((face (cdar list)))
8900 (unless (eq face (get-text-property beg 'face))
8901 (gnus-put-text-property
8903 (setq face (if (boundp face) (symbol-value face) face)))
8904 (when gnus-summary-highlight-line-function
8905 (funcall gnus-summary-highlight-line-function article face))))
8908 (defun gnus-update-read-articles (group unread &optional compute)
8909 "Update the list of read articles in GROUP."
8910 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
8911 (entry (gnus-gethash group gnus-newsrc-hashtb))
8912 (info (nth 2 entry))
8914 (unread (sort (copy-sequence unread) '<))
8916 (if (or (not info) (not active))
8917 ;; There is no info on this group if it was, in fact,
8918 ;; killed. Gnus stores no information on killed groups, so
8919 ;; there's nothing to be done.
8920 ;; One could store the information somewhere temporarily,
8921 ;; perhaps... Hmmm...
8923 ;; Remove any negative articles numbers.
8924 (while (and unread (< (car unread) 0))
8925 (setq unread (cdr unread)))
8926 ;; Remove any expired article numbers
8927 (while (and unread (< (car unread) (car active)))
8928 (setq unread (cdr unread)))
8929 ;; Compute the ranges of read articles by looking at the list of
8932 (when (/= (car unread) prev)
8933 (push (if (= prev (1- (car unread))) prev
8934 (cons prev (1- (car unread))))
8936 (setq prev (1+ (car unread)))
8937 (setq unread (cdr unread)))
8938 (when (<= prev (cdr active))
8939 (push (cons prev (cdr active)) read))
8941 (if (> (length read) 1) (nreverse read) read)
8943 (set-buffer gnus-group-buffer)
8946 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
8947 (gnus-info-set-read ',info ',(gnus-info-read info))
8948 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
8949 (gnus-group-update-group ,group t))))
8950 ;; Enter this list into the group info.
8952 info (if (> (length read) 1) (nreverse read) read))
8953 ;; Set the number of unread articles in gnus-newsrc-hashtb.
8954 (gnus-get-unread-articles-in-group info (gnus-active group))
8957 (defun gnus-offer-save-summaries ()
8958 "Offer to save all active summary buffers."
8960 (let ((buflist (buffer-list))
8962 ;; Go through all buffers and find all summaries.
8964 (and (setq bufname (buffer-name (car buflist)))
8965 (string-match "Summary" bufname)
8967 (set-buffer bufname)
8968 ;; We check that this is, indeed, a summary buffer.
8969 (and (eq major-mode 'gnus-summary-mode)
8970 ;; Also make sure this isn't bogus.
8971 gnus-newsgroup-prepared
8972 ;; Also make sure that this isn't a dead summary buffer.
8973 (not gnus-dead-summary-mode)))
8974 (push bufname buffers))
8975 (setq buflist (cdr buflist)))
8976 ;; Go through all these summary buffers and offer to save them.
8979 "Update summary buffer %s? "
8980 (lambda (buf) (switch-to-buffer buf) (gnus-summary-exit))
8984 ;;; @ for mime-partial
8987 (defun gnus-mime-partial-preview-function ()
8988 (gnus-summary-preview-mime-message (gnus-summary-article-number))
8991 (autoload 'mime-combine-message/partials-automatically
8993 "Internal method to combine message/partial messages automatically.")
8995 (set-atype 'mime-acting-condition
8996 '((type . "message/partial")
8997 (method . mime-combine-message/partials-automatically)
8998 (major-mode . gnus-original-article-mode)
8999 (summary-buffer-exp . gnus-summary-buffer)
9002 (set-alist 'mime-view-partial-message-method-alist
9003 'gnus-original-article-mode
9004 'gnus-mime-partial-preview-function)
9014 (run-hooks 'gnus-sum-load-hook)
9016 ;;; gnus-sum.el ends here