1 ;;; gnus-sum.el --- summary mode commands for Gnus
2 ;; Copyright (C) 1996 Free Software Foundation, Inc.
4 ;; Author: Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
7 ;; This file is part of GNU Emacs.
9 ;; GNU Emacs is free software; you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation; either version 2, or (at your option)
14 ;; GNU Emacs is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 ;; Boston, MA 02111-1307, USA.
36 (defvar gnus-kill-summary-on-exit t
37 "*If non-nil, kill the summary buffer when you exit from it.
38 If nil, the summary will become a \"*Dead Summary*\" buffer, and
39 it will be killed sometime later.")
41 (defvar gnus-fetch-old-headers nil
42 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
43 If an unread article in the group refers to an older, already read (or
44 just marked as read) article, the old article will not normally be
45 displayed in the Summary buffer. If this variable is non-nil, Gnus
46 will attempt to grab the headers to the old articles, and thereby
47 build complete threads. If it has the value `some', only enough
48 headers to connect otherwise loose threads will be displayed.
49 This variable can also be a number. In that case, no more than that
50 number of old headers will be fetched.
52 The server has to support NOV for any of this to work.")
54 (defvar gnus-summary-make-false-root 'adopt
55 "*nil means that Gnus won't gather loose threads.
56 If the root of a thread has expired or been read in a previous
57 session, the information necessary to build a complete thread has been
58 lost. Instead of having many small sub-threads from this original thread
59 scattered all over the summary buffer, Gnus can gather them.
61 If non-nil, Gnus will try to gather all loose sub-threads from an
62 original thread into one large thread.
64 If this variable is non-nil, it should be one of `none', `adopt',
67 If this variable is `none', Gnus will not make a false root, but just
68 present the sub-threads after another.
69 If this variable is `dummy', Gnus will create a dummy root that will
70 have all the sub-threads as children.
71 If this variable is `adopt', Gnus will make one of the \"children\"
72 the parent and mark all the step-children as such.
73 If this variable is `empty', the \"children\" are printed with empty
74 subject fields. (Or rather, they will be printed with a string
75 given by the `gnus-summary-same-subject' variable.)")
77 (defvar gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
78 "*A regexp to match subjects to be excluded from loose thread gathering.
79 As loose thread gathering is done on subjects only, that means that
80 there can be many false gatherings performed. By rooting out certain
81 common subjects, gathering might become saner.")
83 (defvar gnus-summary-gather-subject-limit nil
84 "*Maximum length of subject comparisons when gathering loose threads.
85 Use nil to compare full subjects. Setting this variable to a low
86 number will help gather threads that have been corrupted by
87 newsreaders chopping off subject lines, but it might also mean that
88 unrelated articles that have subject that happen to begin with the
89 same few characters will be incorrectly gathered.
91 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
94 (defvar gnus-simplify-ignored-prefixes nil
95 "*Regexp, matches for which are removed from subject lines when simplifying fuzzily.")
97 (defvar gnus-build-sparse-threads nil
98 "*If non-nil, fill in the gaps in threads.
99 If `some', only fill in the gaps that are needed to tie loose threads
100 together. If `more', fill in all leaf nodes that Gnus can find. If
101 non-nil and non-`some', fill in all gaps that Gnus manages to guess.")
103 (defvar gnus-summary-thread-gathering-function 'gnus-gather-threads-by-subject
104 "Function used for gathering loose threads.
105 There are two pre-defined functions: `gnus-gather-threads-by-subject',
106 which only takes Subjects into consideration; and
107 `gnus-gather-threads-by-references', which compared the References
108 headers of the articles to find matches.")
110 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
111 (defvar gnus-summary-same-subject ""
112 "*String indicating that the current article has the same subject as the previous.
113 This variable will only be used if the value of
114 `gnus-summary-make-false-root' is `empty'.")
116 (defvar gnus-summary-goto-unread t
117 "*If non-nil, marking commands will go to the next unread article.
118 If `never', \\<gnus-summary-mode-map>\\[gnus-summary-next-page] will go to the next article,
119 whether it is read or not.")
121 (defvar gnus-summary-default-score 0
122 "*Default article score level.
123 If this variable is nil, scoring will be disabled.")
125 (defvar gnus-summary-zcore-fuzz 0
126 "*Fuzziness factor for the zcore in the summary buffer.
127 Articles with scores closer than this to `gnus-summary-default-score'
128 will not be marked.")
130 (defvar gnus-simplify-subject-fuzzy-regexp nil
131 "*Strings to be removed when doing fuzzy matches.
132 This can either be a regular expression or list of regular expressions
133 that will be removed from subject strings if fuzzy subject
134 simplification is selected.")
136 (defvar gnus-show-threads t
137 "*If non-nil, display threads in summary mode.")
139 (defvar gnus-thread-hide-subtree nil
140 "*If non-nil, hide all threads initially.
141 If threads are hidden, you have to run the command
142 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
143 to expose hidden threads.")
145 (defvar gnus-thread-hide-killed t
146 "*If non-nil, hide killed threads automatically.")
148 (defvar gnus-thread-ignore-subject nil
149 "*If non-nil, ignore subjects and do all threading based on the Reference header.
150 If nil, which is the default, articles that have different subjects
151 from their parents will start separate threads.")
153 (defvar gnus-thread-operation-ignore-subject t
154 "*If non-nil, subjects will be ignored when doing thread commands.
155 This affects commands like `gnus-summary-kill-thread' and
156 `gnus-summary-lower-thread'.
158 If this variable is nil, articles in the same thread with different
159 subjects will not be included in the operation in question. If this
160 variable is `fuzzy', only articles that have subjects that are fuzzily
161 equal will be included.")
163 (defvar gnus-thread-indent-level 4
164 "*Number that says how much each sub-thread should be indented.")
166 (defvar gnus-auto-extend-newsgroup t
167 "*If non-nil, extend newsgroup forward and backward when requested.")
169 (defvar gnus-auto-select-first t
170 "*If nil, don't select the first unread article when entering a group.
171 If this variable is `best', select the highest-scored unread article
172 in the group. If neither nil nor `best', select the first unread
175 If you want to prevent automatic selection of the first unread article
176 in some newsgroups, set the variable to nil in
177 `gnus-select-group-hook'.")
179 (defvar gnus-auto-select-next t
180 "*If non-nil, offer to go to the next group from the end of the previous.
181 If the value is t and the next newsgroup is empty, Gnus will exit
182 summary mode and go back to group mode. If the value is neither nil
183 nor t, Gnus will select the following unread newsgroup. In
184 particular, if the value is the symbol `quietly', the next unread
185 newsgroup will be selected without any confirmation, and if it is
186 `almost-quietly', the next group will be selected without any
187 confirmation if you are located on the last article in the group.
188 Finally, if this variable is `slightly-quietly', the `Z n' command
189 will go to the next group without confirmation.")
191 (defvar gnus-auto-select-same nil
192 "*If non-nil, select the next article with the same subject.")
194 (defvar gnus-summary-check-current nil
195 "*If non-nil, consider the current article when moving.
196 The \"unread\" movement commands will stay on the same line if the
197 current article is unread.")
199 (defvar gnus-auto-center-summary t
200 "*If non-nil, always center the current summary buffer.
201 In particular, if `vertical' do only vertical recentering. If non-nil
202 and non-`vertical', do both horizontal and vertical recentering.")
204 (defvar gnus-show-all-headers nil
205 "*If non-nil, don't hide any headers.")
207 (defvar gnus-single-article-buffer t
208 "*If non-nil, display all articles in the same buffer.
209 If nil, each group will get its own article buffer.")
211 (defvar gnus-break-pages t
212 "*If non-nil, do page breaking on articles.
213 The page delimiter is specified by the `gnus-page-delimiter'
216 (defvar gnus-show-mime nil
217 "*If non-nil, do mime processing of articles.
218 The articles will simply be fed to the function given by
219 `gnus-show-mime-method'.")
221 (defvar gnus-move-split-methods nil
222 "*Variable used to suggest where articles are to be moved to.
223 It uses the same syntax as the `gnus-split-methods' variable.")
225 ;; Mark variables suggested by Thomas Michanek
226 ;; <Thomas.Michanek@telelogic.se>.
227 (defvar gnus-unread-mark ?
228 "*Mark used for unread articles.")
229 (defvar gnus-ticked-mark ?!
230 "*Mark used for ticked articles.")
231 (defvar gnus-dormant-mark ??
232 "*Mark used for dormant articles.")
233 (defvar gnus-del-mark ?r
234 "*Mark used for del'd articles.")
235 (defvar gnus-read-mark ?R
236 "*Mark used for read articles.")
237 (defvar gnus-expirable-mark ?E
238 "*Mark used for expirable articles.")
239 (defvar gnus-killed-mark ?K
240 "*Mark used for killed articles.")
241 (defvar gnus-souped-mark ?F
242 "*Mark used for killed articles.")
243 (defvar gnus-kill-file-mark ?X
244 "*Mark used for articles killed by kill files.")
245 (defvar gnus-low-score-mark ?Y
246 "*Mark used for articles with a low score.")
247 (defvar gnus-catchup-mark ?C
248 "*Mark used for articles that are caught up.")
249 (defvar gnus-replied-mark ?A
250 "*Mark used for articles that have been replied to.")
251 (defvar gnus-cached-mark ?*
252 "*Mark used for articles that are in the cache.")
253 (defvar gnus-saved-mark ?S
254 "*Mark used for articles that have been saved to.")
255 (defvar gnus-ancient-mark ?O
256 "*Mark used for ancient articles.")
257 (defvar gnus-sparse-mark ?Q
258 "*Mark used for sparsely reffed articles.")
259 (defvar gnus-canceled-mark ?G
260 "*Mark used for canceled articles.")
261 (defvar gnus-duplicate-mark ?M
262 "*Mark used for duplicate articles.")
263 (defvar gnus-score-over-mark ?+
264 "*Score mark used for articles with high scores.")
265 (defvar gnus-score-below-mark ?-
266 "*Score mark used for articles with low scores.")
267 (defvar gnus-empty-thread-mark ?
268 "*There is no thread under the article.")
269 (defvar gnus-not-empty-thread-mark ?=
270 "*There is a thread under the article.")
272 (defvar gnus-view-pseudo-asynchronously nil
273 "*If non-nil, Gnus will view pseudo-articles asynchronously.")
275 (defvar gnus-view-pseudos nil
276 "*If `automatic', pseudo-articles will be viewed automatically.
277 If `not-confirm', pseudos will be viewed automatically, and the user
278 will not be asked to confirm the command.")
280 (defvar gnus-view-pseudos-separately t
281 "*If non-nil, one pseudo-article will be created for each file to be viewed.
282 If nil, all files that use the same viewing command will be given as a
283 list of parameters to that command.")
285 (defvar gnus-insert-pseudo-articles t
286 "*If non-nil, insert pseudo-articles when decoding articles.")
288 (defvar gnus-summary-dummy-line-format
290 "*The format specification for the dummy roots in the summary buffer.
291 It works along the same lines as a normal formatting string,
292 with some simple extensions.
296 (defvar gnus-summary-mode-line-format "Gnus: %%b [%A] %Z"
297 "*The format specification for the summary mode line.
298 It works along the same lines as a normal formatting string,
299 with some simple extensions:
302 %p Unprefixed group name
303 %A Current article number
305 %U Number of unread articles in the group
306 %e Number of unselected articles in the group
307 %Z A string with unread/unselected article counts
308 %g Shortish group name
309 %S Subject of the current article
311 %s Current score file name
312 %d Number of dormant articles
313 %r Number of articles that have been marked as read in this session
314 %E Number of articles expunged by the score files")
316 (defvar gnus-summary-mark-below 0
317 "*Mark all articles with a score below this variable as read.
318 This variable is local to each summary buffer and usually set by the
321 (defvar gnus-article-sort-functions '(gnus-article-sort-by-number)
322 "*List of functions used for sorting articles in the summary buffer.
323 This variable is only used when not using a threaded display.")
325 (defvar gnus-thread-sort-functions '(gnus-thread-sort-by-number)
326 "*List of functions used for sorting threads in the summary buffer.
327 By default, threads are sorted by article number.
329 Each function takes two threads and return non-nil if the first thread
330 should be sorted before the other. If you use more than one function,
331 the primary sort function should be the last. You should probably
332 always include `gnus-thread-sort-by-number' in the list of sorting
333 functions -- preferably first.
335 Ready-mady functions include `gnus-thread-sort-by-number',
336 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
337 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
338 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').")
340 (defvar gnus-thread-score-function '+
341 "*Function used for calculating the total score of a thread.
343 The function is called with the scores of the article and each
344 subthread and should then return the score of the thread.
346 Some functions you can use are `+', `max', or `min'.")
348 (defvar gnus-summary-expunge-below nil
349 "All articles that have a score less than this variable will be expunged.")
351 (defvar gnus-thread-expunge-below nil
352 "All threads that have a total score less than this variable will be expunged.
353 See `gnus-thread-score-function' for en explanation of what a
354 \"thread score\" is.")
356 (defvar gnus-summary-mode-hook nil
357 "*A hook for Gnus summary mode.
358 This hook is run before any variables are set in the summary buffer.")
360 (defvar gnus-summary-exit-hook nil
361 "*A hook called on exit from the summary buffer.")
363 (defvar gnus-summary-prepare-hook nil
364 "*A hook called after the summary buffer has been generated.
365 If you want to modify the summary buffer, you can use this hook.")
367 (defvar gnus-summary-generate-hook nil
368 "*A hook run just before generating the summary buffer.
369 This hook is commonly used to customize threading variables and the
372 (defvar gnus-select-group-hook nil
373 "*A hook called when a newsgroup is selected.
375 If you'd like to simplify subjects like the
376 `gnus-summary-next-same-subject' command does, you can use the
379 (setq gnus-select-group-hook
382 (mapcar (lambda (header)
383 (mail-header-set-subject
385 (gnus-simplify-subject
386 (mail-header-subject header) 're-only)))
387 gnus-newsgroup-headers))))")
389 (defvar gnus-select-article-hook nil
390 "*A hook called when an article is selected.")
392 (defvar gnus-visual-mark-article-hook
393 (list 'gnus-highlight-selected-summary)
394 "*Hook run after selecting an article in the summary buffer.
395 It is meant to be used for highlighting the article in some way. It
396 is not run if `gnus-visual' is nil.")
398 (defvar gnus-parse-headers-hook nil
399 "*A hook called before parsing the headers.")
400 (add-hook 'gnus-parse-headers-hook 'gnus-decode-rfc1522)
402 (defvar gnus-exit-group-hook nil
403 "*A hook called when exiting (not quitting) summary mode.")
405 (defvar gnus-summary-update-hook
406 (list 'gnus-summary-highlight-line)
407 "*A hook called when a summary line is changed.
408 The hook will not be called if `gnus-visual' is nil.
410 The default function `gnus-summary-highlight-line' will
411 highlight the line according to the `gnus-summary-highlight'
414 (defvar gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
415 "*A hook called when an article is selected for the first time.
416 The hook is intended to mark an article as read (or unread)
417 automatically when it is selected.")
419 (defvar gnus-summary-display-table
420 ;; Change the display table. Odd characters have a tendency to mess
421 ;; up nicely formatted displays - we make all possible glyphs
422 ;; display only a single character.
424 ;; We start from the standard display table, if any.
425 (let ((table (or (copy-sequence standard-display-table)
426 (make-display-table)))
427 ;; Nix out all the control chars...
429 (while (>= (setq i (1- i)) 0)
431 ;; ... but not newline and cr, of course. (cr is necessary for the
432 ;; selective display).
435 ;; We nix out any glyphs over 126 that are not set already.
437 (while (>= (setq i (1- i)) 127)
438 ;; Only modify if the entry is nil.
440 (aset table i [??]))))
442 "Display table used in summary mode buffers.")
444 ;;; Internal variables
446 (defvar gnus-original-article nil)
447 (defvar gnus-article-internal-prepare-hook nil)
449 (defvar gnus-thread-indent-array nil)
450 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
452 ;; Avoid highlighting in kill files.
453 (defvar gnus-summary-inhibit-highlight nil)
454 (defvar gnus-newsgroup-selected-overlay nil)
455 (defvar gnus-inhibit-limiting nil)
456 (defvar gnus-newsgroup-adaptive-score-file nil)
457 (defvar gnus-current-score-file nil)
458 (defvar gnus-current-move-group nil)
459 (defvar gnus-current-copy-group nil)
460 (defvar gnus-current-crosspost-group nil)
462 (defvar gnus-newsgroup-dependencies nil)
463 (defvar gnus-newsgroup-adaptive nil)
464 (defvar gnus-summary-display-article-function nil)
465 (defvar gnus-summary-highlight-line-function nil
466 "Function called after highlighting a summary line.")
468 (defvar gnus-summary-line-format-alist
469 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
470 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
471 (?s gnus-tmp-subject-or-nil ?s)
472 (?n gnus-tmp-name ?s)
473 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
475 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
477 (?F gnus-tmp-from ?s)
478 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
479 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
480 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
481 (?o (gnus-date-iso8601 gnus-tmp-header) ?s)
482 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
483 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
484 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
485 (?L gnus-tmp-lines ?d)
486 (?I gnus-tmp-indentation ?s)
487 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
488 (?R gnus-tmp-replied ?c)
489 (?\[ gnus-tmp-opening-bracket ?c)
490 (?\] gnus-tmp-closing-bracket ?c)
491 (?\> (make-string gnus-tmp-level ? ) ?s)
492 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
493 (?i gnus-tmp-score ?d)
494 (?z gnus-tmp-score-char ?c)
495 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
496 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
497 (?U gnus-tmp-unread ?c)
498 (?t (gnus-summary-number-of-articles-in-thread
499 (and (boundp 'thread) (car thread)) gnus-tmp-level)
501 (?e (gnus-summary-number-of-articles-in-thread
502 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
504 (?u gnus-tmp-user-defined ?s)
505 (?P (gnus-pick-line-number) ?d))
506 "An alist of format specifications that can appear in summary lines,
507 and what variables they correspond with, along with the type of the
508 variable (string, integer, character, etc).")
510 (defvar gnus-summary-dummy-line-format-alist
511 `((?S gnus-tmp-subject ?s)
512 (?N gnus-tmp-number ?d)
513 (?u gnus-tmp-user-defined ?s)))
515 (defvar gnus-summary-mode-line-format-alist
516 `((?G gnus-tmp-group-name ?s)
517 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
518 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
519 (?A gnus-tmp-article-number ?d)
520 (?Z gnus-tmp-unread-and-unselected ?s)
522 (?U gnus-tmp-unread-and-unticked ?d)
523 (?S gnus-tmp-subject ?s)
524 (?e gnus-tmp-unselected ?d)
525 (?u gnus-tmp-user-defined ?s)
526 (?d (length gnus-newsgroup-dormant) ?d)
527 (?t (length gnus-newsgroup-marked) ?d)
528 (?r (length gnus-newsgroup-reads) ?d)
529 (?E gnus-newsgroup-expunged-tally ?d)
530 (?s (gnus-current-score-file-nondirectory) ?s)))
532 (defvar gnus-last-search-regexp nil
533 "Default regexp for article search command.")
535 (defvar gnus-last-shell-command nil
536 "Default shell command on article.")
538 (defvar gnus-newsgroup-begin nil)
539 (defvar gnus-newsgroup-end nil)
540 (defvar gnus-newsgroup-last-rmail nil)
541 (defvar gnus-newsgroup-last-mail nil)
542 (defvar gnus-newsgroup-last-folder nil)
543 (defvar gnus-newsgroup-last-file nil)
544 (defvar gnus-newsgroup-auto-expire nil)
545 (defvar gnus-newsgroup-active nil)
547 (defvar gnus-newsgroup-data nil)
548 (defvar gnus-newsgroup-data-reverse nil)
549 (defvar gnus-newsgroup-limit nil)
550 (defvar gnus-newsgroup-limits nil)
552 (defvar gnus-newsgroup-unreads nil
553 "List of unread articles in the current newsgroup.")
555 (defvar gnus-newsgroup-unselected nil
556 "List of unselected unread articles in the current newsgroup.")
558 (defvar gnus-newsgroup-reads nil
559 "Alist of read articles and article marks in the current newsgroup.")
561 (defvar gnus-newsgroup-expunged-tally nil)
563 (defvar gnus-newsgroup-marked nil
564 "List of ticked articles in the current newsgroup (a subset of unread art).")
566 (defvar gnus-newsgroup-killed nil
567 "List of ranges of articles that have been through the scoring process.")
569 (defvar gnus-newsgroup-cached nil
570 "List of articles that come from the article cache.")
572 (defvar gnus-newsgroup-saved nil
573 "List of articles that have been saved.")
575 (defvar gnus-newsgroup-kill-headers nil)
577 (defvar gnus-newsgroup-replied nil
578 "List of articles that have been replied to in the current newsgroup.")
580 (defvar gnus-newsgroup-expirable nil
581 "List of articles in the current newsgroup that can be expired.")
583 (defvar gnus-newsgroup-processable nil
584 "List of articles in the current newsgroup that can be processed.")
586 (defvar gnus-newsgroup-bookmarks nil
587 "List of articles in the current newsgroup that have bookmarks.")
589 (defvar gnus-newsgroup-dormant nil
590 "List of dormant articles in the current newsgroup.")
592 (defvar gnus-newsgroup-scored nil
593 "List of scored articles in the current newsgroup.")
595 (defvar gnus-newsgroup-headers nil
596 "List of article headers in the current newsgroup.")
598 (defvar gnus-newsgroup-threads nil)
600 (defvar gnus-newsgroup-prepared nil
601 "Whether the current group has been prepared properly.")
603 (defvar gnus-newsgroup-ancient nil
604 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
606 (defvar gnus-newsgroup-sparse nil)
608 (defvar gnus-current-article nil)
609 (defvar gnus-article-current nil)
610 (defvar gnus-current-headers nil)
611 (defvar gnus-have-all-headers nil)
612 (defvar gnus-last-article nil)
613 (defvar gnus-newsgroup-history nil)
615 (defconst gnus-summary-local-variables
616 '(gnus-newsgroup-name
617 gnus-newsgroup-begin gnus-newsgroup-end
618 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
619 gnus-newsgroup-last-folder gnus-newsgroup-last-file
620 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
621 gnus-newsgroup-unselected gnus-newsgroup-marked
622 gnus-newsgroup-reads gnus-newsgroup-saved
623 gnus-newsgroup-replied gnus-newsgroup-expirable
624 gnus-newsgroup-processable gnus-newsgroup-killed
625 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
626 gnus-newsgroup-headers gnus-newsgroup-threads
627 gnus-newsgroup-prepared gnus-summary-highlight-line-function
628 gnus-current-article gnus-current-headers gnus-have-all-headers
629 gnus-last-article gnus-article-internal-prepare-hook
630 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
631 gnus-newsgroup-scored gnus-newsgroup-kill-headers
632 gnus-thread-expunge-below
633 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
634 (gnus-summary-mark-below . global)
635 gnus-newsgroup-active gnus-scores-exclude-files
636 gnus-newsgroup-history gnus-newsgroup-ancient
637 gnus-newsgroup-sparse
638 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
639 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
640 (gnus-newsgroup-expunged-tally . 0)
641 gnus-cache-removable-articles gnus-newsgroup-cached
642 gnus-newsgroup-data gnus-newsgroup-data-reverse
643 gnus-newsgroup-limit gnus-newsgroup-limits)
644 "Variables that are buffer-local to the summary buffers.")
646 ;; Byte-compiler warning.
647 (defvar gnus-article-mode-map)
649 ;; Subject simplification.
651 (defsubst gnus-simplify-subject-re (subject)
652 "Remove \"Re:\" from subject lines."
653 (if (string-match "^[Rr][Ee]: *" subject)
654 (substring subject (match-end 0))
657 (defun gnus-simplify-subject (subject &optional re-only)
658 "Remove `Re:' and words in parentheses.
659 If RE-ONLY is non-nil, strip leading `Re:'s only."
660 (let ((case-fold-search t)) ;Ignore case.
661 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
662 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
663 (setq subject (substring subject (match-end 0))))
664 ;; Remove uninteresting prefixes.
665 (if (and (not re-only)
666 gnus-simplify-ignored-prefixes
667 (string-match gnus-simplify-ignored-prefixes subject))
668 (setq subject (substring subject (match-end 0))))
669 ;; Remove words in parentheses from end.
671 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
672 (setq subject (substring subject 0 (match-beginning 0)))))
673 ;; Return subject string.
676 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
678 ;; Written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
679 (defun gnus-simplify-buffer-fuzzy ()
680 (let ((case-fold-search t))
681 (goto-char (point-min))
682 (while (search-forward "\t" nil t)
683 (replace-match " " t t))
684 (goto-char (point-min))
685 (re-search-forward "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *" nil t)
686 (goto-char (match-beginning 0))
688 (looking-at "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
689 (looking-at "^[[].*: .*[]]$"))
690 (goto-char (point-min))
691 (while (re-search-forward "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *"
693 (replace-match "" t t))
694 (goto-char (point-min))
695 (while (re-search-forward "^[[].*: .*[]]$" nil t)
696 (goto-char (match-end 0))
699 (progn (goto-char (match-beginning 0)))
700 (re-search-forward ":"))))
701 (goto-char (point-min))
702 (while (re-search-forward " *[[{(][^()\n]*[]})] *$" nil t)
703 (replace-match "" t t))
704 (goto-char (point-min))
705 (while (re-search-forward " +" nil t)
706 (replace-match " " t t))
707 (goto-char (point-min))
708 (while (re-search-forward " $" nil t)
709 (replace-match "" t t))
710 (goto-char (point-min))
711 (while (re-search-forward "^ +" nil t)
712 (replace-match "" t t))
713 (goto-char (point-min))
714 (when gnus-simplify-subject-fuzzy-regexp
715 (if (listp gnus-simplify-subject-fuzzy-regexp)
716 (let ((list gnus-simplify-subject-fuzzy-regexp))
718 (goto-char (point-min))
719 (while (re-search-forward (car list) nil t)
720 (replace-match "" t t))
721 (setq list (cdr list))))
722 (while (re-search-forward gnus-simplify-subject-fuzzy-regexp nil t)
723 (replace-match "" t t))))))
725 (defun gnus-simplify-subject-fuzzy (subject)
726 "Siplify a subject string fuzzily."
728 (gnus-set-work-buffer)
729 (let ((case-fold-search t))
731 (inline (gnus-simplify-buffer-fuzzy))
734 (defsubst gnus-simplify-subject-fully (subject)
735 "Simplify a subject string according to the user's wishes."
737 ((null gnus-summary-gather-subject-limit)
738 (gnus-simplify-subject-re subject))
739 ((eq gnus-summary-gather-subject-limit 'fuzzy)
740 (gnus-simplify-subject-fuzzy subject))
741 ((numberp gnus-summary-gather-subject-limit)
742 (gnus-limit-string (gnus-simplify-subject-re subject)
743 gnus-summary-gather-subject-limit))
747 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
748 "Check whether two subjects are equal. If optional argument
749 simple-first is t, first argument is already simplified."
752 (equal (gnus-simplify-subject-fully s1)
753 (gnus-simplify-subject-fully s2)))
756 (gnus-simplify-subject-fully s2)))))
758 (defun gnus-offer-save-summaries ()
759 "Offer to save all active summary buffers."
761 (let ((buflist (buffer-list))
763 ;; Go through all buffers and find all summaries.
765 (and (setq bufname (buffer-name (car buflist)))
766 (string-match "Summary" bufname)
769 ;; We check that this is, indeed, a summary buffer.
770 (and (eq major-mode 'gnus-summary-mode)
771 ;; Also make sure this isn't bogus.
772 gnus-newsgroup-prepared))
773 (push bufname buffers))
774 (setq buflist (cdr buflist)))
775 ;; Go through all these summary buffers and offer to save them.
778 "Update summary buffer %s? "
779 (lambda (buf) (set-buffer buf) (gnus-summary-exit))
782 (defun gnus-summary-bubble-group ()
783 "Increase the score of the current group.
784 This is a handy function to add to `gnus-summary-exit-hook' to
785 increase the score of each group you read."
786 (gnus-group-add-score gnus-newsgroup-name))
790 ;;; Gnus summary mode
793 (put 'gnus-summary-mode 'mode-class 'special)
796 ;; Non-orthogonal keys
798 (gnus-define-keys gnus-summary-mode-map
799 " " gnus-summary-next-page
800 "\177" gnus-summary-prev-page
801 [delete] gnus-summary-prev-page
802 "\r" gnus-summary-scroll-up
803 "n" gnus-summary-next-unread-article
804 "p" gnus-summary-prev-unread-article
805 "N" gnus-summary-next-article
806 "P" gnus-summary-prev-article
807 "\M-\C-n" gnus-summary-next-same-subject
808 "\M-\C-p" gnus-summary-prev-same-subject
809 "\M-n" gnus-summary-next-unread-subject
810 "\M-p" gnus-summary-prev-unread-subject
811 "." gnus-summary-first-unread-article
812 "," gnus-summary-best-unread-article
813 "\M-s" gnus-summary-search-article-forward
814 "\M-r" gnus-summary-search-article-backward
815 "<" gnus-summary-beginning-of-article
816 ">" gnus-summary-end-of-article
817 "j" gnus-summary-goto-article
818 "^" gnus-summary-refer-parent-article
819 "\M-^" gnus-summary-refer-article
820 "u" gnus-summary-tick-article-forward
821 "!" gnus-summary-tick-article-forward
822 "U" gnus-summary-tick-article-backward
823 "d" gnus-summary-mark-as-read-forward
824 "D" gnus-summary-mark-as-read-backward
825 "E" gnus-summary-mark-as-expirable
826 "\M-u" gnus-summary-clear-mark-forward
827 "\M-U" gnus-summary-clear-mark-backward
828 "k" gnus-summary-kill-same-subject-and-select
829 "\C-k" gnus-summary-kill-same-subject
830 "\M-\C-k" gnus-summary-kill-thread
831 "\M-\C-l" gnus-summary-lower-thread
832 "e" gnus-summary-edit-article
833 "#" gnus-summary-mark-as-processable
834 "\M-#" gnus-summary-unmark-as-processable
835 "\M-\C-t" gnus-summary-toggle-threads
836 "\M-\C-s" gnus-summary-show-thread
837 "\M-\C-h" gnus-summary-hide-thread
838 "\M-\C-f" gnus-summary-next-thread
839 "\M-\C-b" gnus-summary-prev-thread
840 "\M-\C-u" gnus-summary-up-thread
841 "\M-\C-d" gnus-summary-down-thread
842 "&" gnus-summary-execute-command
843 "c" gnus-summary-catchup-and-exit
844 "\C-w" gnus-summary-mark-region-as-read
845 "\C-t" gnus-summary-toggle-truncation
846 "?" gnus-summary-mark-as-dormant
847 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
848 "\C-c\C-s\C-n" gnus-summary-sort-by-number
849 "\C-c\C-s\C-a" gnus-summary-sort-by-author
850 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
851 "\C-c\C-s\C-d" gnus-summary-sort-by-date
852 "\C-c\C-s\C-i" gnus-summary-sort-by-score
853 "=" gnus-summary-expand-window
854 "\C-x\C-s" gnus-summary-reselect-current-group
855 "\M-g" gnus-summary-rescan-group
856 "w" gnus-summary-stop-page-breaking
857 "\C-c\C-r" gnus-summary-caesar-message
858 "\M-t" gnus-summary-toggle-mime
859 "f" gnus-summary-followup
860 "F" gnus-summary-followup-with-original
861 "C" gnus-summary-cancel-article
862 "r" gnus-summary-reply
863 "R" gnus-summary-reply-with-original
864 "\C-c\C-f" gnus-summary-mail-forward
865 "o" gnus-summary-save-article
866 "\C-o" gnus-summary-save-article-mail
867 "|" gnus-summary-pipe-output
868 "\M-k" gnus-summary-edit-local-kill
869 "\M-K" gnus-summary-edit-global-kill
871 "\C-c\C-d" gnus-summary-describe-group
872 "q" gnus-summary-exit
873 "Q" gnus-summary-exit-no-update
874 "\C-c\C-i" gnus-info-find-node
875 gnus-mouse-2 gnus-mouse-pick-article
876 "m" gnus-summary-mail-other-window
877 "a" gnus-summary-post-news
878 "x" gnus-summary-limit-to-unread
879 "s" gnus-summary-isearch-article
880 "t" gnus-article-hide-headers
881 "g" gnus-summary-show-article
882 "l" gnus-summary-goto-last-article
883 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
884 "\C-d" gnus-summary-enter-digest-group
886 "*" gnus-cache-enter-article
887 "\M-*" gnus-cache-remove-article
888 "\M-&" gnus-summary-universal-argument
890 "I" gnus-summary-increase-score
891 "L" gnus-summary-lower-score
893 "V" gnus-summary-score-map
894 "X" gnus-uu-extract-map
895 "S" gnus-summary-send-map)
897 ;; Sort of orthogonal keymap
898 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
899 "t" gnus-summary-tick-article-forward
900 "!" gnus-summary-tick-article-forward
901 "d" gnus-summary-mark-as-read-forward
902 "r" gnus-summary-mark-as-read-forward
903 "c" gnus-summary-clear-mark-forward
904 " " gnus-summary-clear-mark-forward
905 "e" gnus-summary-mark-as-expirable
906 "x" gnus-summary-mark-as-expirable
907 "?" gnus-summary-mark-as-dormant
908 "b" gnus-summary-set-bookmark
909 "B" gnus-summary-remove-bookmark
910 "#" gnus-summary-mark-as-processable
911 "\M-#" gnus-summary-unmark-as-processable
912 "S" gnus-summary-limit-include-expunged
913 "C" gnus-summary-catchup
914 "H" gnus-summary-catchup-to-here
915 "\C-c" gnus-summary-catchup-all
916 "k" gnus-summary-kill-same-subject-and-select
917 "K" gnus-summary-kill-same-subject
918 "P" gnus-uu-mark-map)
920 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mode-map)
921 "c" gnus-summary-clear-above
922 "u" gnus-summary-tick-above
923 "m" gnus-summary-mark-above
924 "k" gnus-summary-kill-below)
926 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
927 "/" gnus-summary-limit-to-subject
928 "n" gnus-summary-limit-to-articles
929 "w" gnus-summary-pop-limit
930 "s" gnus-summary-limit-to-subject
931 "a" gnus-summary-limit-to-author
932 "u" gnus-summary-limit-to-unread
933 "m" gnus-summary-limit-to-marks
934 "v" gnus-summary-limit-to-score
935 "D" gnus-summary-limit-include-dormant
936 "d" gnus-summary-limit-exclude-dormant
937 ;; "t" gnus-summary-limit-exclude-thread
938 "E" gnus-summary-limit-include-expunged
939 "c" gnus-summary-limit-exclude-childless-dormant
940 "C" gnus-summary-limit-mark-excluded-as-read)
942 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
943 "n" gnus-summary-next-unread-article
944 "p" gnus-summary-prev-unread-article
945 "N" gnus-summary-next-article
946 "P" gnus-summary-prev-article
947 "\C-n" gnus-summary-next-same-subject
948 "\C-p" gnus-summary-prev-same-subject
949 "\M-n" gnus-summary-next-unread-subject
950 "\M-p" gnus-summary-prev-unread-subject
951 "f" gnus-summary-first-unread-article
952 "b" gnus-summary-best-unread-article
953 "j" gnus-summary-goto-article
954 "g" gnus-summary-goto-subject
955 "l" gnus-summary-goto-last-article
956 "p" gnus-summary-pop-article)
958 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
959 "k" gnus-summary-kill-thread
960 "l" gnus-summary-lower-thread
961 "i" gnus-summary-raise-thread
962 "T" gnus-summary-toggle-threads
963 "t" gnus-summary-rethread-current
964 "^" gnus-summary-reparent-thread
965 "s" gnus-summary-show-thread
966 "S" gnus-summary-show-all-threads
967 "h" gnus-summary-hide-thread
968 "H" gnus-summary-hide-all-threads
969 "n" gnus-summary-next-thread
970 "p" gnus-summary-prev-thread
971 "u" gnus-summary-up-thread
972 "o" gnus-summary-top-thread
973 "d" gnus-summary-down-thread
974 "#" gnus-uu-mark-thread
975 "\M-#" gnus-uu-unmark-thread)
977 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
978 "c" gnus-summary-catchup-and-exit
979 "C" gnus-summary-catchup-all-and-exit
980 "E" gnus-summary-exit-no-update
981 "Q" gnus-summary-exit
982 "Z" gnus-summary-exit
983 "n" gnus-summary-catchup-and-goto-next-group
984 "R" gnus-summary-reselect-current-group
985 "G" gnus-summary-rescan-group
986 "N" gnus-summary-next-group
987 "P" gnus-summary-prev-group)
989 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
990 " " gnus-summary-next-page
991 "n" gnus-summary-next-page
992 "\177" gnus-summary-prev-page
993 [delete] gnus-summary-prev-page
994 "p" gnus-summary-prev-page
995 "\r" gnus-summary-scroll-up
996 "<" gnus-summary-beginning-of-article
997 ">" gnus-summary-end-of-article
998 "b" gnus-summary-beginning-of-article
999 "e" gnus-summary-end-of-article
1000 "^" gnus-summary-refer-parent-article
1001 "r" gnus-summary-refer-parent-article
1002 "R" gnus-summary-refer-references
1003 "g" gnus-summary-show-article
1004 "s" gnus-summary-isearch-article)
1006 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1007 "b" gnus-article-add-buttons
1008 "B" gnus-article-add-buttons-to-head
1009 "o" gnus-article-treat-overstrike
1010 "e" gnus-article-emphasize
1011 "w" gnus-article-fill-cited-article
1012 "c" gnus-article-remove-cr
1013 "L" gnus-article-remove-trailing-blank-lines
1014 "q" gnus-article-de-quoted-unreadable
1015 "f" gnus-article-display-x-face
1016 "l" gnus-summary-stop-page-breaking
1017 "r" gnus-summary-caesar-message
1018 "t" gnus-article-hide-headers
1019 "v" gnus-summary-verbose-headers
1020 "m" gnus-summary-toggle-mime)
1022 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1023 "a" gnus-article-hide
1024 "h" gnus-article-hide-headers
1025 "b" gnus-article-hide-boring-headers
1026 "s" gnus-article-hide-signature
1027 "c" gnus-article-hide-citation
1028 "p" gnus-article-hide-pgp
1029 "P" gnus-article-hide-pem
1030 "\C-c" gnus-article-hide-citation-maybe)
1032 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1033 "a" gnus-article-highlight
1034 "h" gnus-article-highlight-headers
1035 "c" gnus-article-highlight-citation
1036 "s" gnus-article-highlight-signature)
1038 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1039 "z" gnus-article-date-ut
1040 "u" gnus-article-date-ut
1041 "l" gnus-article-date-local
1042 "e" gnus-article-date-lapsed
1043 "o" gnus-article-date-original)
1045 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1047 "f" gnus-summary-fetch-faq
1048 "d" gnus-summary-describe-group
1049 "h" gnus-summary-describe-briefly
1050 "i" gnus-info-find-node)
1052 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1053 "e" gnus-summary-expire-articles
1054 "\M-\C-e" gnus-summary-expire-articles-now
1055 "\177" gnus-summary-delete-article
1056 [delete] gnus-summary-delete-article
1057 "m" gnus-summary-move-article
1058 "r" gnus-summary-respool-article
1059 "w" gnus-summary-edit-article
1060 "c" gnus-summary-copy-article
1061 "B" gnus-summary-crosspost-article
1062 "q" gnus-summary-respool-query
1063 "i" gnus-summary-import-article)
1065 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1066 "o" gnus-summary-save-article
1067 "m" gnus-summary-save-article-mail
1068 "r" gnus-summary-save-article-rmail
1069 "f" gnus-summary-save-article-file
1070 "b" gnus-summary-save-article-body-file
1071 "h" gnus-summary-save-article-folder
1072 "v" gnus-summary-save-article-vm
1073 "p" gnus-summary-pipe-output
1074 "s" gnus-soup-add-article)
1079 (defun gnus-summary-mode (&optional group)
1080 "Major mode for reading articles.
1082 All normal editing commands are switched off.
1083 \\<gnus-summary-mode-map>
1084 Each line in this buffer represents one article. To read an
1085 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
1086 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
1089 You can also post articles and send mail from this buffer. To
1090 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
1091 of an article, type `\\[gnus-summary-reply]'.
1093 There are approx. one gazillion commands you can execute in this
1094 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
1096 The following commands are available:
1098 \\{gnus-summary-mode-map}"
1100 (when (and menu-bar-mode
1101 (gnus-visual-p 'summary-menu 'menu))
1102 (gnus-summary-make-menu-bar))
1103 (kill-all-local-variables)
1104 (gnus-summary-make-local-variables)
1105 (gnus-make-thread-indent-array)
1106 (gnus-simplify-mode-line)
1107 (setq major-mode 'gnus-summary-mode)
1108 (setq mode-name "Summary")
1109 (make-local-variable 'minor-mode-alist)
1110 (use-local-map gnus-summary-mode-map)
1111 (buffer-disable-undo (current-buffer))
1112 (setq buffer-read-only t) ;Disable modification
1113 (setq truncate-lines t)
1114 (setq selective-display t)
1115 (setq selective-display-ellipses t) ;Display `...'
1116 (setq buffer-display-table gnus-summary-display-table)
1117 (setq gnus-newsgroup-name group)
1118 (make-local-variable 'gnus-summary-line-format)
1119 (make-local-variable 'gnus-summary-line-format-spec)
1120 (make-local-variable 'gnus-summary-mark-positions)
1121 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
1122 (gnus-update-summary-mark-positions)
1123 (gnus-make-local-hook 'post-command-hook)
1124 (gnus-add-hook 'post-command-hook 'gnus-clear-inboxes-moved nil t)
1125 (run-hooks 'gnus-summary-mode-hook))
1127 (defun gnus-summary-make-local-variables ()
1128 "Make all the local summary buffer variables."
1129 (let ((locals gnus-summary-local-variables)
1131 (while (setq local (pop locals))
1134 (if (eq (cdr local) 'global)
1135 ;; Copy the global value of the variable.
1136 (setq global (symbol-value (car local)))
1137 ;; Use the value from the list.
1138 (setq global (eval (cdr local))))
1139 (make-local-variable (car local))
1140 (set (car local) global))
1141 ;; Simple nil-valued local variable.
1142 (make-local-variable local)
1145 (defun gnus-summary-clear-local-variables ()
1146 (let ((locals gnus-summary-local-variables))
1148 (if (consp (car locals))
1149 (and (vectorp (caar locals))
1150 (set (caar locals) nil))
1151 (and (vectorp (car locals))
1152 (set (car locals) nil)))
1153 (setq locals (cdr locals)))))
1155 ;; Summary data functions.
1157 (defmacro gnus-data-number (data)
1160 (defmacro gnus-data-set-number (data number)
1161 `(setcar ,data ,number))
1163 (defmacro gnus-data-mark (data)
1166 (defmacro gnus-data-set-mark (data mark)
1167 `(setcar (nthcdr 1 ,data) ,mark))
1169 (defmacro gnus-data-pos (data)
1172 (defmacro gnus-data-set-pos (data pos)
1173 `(setcar (nthcdr 2 ,data) ,pos))
1175 (defmacro gnus-data-header (data)
1178 (defmacro gnus-data-level (data)
1181 (defmacro gnus-data-unread-p (data)
1182 `(= (nth 1 ,data) gnus-unread-mark))
1184 (defmacro gnus-data-read-p (data)
1185 `(/= (nth 1 ,data) gnus-unread-mark))
1187 (defmacro gnus-data-pseudo-p (data)
1188 `(consp (nth 3 ,data)))
1190 (defmacro gnus-data-find (number)
1191 `(assq ,number gnus-newsgroup-data))
1193 (defmacro gnus-data-find-list (number &optional data)
1194 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
1195 (memq (assq ,number bdata)
1198 (defmacro gnus-data-make (number mark pos header level)
1199 `(list ,number ,mark ,pos ,header ,level))
1201 (defun gnus-data-enter (after-article number mark pos header level offset)
1202 (let ((data (gnus-data-find-list after-article)))
1203 (or data (error "No such article: %d" after-article))
1204 (setcdr data (cons (gnus-data-make number mark pos header level)
1206 (setq gnus-newsgroup-data-reverse nil)
1207 (gnus-data-update-list (cddr data) offset)))
1209 (defun gnus-data-enter-list (after-article list &optional offset)
1211 (let ((data (and after-article (gnus-data-find-list after-article)))
1213 (or data (not after-article) (error "No such article: %d" after-article))
1214 ;; Find the last element in the list to be spliced into the main
1217 (setq list (cdr list)))
1220 (setcdr list gnus-newsgroup-data)
1221 (setq gnus-newsgroup-data ilist)
1222 (and offset (gnus-data-update-list (cdr list) offset)))
1223 (setcdr list (cdr data))
1225 (and offset (gnus-data-update-list (cdr data) offset)))
1226 (setq gnus-newsgroup-data-reverse nil))))
1228 (defun gnus-data-remove (article &optional offset)
1229 (let ((data gnus-newsgroup-data))
1230 (if (= (gnus-data-number (car data)) article)
1231 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
1232 gnus-newsgroup-data-reverse nil)
1234 (and (= (gnus-data-number (cadr data)) article)
1236 (setcdr data (cddr data))
1237 (and offset (gnus-data-update-list (cdr data) offset))
1239 gnus-newsgroup-data-reverse nil)))
1240 (setq data (cdr data))))))
1242 (defmacro gnus-data-list (backward)
1244 (or gnus-newsgroup-data-reverse
1245 (setq gnus-newsgroup-data-reverse
1246 (reverse gnus-newsgroup-data)))
1247 gnus-newsgroup-data))
1249 (defun gnus-data-update-list (data offset)
1250 "Add OFFSET to the POS of all data entries in DATA."
1252 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
1253 (setq data (cdr data))))
1255 (defun gnus-data-compute-positions ()
1256 "Compute the positions of all articles."
1257 (let ((data gnus-newsgroup-data)
1260 (when (setq pos (text-property-any
1261 (point-min) (point-max)
1262 'gnus-number (gnus-data-number (car data))))
1263 (gnus-data-set-pos (car data) (+ pos 3)))
1264 (setq data (cdr data)))))
1266 (defun gnus-summary-article-pseudo-p (article)
1267 "Say whether this article is a pseudo article or not."
1268 (not (vectorp (gnus-data-header (gnus-data-find article)))))
1270 (defun gnus-article-parent-p (number)
1271 "Say whether this article is a parent or not."
1272 (let ((data (gnus-data-find-list number)))
1273 (and (cdr data) ; There has to be an article after...
1274 (< (gnus-data-level (car data)) ; And it has to have a higher level.
1275 (gnus-data-level (nth 1 data))))))
1277 (defun gnus-article-children (number)
1278 "Return a list of all children to NUMBER."
1279 (let* ((data (gnus-data-find-list number))
1280 (level (gnus-data-level (car data)))
1282 (setq data (cdr data))
1284 (= (gnus-data-level (car data)) (1+ level)))
1285 (push (gnus-data-number (car data)) children)
1286 (setq data (cdr data)))
1289 (defmacro gnus-summary-skip-intangible ()
1290 "If the current article is intangible, then jump to a different article."
1291 '(let ((to (get-text-property (point) 'gnus-intangible)))
1292 (and to (gnus-summary-goto-subject to))))
1294 (defmacro gnus-summary-article-intangible-p ()
1295 "Say whether this article is intangible or not."
1296 '(get-text-property (point) 'gnus-intangible))
1298 ;; Some summary mode macros.
1300 (defmacro gnus-summary-article-number ()
1301 "The article number of the article on the current line.
1302 If there isn's an article number here, then we return the current
1305 (gnus-summary-skip-intangible)
1306 (or (get-text-property (point) 'gnus-number)
1307 (gnus-summary-last-subject))))
1309 (defmacro gnus-summary-article-header (&optional number)
1310 `(gnus-data-header (gnus-data-find
1311 ,(or number '(gnus-summary-article-number)))))
1313 (defmacro gnus-summary-thread-level (&optional number)
1314 `(if (and (eq gnus-summary-make-false-root 'dummy)
1315 (get-text-property (point) 'gnus-intangible))
1317 (gnus-data-level (gnus-data-find
1318 ,(or number '(gnus-summary-article-number))))))
1320 (defmacro gnus-summary-article-mark (&optional number)
1321 `(gnus-data-mark (gnus-data-find
1322 ,(or number '(gnus-summary-article-number)))))
1324 (defmacro gnus-summary-article-pos (&optional number)
1325 `(gnus-data-pos (gnus-data-find
1326 ,(or number '(gnus-summary-article-number)))))
1328 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
1329 (defmacro gnus-summary-article-subject (&optional number)
1330 "Return current subject string or nil if nothing."
1333 `(gnus-data-header (assq ,number gnus-newsgroup-data))
1334 '(gnus-data-header (assq (gnus-summary-article-number)
1335 gnus-newsgroup-data)))))
1338 (mail-header-subject headers))))
1340 (defmacro gnus-summary-article-score (&optional number)
1341 "Return current article score."
1342 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
1343 gnus-newsgroup-scored))
1344 gnus-summary-default-score 0))
1346 (defun gnus-summary-article-children (&optional number)
1347 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
1348 (level (gnus-data-level (car data)))
1350 (while (and (setq data (cdr data))
1351 (> (setq l (gnus-data-level (car data))) level))
1352 (and (= (1+ level) l)
1353 (setq children (cons (gnus-data-number (car data))
1355 (nreverse children)))
1357 (defun gnus-summary-article-parent (&optional number)
1358 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
1359 (gnus-data-list t)))
1360 (level (gnus-data-level (car data))))
1362 () ; This is a root.
1363 ;; We search until we find an article with a level less than
1364 ;; this one. That function has to be the parent.
1365 (while (and (setq data (cdr data))
1366 (not (< (gnus-data-level (car data)) level))))
1367 (and data (gnus-data-number (car data))))))
1369 (defun gnus-unread-mark-p (mark)
1370 "Say whether MARK is the unread mark."
1371 (= mark gnus-unread-mark))
1373 (defun gnus-read-mark-p (mark)
1374 "Say whether MARK is one of the marks that mark as read.
1375 This is all marks except unread, ticked, dormant, and expirable."
1376 (not (or (= mark gnus-unread-mark)
1377 (= mark gnus-ticked-mark)
1378 (= mark gnus-dormant-mark)
1379 (= mark gnus-expirable-mark))))
1381 (defmacro gnus-article-mark (number)
1383 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
1384 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
1385 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
1386 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
1387 (t (or (cdr (assq ,number gnus-newsgroup-reads))
1388 gnus-ancient-mark))))
1390 ;; Saving hidden threads.
1392 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
1393 (put 'gnus-save-hidden-threads 'lisp-indent-hook 0)
1394 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
1396 (defmacro gnus-save-hidden-threads (&rest forms)
1397 "Save hidden threads, eval FORMS, and restore the hidden threads."
1398 (let ((config (make-symbol "config")))
1399 `(let ((,config (gnus-hidden-threads-configuration)))
1403 (gnus-restore-hidden-threads-configuration ,config)))))
1405 (defun gnus-hidden-threads-configuration ()
1406 "Return the current hidden threads configuration."
1409 (goto-char (point-min))
1410 (while (search-forward "\r" nil t)
1411 (push (1- (point)) config))
1414 (defun gnus-restore-hidden-threads-configuration (config)
1415 "Restore hidden threads configuration from CONFIG."
1416 (let (point buffer-read-only)
1417 (while (setq point (pop config))
1418 (when (and (< point (point-max))
1420 (= (following-char) ?\n))
1421 (subst-char-in-region point (1+ point) ?\n ?\r)))))
1423 ;; Various summary mode internalish functions.
1425 (defun gnus-mouse-pick-article (e)
1428 (gnus-summary-next-page nil t))
1430 (defun gnus-summary-setup-buffer (group)
1431 "Initialize summary buffer."
1432 (let ((buffer (concat "*Summary " group "*")))
1433 (if (get-buffer buffer)
1436 (setq gnus-summary-buffer (current-buffer))
1437 (not gnus-newsgroup-prepared))
1438 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
1439 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
1440 (gnus-add-current-to-buffer-list)
1441 (gnus-summary-mode group)
1443 (gnus-carpal-setup-buffer 'summary))
1444 (unless gnus-single-article-buffer
1445 (make-local-variable 'gnus-article-buffer)
1446 (make-local-variable 'gnus-article-current)
1447 (make-local-variable 'gnus-original-article-buffer))
1448 (setq gnus-newsgroup-name group)
1451 (defun gnus-set-global-variables ()
1452 ;; Set the global equivalents of the summary buffer-local variables
1453 ;; to the latest values they had. These reflect the summary buffer
1454 ;; that was in action when the last article was fetched.
1455 (when (eq major-mode 'gnus-summary-mode)
1456 (setq gnus-summary-buffer (current-buffer))
1457 (let ((name gnus-newsgroup-name)
1458 (marked gnus-newsgroup-marked)
1459 (unread gnus-newsgroup-unreads)
1460 (headers gnus-current-headers)
1461 (data gnus-newsgroup-data)
1462 (summary gnus-summary-buffer)
1463 (article-buffer gnus-article-buffer)
1464 (original gnus-original-article-buffer)
1465 (gac gnus-article-current)
1466 (reffed gnus-reffed-article-number)
1467 (score-file gnus-current-score-file))
1469 (set-buffer gnus-group-buffer)
1470 (setq gnus-newsgroup-name name)
1471 (setq gnus-newsgroup-marked marked)
1472 (setq gnus-newsgroup-unreads unread)
1473 (setq gnus-current-headers headers)
1474 (setq gnus-newsgroup-data data)
1475 (setq gnus-article-current gac)
1476 (setq gnus-summary-buffer summary)
1477 (setq gnus-article-buffer article-buffer)
1478 (setq gnus-original-article-buffer original)
1479 (setq gnus-reffed-article-number reffed)
1480 (setq gnus-current-score-file score-file)))))
1482 (defun gnus-summary-last-article-p (&optional article)
1483 "Return whether ARTICLE is the last article in the buffer."
1484 (if (not (setq article (or article (gnus-summary-article-number))))
1485 t ; All non-existant numbers are the last article. :-)
1486 (not (cdr (gnus-data-find-list article)))))
1488 (defun gnus-make-thread-indent-array ()
1490 (unless (and gnus-thread-indent-array
1491 (= gnus-thread-indent-level gnus-thread-indent-array-level))
1492 (setq gnus-thread-indent-array (make-vector 201 "")
1493 gnus-thread-indent-array-level gnus-thread-indent-level)
1495 (aset gnus-thread-indent-array n
1496 (make-string (* n gnus-thread-indent-level) ? ))
1499 (defun gnus-update-summary-mark-positions ()
1500 "Compute where the summary marks are to go."
1502 (when (and gnus-summary-buffer
1503 (get-buffer gnus-summary-buffer)
1504 (buffer-name (get-buffer gnus-summary-buffer)))
1505 (set-buffer gnus-summary-buffer))
1506 (let ((gnus-replied-mark 129)
1507 (gnus-score-below-mark 130)
1508 (gnus-score-over-mark 130)
1511 (spec gnus-summary-line-format-spec)
1514 (gnus-set-work-buffer)
1515 (let ((gnus-summary-line-format-spec spec))
1516 (gnus-summary-insert-line
1517 [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
1518 (goto-char (point-min))
1519 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
1521 (goto-char (point-min))
1522 (push (cons 'replied (and (search-forward "\201" nil t)
1525 (goto-char (point-min))
1526 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
1528 (setq gnus-summary-mark-positions pos))))
1530 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
1531 "Insert a dummy root in the summary buffer."
1533 (gnus-add-text-properties
1534 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
1535 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
1537 (defun gnus-summary-insert-line
1538 (gnus-tmp-header gnus-tmp-level gnus-tmp-current gnus-tmp-unread
1539 gnus-tmp-replied gnus-tmp-expirable gnus-tmp-subject-or-nil
1540 &optional gnus-tmp-dummy gnus-tmp-score gnus-tmp-process)
1541 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
1542 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
1543 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
1544 (gnus-tmp-score-char
1545 (if (or (null gnus-summary-default-score)
1546 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
1547 gnus-summary-zcore-fuzz)) ?
1548 (if (< gnus-tmp-score gnus-summary-default-score)
1549 gnus-score-below-mark gnus-score-over-mark)))
1550 (gnus-tmp-replied (cond (gnus-tmp-process gnus-process-mark)
1551 ((memq gnus-tmp-current gnus-newsgroup-cached)
1553 (gnus-tmp-replied gnus-replied-mark)
1554 ((memq gnus-tmp-current gnus-newsgroup-saved)
1556 (t gnus-unread-mark)))
1557 (gnus-tmp-from (mail-header-from gnus-tmp-header))
1560 ((string-match "(.+)" gnus-tmp-from)
1561 (substring gnus-tmp-from
1562 (1+ (match-beginning 0)) (1- (match-end 0))))
1563 ((string-match "<[^>]+> *$" gnus-tmp-from)
1564 (let ((beg (match-beginning 0)))
1565 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
1566 (substring gnus-tmp-from (1+ (match-beginning 0))
1567 (1- (match-end 0))))
1568 (substring gnus-tmp-from 0 beg))))
1570 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
1571 (gnus-tmp-number (mail-header-number gnus-tmp-header))
1572 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
1573 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
1574 (buffer-read-only nil))
1575 (when (string= gnus-tmp-name "")
1576 (setq gnus-tmp-name gnus-tmp-from))
1577 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
1578 (gnus-put-text-property
1580 (progn (eval gnus-summary-line-format-spec) (point))
1581 'gnus-number gnus-tmp-number)
1582 (when (gnus-visual-p 'summary-highlight 'highlight)
1584 (run-hooks 'gnus-summary-update-hook)
1587 (defun gnus-summary-update-line (&optional dont-update)
1588 ;; Update summary line after change.
1589 (when (and gnus-summary-default-score
1590 (not gnus-summary-inhibit-highlight))
1591 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
1592 (article (gnus-summary-article-number))
1593 (score (gnus-summary-article-score article)))
1595 (if (and gnus-summary-mark-below
1596 (< (gnus-summary-article-score)
1597 gnus-summary-mark-below))
1598 ;; This article has a low score, so we mark it as read.
1599 (when (memq article gnus-newsgroup-unreads)
1600 (gnus-summary-mark-article-as-read gnus-low-score-mark))
1601 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
1602 ;; This article was previously marked as read on account
1603 ;; of a low score, but now it has risen, so we mark it as
1605 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
1606 (gnus-summary-update-mark
1607 (if (or (null gnus-summary-default-score)
1608 (<= (abs (- score gnus-summary-default-score))
1609 gnus-summary-zcore-fuzz)) ?
1610 (if (< score gnus-summary-default-score)
1611 gnus-score-below-mark gnus-score-over-mark)) 'score))
1612 ;; Do visual highlighting.
1613 (when (gnus-visual-p 'summary-highlight 'highlight)
1614 (run-hooks 'gnus-summary-update-hook)))))
1616 (defvar gnus-tmp-new-adopts nil)
1618 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
1619 ;; Sum up all elements (and sub-elements) in a list.
1621 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
1623 ((and (consp thread) (cdr thread))
1626 'gnus-summary-number-of-articles-in-thread (cdr thread))))
1629 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
1632 (when (and level (zerop level) gnus-tmp-new-adopts)
1635 'gnus-summary-number-of-articles-in-thread
1636 gnus-tmp-new-adopts))))
1638 (if (> number 1) gnus-not-empty-thread-mark
1639 gnus-empty-thread-mark)
1642 (defun gnus-summary-set-local-parameters (group)
1643 "Go through the local params of GROUP and set all variable specs in that list."
1644 (let ((params (gnus-info-params (gnus-get-info group)))
1647 (setq elem (car params)
1648 params (cdr params))
1649 (and (consp elem) ; Has to be a cons.
1650 (consp (cdr elem)) ; The cdr has to be a list.
1651 (symbolp (car elem)) ; Has to be a symbol in there.
1652 (not (memq (car elem)
1653 '(quit-config to-address to-list to-group)))
1654 (progn ; So we set it.
1655 (make-local-variable (car elem))
1656 (set (car elem) (eval (nth 1 elem))))))))
1658 (defun gnus-summary-read-group (group &optional show-all no-article
1659 kill-buffer no-display)
1660 "Start reading news in newsgroup GROUP.
1661 If SHOW-ALL is non-nil, already read articles are also listed.
1662 If NO-ARTICLE is non-nil, no article is selected initially.
1663 If NO-DISPLAY, don't generate a summary buffer."
1664 (gnus-message 5 "Retrieving newsgroup: %s..." group)
1665 (let* ((new-group (gnus-summary-setup-buffer group))
1666 (quit-config (gnus-group-quit-config group))
1667 (did-select (and new-group (gnus-select-newsgroup group show-all))))
1669 ;; This summary buffer exists already, so we just select it.
1671 (gnus-set-global-variables)
1673 (gnus-kill-or-deaden-summary kill-buffer))
1674 (gnus-configure-windows 'summary 'force)
1675 (gnus-set-mode-line 'summary)
1676 (gnus-summary-position-point)
1679 ;; We couldn't select this group.
1681 (when (and (eq major-mode 'gnus-summary-mode)
1682 (not (equal (current-buffer) kill-buffer)))
1683 (kill-buffer (current-buffer))
1684 (if (not quit-config)
1686 (set-buffer gnus-group-buffer)
1687 (gnus-group-jump-to-group group)
1688 (gnus-group-next-unread-group 1))
1689 (if (not (buffer-name (car quit-config)))
1690 (gnus-configure-windows 'group 'force)
1691 (set-buffer (car quit-config))
1692 (and (eq major-mode 'gnus-summary-mode)
1693 (gnus-set-global-variables))
1694 (gnus-configure-windows (cdr quit-config)))))
1695 (gnus-message 3 "Can't select group")
1697 ;; The user did a `C-g' while prompting for number of articles,
1698 ;; so we exit this group.
1699 ((eq did-select 'quit)
1700 (and (eq major-mode 'gnus-summary-mode)
1701 (not (equal (current-buffer) kill-buffer))
1702 (kill-buffer (current-buffer)))
1704 (gnus-kill-or-deaden-summary kill-buffer))
1705 (if (not quit-config)
1707 (set-buffer gnus-group-buffer)
1708 (gnus-group-jump-to-group group)
1709 (gnus-group-next-unread-group 1)
1710 (gnus-configure-windows 'group 'force))
1711 (if (not (buffer-name (car quit-config)))
1712 (gnus-configure-windows 'group 'force)
1713 (set-buffer (car quit-config))
1714 (and (eq major-mode 'gnus-summary-mode)
1715 (gnus-set-global-variables))
1716 (gnus-configure-windows (cdr quit-config))))
1717 ;; Finally signal the quit.
1719 ;; The group was successfully selected.
1721 (gnus-set-global-variables)
1722 ;; Save the active value in effect when the group was entered.
1723 (setq gnus-newsgroup-active
1725 (gnus-active gnus-newsgroup-name)))
1726 ;; You can change the summary buffer in some way with this hook.
1727 (run-hooks 'gnus-select-group-hook)
1728 ;; Set any local variables in the group parameters.
1729 (gnus-summary-set-local-parameters gnus-newsgroup-name)
1730 (gnus-update-format-specifications)
1731 ;; Do score processing.
1732 (when gnus-use-scoring
1733 (gnus-possibly-score-headers))
1734 ;; Check whether to fill in the gaps in the threads.
1735 (when gnus-build-sparse-threads
1736 (gnus-build-sparse-threads))
1737 ;; Find the initial limit.
1738 (if gnus-show-threads
1740 (let ((gnus-newsgroup-dormant nil))
1741 (gnus-summary-initial-limit show-all))
1742 (gnus-summary-initial-limit show-all))
1743 (setq gnus-newsgroup-limit
1745 (lambda (header) (mail-header-number header))
1746 gnus-newsgroup-headers)))
1747 ;; Generate the summary buffer.
1749 (gnus-summary-prepare))
1750 (when gnus-use-trees
1751 (gnus-tree-open group)
1752 (setq gnus-summary-highlight-line-function
1753 'gnus-tree-highlight-article))
1754 ;; If the summary buffer is empty, but there are some low-scored
1755 ;; articles or some excluded dormants, we include these in the
1757 (when (and (zerop (buffer-size))
1759 (cond (gnus-newsgroup-dormant
1760 (gnus-summary-limit-include-dormant))
1761 ((and gnus-newsgroup-scored show-all)
1762 (gnus-summary-limit-include-expunged t))))
1763 ;; Function `gnus-apply-kill-file' must be called in this hook.
1764 (run-hooks 'gnus-apply-kill-hook)
1765 (if (and (zerop (buffer-size))
1768 ;; This newsgroup is empty.
1769 (gnus-summary-catchup-and-exit nil t) ;Without confirmations.
1770 (gnus-message 6 "No unread news")
1772 (gnus-kill-or-deaden-summary kill-buffer))
1773 ;; Return nil from this function.
1775 ;; Hide conversation thread subtrees. We cannot do this in
1776 ;; gnus-summary-prepare-hook since kill processing may not
1777 ;; work with hidden articles.
1778 (and gnus-show-threads
1779 gnus-thread-hide-subtree
1780 (gnus-summary-hide-all-threads))
1781 ;; Show first unread article if requested.
1782 (if (and (not no-article)
1784 gnus-newsgroup-unreads
1785 gnus-auto-select-first)
1786 (unless (if (eq gnus-auto-select-first 'best)
1787 (gnus-summary-best-unread-article)
1788 (gnus-summary-first-unread-article))
1789 (gnus-configure-windows 'summary))
1790 ;; Don't select any articles, just move point to the first
1791 ;; article in the group.
1792 (goto-char (point-min))
1793 (gnus-summary-position-point)
1794 (gnus-set-mode-line 'summary)
1795 (gnus-configure-windows 'summary 'force))
1797 (gnus-kill-or-deaden-summary kill-buffer))
1798 (when (get-buffer-window gnus-group-buffer t)
1799 ;; Gotta use windows, because recenter does wierd stuff if
1800 ;; the current buffer ain't the displayed window.
1801 (let ((owin (selected-window)))
1802 (select-window (get-buffer-window gnus-group-buffer t))
1803 (when (gnus-group-goto-group group)
1805 (select-window owin))))
1806 ;; Mark this buffer as "prepared".
1807 (setq gnus-newsgroup-prepared t)
1810 (defun gnus-summary-prepare ()
1811 "Generate the summary buffer."
1812 (let ((buffer-read-only nil))
1814 (setq gnus-newsgroup-data nil
1815 gnus-newsgroup-data-reverse nil)
1816 (run-hooks 'gnus-summary-generate-hook)
1817 ;; Generate the buffer, either with threads or without.
1818 (when gnus-newsgroup-headers
1819 (gnus-summary-prepare-threads
1820 (if gnus-show-threads
1821 (gnus-sort-gathered-threads
1822 (funcall gnus-summary-thread-gathering-function
1824 (gnus-cut-threads (gnus-make-threads)))))
1825 ;; Unthreaded display.
1826 (gnus-sort-articles gnus-newsgroup-headers))))
1827 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
1828 ;; Call hooks for modifying summary buffer.
1829 (goto-char (point-min))
1830 (run-hooks 'gnus-summary-prepare-hook)))
1832 (defsubst gnus-general-simplify-subject (subject)
1833 "Simply subject by the same rules as gnus-gather-threads-by-subject."
1836 ;; Truncate the subject.
1837 ((numberp gnus-summary-gather-subject-limit)
1838 (setq subject (gnus-simplify-subject-re subject))
1839 (if (> (length subject) gnus-summary-gather-subject-limit)
1840 (substring subject 0 gnus-summary-gather-subject-limit)
1842 ;; Fuzzily simplify it.
1843 ((eq 'fuzzy gnus-summary-gather-subject-limit)
1844 (gnus-simplify-subject-fuzzy subject))
1845 ;; Just remove the leading "Re:".
1847 (gnus-simplify-subject-re subject))))
1849 (if (and gnus-summary-gather-exclude-subject
1850 (string-match gnus-summary-gather-exclude-subject subject))
1851 nil ; This article shouldn't be gathered
1854 (defun gnus-summary-simplify-subject-query ()
1855 "Query where the respool algorithm would put this article."
1857 (gnus-set-global-variables)
1858 (gnus-summary-select-article)
1859 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
1861 (defun gnus-gather-threads-by-subject (threads)
1862 "Gather threads by looking at Subject headers."
1863 (if (not gnus-summary-make-false-root)
1865 (let ((hashtb (gnus-make-hashtable 1023))
1868 subject hthread whole-subject)
1870 (setq subject (gnus-general-simplify-subject
1871 (setq whole-subject (mail-header-subject
1874 (if (setq hthread (gnus-gethash subject hashtb))
1876 ;; We enter a dummy root into the thread, if we
1877 ;; haven't done that already.
1878 (unless (stringp (caar hthread))
1879 (setcar hthread (list whole-subject (car hthread))))
1880 ;; We add this new gathered thread to this gathered
1882 (setcdr (car hthread)
1883 (nconc (cdar hthread) (list (car threads))))
1884 ;; Remove it from the list of threads.
1885 (setcdr prev (cdr threads))
1886 (setq threads prev))
1887 ;; Enter this thread into the hash table.
1888 (gnus-sethash subject threads hashtb)))
1890 (setq threads (cdr threads)))
1893 (defun gnus-gather-threads-by-references (threads)
1894 "Gather threads by looking at References headers."
1895 (let ((idhashtb (gnus-make-hashtable 1023))
1896 (thhashtb (gnus-make-hashtable 1023))
1899 ids references id gthread gid entered)
1901 (when (setq references (mail-header-references (caar threads)))
1902 (setq id (mail-header-id (caar threads)))
1903 (setq ids (gnus-split-references references))
1906 (if (not (setq gid (gnus-gethash (car ids) idhashtb)))
1908 (gnus-sethash (car ids) id idhashtb)
1909 (gnus-sethash id threads thhashtb))
1910 (setq gthread (gnus-gethash gid thhashtb))
1912 ;; We enter a dummy root into the thread, if we
1913 ;; haven't done that already.
1914 (unless (stringp (caar gthread))
1915 (setcar gthread (list (mail-header-subject (caar gthread))
1917 ;; We add this new gathered thread to this gathered
1919 (setcdr (car gthread)
1920 (nconc (cdar gthread) (list (car threads)))))
1921 ;; Add it into the thread hash table.
1922 (gnus-sethash id gthread thhashtb)
1924 ;; Remove it from the list of threads.
1925 (setcdr prev (cdr threads))
1926 (setq threads prev))
1927 (setq ids (cdr ids))))
1929 (setq threads (cdr threads)))
1932 (defun gnus-sort-gathered-threads (threads)
1933 "Sort subtreads inside each gathered thread by article number."
1934 (let ((result threads))
1936 (when (stringp (caar threads))
1937 (setcdr (car threads)
1938 (sort (cdar threads) 'gnus-thread-sort-by-number)))
1939 (setq threads (cdr threads)))
1942 (defun gnus-make-threads ()
1943 "Go through the dependency hashtb and find the roots. Return all threads."
1947 (unless (car (symbol-value refs))
1948 ;; These threads do not refer back to any other articles,
1949 ;; so they're roots.
1950 (setq threads (append (cdr (symbol-value refs)) threads))))
1951 gnus-newsgroup-dependencies)
1954 (defun gnus-build-sparse-threads ()
1955 (let ((headers gnus-newsgroup-headers)
1956 (deps gnus-newsgroup-dependencies)
1957 header references generation relations
1958 cthread subject child end pthread relation)
1959 ;; First we create an alist of generations/relations, where
1960 ;; generations is how much we trust the ralation, and the relation
1962 (gnus-message 7 "Making sparse threads...")
1964 (nnheader-set-temp-buffer " *gnus sparse threads*")
1965 (while (setq header (pop headers))
1966 (when (and (setq references (mail-header-references header))
1967 (not (string= references "")))
1969 (setq child (mail-header-id header)
1970 subject (mail-header-subject header))
1972 (while (search-backward ">" nil t)
1973 (setq end (1+ (point)))
1974 (when (search-backward "<" nil t)
1975 (push (list (incf generation)
1976 child (setq child (buffer-substring (point) end))
1979 (push (list (1+ generation) child nil subject) relations)
1981 (kill-buffer (current-buffer)))
1982 ;; Sort over trustworthiness.
1983 (setq relations (sort relations (lambda (r1 r2) (< (car r1) (car r2)))))
1984 (while (setq relation (pop relations))
1985 (when (if (boundp (setq cthread (intern (cadr relation) deps)))
1986 (unless (car (symbol-value cthread))
1987 ;; Make this article the parent of these threads.
1988 (setcar (symbol-value cthread)
1989 (vector gnus-reffed-article-number
1993 (or (caddr relation) "") 0 0 "")))
1994 (set cthread (list (vector gnus-reffed-article-number
1996 "" "" (cadr relation)
1997 (or (caddr relation) "") 0 0 ""))))
1998 (push gnus-reffed-article-number gnus-newsgroup-limit)
1999 (push gnus-reffed-article-number gnus-newsgroup-sparse)
2000 (push (cons gnus-reffed-article-number gnus-sparse-mark)
2001 gnus-newsgroup-reads)
2002 (decf gnus-reffed-article-number)
2003 ;; Make this new thread the child of its parent.
2004 (if (boundp (setq pthread (intern (or (caddr relation) "none") deps)))
2005 (setcdr (symbol-value pthread)
2006 (nconc (cdr (symbol-value pthread))
2007 (list (symbol-value cthread))))
2008 (set pthread (list nil (symbol-value cthread))))))
2009 (gnus-message 7 "Making sparse threads...done")))
2011 (defun gnus-build-old-threads ()
2012 ;; Look at all the articles that refer back to old articles, and
2013 ;; fetch the headers for the articles that aren't there. This will
2014 ;; build complete threads - if the roots haven't been expired by the
2019 (when (not (car (symbol-value refs)))
2020 (setq heads (cdr (symbol-value refs)))
2022 (if (memq (mail-header-number (caar heads))
2023 gnus-newsgroup-dormant)
2024 (setq heads (cdr heads))
2025 (setq id (symbol-name refs))
2026 (while (and (setq id (gnus-build-get-header id))
2027 (not (car (gnus-gethash
2028 id gnus-newsgroup-dependencies)))))
2029 (setq heads nil)))))
2030 gnus-newsgroup-dependencies)))
2032 (defun gnus-build-get-header (id)
2033 ;; Look through the buffer of NOV lines and find the header to
2034 ;; ID. Enter this line into the dependencies hash table, and return
2035 ;; the id of the parent article (if any).
2036 (let ((deps gnus-newsgroup-dependencies)
2040 (set-buffer nntp-server-buffer)
2041 (goto-char (point-min))
2042 (while (and (not found) (search-forward id nil t))
2044 (setq found (looking-at
2045 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
2046 (regexp-quote id))))
2047 (or found (beginning-of-line 2)))
2051 (setq header (gnus-nov-parse-line
2052 (read (current-buffer)) deps))
2053 (gnus-parent-id (mail-header-references header)))))
2055 (let ((number (mail-header-number header)))
2056 (push number gnus-newsgroup-limit)
2057 (push header gnus-newsgroup-headers)
2058 (if (memq number gnus-newsgroup-unselected)
2060 (push number gnus-newsgroup-unreads)
2061 (setq gnus-newsgroup-unselected
2062 (delq number gnus-newsgroup-unselected)))
2063 (push number gnus-newsgroup-ancient)))))))
2065 (defun gnus-summary-update-article-line (article header)
2066 "Update the line for ARTICLE using HEADERS."
2067 (let* ((id (mail-header-id header))
2068 (thread (gnus-id-to-thread id)))
2070 (error "Article in no thread"))
2071 ;; Update the thread.
2072 (setcar thread header)
2073 (gnus-summary-goto-subject article)
2074 (let* ((datal (gnus-data-find-list article))
2076 (length (when (cdr datal)
2077 (- (gnus-data-pos data)
2078 (gnus-data-pos (cadr datal)))))
2079 (buffer-read-only nil)
2080 (level (gnus-summary-thread-level)))
2082 (gnus-summary-insert-line
2083 header level nil (gnus-article-mark article)
2084 (memq article gnus-newsgroup-replied)
2085 (memq article gnus-newsgroup-expirable)
2086 (mail-header-subject header)
2087 nil (cdr (assq article gnus-newsgroup-scored))
2088 (memq article gnus-newsgroup-processable))
2090 (gnus-data-update-list
2091 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
2093 (defun gnus-summary-update-article (article &optional iheader)
2094 "Update ARTICLE in the summary buffer."
2095 (set-buffer gnus-summary-buffer)
2096 (let* ((header (or iheader (gnus-summary-article-header article)))
2097 (id (mail-header-id header))
2098 (data (gnus-data-find article))
2099 (thread (gnus-id-to-thread id))
2100 (references (mail-header-references header))
2105 (not (equal "" references)))
2108 (buffer-read-only nil)
2110 (number (mail-header-number header))
2113 ;; !!! Should this be in or not?
2115 (setcar thread nil))
2117 (delq thread parent))
2118 (if (gnus-summary-insert-subject id header iheader)
2119 ;; Set the (possibly) new article number in the data structure.
2120 (gnus-data-set-number data (gnus-id-to-article id))
2124 (defun gnus-rebuild-thread (id)
2125 "Rebuild the thread containing ID."
2126 (let ((buffer-read-only nil)
2127 current thread data)
2128 (if (not gnus-show-threads)
2129 (setq thread (list (car (gnus-id-to-thread id))))
2130 ;; Get the thread this article is part of.
2131 (setq thread (gnus-remove-thread id)))
2132 (setq current (save-excursion
2133 (and (zerop (forward-line -1))
2134 (gnus-summary-article-number))))
2135 ;; If this is a gathered thread, we have to go some re-gathering.
2136 (when (stringp (car thread))
2137 (let ((subject (car thread))
2139 (setq thread (cdr thread))
2141 (unless (memq (setq thr (gnus-id-to-thread
2143 (mail-header-id (caar thread)))))
2146 (setq thread (cdr thread)))
2147 ;; We now have all (unique) roots.
2148 (if (= (length roots) 1)
2149 ;; All the loose roots are now one solid root.
2150 (setq thread (car roots))
2151 (setq thread (cons subject (gnus-sort-threads roots))))))
2153 ;; We then insert this thread into the summary buffer.
2154 (let (gnus-newsgroup-data gnus-newsgroup-threads)
2155 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
2156 (setq data (nreverse gnus-newsgroup-data))
2157 (setq threads gnus-newsgroup-threads))
2158 ;; We splice the new data into the data structure.
2159 (gnus-data-enter-list current data)
2160 (gnus-data-compute-positions)
2161 (setq gnus-newsgroup-threads (nconc threads gnus-newsgroup-threads)))))
2163 (defun gnus-number-to-header (number)
2164 "Return the header for article NUMBER."
2165 (let ((headers gnus-newsgroup-headers))
2167 (not (= number (mail-header-number (car headers)))))
2172 (defun gnus-parent-headers (headers &optional generation)
2173 "Return the headers of the GENERATIONeth parent of HEADERS."
2175 (setq generation 1))
2176 (let (references parent)
2177 (while (and headers (not (zerop generation)))
2178 (setq references (mail-header-references headers))
2179 (when (and references
2180 (setq parent (gnus-parent-id references))
2181 (setq headers (car (gnus-id-to-thread parent))))
2185 (defun gnus-id-to-thread (id)
2186 "Return the (sub-)thread where ID appears."
2187 (gnus-gethash id gnus-newsgroup-dependencies))
2189 (defun gnus-id-to-article (id)
2190 "Return the article number of ID."
2191 (let ((thread (gnus-id-to-thread id)))
2194 (mail-header-number (car thread)))))
2196 (defun gnus-id-to-header (id)
2197 "Return the article headers of ID."
2198 (car (gnus-id-to-thread id)))
2200 (defun gnus-article-displayed-root-p (article)
2201 "Say whether ARTICLE is a root(ish) article."
2202 (let ((level (gnus-summary-thread-level article))
2203 (refs (mail-header-references (gnus-summary-article-header article)))
2209 ((null (gnus-parent-id refs)) t)
2211 (null (setq particle (gnus-id-to-article
2212 (gnus-parent-id refs))))
2213 (null (gnus-summary-thread-level particle)))))))
2215 (defun gnus-root-id (id)
2216 "Return the id of the root of the thread where ID appears."
2218 (while (and id (setq prev (car (gnus-gethash
2219 id gnus-newsgroup-dependencies))))
2221 id (gnus-parent-id (mail-header-references prev))))
2224 (defun gnus-remove-thread (id &optional dont-remove)
2225 "Remove the thread that has ID in it."
2226 (let ((dep gnus-newsgroup-dependencies)
2227 headers thread last-id)
2228 ;; First go up in this thread until we find the root.
2229 (setq last-id (gnus-root-id id))
2230 (setq headers (list (car (gnus-id-to-thread last-id))
2231 (caadr (gnus-id-to-thread last-id))))
2232 ;; We have now found the real root of this thread. It might have
2233 ;; been gathered into some loose thread, so we have to search
2234 ;; through the threads to find the thread we wanted.
2235 (let ((threads gnus-newsgroup-threads)
2238 (setq sub (car threads))
2239 (if (stringp (car sub))
2240 ;; This is a gathered thread, so we look at the roots
2241 ;; below it to find whether this article is in this
2244 (setq sub (cdr sub))
2246 (when (member (caar sub) headers)
2247 (setq thread (car threads)
2250 (setq sub (cdr sub))))
2251 ;; It's an ordinary thread, so we check it.
2252 (when (eq (car sub) (car headers))
2255 (setq threads (cdr threads)))
2256 ;; If this article is in no thread, then it's a root.
2259 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
2260 (setq thread (gnus-gethash last-id dep)))
2263 thread ; We return this thread.
2265 (if (stringp (car thread))
2267 ;; If we use dummy roots, then we have to remove the
2268 ;; dummy root as well.
2269 (when (eq gnus-summary-make-false-root 'dummy)
2272 (setq thread (cdr thread))
2274 (gnus-remove-thread-1 (car thread))
2275 (setq thread (cdr thread))))
2276 (gnus-remove-thread-1 thread))))))))
2278 (defun gnus-remove-thread-1 (thread)
2279 "Remove the thread THREAD recursively."
2280 (let ((number (mail-header-number (car thread)))
2282 (when (setq pos (text-property-any
2283 (point-min) (point-max) 'gnus-number number))
2286 (gnus-data-remove number))
2287 (setq thread (cdr thread))
2289 (gnus-remove-thread-1 (pop thread)))))
2291 (defun gnus-sort-threads (threads)
2293 (if (not gnus-thread-sort-functions)
2295 (let ((func (if (= 1 (length gnus-thread-sort-functions))
2296 (car gnus-thread-sort-functions)
2298 ,(gnus-make-sort-function
2299 (reverse gnus-thread-sort-functions))))))
2300 (gnus-message 7 "Sorting threads...")
2303 (gnus-message 7 "Sorting threads...done")))))
2305 (defun gnus-sort-articles (articles)
2307 (when gnus-article-sort-functions
2308 (let ((func (if (= 1 (length gnus-article-sort-functions))
2309 (car gnus-article-sort-functions)
2311 ,(gnus-make-sort-function
2312 (reverse gnus-article-sort-functions))))))
2313 (gnus-message 7 "Sorting articles...")
2315 (setq gnus-newsgroup-headers (sort articles func))
2316 (gnus-message 7 "Sorting articles...done")))))
2318 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
2319 (defmacro gnus-thread-header (thread)
2320 ;; Return header of first article in THREAD.
2321 ;; Note that THREAD must never, ever be anything else than a variable -
2322 ;; using some other form will lead to serious barfage.
2323 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
2324 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
2325 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
2328 (defsubst gnus-article-sort-by-number (h1 h2)
2329 "Sort articles by article number."
2330 (< (mail-header-number h1)
2331 (mail-header-number h2)))
2333 (defun gnus-thread-sort-by-number (h1 h2)
2334 "Sort threads by root article number."
2335 (gnus-article-sort-by-number
2336 (gnus-thread-header h1) (gnus-thread-header h2)))
2338 (defsubst gnus-article-sort-by-author (h1 h2)
2339 "Sort articles by root author."
2341 (let ((extract (funcall
2342 gnus-extract-address-components
2343 (mail-header-from h1))))
2344 (or (car extract) (cdr extract)))
2345 (let ((extract (funcall
2346 gnus-extract-address-components
2347 (mail-header-from h2))))
2348 (or (car extract) (cdr extract)))))
2350 (defun gnus-thread-sort-by-author (h1 h2)
2351 "Sort threads by root author."
2352 (gnus-article-sort-by-author
2353 (gnus-thread-header h1) (gnus-thread-header h2)))
2355 (defsubst gnus-article-sort-by-subject (h1 h2)
2356 "Sort articles by root subject."
2358 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
2359 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
2361 (defun gnus-thread-sort-by-subject (h1 h2)
2362 "Sort threads by root subject."
2363 (gnus-article-sort-by-subject
2364 (gnus-thread-header h1) (gnus-thread-header h2)))
2366 (defsubst gnus-article-sort-by-date (h1 h2)
2367 "Sort articles by root article date."
2369 (inline (gnus-sortable-date (mail-header-date h1)))
2370 (inline (gnus-sortable-date (mail-header-date h2)))))
2372 (defun gnus-thread-sort-by-date (h1 h2)
2373 "Sort threads by root article date."
2374 (gnus-article-sort-by-date
2375 (gnus-thread-header h1) (gnus-thread-header h2)))
2377 (defsubst gnus-article-sort-by-score (h1 h2)
2378 "Sort articles by root article score.
2379 Unscored articles will be counted as having a score of zero."
2380 (> (or (cdr (assq (mail-header-number h1)
2381 gnus-newsgroup-scored))
2382 gnus-summary-default-score 0)
2383 (or (cdr (assq (mail-header-number h2)
2384 gnus-newsgroup-scored))
2385 gnus-summary-default-score 0)))
2387 (defun gnus-thread-sort-by-score (h1 h2)
2388 "Sort threads by root article score."
2389 (gnus-article-sort-by-score
2390 (gnus-thread-header h1) (gnus-thread-header h2)))
2392 (defun gnus-thread-sort-by-total-score (h1 h2)
2393 "Sort threads by the sum of all scores in the thread.
2394 Unscored articles will be counted as having a score of zero."
2395 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
2397 (defun gnus-thread-total-score (thread)
2398 ;; This function find the total score of THREAD.
2399 (cond ((null thread)
2402 (if (stringp (car thread))
2403 (apply gnus-thread-score-function 0
2404 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
2405 (gnus-thread-total-score-1 thread)))
2407 (gnus-thread-total-score-1 (list thread)))))
2409 (defun gnus-thread-total-score-1 (root)
2410 ;; This function find the total score of the thread below ROOT.
2411 (setq root (car root))
2412 (apply gnus-thread-score-function
2414 (mapcar 'gnus-thread-total-score
2415 (cdr (gnus-gethash (mail-header-id root)
2416 gnus-newsgroup-dependencies)))
2417 (if (> (mail-header-number root) 0)
2418 (list (or (cdr (assq (mail-header-number root)
2419 gnus-newsgroup-scored))
2420 gnus-summary-default-score 0))))
2421 (list gnus-summary-default-score)
2424 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
2425 (defvar gnus-tmp-prev-subject nil)
2426 (defvar gnus-tmp-false-parent nil)
2427 (defvar gnus-tmp-root-expunged nil)
2428 (defvar gnus-tmp-dummy-line nil)
2430 (defun gnus-summary-prepare-threads (threads)
2431 "Prepare summary buffer from THREADS and indentation LEVEL.
2432 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
2433 or a straight list of headers."
2434 (gnus-message 7 "Generating summary...")
2436 (setq gnus-newsgroup-threads threads)
2439 (let ((gnus-tmp-level 0)
2440 (default-score (or gnus-summary-default-score 0))
2441 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
2442 thread number subject stack state gnus-tmp-gathered beg-match
2443 new-roots gnus-tmp-new-adopts thread-end
2444 gnus-tmp-header gnus-tmp-unread
2445 gnus-tmp-replied gnus-tmp-subject-or-nil
2446 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
2447 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
2448 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
2450 (setq gnus-tmp-prev-subject nil)
2452 (if (vectorp (car threads))
2453 ;; If this is a straight (sic) list of headers, then a
2454 ;; threaded summary display isn't required, so we just create
2455 ;; an unthreaded one.
2456 (gnus-summary-prepare-unthreaded threads)
2458 ;; Do the threaded display.
2460 (while (or threads stack gnus-tmp-new-adopts new-roots)
2462 (if (and (= gnus-tmp-level 0)
2463 (not (setq gnus-tmp-dummy-line nil))
2466 (not gnus-tmp-false-parent)
2467 (or gnus-tmp-new-adopts new-roots))
2468 (if gnus-tmp-new-adopts
2469 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
2470 thread (list (car gnus-tmp-new-adopts))
2471 gnus-tmp-header (caar thread)
2472 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
2474 (setq thread (list (car new-roots))
2475 gnus-tmp-header (caar thread)
2476 new-roots (cdr new-roots))))
2479 ;; If there are some threads, we do them before the
2480 ;; threads on the stack.
2481 (setq thread threads
2482 gnus-tmp-header (caar thread))
2483 ;; There were no current threads, so we pop something off
2485 (setq state (car stack)
2486 gnus-tmp-level (car state)
2489 gnus-tmp-header (caar thread))))
2491 (setq gnus-tmp-false-parent nil)
2492 (setq gnus-tmp-root-expunged nil)
2493 (setq thread-end nil)
2495 (if (stringp gnus-tmp-header)
2496 ;; The header is a dummy root.
2498 ((eq gnus-summary-make-false-root 'adopt)
2499 ;; We let the first article adopt the rest.
2500 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
2502 (setq gnus-tmp-gathered
2504 (lambda (h) (mail-header-number (car h)))
2507 (setq thread (cons (list (caar thread)
2510 (setq gnus-tmp-level -1
2511 gnus-tmp-false-parent t))
2512 ((eq gnus-summary-make-false-root 'empty)
2513 ;; We print adopted articles with empty subject fields.
2514 (setq gnus-tmp-gathered
2516 (lambda (h) (mail-header-number (car h)))
2519 (setq gnus-tmp-level -1))
2520 ((eq gnus-summary-make-false-root 'dummy)
2521 ;; We remember that we probably want to output a dummy
2523 (setq gnus-tmp-dummy-line gnus-tmp-header)
2524 (setq gnus-tmp-prev-subject gnus-tmp-header))
2526 ;; We do not make a root for the gathered
2527 ;; sub-threads at all.
2528 (setq gnus-tmp-level -1)))
2530 (setq number (mail-header-number gnus-tmp-header)
2531 subject (mail-header-subject gnus-tmp-header))
2534 ;; If the thread has changed subject, we might want to make
2535 ;; this subthread into a root.
2536 ((and (null gnus-thread-ignore-subject)
2537 (not (zerop gnus-tmp-level))
2538 gnus-tmp-prev-subject
2540 (gnus-subject-equal gnus-tmp-prev-subject subject))))
2541 (setq new-roots (nconc new-roots (list (car thread)))
2543 gnus-tmp-header nil))
2544 ;; If the article lies outside the current limit,
2545 ;; then we do not display it.
2546 ((and (not (memq number gnus-newsgroup-limit))
2547 (not gnus-tmp-dummy-line))
2548 (setq gnus-tmp-gathered
2550 (lambda (h) (mail-header-number (car h)))
2553 (setq gnus-tmp-new-adopts (if (cdar thread)
2554 (append gnus-tmp-new-adopts
2556 gnus-tmp-new-adopts)
2558 gnus-tmp-header nil)
2559 (when (zerop gnus-tmp-level)
2560 (setq gnus-tmp-root-expunged t)))
2561 ;; Perhaps this article is to be marked as read?
2562 ((and gnus-summary-mark-below
2563 (< (or (cdr (assq number gnus-newsgroup-scored))
2565 gnus-summary-mark-below)
2566 ;; Don't touch sparse articles.
2567 (not (memq number gnus-newsgroup-sparse))
2568 (not (memq number gnus-newsgroup-ancient)))
2569 (setq gnus-newsgroup-unreads
2570 (delq number gnus-newsgroup-unreads))
2571 (if gnus-newsgroup-auto-expire
2572 (push number gnus-newsgroup-expirable)
2573 (push (cons number gnus-low-score-mark)
2574 gnus-newsgroup-reads))))
2576 (when gnus-tmp-header
2577 ;; We may have an old dummy line to output before this
2579 (when gnus-tmp-dummy-line
2580 (gnus-summary-insert-dummy-line
2581 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
2582 (setq gnus-tmp-dummy-line nil))
2584 ;; Compute the mark.
2585 (setq gnus-tmp-unread (gnus-article-mark number))
2587 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
2588 gnus-tmp-header gnus-tmp-level)
2589 gnus-newsgroup-data)
2591 ;; Actually insert the line.
2593 gnus-tmp-subject-or-nil
2595 ((and gnus-thread-ignore-subject
2596 gnus-tmp-prev-subject
2597 (not (inline (gnus-subject-equal
2598 gnus-tmp-prev-subject subject))))
2600 ((zerop gnus-tmp-level)
2601 (if (and (eq gnus-summary-make-false-root 'empty)
2602 (memq number gnus-tmp-gathered)
2603 gnus-tmp-prev-subject
2604 (inline (gnus-subject-equal
2605 gnus-tmp-prev-subject subject)))
2606 gnus-summary-same-subject
2608 (t gnus-summary-same-subject)))
2609 (if (and (eq gnus-summary-make-false-root 'adopt)
2610 (= gnus-tmp-level 1)
2611 (memq number gnus-tmp-gathered))
2612 (setq gnus-tmp-opening-bracket ?\<
2613 gnus-tmp-closing-bracket ?\>)
2614 (setq gnus-tmp-opening-bracket ?\[
2615 gnus-tmp-closing-bracket ?\]))
2617 gnus-tmp-indentation
2618 (aref gnus-thread-indent-array gnus-tmp-level)
2619 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
2620 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
2621 gnus-summary-default-score 0)
2623 (if (or (null gnus-summary-default-score)
2624 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2625 gnus-summary-zcore-fuzz)) ?
2626 (if (< gnus-tmp-score gnus-summary-default-score)
2627 gnus-score-below-mark gnus-score-over-mark))
2629 (cond ((memq number gnus-newsgroup-processable)
2631 ((memq number gnus-newsgroup-cached)
2633 ((memq number gnus-newsgroup-replied)
2635 ((memq number gnus-newsgroup-saved)
2637 (t gnus-unread-mark))
2638 gnus-tmp-from (mail-header-from gnus-tmp-header)
2641 ((string-match "(.+)" gnus-tmp-from)
2642 (substring gnus-tmp-from
2643 (1+ (match-beginning 0)) (1- (match-end 0))))
2644 ((string-match "<[^>]+> *$" gnus-tmp-from)
2645 (setq beg-match (match-beginning 0))
2646 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
2647 (substring gnus-tmp-from (1+ (match-beginning 0))
2648 (1- (match-end 0))))
2649 (substring gnus-tmp-from 0 beg-match)))
2651 (when (string= gnus-tmp-name "")
2652 (setq gnus-tmp-name gnus-tmp-from))
2653 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
2654 (gnus-put-text-property
2656 (progn (eval gnus-summary-line-format-spec) (point))
2657 'gnus-number number)
2660 (run-hooks 'gnus-summary-update-hook)
2663 (setq gnus-tmp-prev-subject subject)))
2665 (when (nth 1 thread)
2666 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
2667 (incf gnus-tmp-level)
2668 (setq threads (if thread-end nil (cdar thread)))
2670 (setq gnus-tmp-level 0)))))
2671 (gnus-message 7 "Generating summary...done"))
2673 (defun gnus-summary-prepare-unthreaded (headers)
2674 "Generate an unthreaded summary buffer based on HEADERS."
2675 (let (header number mark)
2678 ;; We may have to root out some bad articles...
2679 (when (memq (setq number (mail-header-number
2680 (setq header (pop headers))))
2681 gnus-newsgroup-limit)
2682 ;; Mark article as read when it has a low score.
2683 (when (and gnus-summary-mark-below
2684 (< (or (cdr (assq number gnus-newsgroup-scored))
2685 gnus-summary-default-score 0)
2686 gnus-summary-mark-below)
2687 (not (memq number gnus-newsgroup-ancient)))
2688 (setq gnus-newsgroup-unreads
2689 (delq number gnus-newsgroup-unreads))
2690 (if gnus-newsgroup-auto-expire
2691 (push number gnus-newsgroup-expirable)
2692 (push (cons number gnus-low-score-mark)
2693 gnus-newsgroup-reads)))
2695 (setq mark (gnus-article-mark number))
2696 (setq gnus-newsgroup-data
2697 (cons (gnus-data-make number mark (1+ (point)) header 0)
2698 gnus-newsgroup-data))
2699 (gnus-summary-insert-line
2700 header 0 nil mark (memq number gnus-newsgroup-replied)
2701 (memq number gnus-newsgroup-expirable)
2702 (mail-header-subject header) nil
2703 (cdr (assq number gnus-newsgroup-scored))
2704 (memq number gnus-newsgroup-processable))))))
2706 (defun gnus-select-newsgroup (group &optional read-all)
2707 "Select newsgroup GROUP.
2708 If READ-ALL is non-nil, all articles in the group are selected."
2709 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
2710 (info (nth 2 entry))
2711 articles fetched-articles cached)
2713 (or (gnus-check-server
2714 (setq gnus-current-select-method (gnus-find-method-for-group group)))
2715 (error "Couldn't open server"))
2717 (or (and entry (not (eq (car entry) t))) ; Either it's active...
2718 (gnus-activate-group group) ; Or we can activate it...
2719 (progn ; Or we bug out.
2720 (when (equal major-mode 'gnus-summary-mode)
2721 (kill-buffer (current-buffer)))
2722 (error "Couldn't request group %s: %s"
2723 group (gnus-status-message group))))
2725 (unless (gnus-request-group group t)
2726 (when (equal major-mode 'gnus-summary-mode)
2727 (kill-buffer (current-buffer)))
2728 (error "Couldn't request group %s: %s"
2729 group (gnus-status-message group)))
2731 (setq gnus-newsgroup-name group)
2732 (setq gnus-newsgroup-unselected nil)
2733 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
2735 ;; Adjust and set lists of article marks.
2737 (gnus-adjust-marked-articles info))
2739 ;; Kludge to avoid having cached articles nixed out in virtual groups.
2740 (when (gnus-virtual-group-p group)
2741 (setq cached gnus-newsgroup-cached))
2743 (setq gnus-newsgroup-unreads
2744 (gnus-set-difference
2745 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
2746 gnus-newsgroup-dormant))
2748 (setq gnus-newsgroup-processable nil)
2750 (setq articles (gnus-articles-to-read group read-all))
2754 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
2756 ((eq articles 0) nil)
2758 ;; Init the dependencies hash table.
2759 (setq gnus-newsgroup-dependencies
2760 (gnus-make-hashtable (length articles)))
2761 ;; Retrieve the headers and read them in.
2762 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
2763 (setq gnus-newsgroup-headers
2765 (setq gnus-headers-retrieved-by
2766 (gnus-retrieve-headers
2767 articles gnus-newsgroup-name
2768 ;; We might want to fetch old headers, but
2769 ;; not if there is only 1 article.
2770 (and gnus-fetch-old-headers
2772 (not (eq gnus-fetch-old-headers 'some))
2773 (not (numberp gnus-fetch-old-headers)))
2774 (> (length articles) 1))))))
2775 (gnus-get-newsgroup-headers-xover articles)
2776 (gnus-get-newsgroup-headers)))
2777 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
2779 ;; Kludge to avoid having cached articles nixed out in virtual groups.
2781 (setq gnus-newsgroup-cached cached))
2783 ;; Suppress duplicates?
2784 (when gnus-suppress-duplicates
2785 (gnus-dup-suppress-articles))
2787 ;; Set the initial limit.
2788 (setq gnus-newsgroup-limit (copy-sequence articles))
2789 ;; Remove canceled articles from the list of unread articles.
2790 (setq gnus-newsgroup-unreads
2791 (gnus-set-sorted-intersection
2792 gnus-newsgroup-unreads
2793 (setq fetched-articles
2794 (mapcar (lambda (headers) (mail-header-number headers))
2795 gnus-newsgroup-headers))))
2796 ;; Removed marked articles that do not exist.
2797 (gnus-update-missing-marks
2798 (gnus-sorted-complement fetched-articles articles))
2799 ;; We might want to build some more threads first.
2800 (and gnus-fetch-old-headers
2801 (eq gnus-headers-retrieved-by 'nov)
2802 (gnus-build-old-threads))
2803 ;; Check whether auto-expire is to be done in this group.
2804 (setq gnus-newsgroup-auto-expire
2805 (gnus-group-auto-expirable-p group))
2806 ;; Set up the article buffer now, if necessary.
2807 (unless gnus-single-article-buffer
2808 (gnus-article-setup-buffer))
2809 ;; First and last article in this newsgroup.
2810 (when gnus-newsgroup-headers
2811 (setq gnus-newsgroup-begin
2812 (mail-header-number (car gnus-newsgroup-headers))
2815 (gnus-last-element gnus-newsgroup-headers))))
2816 ;; GROUP is successfully selected.
2817 (or gnus-newsgroup-headers t)))))
2819 (defun gnus-articles-to-read (group read-all)
2820 ;; Find out what articles the user wants to read.
2822 ;; Select all articles if `read-all' is non-nil, or if there
2823 ;; are no unread articles.
2825 (and (zerop (length gnus-newsgroup-marked))
2826 (zerop (length gnus-newsgroup-unreads))))
2827 (gnus-uncompress-range (gnus-active group))
2828 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
2829 (copy-sequence gnus-newsgroup-unreads))
2831 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
2832 (scored (length scored-list))
2833 (number (length articles))
2834 (marked (+ (length gnus-newsgroup-marked)
2835 (length gnus-newsgroup-dormant)))
2843 ((and (or (<= scored marked) (= scored number))
2844 (numberp gnus-large-newsgroup)
2845 (> number gnus-large-newsgroup))
2849 "How many articles from %s (default %d): "
2850 gnus-newsgroup-name number))))
2851 (if (string-match "^[ \t]*$" input) number input)))
2852 ((and (> scored marked) (< scored number)
2853 (> (- scored number) 20))
2856 (format "%s %s (%d scored, %d total): "
2857 "How many articles from"
2858 group scored number))))
2859 (if (string-match "^[ \t]*$" input)
2863 (setq select (if (stringp select) (string-to-number select) select))
2864 (if (or (null select) (zerop select))
2866 (if (and (not (zerop scored)) (<= (abs select) scored))
2868 (setq articles (sort scored-list '<))
2869 (setq number (length articles)))
2870 (setq articles (copy-sequence articles)))
2872 (if (< (abs select) number)
2874 ;; Select the N oldest articles.
2875 (setcdr (nthcdr (1- (abs select)) articles) nil)
2876 ;; Select the N most recent articles.
2877 (setq articles (nthcdr (- number select) articles))))
2878 (setq gnus-newsgroup-unselected
2879 (gnus-sorted-intersection
2880 gnus-newsgroup-unreads
2881 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
2884 (defun gnus-killed-articles (killed articles)
2887 (if (inline (gnus-member-of-range (car articles) killed))
2888 (setq out (cons (car articles) out)))
2889 (setq articles (cdr articles)))
2892 (defun gnus-uncompress-marks (marks)
2893 "Uncompress the mark ranges in MARKS."
2894 (let ((uncompressed '(score bookmark))
2897 (if (memq (caar marks) uncompressed)
2898 (push (car marks) out)
2899 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
2900 (setq marks (cdr marks)))
2903 (defun gnus-adjust-marked-articles (info)
2904 "Set all article lists and remove all marks that are no longer legal."
2905 (let* ((marked-lists (gnus-info-marks info))
2906 (active (gnus-active (gnus-info-group info)))
2909 (types gnus-article-mark-lists)
2910 (uncompressed '(score bookmark killed))
2911 marks var articles article mark)
2914 (setq marks (pop marked-lists))
2915 (set (setq var (intern (format "gnus-newsgroup-%s"
2916 (car (rassq (setq mark (car marks))
2918 (if (memq (car marks) uncompressed) (cdr marks)
2919 (gnus-uncompress-range (cdr marks))))
2921 (setq articles (symbol-value var))
2923 ;; All articles have to be subsets of the active articles.
2925 ;; Adjust "simple" lists.
2926 ((memq mark '(tick dormant expirable reply save))
2928 (when (or (< (setq article (pop articles)) min) (> article max))
2929 (set var (delq article (symbol-value var))))))
2931 ((memq mark uncompressed)
2933 (when (or (not (consp (setq article (pop articles))))
2934 (< (car article) min)
2935 (> (car article) max))
2936 (set var (delq article (symbol-value var))))))))))
2938 (defun gnus-update-missing-marks (missing)
2939 "Go through the list of MISSING articles and remove them mark lists."
2941 (let ((types gnus-article-mark-lists)
2943 ;; Go through all types.
2945 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
2946 (when (symbol-value var)
2947 ;; This list has articles. So we delete all missing articles
2951 (set var (delq (pop m) (symbol-value var)))))))))
2953 (defun gnus-update-marks ()
2954 "Enter the various lists of marked articles into the newsgroup info list."
2955 (let ((types gnus-article-mark-lists)
2956 (info (gnus-get-info gnus-newsgroup-name))
2957 (uncompressed '(score bookmark killed))
2958 type list newmarked symbol)
2960 ;; Add all marks lists that are non-nil to the list of marks lists.
2962 (setq type (pop types))
2963 (when (setq list (symbol-value
2965 (intern (format "gnus-newsgroup-%s"
2967 (push (cons (cdr type)
2968 (if (memq (cdr type) uncompressed) list
2969 (gnus-compress-sequence
2970 (set symbol (sort list '<)) t)))
2973 ;; Enter these new marks into the info of the group.
2975 (setcar (nthcdr 3 info) newmarked)
2976 ;; Add the marks lists to the end of the info.
2978 (setcdr (nthcdr 2 info) (list newmarked))))
2980 ;; Cut off the end of the info if there's nothing else there.
2984 (when (nthcdr (decf i) info)
2985 (setcdr (nthcdr i info) nil)))))))
2987 (defun gnus-set-mode-line (where)
2988 "This function sets the mode line of the article or summary buffers.
2989 If WHERE is `summary', the summary mode line format will be used."
2990 ;; Is this mode line one we keep updated?
2991 (when (memq where gnus-updated-mode-lines)
2994 ;; We evaluate this in the summary buffer since these
2995 ;; variables are buffer-local to that buffer.
2996 (set-buffer gnus-summary-buffer)
2997 ;; We bind all these variables that are used in the `eval' form
2999 (let* ((mformat (symbol-value
3001 (format "gnus-%s-mode-line-format-spec" where))))
3002 (gnus-tmp-group-name gnus-newsgroup-name)
3003 (gnus-tmp-article-number (or gnus-current-article 0))
3004 (gnus-tmp-unread gnus-newsgroup-unreads)
3005 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
3006 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
3007 (gnus-tmp-unread-and-unselected
3008 (cond ((and (zerop gnus-tmp-unread-and-unticked)
3009 (zerop gnus-tmp-unselected)) "")
3010 ((zerop gnus-tmp-unselected)
3011 (format "{%d more}" gnus-tmp-unread-and-unticked))
3012 (t (format "{%d(+%d) more}"
3013 gnus-tmp-unread-and-unticked
3014 gnus-tmp-unselected))))
3016 (if (and gnus-current-headers
3017 (vectorp gnus-current-headers))
3018 (gnus-mode-string-quote
3019 (mail-header-subject gnus-current-headers)) ""))
3021 gnus-tmp-header);; passed as argument to any user-format-funcs
3022 (setq mode-string (eval mformat))
3023 (setq max-len (max 4 (if gnus-mode-non-string-length
3025 gnus-mode-non-string-length)
3026 (length mode-string))))
3027 ;; We might have to chop a bit of the string off...
3028 (when (> (length mode-string) max-len)
3030 (concat (gnus-truncate-string mode-string (- max-len 3))
3032 ;; Pad the mode string a bit.
3033 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
3034 ;; Update the mode line.
3035 (setq mode-line-buffer-identification
3036 (gnus-mode-line-buffer-identification
3037 (list mode-string)))
3038 (set-buffer-modified-p t))))
3040 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
3041 "Go through the HEADERS list and add all Xrefs to a hash table.
3042 The resulting hash table is returned, or nil if no Xrefs were found."
3043 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
3044 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
3045 (xref-hashtb (make-vector 63 0))
3046 start group entry number xrefs header)
3048 (setq header (pop headers))
3049 (when (and (setq xrefs (mail-header-xref header))
3050 (not (memq (setq number (mail-header-number header))
3053 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
3054 (setq start (match-end 0))
3055 (setq group (if prefix
3056 (concat prefix (substring xrefs (match-beginning 1)
3058 (substring xrefs (match-beginning 1) (match-end 1))))
3060 (string-to-int (substring xrefs (match-beginning 2)
3062 (if (setq entry (gnus-gethash group xref-hashtb))
3063 (setcdr entry (cons number (cdr entry)))
3064 (gnus-sethash group (cons number nil) xref-hashtb)))))
3065 (and start xref-hashtb)))
3067 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
3068 "Look through all the headers and mark the Xrefs as read."
3069 (let ((virtual (gnus-virtual-group-p from-newsgroup))
3070 name entry info xref-hashtb idlist method nth4)
3072 (set-buffer gnus-group-buffer)
3073 (when (setq xref-hashtb
3074 (gnus-create-xref-hashtb from-newsgroup headers unreads))
3077 (unless (string= from-newsgroup (setq name (symbol-name group)))
3078 (setq idlist (symbol-value group))
3079 ;; Dead groups are not updated.
3081 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
3083 (if (stringp (setq nth4 (gnus-info-method info)))
3084 (setq nth4 (gnus-server-to-method nth4))))
3085 ;; Only do the xrefs if the group has the same
3086 ;; select method as the group we have just read.
3087 (or (gnus-methods-equal-p
3088 nth4 (gnus-find-method-for-group from-newsgroup))
3090 (equal nth4 (setq method (gnus-find-method-for-group
3092 (and (equal (car nth4) (car method))
3093 (equal (nth 1 nth4) (nth 1 method))))
3094 gnus-use-cross-reference
3095 (or (not (eq gnus-use-cross-reference t))
3097 ;; Only do cross-references on subscribed
3098 ;; groups, if that is what is wanted.
3099 (<= (gnus-info-level info) gnus-level-subscribed))
3100 (gnus-group-make-articles-read name idlist))))
3103 (defun gnus-group-make-articles-read (group articles)
3105 (entry (gnus-gethash group gnus-newsrc-hashtb))
3106 (info (nth 2 entry))
3107 (active (gnus-active group))
3109 ;; First peel off all illegal article numbers.
3111 (let ((ids articles)
3113 (while (setq id (pop ids))
3114 (when (and first (> id (cdr active)))
3115 ;; We'll end up in this situation in one particular
3116 ;; obscure situation. If you re-scan a group and get
3117 ;; a new article that is cross-posted to a different
3118 ;; group that has not been re-scanned, you might get
3119 ;; crossposted article that has a higher number than
3120 ;; Gnus believes possible. So we re-activate this
3121 ;; group as well. This might mean doing the
3122 ;; crossposting thingy will *increase* the number
3123 ;; of articles in some groups. Tsk, tsk.
3124 (setq active (or (gnus-activate-group group) active)))
3125 (when (or (> id (cdr active))
3126 (< id (car active)))
3127 (setq articles (delq id articles))))))
3128 ;; If the read list is nil, we init it.
3130 (null (gnus-info-read info))
3132 (gnus-info-set-read info (cons 1 (1- (car active)))))
3133 ;; Then we add the read articles to the range.
3138 (gnus-info-read info) (setq articles (sort articles '<)))))
3139 ;; Then we have to re-compute how many unread
3140 ;; articles there are in this group.
3145 (setq num (- (1+ (cdr active)) (car active))))
3146 ((not (listp (cdr range)))
3147 (setq num (- (cdr active) (- (1+ (cdr range))
3151 (if (numberp (car range))
3153 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
3154 (setq range (cdr range)))
3155 (setq num (- (cdr active) num))))
3156 ;; Update the number of unread articles.
3158 ;; Update the group buffer.
3159 (gnus-group-update-group group t)))))
3161 (defun gnus-methods-equal-p (m1 m2)
3162 (let ((m1 (or m1 gnus-select-method))
3163 (m2 (or m2 gnus-select-method)))
3165 (and (eq (car m1) (car m2))
3166 (or (not (memq 'address (assoc (symbol-name (car m1))
3167 gnus-valid-select-methods)))
3168 (equal (nth 1 m1) (nth 1 m2)))))))
3170 (defsubst gnus-header-value ()
3171 (buffer-substring (match-end 0) (gnus-point-at-eol)))
3173 (defvar gnus-newsgroup-none-id 0)
3175 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
3176 (let ((cur nntp-server-buffer)
3179 (save-excursion (set-buffer gnus-summary-buffer)
3180 gnus-newsgroup-dependencies)))
3181 headers id id-dep ref-dep end ref)
3183 (set-buffer nntp-server-buffer)
3184 (run-hooks 'gnus-parse-headers-hook)
3185 (let ((case-fold-search t)
3186 in-reply-to header p lines)
3187 (goto-char (point-min))
3188 ;; Search to the beginning of the next header. Error messages
3189 ;; do not begin with 2 or 3.
3190 (while (re-search-forward "^[23][0-9]+ " nil t)
3193 ;; This implementation of this function, with nine
3194 ;; search-forwards instead of the one re-search-forward and
3195 ;; a case (which basically was the old function) is actually
3196 ;; about twice as fast, even though it looks messier. You
3197 ;; can't have everything, I guess. Speed and elegance
3198 ;; doesn't always go hand in hand.
3207 (narrow-to-region (point)
3208 (or (and (search-forward "\n.\n" nil t)
3214 (if (search-forward "\nsubject: " nil t)
3215 (gnus-header-value) "(none)"))
3219 (if (search-forward "\nfrom: " nil t)
3220 (gnus-header-value) "(nobody)"))
3224 (if (search-forward "\ndate: " nil t)
3225 (gnus-header-value) ""))
3229 (if (search-forward "\nmessage-id: " nil t)
3230 (setq id (gnus-header-value))
3231 ;; If there was no message-id, we just fake one to make
3232 ;; subsequent routines simpler.
3233 (setq id (concat "none+"
3235 (setq gnus-newsgroup-none-id
3236 (1+ gnus-newsgroup-none-id)))))))
3240 (if (search-forward "\nreferences: " nil t)
3249 (search-backward ">" end t)
3252 (search-backward "<" end t)
3254 ;; Get the references from the in-reply-to header if there
3255 ;; were no references and the in-reply-to header looks
3257 (if (and (search-forward "\nin-reply-to: " nil t)
3258 (setq in-reply-to (gnus-header-value))
3259 (string-match "<[^>]+>" in-reply-to))
3260 (setq ref (substring in-reply-to (match-beginning 0)
3268 (if (search-forward "\nlines: " nil t)
3269 (if (numberp (setq lines (read cur)))
3275 (and (search-forward "\nxref: " nil t)
3276 (gnus-header-value)))))
3277 ;; We do the threading while we read the headers. The
3278 ;; message-id and the last reference are both entered into
3279 ;; the same hash table. Some tippy-toeing around has to be
3280 ;; done in case an article has arrived before the article
3281 ;; which it refers to.
3282 (if (boundp (setq id-dep (intern id dependencies)))
3283 (if (and (car (symbol-value id-dep))
3285 ;; An article with this Message-ID has already
3286 ;; been seen, so we ignore this one, except we add
3287 ;; any additional Xrefs (in case the two articles
3288 ;; came from different servers).
3290 (mail-header-set-xref
3291 (car (symbol-value id-dep))
3292 (concat (or (mail-header-xref
3293 (car (symbol-value id-dep))) "")
3294 (or (mail-header-xref header) "")))
3296 (setcar (symbol-value id-dep) header))
3297 (set id-dep (list header)))
3299 (if (boundp (setq ref-dep (intern ref dependencies)))
3300 (setcdr (symbol-value ref-dep)
3301 (nconc (cdr (symbol-value ref-dep))
3302 (list (symbol-value id-dep))))
3303 (set ref-dep (list nil (symbol-value id-dep))))
3304 (setq headers (cons header headers)))
3305 (goto-char (point-max))
3307 (nreverse headers)))))
3309 ;; The following macros and functions were written by Felix Lee
3310 ;; <flee@cse.psu.edu>.
3312 (defmacro gnus-nov-read-integer ()
3314 (if (= (following-char) ?\t)
3316 (let ((num (condition-case nil (read buffer) (error nil))))
3317 (if (numberp num) num 0)))
3318 (or (eobp) (forward-char 1))))
3320 (defmacro gnus-nov-skip-field ()
3321 '(search-forward "\t" eol 'move))
3323 (defmacro gnus-nov-field ()
3324 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
3326 ;; Goes through the xover lines and returns a list of vectors
3327 (defun gnus-get-newsgroup-headers-xover (sequence &optional
3328 force-new dependencies)
3329 "Parse the news overview data in the server buffer, and return a
3330 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
3331 ;; Get the Xref when the users reads the articles since most/some
3332 ;; NNTP servers do not include Xrefs when using XOVER.
3333 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
3334 (let ((cur nntp-server-buffer)
3335 (dependencies (or dependencies gnus-newsgroup-dependencies))
3336 number headers header)
3338 (set-buffer nntp-server-buffer)
3339 ;; Allow the user to mangle the headers before parsing them.
3340 (run-hooks 'gnus-parse-headers-hook)
3341 (goto-char (point-min))
3342 (while (and sequence (not (eobp)))
3343 (setq number (read cur))
3344 (while (and sequence (< (car sequence) number))
3345 (setq sequence (cdr sequence)))
3347 (eq number (car sequence))
3349 (setq sequence (cdr sequence))
3351 (inline (gnus-nov-parse-line
3352 number dependencies force-new)))
3353 (setq headers (cons header headers)))))
3355 (setq headers (nreverse headers)))
3358 ;; This function has to be called with point after the article number
3359 ;; on the beginning of the line.
3360 (defun gnus-nov-parse-line (number dependencies &optional force-new)
3362 (eol (gnus-point-at-eol))
3363 (buffer (current-buffer))
3364 header ref id id-dep ref-dep)
3366 ;; overview: [num subject from date id refs chars lines misc]
3367 (narrow-to-region (point) eol)
3368 (or (eobp) (forward-char))
3374 (gnus-nov-field) ; subject
3375 (gnus-nov-field) ; from
3376 (gnus-nov-field) ; date
3377 (setq id (or (gnus-nov-field)
3380 (setq none (1+ none)))))) ; id
3383 (let ((beg (point)))
3384 (search-forward "\t" eol)
3385 (if (search-backward ">" beg t)
3389 (search-backward "<" beg t)))
3391 (gnus-nov-field)) ; refs
3392 (gnus-nov-read-integer) ; chars
3393 (gnus-nov-read-integer) ; lines
3394 (if (= (following-char) ?\n)
3396 (gnus-nov-field)) ; misc
3399 (gnus-error 4 "Strange nov line")
3405 ;; We build the thread tree.
3407 (if (boundp (setq id-dep (intern id dependencies)))
3408 (if (and (car (symbol-value id-dep))
3410 ;; An article with this Message-ID has already been seen,
3411 ;; so we ignore this one, except we add any additional
3412 ;; Xrefs (in case the two articles came from different
3415 (mail-header-set-xref
3416 (car (symbol-value id-dep))
3417 (concat (or (mail-header-xref
3418 (car (symbol-value id-dep))) "")
3419 (or (mail-header-xref header) "")))
3421 (setcar (symbol-value id-dep) header))
3422 (set id-dep (list header))))
3424 (if (boundp (setq ref-dep (intern (or ref "none") dependencies)))
3425 (setcdr (symbol-value ref-dep)
3426 (nconc (cdr (symbol-value ref-dep))
3427 (list (symbol-value id-dep))))
3428 (set ref-dep (list nil (symbol-value id-dep)))))
3431 (defun gnus-article-get-xrefs ()
3432 "Fill in the Xref value in `gnus-current-headers', if necessary.
3433 This is meant to be called in `gnus-article-internal-prepare-hook'."
3434 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
3435 gnus-current-headers)))
3436 (or (not gnus-use-cross-reference)
3438 (and (mail-header-xref headers)
3439 (not (string= (mail-header-xref headers) "")))
3440 (let ((case-fold-search t)
3443 (nnheader-narrow-to-headers)
3444 (goto-char (point-min))
3445 (if (or (and (eq (downcase (following-char)) ?x)
3446 (looking-at "Xref:"))
3447 (search-forward "\nXref:" nil t))
3449 (goto-char (1+ (match-end 0)))
3450 (setq xref (buffer-substring (point)
3451 (progn (end-of-line) (point))))
3452 (mail-header-set-xref headers xref))))))))
3454 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
3455 "Find article ID and insert the summary line for that article."
3456 (let ((header (if (and old-header use-old-header)
3457 old-header (gnus-read-header id)))
3458 (number (and (numberp id) id))
3461 ;; Rebuild the thread that this article is part of and go to the
3462 ;; article we have fetched.
3463 (when (and (not gnus-show-threads)
3465 (when (setq pos (text-property-any
3466 (point-min) (point-max) 'gnus-number
3467 (mail-header-number old-header)))
3470 (gnus-data-remove (mail-header-number old-header))))
3472 (mail-header-set-number header (mail-header-number old-header)))
3473 (setq gnus-newsgroup-sparse
3474 (delq (setq number (mail-header-number header))
3475 gnus-newsgroup-sparse))
3476 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
3477 (gnus-rebuild-thread (mail-header-id header))
3478 (gnus-summary-goto-subject number nil t))
3479 (when (and (numberp number)
3481 ;; We have to update the boundaries even if we can't fetch the
3482 ;; article if ID is a number -- so that the next `P' or `N'
3483 ;; command will fetch the previous (or next) article even
3484 ;; if the one we tried to fetch this time has been canceled.
3485 (and (> number gnus-newsgroup-end)
3486 (setq gnus-newsgroup-end number))
3487 (and (< number gnus-newsgroup-begin)
3488 (setq gnus-newsgroup-begin number))
3489 (setq gnus-newsgroup-unselected
3490 (delq number gnus-newsgroup-unselected)))
3491 ;; Report back a success?
3492 (and header (mail-header-number header))))
3494 (defun gnus-summary-work-articles (n)
3495 "Return a list of articles to be worked upon. The prefix argument,
3496 the list of process marked articles, and the current article will be
3497 taken into consideration."
3500 ;; A numerical prefix has been given.
3501 (let ((backward (< n 0))
3502 (n (abs (prefix-numeric-value n)))
3507 (push (setq article (gnus-summary-article-number))
3510 (gnus-summary-find-prev nil article)
3511 (gnus-summary-find-next nil article)))
3513 (nreverse articles)))
3514 ((and (boundp 'transient-mark-mode)
3517 ;; Work on the region between point and mark.
3518 (let ((max (max (point) (mark)))
3521 (goto-char (min (point) (mark)))
3524 (push (setq article (gnus-summary-article-number)) articles)
3525 (gnus-summary-find-next nil article)
3527 (nreverse articles))))
3528 (gnus-newsgroup-processable
3529 ;; There are process-marked articles present.
3530 (reverse gnus-newsgroup-processable))
3532 ;; Just return the current article.
3533 (list (gnus-summary-article-number)))))
3535 (defun gnus-summary-search-group (&optional backward use-level)
3536 "Search for next unread newsgroup.
3537 If optional argument BACKWARD is non-nil, search backward instead."
3539 (set-buffer gnus-group-buffer)
3540 (if (gnus-group-search-forward
3541 backward nil (if use-level (gnus-group-group-level) nil))
3542 (gnus-group-group-name))))
3544 (defun gnus-summary-best-group (&optional exclude-group)
3545 "Find the name of the best unread group.
3546 If EXCLUDE-GROUP, do not go to this group."
3548 (set-buffer gnus-group-buffer)
3550 (gnus-group-best-unread-group exclude-group))))
3552 (defun gnus-summary-find-next (&optional unread article backward)
3553 (if backward (gnus-summary-find-prev)
3554 (let* ((dummy (gnus-summary-article-intangible-p))
3555 (article (or article (gnus-summary-article-number)))
3556 (arts (gnus-data-find-list article))
3558 (when (and (not dummy)
3559 (or (not gnus-summary-check-current)
3561 (not (gnus-data-unread-p (car arts)))))
3562 (setq arts (cdr arts)))
3567 (when (gnus-data-unread-p (car arts))
3568 (setq result (car arts)
3570 (setq arts (cdr arts)))
3573 (goto-char (gnus-data-pos result))
3574 (gnus-data-number result)))))
3576 (defun gnus-summary-find-prev (&optional unread article)
3577 (let* ((eobp (eobp))
3578 (article (or article (gnus-summary-article-number)))
3579 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
3581 (when (and (not eobp)
3582 (or (not gnus-summary-check-current)
3584 (not (gnus-data-unread-p (car arts)))))
3585 (setq arts (cdr arts)))
3590 (and (gnus-data-unread-p (car arts))
3591 (setq result (car arts)
3593 (setq arts (cdr arts)))
3597 (goto-char (gnus-data-pos result))
3598 (gnus-data-number result)))))
3600 (defun gnus-summary-find-subject (subject &optional unread backward article)
3601 (let* ((simp-subject (gnus-simplify-subject-fully subject))
3602 (article (or article (gnus-summary-article-number)))
3603 (articles (gnus-data-list backward))
3604 (arts (gnus-data-find-list article articles))
3606 (when (or (not gnus-summary-check-current)
3608 (not (gnus-data-unread-p (car arts))))
3609 (setq arts (cdr arts)))
3611 (and (or (not unread)
3612 (gnus-data-unread-p (car arts)))
3613 (vectorp (gnus-data-header (car arts)))
3615 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
3616 (setq result (car arts)
3618 (setq arts (cdr arts)))
3620 (goto-char (gnus-data-pos result))
3621 (gnus-data-number result))))
3623 (defun gnus-summary-search-forward (&optional unread subject backward)
3624 "Search forward for an article.
3625 If UNREAD, look for unread articles. If SUBJECT, look for
3626 articles with that subject. If BACKWARD, search backward instead."
3627 (cond (subject (gnus-summary-find-subject subject unread backward))
3628 (backward (gnus-summary-find-prev unread))
3629 (t (gnus-summary-find-next unread))))
3631 (defun gnus-recenter (&optional n)
3632 "Center point in window and redisplay frame.
3633 Also do horizontal recentering."
3635 (when (and gnus-auto-center-summary
3636 (not (eq gnus-auto-center-summary 'vertical)))
3637 (gnus-horizontal-recenter))
3640 (defun gnus-summary-recenter ()
3641 "Center point in the summary window.
3642 If `gnus-auto-center-summary' is nil, or the article buffer isn't
3643 displayed, no centering will be performed."
3644 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
3645 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
3646 (let* ((top (cond ((< (window-height) 4) 0)
3647 ((< (window-height) 7) 1)
3649 (height (1- (window-height)))
3650 (bottom (save-excursion (goto-char (point-max))
3651 (forward-line (- height))
3653 (window (get-buffer-window (current-buffer))))
3654 ;; The user has to want it.
3655 (when gnus-auto-center-summary
3656 (when (get-buffer-window gnus-article-buffer)
3657 ;; Only do recentering when the article buffer is displayed,
3658 ;; Set the window start to either `bottom', which is the biggest
3659 ;; possible valid number, or the second line from the top,
3660 ;; whichever is the least.
3662 window (min bottom (save-excursion
3663 (forward-line (- top)) (point)))))
3664 ;; Do horizontal recentering while we're at it.
3665 (when (and (get-buffer-window (current-buffer) t)
3666 (not (eq gnus-auto-center-summary 'vertical)))
3667 (let ((selected (selected-window)))
3668 (select-window (get-buffer-window (current-buffer) t))
3669 (gnus-summary-position-point)
3670 (gnus-horizontal-recenter)
3671 (select-window selected))))))
3673 (defun gnus-summary-jump-to-group (newsgroup)
3674 "Move point to NEWSGROUP in group mode buffer."
3675 ;; Keep update point of group mode buffer if visible.
3676 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
3677 (save-window-excursion
3678 ;; Take care of tree window mode.
3679 (if (get-buffer-window gnus-group-buffer)
3680 (pop-to-buffer gnus-group-buffer))
3681 (gnus-group-jump-to-group newsgroup))
3683 ;; Take care of tree window mode.
3684 (if (get-buffer-window gnus-group-buffer)
3685 (pop-to-buffer gnus-group-buffer)
3686 (set-buffer gnus-group-buffer))
3687 (gnus-group-jump-to-group newsgroup))))
3689 ;; This function returns a list of article numbers based on the
3690 ;; difference between the ranges of read articles in this group and
3691 ;; the range of active articles.
3692 (defun gnus-list-of-unread-articles (group)
3693 (let* ((read (gnus-info-read (gnus-get-info group)))
3694 (active (gnus-active group))
3697 ;; If none are read, then all are unread.
3699 (setq first (car active))
3700 ;; If the range of read articles is a single range, then the
3701 ;; first unread article is the article after the last read
3702 ;; article. Sounds logical, doesn't it?
3703 (if (not (listp (cdr read)))
3704 (setq first (1+ (cdr read)))
3705 ;; `read' is a list of ranges.
3706 (if (/= (setq nlast (or (and (numberp (car read)) (car read))
3711 (while (< first nlast)
3712 (setq unread (cons first unread))
3713 (setq first (1+ first))))
3714 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
3715 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
3716 (setq read (cdr read)))))
3717 ;; And add the last unread articles.
3718 (while (<= first last)
3719 (setq unread (cons first unread))
3720 (setq first (1+ first)))
3721 ;; Return the list of unread articles.
3724 (defun gnus-list-of-read-articles (group)
3725 "Return a list of unread, unticked and non-dormant articles."
3726 (let* ((info (gnus-get-info group))
3727 (marked (gnus-info-marks info))
3728 (active (gnus-active group)))
3730 (gnus-set-difference
3731 (gnus-sorted-complement
3732 (gnus-uncompress-range active)
3733 (gnus-list-of-unread-articles group))
3735 (gnus-uncompress-range (cdr (assq 'dormant marked)))
3736 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
3738 ;; Various summary commands
3740 (defun gnus-summary-universal-argument (arg)
3741 "Perform any operation on all articles that are process/prefixed."
3743 (gnus-set-global-variables)
3744 (let ((articles (gnus-summary-work-articles arg))
3751 (substitute-command-keys
3752 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
3755 (gnus-error 1 "Undefined key")
3758 (gnus-summary-goto-subject (setq article (pop articles)))
3759 (command-execute func)
3760 (gnus-summary-remove-process-mark article)))))
3761 (gnus-summary-position-point))
3763 (defun gnus-summary-toggle-truncation (&optional arg)
3764 "Toggle truncation of summary lines.
3765 With arg, turn line truncation on iff arg is positive."
3767 (setq truncate-lines
3768 (if (null arg) (not truncate-lines)
3769 (> (prefix-numeric-value arg) 0)))
3772 (defun gnus-summary-reselect-current-group (&optional all rescan)
3773 "Exit and then reselect the current newsgroup.
3774 The prefix argument ALL means to select all articles."
3776 (gnus-set-global-variables)
3777 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
3778 (error "Ephemeral groups can't be reselected"))
3779 (let ((current-subject (gnus-summary-article-number))
3780 (group gnus-newsgroup-name))
3781 (setq gnus-newsgroup-begin nil)
3783 ;; We have to adjust the point of group mode buffer because the
3784 ;; current point was moved to the next unread newsgroup by
3786 (gnus-summary-jump-to-group group)
3789 (gnus-group-get-new-news-this-group 1)))
3790 (gnus-group-read-group all t)
3791 (gnus-summary-goto-subject current-subject nil t)))
3793 (defun gnus-summary-rescan-group (&optional all)
3794 "Exit the newsgroup, ask for new articles, and select the newsgroup."
3796 (gnus-summary-reselect-current-group all t))
3798 (defun gnus-summary-update-info ()
3799 (let ((group gnus-newsgroup-name))
3800 (when gnus-newsgroup-kill-headers
3801 (setq gnus-newsgroup-killed
3802 (gnus-compress-sequence
3804 (gnus-set-sorted-intersection
3805 (gnus-uncompress-range gnus-newsgroup-killed)
3806 (setq gnus-newsgroup-unselected
3807 (sort gnus-newsgroup-unselected '<)))
3808 (setq gnus-newsgroup-unreads
3809 (sort gnus-newsgroup-unreads '<))) t)))
3810 (unless (listp (cdr gnus-newsgroup-killed))
3811 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
3812 (let ((headers gnus-newsgroup-headers))
3813 (run-hooks 'gnus-exit-group-hook)
3814 (unless gnus-save-score
3815 (setq gnus-newsgroup-scored nil))
3816 ;; Set the new ranges of read articles.
3817 (gnus-update-read-articles
3818 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
3819 ;; Set the current article marks.
3821 ;; Do the cross-ref thing.
3822 (when gnus-use-cross-reference
3823 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
3824 ;; Do adaptive scoring, and possibly save score files.
3825 (when gnus-newsgroup-adaptive
3826 (gnus-score-adaptive))
3827 (when gnus-use-scoring
3829 ;; Do not switch windows but change the buffer to work.
3830 (set-buffer gnus-group-buffer)
3831 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
3832 (gnus-group-update-group group)))))
3834 (defun gnus-summary-exit (&optional temporary)
3835 "Exit reading current newsgroup, and then return to group selection mode.
3836 gnus-exit-group-hook is called with no arguments if that value is non-nil."
3838 (gnus-set-global-variables)
3839 (gnus-kill-save-kill-buffer)
3840 (let* ((group gnus-newsgroup-name)
3841 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
3843 (buf (current-buffer)))
3844 (run-hooks 'gnus-summary-prepare-exit-hook)
3845 ;; If we have several article buffers, we kill them at exit.
3846 (unless gnus-single-article-buffer
3847 (gnus-kill-buffer gnus-original-article-buffer)
3848 (setq gnus-article-current nil))
3849 (when gnus-use-cache
3850 (gnus-cache-possibly-remove-articles)
3851 (gnus-cache-save-buffers))
3852 (gnus-async-prefetch-remove-group group)
3853 (when gnus-suppress-duplicates
3854 (gnus-dup-enter-articles))
3855 (when gnus-use-trees
3856 (gnus-tree-close group))
3857 ;; Make all changes in this group permanent.
3859 (gnus-summary-update-info))
3860 (gnus-close-group group)
3861 ;; Make sure where I was, and go to next newsgroup.
3862 (set-buffer gnus-group-buffer)
3864 (gnus-group-jump-to-group group))
3865 (run-hooks 'gnus-summary-exit-hook)
3867 (gnus-group-next-unread-group 1))
3870 ;; If we have several article buffers, we kill them at exit.
3871 (unless gnus-single-article-buffer
3872 (gnus-kill-buffer gnus-article-buffer)
3873 (gnus-kill-buffer gnus-original-article-buffer)
3874 (setq gnus-article-current nil))
3876 (if (not gnus-kill-summary-on-exit)
3877 (gnus-deaden-summary)
3878 ;; We set all buffer-local variables to nil. It is unclear why
3879 ;; this is needed, but if we don't, buffer-local variables are
3880 ;; not garbage-collected, it seems. This would the lead to en
3881 ;; ever-growing Emacs.
3882 (gnus-summary-clear-local-variables)
3883 (when (get-buffer gnus-article-buffer)
3884 (bury-buffer gnus-article-buffer))
3885 ;; We clear the global counterparts of the buffer-local
3886 ;; variables as well, just to be on the safe side.
3887 (gnus-configure-windows 'group 'force)
3888 (gnus-summary-clear-local-variables)
3889 ;; Return to group mode buffer.
3890 (if (eq mode 'gnus-summary-mode)
3891 (gnus-kill-buffer buf)))
3892 (setq gnus-current-select-method gnus-select-method)
3893 (pop-to-buffer gnus-group-buffer)
3894 ;; Clear the current group name.
3895 (if (not quit-config)
3897 (gnus-group-jump-to-group group)
3898 (gnus-group-next-unread-group 1)
3899 (gnus-configure-windows 'group 'force))
3900 (if (not (buffer-name (car quit-config)))
3901 (gnus-configure-windows 'group 'force)
3902 (set-buffer (car quit-config))
3903 (and (eq major-mode 'gnus-summary-mode)
3904 (gnus-set-global-variables))
3905 (gnus-configure-windows (cdr quit-config))))
3907 (setq gnus-newsgroup-name nil)))))
3909 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
3910 (defun gnus-summary-exit-no-update (&optional no-questions)
3911 "Quit reading current newsgroup without updating read article info."
3913 (gnus-set-global-variables)
3914 (let* ((group gnus-newsgroup-name)
3915 (quit-config (gnus-group-quit-config group)))
3916 (when (or no-questions
3918 (gnus-y-or-n-p "Do you really wanna quit reading this group? "))
3919 ;; If we have several article buffers, we kill them at exit.
3920 (unless gnus-single-article-buffer
3921 (gnus-kill-buffer gnus-article-buffer)
3922 (gnus-kill-buffer gnus-original-article-buffer)
3923 (setq gnus-article-current nil))
3924 (if (not gnus-kill-summary-on-exit)
3925 (gnus-deaden-summary)
3926 (gnus-close-group group)
3927 (gnus-summary-clear-local-variables)
3928 (set-buffer gnus-group-buffer)
3929 (gnus-summary-clear-local-variables)
3930 (when (get-buffer gnus-summary-buffer)
3931 (kill-buffer gnus-summary-buffer)))
3932 (unless gnus-single-article-buffer
3933 (setq gnus-article-current nil))
3934 (when gnus-use-trees
3935 (gnus-tree-close group))
3936 (gnus-async-prefetch-remove-group group)
3937 (when (get-buffer gnus-article-buffer)
3938 (bury-buffer gnus-article-buffer))
3939 ;; Return to the group buffer.
3940 (gnus-configure-windows 'group 'force)
3941 ;; Clear the current group name.
3942 (setq gnus-newsgroup-name nil)
3943 (when (equal (gnus-group-group-name) group)
3944 (gnus-group-next-unread-group 1))
3946 (if (not (buffer-name (car quit-config)))
3947 (gnus-configure-windows 'group 'force)
3948 (set-buffer (car quit-config))
3949 (when (eq major-mode 'gnus-summary-mode)
3950 (gnus-set-global-variables))
3951 (gnus-configure-windows (cdr quit-config)))))))
3955 (defvar gnus-dead-summary-mode-map nil)
3957 (if gnus-dead-summary-mode-map
3959 (setq gnus-dead-summary-mode-map (make-keymap))
3960 (suppress-keymap gnus-dead-summary-mode-map)
3961 (substitute-key-definition
3962 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
3963 (let ((keys '("\C-d" "\r" "\177")))
3965 (define-key gnus-dead-summary-mode-map
3966 (pop keys) 'gnus-summary-wake-up-the-dead))))
3968 (defvar gnus-dead-summary-mode nil
3969 "Minor mode for Gnus summary buffers.")
3971 (defun gnus-dead-summary-mode (&optional arg)
3972 "Minor mode for Gnus summary buffers."
3974 (when (eq major-mode 'gnus-summary-mode)
3975 (make-local-variable 'gnus-dead-summary-mode)
3976 (setq gnus-dead-summary-mode
3977 (if (null arg) (not gnus-dead-summary-mode)
3978 (> (prefix-numeric-value arg) 0)))
3979 (when gnus-dead-summary-mode
3980 (unless (assq 'gnus-dead-summary-mode minor-mode-alist)
3981 (push '(gnus-dead-summary-mode " Dead") minor-mode-alist))
3982 (unless (assq 'gnus-dead-summary-mode minor-mode-map-alist)
3983 (push (cons 'gnus-dead-summary-mode gnus-dead-summary-mode-map)
3984 minor-mode-map-alist)))))
3986 (defun gnus-deaden-summary ()
3987 "Make the current summary buffer into a dead summary buffer."
3988 ;; Kill any previous dead summary buffer.
3989 (when (and gnus-dead-summary
3990 (buffer-name gnus-dead-summary))
3992 (set-buffer gnus-dead-summary)
3993 (when gnus-dead-summary-mode
3994 (kill-buffer (current-buffer)))))
3995 ;; Make this the current dead summary.
3996 (setq gnus-dead-summary (current-buffer))
3997 (gnus-dead-summary-mode 1)
3998 (let ((name (buffer-name)))
3999 (when (string-match "Summary" name)
4001 (concat (substring name 0 (match-beginning 0)) "Dead "
4002 (substring name (match-beginning 0))) t))))
4004 (defun gnus-kill-or-deaden-summary (buffer)
4005 "Kill or deaden the summary BUFFER."
4006 (when (and (buffer-name buffer)
4007 (not gnus-single-article-buffer))
4010 (gnus-kill-buffer gnus-article-buffer)
4011 (gnus-kill-buffer gnus-original-article-buffer)))
4012 (cond (gnus-kill-summary-on-exit
4013 (when (and gnus-use-trees
4014 (and (get-buffer buffer)
4015 (buffer-name (get-buffer buffer))))
4017 (set-buffer (get-buffer buffer))
4018 (gnus-tree-close gnus-newsgroup-name)))
4019 (gnus-kill-buffer buffer))
4020 ((and (get-buffer buffer)
4021 (buffer-name (get-buffer buffer)))
4024 (gnus-deaden-summary)))))
4026 (defun gnus-summary-wake-up-the-dead (&rest args)
4027 "Wake up the dead summary buffer."
4029 (gnus-dead-summary-mode -1)
4030 (let ((name (buffer-name)))
4031 (when (string-match "Dead " name)
4033 (concat (substring name 0 (match-beginning 0))
4034 (substring name (match-end 0))) t)))
4035 (gnus-message 3 "This dead summary is now alive again"))
4037 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
4038 (defun gnus-summary-fetch-faq (&optional faq-dir)
4039 "Fetch the FAQ for the current group.
4040 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
4044 (if current-prefix-arg
4046 "Faq dir: " (and (listp gnus-group-faq-directory)
4047 gnus-group-faq-directory)))))
4048 (let (gnus-faq-buffer)
4049 (and (setq gnus-faq-buffer
4050 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
4051 (gnus-configure-windows 'summary-faq))))
4053 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
4054 (defun gnus-summary-describe-group (&optional force)
4055 "Describe the current newsgroup."
4057 (gnus-group-describe-group force gnus-newsgroup-name))
4059 (defun gnus-summary-describe-briefly ()
4060 "Describe summary mode commands briefly."
4063 (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")))
4065 ;; Walking around group mode buffer from summary mode.
4067 (defun gnus-summary-next-group (&optional no-article target-group backward)
4068 "Exit current newsgroup and then select next unread newsgroup.
4069 If prefix argument NO-ARTICLE is non-nil, no article is selected
4070 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
4071 previous group instead."
4073 (gnus-set-global-variables)
4074 (let ((current-group gnus-newsgroup-name)
4075 (current-buffer (current-buffer))
4077 ;; First we semi-exit this group to update Xrefs and all variables.
4078 ;; We can't do a real exit, because the window conf must remain
4079 ;; the same in case the user is prompted for info, and we don't
4080 ;; want the window conf to change before that...
4081 (gnus-summary-exit t)
4082 (while (not entered)
4083 ;; Then we find what group we are supposed to enter.
4084 (set-buffer gnus-group-buffer)
4085 (gnus-group-jump-to-group current-group)
4088 (if (eq gnus-keep-same-level 'best)
4089 (gnus-summary-best-group gnus-newsgroup-name)
4090 (gnus-summary-search-group backward gnus-keep-same-level))))
4091 (if (not target-group)
4092 ;; There are no further groups, so we return to the group
4095 (gnus-message 5 "Returning to the group buffer")
4097 (set-buffer current-buffer)
4098 (gnus-summary-exit))
4099 ;; We try to enter the target group.
4100 (gnus-group-jump-to-group target-group)
4101 (let ((unreads (gnus-group-group-unread)))
4102 (if (and (or (eq t unreads)
4103 (and unreads (not (zerop unreads))))
4104 (gnus-summary-read-group
4105 target-group nil no-article current-buffer))
4107 (setq current-group target-group
4108 target-group nil)))))))
4110 (defun gnus-summary-prev-group (&optional no-article)
4111 "Exit current newsgroup and then select previous unread newsgroup.
4112 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
4114 (gnus-summary-next-group no-article nil t))
4116 ;; Walking around summary lines.
4118 (defun gnus-summary-first-subject (&optional unread)
4119 "Go to the first unread subject.
4120 If UNREAD is non-nil, go to the first unread article.
4121 Returns the article selected or nil if there are no unread articles."
4126 ((null gnus-newsgroup-data)
4127 (gnus-message 3 "No articles in the group")
4129 ;; Pick the first article.
4131 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
4132 (gnus-data-number (car gnus-newsgroup-data)))
4133 ;; No unread articles.
4134 ((null gnus-newsgroup-unreads)
4135 (gnus-message 3 "No more unread articles")
4137 ;; Find the first unread article.
4139 (let ((data gnus-newsgroup-data))
4141 (not (gnus-data-unread-p (car data))))
4142 (setq data (cdr data)))
4145 (goto-char (gnus-data-pos (car data)))
4146 (gnus-data-number (car data)))))))
4147 (gnus-summary-position-point)))
4149 (defun gnus-summary-next-subject (n &optional unread dont-display)
4150 "Go to next N'th summary line.
4151 If N is negative, go to the previous N'th subject line.
4152 If UNREAD is non-nil, only unread articles are selected.
4153 The difference between N and the actual number of steps taken is
4156 (let ((backward (< n 0))
4160 (gnus-summary-find-prev unread)
4161 (gnus-summary-find-next unread)))
4163 (if (/= 0 n) (gnus-message 7 "No more%s articles"
4164 (if unread " unread" "")))
4165 (unless dont-display
4166 (gnus-summary-recenter)
4167 (gnus-summary-position-point))
4170 (defun gnus-summary-next-unread-subject (n)
4171 "Go to next N'th unread summary line."
4173 (gnus-summary-next-subject n t))
4175 (defun gnus-summary-prev-subject (n &optional unread)
4176 "Go to previous N'th summary line.
4177 If optional argument UNREAD is non-nil, only unread article is selected."
4179 (gnus-summary-next-subject (- n) unread))
4181 (defun gnus-summary-prev-unread-subject (n)
4182 "Go to previous N'th unread summary line."
4184 (gnus-summary-next-subject (- n) t))
4186 (defun gnus-summary-goto-subject (article &optional force silent)
4187 "Go the subject line of ARTICLE.
4188 If FORCE, also allow jumping to articles not currently shown."
4190 (data (gnus-data-find article)))
4191 ;; We read in the article if we have to.
4194 (gnus-summary-insert-subject article (and (vectorp force) force) t)
4195 (setq data (gnus-data-find article)))
4200 (gnus-message 3 "Can't find article %d" article))
4202 (goto-char (gnus-data-pos data))
4205 ;; Walking around summary lines with displaying articles.
4207 (defun gnus-summary-expand-window (&optional arg)
4208 "Make the summary buffer take up the entire Emacs frame.
4209 Given a prefix, will force an `article' buffer configuration."
4211 (gnus-set-global-variables)
4213 (gnus-configure-windows 'article 'force)
4214 (gnus-configure-windows 'summary 'force)))
4216 (defun gnus-summary-display-article (article &optional all-header)
4217 "Display ARTICLE in article buffer."
4218 (gnus-set-global-variables)
4222 (if gnus-summary-display-article-function
4223 (funcall gnus-summary-display-article-function article all-header)
4224 (gnus-article-prepare article all-header))
4225 (run-hooks 'gnus-select-article-hook)
4226 (unless (zerop gnus-current-article)
4227 (gnus-summary-goto-subject gnus-current-article))
4228 (gnus-summary-recenter)
4229 (when gnus-use-trees
4230 (gnus-possibly-generate-tree article)
4231 (gnus-highlight-selected-tree article))
4232 ;; Successfully display article.
4233 (gnus-article-set-window-start
4234 (cdr (assq article gnus-newsgroup-bookmarks))))))
4236 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
4237 "Select the current article.
4238 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
4239 non-nil, the article will be re-fetched even if it already present in
4240 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
4242 ;; Make sure we are in the summary buffer to work around bbdb bug.
4243 (unless (eq major-mode 'gnus-summary-mode)
4244 (set-buffer gnus-summary-buffer))
4245 (let ((article (or article (gnus-summary-article-number)))
4246 (all-headers (not (not all-headers))) ;Must be T or NIL.
4247 gnus-summary-display-article-function
4250 (gnus-summary-article-pseudo-p article)
4251 (error "This is a pseudo-article."))
4254 (set-buffer gnus-summary-buffer)
4255 (if (or (and gnus-single-article-buffer
4256 (or (null gnus-current-article)
4257 (null gnus-article-current)
4258 (null (get-buffer gnus-article-buffer))
4259 (not (eq article (cdr gnus-article-current)))
4260 (not (equal (car gnus-article-current)
4261 gnus-newsgroup-name))))
4262 (and (not gnus-single-article-buffer)
4263 (or (null gnus-current-article)
4264 (not (eq gnus-current-article article))))
4266 ;; The requested article is different from the current article.
4268 (gnus-summary-display-article article all-headers)
4270 (if (or all-headers gnus-show-all-headers)
4271 (gnus-article-show-all-headers))
4274 (gnus-article-set-window-start
4275 (cdr (assq article gnus-newsgroup-bookmarks)))))))
4277 (defun gnus-summary-set-current-mark (&optional current-mark)
4278 "Obsolete function."
4281 (defun gnus-summary-next-article (&optional unread subject backward push)
4282 "Select the next article.
4283 If UNREAD, only unread articles are selected.
4284 If SUBJECT, only articles with SUBJECT are selected.
4285 If BACKWARD, the previous article is selected instead of the next."
4287 (gnus-set-global-variables)
4289 ;; Is there such an article?
4290 ((and (gnus-summary-search-forward unread subject backward)
4291 (or (gnus-summary-display-article (gnus-summary-article-number))
4292 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
4293 (gnus-summary-position-point))
4294 ;; If not, we try the first unread, if that is wanted.
4296 gnus-auto-select-same
4297 ;; Make sure that we don't select the current article.
4298 (not (eq (gnus-summary-article-number)
4300 (gnus-summary-first-subject t)
4301 (gnus-summary-article-number))))
4302 (gnus-summary-first-unread-article))
4303 (gnus-summary-position-point)
4304 (gnus-message 6 "Wrapped"))
4305 ;; Try to get next/previous article not displayed in this group.
4306 ((and gnus-auto-extend-newsgroup
4307 (not unread) (not subject))
4308 (gnus-summary-goto-article
4309 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
4311 ;; Go to next/previous group.
4313 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
4314 (gnus-summary-jump-to-group gnus-newsgroup-name))
4315 (let ((cmd last-command-char)
4317 (if (eq gnus-keep-same-level 'best)
4318 (gnus-summary-best-group gnus-newsgroup-name)
4319 (gnus-summary-search-group backward gnus-keep-same-level))))
4320 ;; For some reason, the group window gets selected. We change
4322 (select-window (get-buffer-window (current-buffer)))
4323 ;; Select next unread newsgroup automagically.
4325 ((or (not gnus-auto-select-next)
4327 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
4328 ((or (eq gnus-auto-select-next 'quietly)
4329 (and (eq gnus-auto-select-next 'slightly-quietly)
4331 (and (eq gnus-auto-select-next 'almost-quietly)
4332 (gnus-summary-last-article-p)))
4334 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
4336 (gnus-message 7 "No more%s articles (%s)..."
4337 (if unread " unread" "")
4338 (if group (concat "selecting " group)
4340 (gnus-summary-next-group nil group backward)))
4342 (gnus-summary-walk-group-buffer
4343 gnus-newsgroup-name cmd unread backward)))))))
4345 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward)
4346 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
4347 (?\C-p (gnus-group-prev-unread-group 1))))
4348 keve key group ended)
4350 (set-buffer gnus-group-buffer)
4351 (gnus-summary-jump-to-group from-group)
4353 (if (eq gnus-keep-same-level 'best)
4354 (gnus-summary-best-group gnus-newsgroup-name)
4355 (gnus-summary-search-group backward gnus-keep-same-level))))
4358 5 "No more%s articles%s" (if unread " unread" "")
4360 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
4361 (format " (Type %s for %s [%s])"
4362 (single-key-description cmd) group
4363 (car (gnus-gethash group gnus-newsrc-hashtb)))
4364 (format " (Type %s to exit %s)"
4365 (single-key-description cmd)
4366 gnus-newsgroup-name)))
4367 ;; Confirm auto selection.
4368 (setq key (car (setq keve (gnus-read-event-char))))
4371 ((assq key keystrokes)
4372 (let ((obuf (current-buffer)))
4373 (switch-to-buffer gnus-group-buffer)
4375 (gnus-group-jump-to-group group))
4376 (eval (cadr (assq key keystrokes)))
4377 (setq group (gnus-group-group-name))
4378 (switch-to-buffer obuf))
4382 (gnus-ephemeral-group-p gnus-newsgroup-name))
4384 (gnus-summary-next-group nil group backward)))
4386 (push (cdr keve) unread-command-events))))))
4388 (defun gnus-summary-next-unread-article ()
4389 "Select unread article after current one."
4391 (gnus-summary-next-article t (and gnus-auto-select-same
4392 (gnus-summary-article-subject))))
4394 (defun gnus-summary-prev-article (&optional unread subject)
4395 "Select the article after the current one.
4396 If UNREAD is non-nil, only unread articles are selected."
4398 (gnus-summary-next-article unread subject t))
4400 (defun gnus-summary-prev-unread-article ()
4401 "Select unred article before current one."
4403 (gnus-summary-prev-article t (and gnus-auto-select-same
4404 (gnus-summary-article-subject))))
4406 (defun gnus-summary-next-page (&optional lines circular)
4407 "Show next page of the selected article.
4408 If at the end of the current article, select the next article.
4409 LINES says how many lines should be scrolled up.
4411 If CIRCULAR is non-nil, go to the start of the article instead of
4412 selecting the next article when reaching the end of the current
4415 (setq gnus-summary-buffer (current-buffer))
4416 (gnus-set-global-variables)
4417 (let ((article (gnus-summary-article-number))
4419 (gnus-configure-windows 'article)
4420 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
4421 (if (and (eq gnus-summary-goto-unread 'never)
4422 (not (gnus-summary-last-article-p article)))
4423 (gnus-summary-next-article)
4424 (gnus-summary-next-unread-article))
4425 (if (or (null gnus-current-article)
4426 (null gnus-article-current)
4427 (/= article (cdr gnus-article-current))
4428 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
4429 ;; Selected subject is different from current article's.
4430 (gnus-summary-display-article article)
4431 (gnus-eval-in-buffer-window gnus-article-buffer
4432 (setq endp (gnus-article-next-page lines)))
4435 (gnus-summary-beginning-of-article))
4437 (gnus-message 3 "End of message"))
4439 (if (and (eq gnus-summary-goto-unread 'never)
4440 (not (gnus-summary-last-article-p article)))
4441 (gnus-summary-next-article)
4442 (gnus-summary-next-unread-article)))))))
4443 (gnus-summary-recenter)
4444 (gnus-summary-position-point)))
4446 (defun gnus-summary-prev-page (&optional lines)
4447 "Show previous page of selected article.
4448 Argument LINES specifies lines to be scrolled down."
4450 (gnus-set-global-variables)
4451 (let ((article (gnus-summary-article-number)))
4452 (gnus-configure-windows 'article)
4453 (if (or (null gnus-current-article)
4454 (null gnus-article-current)
4455 (/= article (cdr gnus-article-current))
4456 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
4457 ;; Selected subject is different from current article's.
4458 (gnus-summary-display-article article)
4459 (gnus-summary-recenter)
4460 (gnus-eval-in-buffer-window gnus-article-buffer
4461 (gnus-article-prev-page lines))))
4462 (gnus-summary-position-point))
4464 (defun gnus-summary-scroll-up (lines)
4465 "Scroll up (or down) one line current article.
4466 Argument LINES specifies lines to be scrolled up (or down if negative)."
4468 (gnus-set-global-variables)
4469 (gnus-configure-windows 'article)
4470 (gnus-summary-show-thread)
4471 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
4472 (gnus-eval-in-buffer-window gnus-article-buffer
4474 (if (gnus-article-next-page lines)
4475 (gnus-message 3 "End of message")))
4477 (gnus-article-prev-page (- lines))))))
4478 (gnus-summary-recenter)
4479 (gnus-summary-position-point))
4481 (defun gnus-summary-next-same-subject ()
4482 "Select next article which has the same subject as current one."
4484 (gnus-set-global-variables)
4485 (gnus-summary-next-article nil (gnus-summary-article-subject)))
4487 (defun gnus-summary-prev-same-subject ()
4488 "Select previous article which has the same subject as current one."
4490 (gnus-set-global-variables)
4491 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
4493 (defun gnus-summary-next-unread-same-subject ()
4494 "Select next unread article which has the same subject as current one."
4496 (gnus-set-global-variables)
4497 (gnus-summary-next-article t (gnus-summary-article-subject)))
4499 (defun gnus-summary-prev-unread-same-subject ()
4500 "Select previous unread article which has the same subject as current one."
4502 (gnus-set-global-variables)
4503 (gnus-summary-prev-article t (gnus-summary-article-subject)))
4505 (defun gnus-summary-first-unread-article ()
4506 "Select the first unread article.
4507 Return nil if there are no unread articles."
4509 (gnus-set-global-variables)
4511 (when (gnus-summary-first-subject t)
4512 (gnus-summary-show-thread)
4513 (gnus-summary-first-subject t)
4514 (gnus-summary-display-article (gnus-summary-article-number)))
4515 (gnus-summary-position-point)))
4517 (defun gnus-summary-best-unread-article ()
4518 "Select the unread article with the highest score."
4520 (gnus-set-global-variables)
4521 (let ((best -1000000)
4522 (data gnus-newsgroup-data)
4525 (and (gnus-data-unread-p (car data))
4527 (gnus-summary-article-score (gnus-data-number (car data))))
4530 article (gnus-data-number (car data))))
4531 (setq data (cdr data)))
4534 (gnus-summary-goto-article article)
4535 (error "No unread articles"))
4536 (gnus-summary-position-point))))
4538 (defun gnus-summary-last-subject ()
4539 "Go to the last displayed subject line in the group."
4540 (let ((article (gnus-data-number (car (gnus-data-list t)))))
4542 (gnus-summary-goto-subject article))))
4544 (defun gnus-summary-goto-article (article &optional all-headers force)
4545 "Fetch ARTICLE and display it if it exists.
4546 If ALL-HEADERS is non-nil, no header lines are hidden."
4552 (mapcar (lambda (number) (list (int-to-string number)))
4553 gnus-newsgroup-limit)))
4557 (if (gnus-summary-goto-subject article force)
4558 (gnus-summary-display-article article all-headers)
4559 (gnus-message 4 "Couldn't go to article %s" article) nil)
4560 (gnus-summary-position-point)))
4562 (defun gnus-summary-goto-last-article ()
4563 "Go to the previously read article."
4566 (and gnus-last-article
4567 (gnus-summary-goto-article gnus-last-article))
4568 (gnus-summary-position-point)))
4570 (defun gnus-summary-pop-article (number)
4571 "Pop one article off the history and go to the previous.
4572 NUMBER articles will be popped off."
4575 (setq gnus-newsgroup-history
4576 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
4578 (gnus-summary-goto-article (car to))
4579 (error "Article history empty")))
4580 (gnus-summary-position-point))
4582 ;; Summary commands and functions for limiting the summary buffer.
4584 (defun gnus-summary-limit-to-articles (n)
4585 "Limit the summary buffer to the next N articles.
4586 If not given a prefix, use the process marked articles instead."
4588 (gnus-set-global-variables)
4590 (let ((articles (gnus-summary-work-articles n)))
4591 (setq gnus-newsgroup-processable nil)
4592 (gnus-summary-limit articles))
4593 (gnus-summary-position-point)))
4595 (defun gnus-summary-pop-limit (&optional total)
4596 "Restore the previous limit.
4597 If given a prefix, remove all limits."
4599 (gnus-set-global-variables)
4601 (setq gnus-newsgroup-limits
4602 (list (mapcar (lambda (h) (mail-header-number h))
4603 gnus-newsgroup-headers))))
4604 (unless gnus-newsgroup-limits
4605 (error "No limit to pop"))
4607 (gnus-summary-limit nil 'pop)
4608 (gnus-summary-position-point)))
4610 (defun gnus-summary-limit-to-subject (subject &optional header)
4611 "Limit the summary buffer to articles that have subjects that match a regexp."
4612 (interactive "sRegexp: ")
4614 (setq header "subject"))
4615 (when (not (equal "" subject))
4617 (let ((articles (gnus-summary-find-matching
4618 (or header "subject") subject 'all)))
4619 (or articles (error "Found no matches for \"%s\"" subject))
4620 (gnus-summary-limit articles))
4621 (gnus-summary-position-point))))
4623 (defun gnus-summary-limit-to-author (from)
4624 "Limit the summary buffer to articles that have authors that match a regexp."
4625 (interactive "sRegexp: ")
4626 (gnus-summary-limit-to-subject from "from"))
4628 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
4630 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
4632 (defun gnus-summary-limit-to-unread (&optional all)
4633 "Limit the summary buffer to articles that are not marked as read.
4634 If ALL is non-nil, limit strictly to unread articles."
4637 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
4638 (gnus-summary-limit-to-marks
4639 ;; Concat all the marks that say that an article is read and have
4641 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
4642 gnus-killed-mark gnus-kill-file-mark
4643 gnus-low-score-mark gnus-expirable-mark
4644 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
4645 gnus-duplicate-mark)
4648 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
4649 (make-obsolete 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
4651 (defun gnus-summary-limit-to-marks (marks &optional reverse)
4652 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
4653 If REVERSE, limit the summary buffer to articles that are not marked
4654 with MARKS. MARKS can either be a string of marks or a list of marks.
4655 Returns how many articles were removed."
4656 (interactive "sMarks: ")
4657 (gnus-set-global-variables)
4659 (let ((data gnus-newsgroup-data)
4660 (marks (if (listp marks) marks
4661 (append marks nil))) ; Transform to list.
4664 (and (if reverse (not (memq (gnus-data-mark (car data)) marks))
4665 (memq (gnus-data-mark (car data)) marks))
4666 (setq articles (cons (gnus-data-number (car data)) articles)))
4667 (setq data (cdr data)))
4668 (gnus-summary-limit articles))
4669 (gnus-summary-position-point)))
4671 (defun gnus-summary-limit-to-score (&optional score)
4672 "Limit to articles with score at or above SCORE."
4674 (gnus-set-global-variables)
4675 (setq score (if score
4676 (prefix-numeric-value score)
4677 (or gnus-summary-default-score 0)))
4678 (let ((data gnus-newsgroup-data)
4681 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
4683 (push (gnus-data-number (car data)) articles))
4684 (setq data (cdr data)))
4686 (gnus-summary-limit articles)
4687 (gnus-summary-position-point))))
4689 (defun gnus-summary-limit-include-dormant ()
4690 "Display all the hidden articles that are marked as dormant."
4692 (gnus-set-global-variables)
4693 (or gnus-newsgroup-dormant
4694 (error "There are no dormant articles in this group"))
4696 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
4697 (gnus-summary-position-point)))
4699 (defun gnus-summary-limit-exclude-dormant ()
4700 "Hide all dormant articles."
4702 (gnus-set-global-variables)
4704 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
4705 (gnus-summary-position-point)))
4707 (defun gnus-summary-limit-exclude-childless-dormant ()
4708 "Hide all dormant articles that have no children."
4710 (gnus-set-global-variables)
4711 (let ((data (gnus-data-list t))
4712 articles d children)
4713 ;; Find all articles that are either not dormant or have
4715 (while (setq d (pop data))
4716 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
4718 (gnus-article-children (gnus-data-number d)))
4721 (when (memq (car children) articles)
4726 (push (gnus-data-number d) articles)))
4729 (gnus-summary-limit articles)
4730 (gnus-summary-position-point))))
4732 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
4733 "Mark all unread excluded articles as read.
4734 If ALL, mark even excluded ticked and dormants as read."
4736 (let ((articles (gnus-sorted-complement
4738 (mapcar (lambda (h) (mail-header-number h))
4739 gnus-newsgroup-headers)
4741 (sort gnus-newsgroup-limit '<)))
4743 (setq gnus-newsgroup-unreads nil)
4745 (setq gnus-newsgroup-dormant nil
4746 gnus-newsgroup-marked nil
4747 gnus-newsgroup-reads
4749 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
4750 gnus-newsgroup-reads))
4751 (while (setq article (pop articles))
4752 (unless (or (memq article gnus-newsgroup-dormant)
4753 (memq article gnus-newsgroup-marked))
4754 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
4756 (defun gnus-summary-limit (articles &optional pop)
4758 ;; We pop the previous limit off the stack and use that.
4759 (setq articles (car gnus-newsgroup-limits)
4760 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
4761 ;; We use the new limit, so we push the old limit on the stack.
4762 (setq gnus-newsgroup-limits
4763 (cons gnus-newsgroup-limit gnus-newsgroup-limits)))
4765 (setq gnus-newsgroup-limit articles)
4766 (let ((total (length gnus-newsgroup-data))
4767 (data (gnus-data-find-list (gnus-summary-article-number)))
4768 (gnus-summary-mark-below nil) ; Inhibit this.
4770 ;; This will do all the work of generating the new summary buffer
4771 ;; according to the new limit.
4772 (gnus-summary-prepare)
4773 ;; Hide any threads, possibly.
4774 (and gnus-show-threads
4775 gnus-thread-hide-subtree
4776 (gnus-summary-hide-all-threads))
4777 ;; Try to return to the article you were at, or one in the
4780 ;; We try to find some article after the current one.
4782 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
4785 (setq data (cdr data))))
4787 ;; If there is no data, that means that we were after the last
4788 ;; article. The same goes when we can't find any articles
4789 ;; after the current one.
4790 (goto-char (point-max))
4791 (gnus-summary-find-prev))
4792 ;; We return how many articles were removed from the summary
4793 ;; buffer as a result of the new limit.
4794 (- total (length gnus-newsgroup-data))))
4796 (defsubst gnus-invisible-cut-children (threads)
4799 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
4804 (defsubst gnus-cut-thread (thread)
4805 "Go forwards in the thread until we find an article that we want to display."
4806 (when (or (eq gnus-fetch-old-headers 'some)
4807 (eq gnus-build-sparse-threads 'some)
4808 (eq gnus-build-sparse-threads 'more))
4809 ;; Deal with old-fetched headers and sparse threads.
4813 (memq (mail-header-number (car thread)) gnus-newsgroup-sparse)
4814 (memq (mail-header-number (car thread)) gnus-newsgroup-ancient))
4815 (or (<= (length (cdr thread)) 1)
4816 (gnus-invisible-cut-children (cdr thread))))
4817 (setq thread (cadr thread))))
4820 (defun gnus-cut-threads (threads)
4821 "Cut off all uninteresting articles from the beginning of threads."
4822 (when (or (eq gnus-fetch-old-headers 'some)
4823 (eq gnus-build-sparse-threads 'some)
4824 (eq gnus-build-sparse-threads 'more))
4827 (setcar th (gnus-cut-thread (car th)))
4828 (setq th (cdr th)))))
4829 ;; Remove nixed out threads.
4832 (defun gnus-summary-initial-limit (&optional show-if-empty)
4833 "Figure out what the initial limit is supposed to be on group entry.
4834 This entails weeding out unwanted dormants, low-scored articles,
4835 fetch-old-headers verbiage, and so on."
4836 ;; Most groups have nothing to remove.
4837 (if (or gnus-inhibit-limiting
4838 (and (null gnus-newsgroup-dormant)
4839 (not (eq gnus-fetch-old-headers 'some))
4840 (null gnus-summary-expunge-below)
4841 (not (eq gnus-build-sparse-threads 'some))
4842 (not (eq gnus-build-sparse-threads 'more))
4843 (null gnus-thread-expunge-below)
4844 (not gnus-use-nocem)))
4846 (push gnus-newsgroup-limit gnus-newsgroup-limits)
4847 (setq gnus-newsgroup-limit nil)
4850 (unless (car (symbol-value node))
4851 ;; These threads have no parents -- they are roots.
4852 (let ((nodes (cdr (symbol-value node)))
4855 (if (and gnus-thread-expunge-below
4856 (< (gnus-thread-total-score (car nodes))
4857 gnus-thread-expunge-below))
4858 (gnus-expunge-thread (pop nodes))
4859 (setq thread (pop nodes))
4860 (gnus-summary-limit-children thread))))))
4861 gnus-newsgroup-dependencies)
4862 ;; If this limitation resulted in an empty group, we might
4863 ;; pop the previous limit and use it instead.
4864 (when (and (not gnus-newsgroup-limit)
4866 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
4867 gnus-newsgroup-limit))
4869 (defun gnus-summary-limit-children (thread)
4870 "Return 1 if this subthread is visible and 0 if it is not."
4871 ;; First we get the number of visible children to this thread. This
4872 ;; is done by recursing down the thread using this function, so this
4873 ;; will really go down to a leaf article first, before slowly
4874 ;; working its way up towards the root.
4878 (apply '+ (mapcar 'gnus-summary-limit-children
4881 (number (mail-header-number (car thread)))
4884 ;; If this article is dormant and has absolutely no visible
4885 ;; children, then this article isn't visible.
4886 (and (memq number gnus-newsgroup-dormant)
4888 ;; If this is "fetch-old-headered" and there is only one
4889 ;; visible child (or less), then we don't want this article.
4890 (and (eq gnus-fetch-old-headers 'some)
4891 (memq number gnus-newsgroup-ancient)
4893 ;; If this is a sparsely inserted article with no children,
4894 ;; we don't want it.
4895 (and (eq gnus-build-sparse-threads 'some)
4896 (memq number gnus-newsgroup-sparse)
4898 ;; If we use expunging, and this article is really
4899 ;; low-scored, then we don't want this article.
4900 (when (and gnus-summary-expunge-below
4902 (or (cdr (assq number gnus-newsgroup-scored))
4903 gnus-summary-default-score))
4904 gnus-summary-expunge-below))
4905 ;; We increase the expunge-tally here, but that has
4906 ;; nothing to do with the limits, really.
4907 (incf gnus-newsgroup-expunged-tally)
4908 ;; We also mark as read here, if that's wanted.
4909 (when (and gnus-summary-mark-below
4910 (< score gnus-summary-mark-below))
4911 (setq gnus-newsgroup-unreads
4912 (delq number gnus-newsgroup-unreads))
4913 (if gnus-newsgroup-auto-expire
4914 (push number gnus-newsgroup-expirable)
4915 (push (cons number gnus-low-score-mark)
4916 gnus-newsgroup-reads)))
4919 (gnus-nocem-unwanted-article-p (mail-header-id (car thread)))))
4920 ;; Nope, invisible article.
4922 ;; Ok, this article is to be visible, so we add it to the limit
4924 (setq gnus-newsgroup-limit (cons number gnus-newsgroup-limit))
4927 (defun gnus-expunge-thread (thread)
4928 "Mark all articles in THREAD as read."
4929 (let* ((number (mail-header-number (car thread))))
4930 (incf gnus-newsgroup-expunged-tally)
4931 ;; We also mark as read here, if that's wanted.
4932 (setq gnus-newsgroup-unreads
4933 (delq number gnus-newsgroup-unreads))
4934 (if gnus-newsgroup-auto-expire
4935 (push number gnus-newsgroup-expirable)
4936 (push (cons number gnus-low-score-mark)
4937 gnus-newsgroup-reads)))
4938 ;; Go recursively through all subthreads.
4939 (mapcar 'gnus-expunge-thread (cdr thread)))
4941 ;; Summary article oriented commands
4943 (defun gnus-summary-refer-parent-article (n)
4944 "Refer parent article N times.
4945 The difference between N and the number of articles fetched is returned."
4947 (gnus-set-global-variables)
4951 (let* ((header (gnus-summary-article-header))
4953 ;; If we try to find the parent of the currently
4954 ;; displayed article, then we take a look at the actual
4955 ;; References header, since this is slightly more
4956 ;; reliable than the References field we got from the
4958 (if (and (eq (mail-header-number header)
4959 (cdr gnus-article-current))
4960 (equal gnus-newsgroup-name
4961 (car gnus-article-current)))
4963 (set-buffer gnus-original-article-buffer)
4964 (nnheader-narrow-to-headers)
4966 (message-fetch-field "references")
4968 ;; It's not the current article, so we take a bet on
4969 ;; the value we got from the server.
4970 (mail-header-references header))))
4971 (if (setq ref (or ref (mail-header-references header)))
4972 (or (gnus-summary-refer-article (gnus-parent-id ref))
4973 (gnus-message 1 "Couldn't find parent"))
4974 (gnus-message 1 "No references in article %d"
4975 (gnus-summary-article-number))
4978 (gnus-summary-position-point)
4981 (defun gnus-summary-refer-references ()
4982 "Fetch all articles mentioned in the References header.
4983 Return how many articles were fetched."
4985 (gnus-set-global-variables)
4986 (let ((ref (mail-header-references (gnus-summary-article-header)))
4987 (current (gnus-summary-article-number))
4989 ;; For each Message-ID in the References header...
4990 (while (string-match "<[^>]*>" ref)
4992 ;; ... fetch that article.
4993 (gnus-summary-refer-article
4994 (prog1 (match-string 0 ref)
4995 (setq ref (substring ref (match-end 0))))))
4996 (gnus-summary-goto-subject current)
4997 (gnus-summary-position-point)
5000 (defun gnus-summary-refer-article (message-id)
5001 "Fetch an article specified by MESSAGE-ID."
5002 (interactive "sMessage-ID: ")
5003 (when (and (stringp message-id)
5004 (not (zerop (length message-id))))
5005 ;; Construct the correct Message-ID if necessary.
5006 ;; Suggested by tale@pawl.rpi.edu.
5007 (unless (string-match "^<" message-id)
5008 (setq message-id (concat "<" message-id)))
5009 (unless (string-match ">$" message-id)
5010 (setq message-id (concat message-id ">")))
5011 (let* ((header (gnus-id-to-header message-id))
5013 (memq (mail-header-number header)
5014 gnus-newsgroup-sparse))))
5017 ;; The article is present in the buffer, to we just go to it.
5018 (gnus-summary-goto-article
5019 (mail-header-number header) nil header)
5021 (gnus-summary-update-article (mail-header-number header))))
5022 ;; We fetch the article
5023 (let ((gnus-override-method
5024 (and (gnus-news-group-p gnus-newsgroup-name)
5025 gnus-refer-article-method))
5027 ;; Start the special refer-article method, if necessary.
5028 (when (and gnus-refer-article-method
5029 (gnus-news-group-p gnus-newsgroup-name))
5030 (gnus-check-server gnus-refer-article-method))
5031 ;; Fetch the header, and display the article.
5032 (if (setq number (gnus-summary-insert-subject message-id))
5033 (gnus-summary-select-article nil nil nil number)
5034 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
5036 (defun gnus-summary-enter-digest-group (&optional force)
5037 "Enter a digest group based on the current article."
5039 (gnus-set-global-variables)
5040 (gnus-summary-select-article)
5041 (let ((name (format "%s-%d"
5042 (gnus-group-prefixed-name
5043 gnus-newsgroup-name (list 'nndoc ""))
5044 gnus-current-article))
5045 (ogroup gnus-newsgroup-name)
5046 (case-fold-search t)
5047 (buf (current-buffer))
5050 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
5051 (insert-buffer-substring gnus-original-article-buffer)
5053 (goto-char (point-min))
5054 (or (search-forward "\n\n" nil t) (point)))
5055 (goto-char (point-min))
5056 (delete-matching-lines "^\\(Path\\):\\|^From ")
5059 (if (gnus-group-read-ephemeral-group
5060 name `(nndoc ,name (nndoc-address
5062 (nndoc-article-type ,(if force 'digest 'guess))) t)
5063 ;; Make all postings to this group go to the parent group.
5064 (nconc (gnus-info-params (gnus-get-info name))
5065 (list (cons 'to-group ogroup)))
5066 ;; Couldn't select this doc group.
5067 (switch-to-buffer buf)
5068 (gnus-set-global-variables)
5069 (gnus-configure-windows 'summary)
5070 (gnus-message 3 "Article couldn't be entered?"))
5071 (kill-buffer dig))))
5073 (defun gnus-summary-isearch-article (&optional regexp-p)
5074 "Do incremental search forward on the current article.
5075 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
5077 (gnus-set-global-variables)
5078 (gnus-summary-select-article)
5079 (gnus-configure-windows 'article)
5080 (gnus-eval-in-buffer-window gnus-article-buffer
5081 ;;(goto-char (point-min))
5082 (isearch-forward regexp-p)))
5084 (defun gnus-summary-search-article-forward (regexp &optional backward)
5085 "Search for an article containing REGEXP forward.
5086 If BACKWARD, search backward instead."
5089 (format "Search article %s (regexp%s): "
5090 (if current-prefix-arg "backward" "forward")
5091 (if gnus-last-search-regexp
5092 (concat ", default " gnus-last-search-regexp)
5094 current-prefix-arg))
5095 (gnus-set-global-variables)
5096 (if (string-equal regexp "")
5097 (setq regexp (or gnus-last-search-regexp ""))
5098 (setq gnus-last-search-regexp regexp))
5099 (if (gnus-summary-search-article regexp backward)
5100 (gnus-summary-show-thread)
5101 (error "Search failed: \"%s\"" regexp)))
5103 (defun gnus-summary-search-article-backward (regexp)
5104 "Search for an article containing REGEXP backward."
5107 (format "Search article backward (regexp%s): "
5108 (if gnus-last-search-regexp
5109 (concat ", default " gnus-last-search-regexp)
5111 (gnus-summary-search-article-forward regexp 'backward))
5113 (defun gnus-summary-search-article (regexp &optional backward)
5114 "Search for an article containing REGEXP.
5115 Optional argument BACKWARD means do search for backward.
5116 `gnus-select-article-hook' is not called during the search."
5117 (let ((gnus-select-article-hook nil) ;Disable hook.
5118 (gnus-article-display-hook nil)
5119 (gnus-mark-article-hook nil) ;Inhibit marking as read.
5120 (gnus-use-article-prefetch nil)
5123 're-search-backward 're-search-forward))
5124 (sum (current-buffer))
5126 (gnus-save-hidden-threads
5127 (gnus-summary-select-article)
5128 (set-buffer gnus-article-buffer)
5132 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
5134 (re-search-backward regexp nil t)
5135 (re-search-forward regexp nil t))
5136 ;; We found the regexp.
5141 (get-buffer-window (current-buffer))
5145 ;; We didn't find it, so we go to the next article.
5147 (if (not (if backward (gnus-summary-find-prev)
5148 (gnus-summary-find-next)))
5149 ;; No more articles.
5151 ;; Select the next article and adjust point.
5152 (gnus-summary-select-article)
5153 (set-buffer gnus-article-buffer)
5155 (goto-char (if backward (point-max) (point-min))))))
5156 (gnus-message 7 ""))
5157 ;; Return whether we found the regexp.
5158 (when (eq found 'found)
5159 (gnus-summary-show-thread)
5160 (gnus-summary-goto-subject gnus-current-article)
5161 (gnus-summary-position-point)
5164 (defun gnus-summary-find-matching (header regexp &optional backward unread
5166 "Return a list of all articles that match REGEXP on HEADER.
5167 The search stars on the current article and goes forwards unless
5168 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
5169 If UNREAD is non-nil, only unread articles will
5170 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
5171 in the comparisons."
5172 (let ((data (if (eq backward 'all) gnus-newsgroup-data
5173 (gnus-data-find-list
5174 (gnus-summary-article-number) (gnus-data-list backward))))
5175 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
5176 (case-fold-search (not not-case-fold))
5178 (or (fboundp (intern (concat "mail-header-" header)))
5179 (error "%s is not a valid header" header))
5182 (and (or (not unread) ; We want all articles...
5183 (gnus-data-unread-p d)) ; Or just unreads.
5184 (vectorp (gnus-data-header d)) ; It's not a pseudo.
5185 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
5186 (setq articles (cons (gnus-data-number d) articles))) ; Success!
5187 (setq data (cdr data)))
5188 (nreverse articles)))
5190 (defun gnus-summary-execute-command (header regexp command &optional backward)
5191 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
5192 If HEADER is an empty string (or nil), the match is done on the entire
5193 article. If BACKWARD (the prefix) is non-nil, search backward instead."
5195 (list (let ((completion-ignore-case t))
5198 (mapcar (lambda (string) (list string))
5199 '("Number" "Subject" "From" "Lines" "Date"
5200 "Message-ID" "Xref" "References" "Body"))
5201 nil 'require-match))
5202 (read-string "Regexp: ")
5203 (read-key-sequence "Command: ")
5204 current-prefix-arg))
5205 (when (equal header "Body")
5207 (gnus-set-global-variables)
5208 ;; Hidden thread subtrees must be searched as well.
5209 (gnus-summary-show-all-threads)
5210 ;; We don't want to change current point nor window configuration.
5212 (save-window-excursion
5213 (gnus-message 6 "Executing %s..." (key-description command))
5214 ;; We'd like to execute COMMAND interactively so as to give arguments.
5215 (gnus-execute header regexp
5216 `(lambda () (call-interactively ',(key-binding command)))
5218 (gnus-message 6 "Executing %s...done" (key-description command)))))
5220 (defun gnus-summary-beginning-of-article ()
5221 "Scroll the article back to the beginning."
5223 (gnus-set-global-variables)
5224 (gnus-summary-select-article)
5225 (gnus-configure-windows 'article)
5226 (gnus-eval-in-buffer-window gnus-article-buffer
5228 (goto-char (point-min))
5229 (and gnus-break-pages (gnus-narrow-to-page))))
5231 (defun gnus-summary-end-of-article ()
5232 "Scroll to the end of the article."
5234 (gnus-set-global-variables)
5235 (gnus-summary-select-article)
5236 (gnus-configure-windows 'article)
5237 (gnus-eval-in-buffer-window gnus-article-buffer
5239 (goto-char (point-max))
5241 (and gnus-break-pages (gnus-narrow-to-page))))
5243 (defun gnus-summary-show-article (&optional arg)
5244 "Force re-fetching of the current article.
5245 If ARG (the prefix) is non-nil, show the raw article without any
5246 article massaging functions being run."
5248 (gnus-set-global-variables)
5250 ;; Select the article the normal way.
5251 (gnus-summary-select-article nil 'force)
5252 ;; Bind the article treatment functions to nil.
5253 (let ((gnus-have-all-headers t)
5254 gnus-article-display-hook
5255 gnus-article-prepare-hook
5258 (gnus-summary-select-article nil 'force)))
5259 (gnus-summary-goto-subject gnus-current-article)
5260 ; (gnus-configure-windows 'article)
5261 (gnus-summary-position-point))
5263 (defun gnus-summary-verbose-headers (&optional arg)
5264 "Toggle permanent full header display.
5265 If ARG is a positive number, turn header display on.
5266 If ARG is a negative number, turn header display off."
5268 (gnus-set-global-variables)
5269 (gnus-summary-toggle-header arg)
5270 (setq gnus-show-all-headers
5271 (cond ((or (not (numberp arg))
5273 (not gnus-show-all-headers))
5277 (defun gnus-summary-toggle-header (&optional arg)
5278 "Show the headers if they are hidden, or hide them if they are shown.
5279 If ARG is a positive number, show the entire header.
5280 If ARG is a negative number, hide the unwanted header lines."
5282 (gnus-set-global-variables)
5284 (set-buffer gnus-article-buffer)
5285 (let* ((buffer-read-only nil)
5286 (inhibit-point-motion-hooks t)
5287 (hidden (text-property-any
5288 (goto-char (point-min)) (search-forward "\n\n")
5291 (goto-char (point-min))
5292 (when (search-forward "\n\n" nil t)
5293 (delete-region (point-min) (1- (point))))
5294 (goto-char (point-min))
5296 (set-buffer gnus-original-article-buffer)
5297 (goto-char (point-min))
5298 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
5299 (insert-buffer-substring gnus-original-article-buffer 1 e)
5300 (let ((article-inhibit-hiding t))
5301 (run-hooks 'gnus-article-display-hook))
5302 (if (or (not hidden) (and (numberp arg) (< arg 0)))
5303 (gnus-article-hide-headers)))))
5305 (defun gnus-summary-show-all-headers ()
5306 "Make all header lines visible."
5308 (gnus-set-global-variables)
5309 (gnus-article-show-all-headers))
5311 (defun gnus-summary-toggle-mime (&optional arg)
5312 "Toggle MIME processing.
5313 If ARG is a positive number, turn MIME processing on."
5315 (gnus-set-global-variables)
5316 (setq gnus-show-mime
5317 (if (null arg) (not gnus-show-mime)
5318 (> (prefix-numeric-value arg) 0)))
5319 (gnus-summary-select-article t 'force))
5321 (defun gnus-summary-caesar-message (&optional arg)
5322 "Caesar rotate the current article by 13.
5323 The numerical prefix specifies how manu places to rotate each letter
5326 (gnus-set-global-variables)
5327 (gnus-summary-select-article)
5328 (let ((mail-header-separator ""))
5329 (gnus-eval-in-buffer-window gnus-article-buffer
5332 (let ((start (window-start))
5334 (message-caesar-buffer-body arg)
5335 (set-window-start (get-buffer-window (current-buffer)) start))))))
5337 (defun gnus-summary-stop-page-breaking ()
5338 "Stop page breaking in the current article."
5340 (gnus-set-global-variables)
5341 (gnus-summary-select-article)
5342 (gnus-eval-in-buffer-window gnus-article-buffer
5345 (defun gnus-summary-move-article (&optional n to-newsgroup select-method action)
5346 "Move the current article to a different newsgroup.
5347 If N is a positive number, move the N next articles.
5348 If N is a negative number, move the N previous articles.
5349 If N is nil and any articles have been marked with the process mark,
5350 move those articles instead.
5351 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
5352 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
5353 re-spool using this method.
5355 For this function to work, both the current newsgroup and the
5356 newsgroup that you want to move to have to support the `request-move'
5357 and `request-accept' functions."
5359 (unless action (setq action 'move))
5360 (gnus-set-global-variables)
5361 ;; Check whether the source group supports the required functions.
5362 (cond ((and (eq action 'move)
5363 (not (gnus-check-backend-function
5364 'request-move-article gnus-newsgroup-name)))
5365 (error "The current group does not support article moving"))
5366 ((and (eq action 'crosspost)
5367 (not (gnus-check-backend-function
5368 'request-replace-article gnus-newsgroup-name)))
5369 (error "The current group does not support article editing")))
5370 (let ((articles (gnus-summary-work-articles n))
5371 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
5372 (names '((move "Move" "Moving")
5373 (copy "Copy" "Copying")
5374 (crosspost "Crosspost" "Crossposting")))
5375 (copy-buf (save-excursion
5376 (nnheader-set-temp-buffer " *copy article*")))
5377 art-group to-method new-xref article to-groups)
5378 (unless (assq action names)
5379 (error "Unknown action %s" action))
5380 ;; Read the newsgroup name.
5381 (when (and (not to-newsgroup)
5382 (not select-method))
5384 (gnus-read-move-group-name
5385 (cadr (assq action names))
5386 (symbol-value (intern (format "gnus-current-%s-group" action)))
5388 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
5389 (setq to-method (or select-method
5390 (gnus-group-name-to-method to-newsgroup)))
5391 ;; Check the method we are to move this article to...
5392 (or (gnus-check-backend-function 'request-accept-article (car to-method))
5393 (error "%s does not support article copying" (car to-method)))
5394 (or (gnus-check-server to-method)
5395 (error "Can't open server %s" (car to-method)))
5396 (gnus-message 6 "%s to %s: %s..."
5397 (caddr (assq action names))
5398 (or (car select-method) to-newsgroup) articles)
5400 (setq article (pop articles))
5404 ;; Move the article.
5406 (gnus-request-move-article
5407 article ; Article to move
5408 gnus-newsgroup-name ; From newsgrouo
5409 (nth 1 (gnus-find-method-for-group
5410 gnus-newsgroup-name)) ; Server
5411 (list 'gnus-request-accept-article
5412 to-newsgroup (list 'quote select-method)
5413 (not articles)) ; Accept form
5414 (not articles))) ; Only save nov last time
5415 ;; Copy the article.
5418 (set-buffer copy-buf)
5419 (gnus-request-article-this-buffer article gnus-newsgroup-name)
5420 (gnus-request-accept-article
5421 to-newsgroup select-method (not articles))))
5422 ;; Crosspost the article.
5423 ((eq action 'crosspost)
5424 (let ((xref (mail-header-xref (gnus-summary-article-header article))))
5425 (setq new-xref (concat gnus-newsgroup-name ":" article))
5426 (if (and xref (not (string= xref "")))
5428 (when (string-match "^Xref: " xref)
5429 (setq xref (substring xref (match-end 0))))
5430 (setq new-xref (concat xref " " new-xref)))
5431 (setq new-xref (concat (system-name) " " new-xref)))
5433 (set-buffer copy-buf)
5434 (gnus-request-article-this-buffer article gnus-newsgroup-name)
5435 (nnheader-replace-header "xref" new-xref)
5436 (gnus-request-accept-article
5437 to-newsgroup select-method (not articles)))))))
5439 (gnus-message 1 "Couldn't %s article %s"
5440 (cadr (assq action names)) article)
5443 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
5445 (gnus-group-prefixed-name
5448 (gnus-find-method-for-group to-newsgroup)))
5449 gnus-newsrc-hashtb)))
5450 (info (nth 2 entry))
5451 (to-group (gnus-info-group info)))
5452 ;; Update the group that has been moved to.
5454 (memq action '(move copy)))
5455 (unless (member to-group to-groups)
5456 (push to-group to-groups))
5458 (unless (memq article gnus-newsgroup-unreads)
5460 info (gnus-add-to-range (gnus-info-read info)
5461 (list (cdr art-group)))))
5463 ;; Copy any marks over to the new group.
5464 (let ((marks gnus-article-mark-lists)
5465 (to-article (cdr art-group)))
5467 ;; See whether the article is to be put in the cache.
5468 (when gnus-use-cache
5469 (gnus-cache-possibly-enter-article
5471 (let ((header (copy-sequence
5472 (gnus-summary-article-header article))))
5473 (mail-header-set-number header to-article)
5475 (memq article gnus-newsgroup-marked)
5476 (memq article gnus-newsgroup-dormant)
5477 (memq article gnus-newsgroup-unreads)))
5480 (when (memq article (symbol-value
5481 (intern (format "gnus-newsgroup-%s"
5483 ;; If the other group is the same as this group,
5484 ;; then we have to add the mark to the list.
5485 (when (equal to-group gnus-newsgroup-name)
5486 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
5489 (intern (format "gnus-newsgroup-%s"
5491 ;; Copy mark to other group.
5492 (gnus-add-marked-articles
5493 to-group (cdar marks) (list to-article) info))
5494 (setq marks (cdr marks)))))
5496 ;; Update the Xref header in this article to point to
5497 ;; the new crossposted article we have just created.
5498 (when (eq action 'crosspost)
5500 (set-buffer copy-buf)
5501 (gnus-request-article-this-buffer article gnus-newsgroup-name)
5502 (nnheader-replace-header
5503 "xref" (concat new-xref " " (gnus-group-prefixed-name
5504 (car art-group) to-method)
5505 ":" (cdr art-group)))
5506 (gnus-request-replace-article
5507 article gnus-newsgroup-name (current-buffer)))))
5509 (gnus-summary-goto-subject article)
5510 (when (eq action 'move)
5511 (gnus-summary-mark-article article gnus-canceled-mark)))
5512 (gnus-summary-remove-process-mark article))
5513 ;; Re-activate all groups that have been moved to.
5515 (gnus-activate-group (pop to-groups)))
5517 (gnus-kill-buffer copy-buf)
5518 (gnus-summary-position-point)
5519 (gnus-set-mode-line 'summary)))
5521 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
5522 "Move the current article to a different newsgroup.
5523 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
5524 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
5525 re-spool using this method."
5527 (gnus-summary-move-article n nil select-method 'copy))
5529 (defun gnus-summary-crosspost-article (&optional n)
5530 "Crosspost the current article to some other group."
5532 (gnus-summary-move-article n nil nil 'crosspost))
5534 (defvar gnus-summary-respool-default-method nil
5535 "Default method for respooling an article.
5536 If nil, use to the current newsgroup method.")
5538 (defun gnus-summary-respool-article (&optional n method)
5539 "Respool the current article.
5540 The article will be squeezed through the mail spooling process again,
5541 which means that it will be put in some mail newsgroup or other
5542 depending on `nnmail-split-methods'.
5543 If N is a positive number, respool the N next articles.
5544 If N is a negative number, respool the N previous articles.
5545 If N is nil and any articles have been marked with the process mark,
5546 respool those articles instead.
5548 Respooling can be done both from mail groups and \"real\" newsgroups.
5549 In the former case, the articles in question will be moved from the
5550 current group into whatever groups they are destined to. In the
5551 latter case, they will be copied into the relevant groups."
5553 (list current-prefix-arg
5554 (let* ((methods (gnus-methods-using 'respool))
5556 (symbol-name (or gnus-summary-respool-default-method
5557 (car (gnus-find-method-for-group
5558 gnus-newsgroup-name)))))
5560 (gnus-completing-read
5561 methname "What backend do you want to use when respooling?"
5562 methods nil t nil 'gnus-method-history))
5565 ((zerop (length (setq ms (gnus-servers-using-backend method))))
5566 (list (intern method) ""))
5570 (cdr (completing-read
5572 (mapcar (lambda (m) (cons (cadr m) m)) ms) nil t)))))))
5573 (gnus-set-global-variables)
5575 (error "No method given for respooling"))
5576 (if (assoc (symbol-name
5577 (car (gnus-find-method-for-group gnus-newsgroup-name)))
5578 (gnus-methods-using 'respool))
5579 (gnus-summary-move-article n nil method)
5580 (gnus-summary-copy-article n nil method)))
5582 (defun gnus-summary-import-article (file)
5583 "Import a random file into a mail newsgroup."
5584 (interactive "fImport file: ")
5585 (gnus-set-global-variables)
5586 (let ((group gnus-newsgroup-name)
5587 (now (current-time))
5589 (or (gnus-check-backend-function 'request-accept-article group)
5590 (error "%s does not support article importing" group))
5591 (or (file-readable-p file)
5592 (not (file-regular-p file))
5593 (error "Can't read %s" file))
5595 (set-buffer (get-buffer-create " *import file*"))
5596 (buffer-disable-undo (current-buffer))
5598 (insert-file-contents file)
5599 (goto-char (point-min))
5600 (unless (nnheader-article-p)
5601 ;; This doesn't look like an article, so we fudge some headers.
5602 (setq atts (file-attributes file)
5603 lines (count-lines (point-min) (point-max)))
5604 (insert "From: " (read-string "From: ") "\n"
5605 "Subject: " (read-string "Subject: ") "\n"
5606 "Date: " (timezone-make-date-arpa-standard
5607 (current-time-string (nth 5 atts))
5608 (current-time-zone now)
5609 (current-time-zone now)) "\n"
5610 "Message-ID: " (message-make-message-id) "\n"
5611 "Lines: " (int-to-string lines) "\n"
5612 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
5613 (gnus-request-accept-article group nil t)
5614 (kill-buffer (current-buffer)))))
5616 (defun gnus-summary-expire-articles (&optional now)
5617 "Expire all articles that are marked as expirable in the current group."
5619 (gnus-set-global-variables)
5620 (when (gnus-check-backend-function
5621 'request-expire-articles gnus-newsgroup-name)
5622 ;; This backend supports expiry.
5623 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
5624 (expirable (if total
5625 (gnus-list-of-read-articles gnus-newsgroup-name)
5626 (setq gnus-newsgroup-expirable
5627 (sort gnus-newsgroup-expirable '<))))
5628 (expiry-wait (if now 'immediate
5629 (gnus-group-get-parameter
5630 gnus-newsgroup-name 'expiry-wait)))
5633 ;; There are expirable articles in this group, so we run them
5634 ;; through the expiry process.
5635 (gnus-message 6 "Expiring articles...")
5636 ;; The list of articles that weren't expired is returned.
5638 (let ((nnmail-expiry-wait-function nil)
5639 (nnmail-expiry-wait expiry-wait))
5640 (setq es (gnus-request-expire-articles
5641 expirable gnus-newsgroup-name)))
5642 (setq es (gnus-request-expire-articles
5643 expirable gnus-newsgroup-name)))
5644 (or total (setq gnus-newsgroup-expirable es))
5645 ;; We go through the old list of expirable, and mark all
5646 ;; really expired articles as nonexistent.
5647 (unless (eq es expirable) ;If nothing was expired, we don't mark.
5648 (let ((gnus-use-cache nil))
5650 (unless (memq (car expirable) es)
5651 (when (gnus-data-find (car expirable))
5652 (gnus-summary-mark-article
5653 (car expirable) gnus-canceled-mark)))
5654 (setq expirable (cdr expirable)))))
5655 (gnus-message 6 "Expiring articles...done")))))
5657 (defun gnus-summary-expire-articles-now ()
5658 "Expunge all expirable articles in the current group.
5659 This means that *all* articles that are marked as expirable will be
5660 deleted forever, right now."
5662 (gnus-set-global-variables)
5663 (or gnus-expert-user
5665 "Are you really, really, really sure you want to delete all these messages? ")
5667 (gnus-summary-expire-articles t))
5669 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
5670 (defun gnus-summary-delete-article (&optional n)
5671 "Delete the N next (mail) articles.
5672 This command actually deletes articles. This is not a marking
5673 command. The article will disappear forever from your life, never to
5675 If N is negative, delete backwards.
5676 If N is nil and articles have been marked with the process mark,
5677 delete these instead."
5679 (gnus-set-global-variables)
5680 (or (gnus-check-backend-function 'request-expire-articles
5681 gnus-newsgroup-name)
5682 (error "The current newsgroup does not support article deletion."))
5683 ;; Compute the list of articles to delete.
5684 (let ((articles (gnus-summary-work-articles n))
5686 (if (and gnus-novice-user
5688 (format "Do you really want to delete %s forever? "
5689 (if (> (length articles) 1)
5690 (format "these %s articles" (length articles))
5693 ;; Delete the articles.
5694 (setq not-deleted (gnus-request-expire-articles
5695 articles gnus-newsgroup-name 'force))
5697 (gnus-summary-remove-process-mark (car articles))
5698 ;; The backend might not have been able to delete the article
5700 (or (memq (car articles) not-deleted)
5701 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
5702 (setq articles (cdr articles))))
5703 (gnus-summary-position-point)
5704 (gnus-set-mode-line 'summary)
5707 (defun gnus-summary-edit-article (&optional force)
5708 "Edit the current article.
5709 This will have permanent effect only in mail groups.
5710 If FORCE is non-nil, allow editing of articles even in read-only
5714 (set-buffer gnus-summary-buffer)
5715 (gnus-set-global-variables)
5716 (when (and (not force)
5717 (gnus-group-read-only-p))
5718 (error "The current newsgroup does not support article editing."))
5719 ;; Select article if needed.
5720 (unless (eq (gnus-summary-article-number)
5721 gnus-current-article)
5722 (gnus-summary-select-article t))
5723 (gnus-article-edit-article
5725 (gnus-summary-edit-article-done
5726 ,(or (mail-header-references gnus-current-headers) "")
5727 ,(gnus-group-read-only-p) ,gnus-summary-buffer)))))
5729 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
5731 (defun gnus-summary-edit-article-done (references read-only buffer)
5732 "Make edits to the current article permanent."
5734 ;; Replace the article.
5735 (if (and (not read-only)
5736 (not (gnus-request-replace-article
5737 (cdr gnus-article-current) (car gnus-article-current)
5739 (error "Couldn't replace article.")
5740 ;; Update the summary buffer.
5741 (if (equal (message-tokenize-header references " ")
5742 (message-tokenize-header
5743 (or (message-fetch-field "references") "") " "))
5744 ;; We only have to update this line.
5747 (message-narrow-to-head)
5748 (let ((header (nnheader-parse-head t)))
5750 (mail-header-set-number header (cdr gnus-article-current))
5751 (gnus-summary-update-article-line
5752 (cdr gnus-article-current) header))))
5755 (gnus-summary-update-article (cdr gnus-article-current)))
5756 ;; Prettify the article buffer again.
5758 (set-buffer gnus-article-buffer)
5759 (run-hooks 'gnus-article-display-hook))
5760 ;; Prettify the summary buffer line.
5761 (when (gnus-visual-p 'summary-highlight 'highlight)
5762 (run-hooks 'gnus-visual-mark-article-hook))))
5764 (defun gnus-summary-edit-wash (key)
5765 "Perform editing command in the article buffer."
5769 (message "%s" (concat (this-command-keys) "- "))
5772 (gnus-summary-edit-article)
5773 (execute-kbd-macro (concat (this-command-keys) key))
5774 (gnus-article-edit-done))
5778 (defun gnus-summary-respool-query ()
5779 "Query where the respool algorithm would put this article."
5781 (gnus-set-global-variables)
5782 (gnus-summary-select-article)
5784 (set-buffer gnus-article-buffer)
5786 (goto-char (point-min))
5787 (search-forward "\n\n")
5788 (narrow-to-region (point-min) (point))
5790 (list 'quote (mapcar 'car (nnmail-article-group 'identity)))))))
5792 ;; Summary marking commands.
5794 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
5795 "Mark articles which has the same subject as read, and then select the next.
5796 If UNMARK is positive, remove any kind of mark.
5797 If UNMARK is negative, tick articles."
5799 (gnus-set-global-variables)
5801 (setq unmark (prefix-numeric-value unmark)))
5803 (gnus-summary-mark-same-subject
5804 (gnus-summary-article-subject) unmark)))
5805 ;; Select next unread article. If auto-select-same mode, should
5806 ;; select the first unread article.
5807 (gnus-summary-next-article t (and gnus-auto-select-same
5808 (gnus-summary-article-subject)))
5809 (gnus-message 7 "%d article%s marked as %s"
5810 count (if (= count 1) " is" "s are")
5811 (if unmark "unread" "read"))))
5813 (defun gnus-summary-kill-same-subject (&optional unmark)
5814 "Mark articles which has the same subject as read.
5815 If UNMARK is positive, remove any kind of mark.
5816 If UNMARK is negative, tick articles."
5818 (gnus-set-global-variables)
5820 (setq unmark (prefix-numeric-value unmark)))
5822 (gnus-summary-mark-same-subject
5823 (gnus-summary-article-subject) unmark)))
5824 ;; If marked as read, go to next unread subject.
5826 ;; Go to next unread subject.
5827 (gnus-summary-next-subject 1 t))
5828 (gnus-message 7 "%d articles are marked as %s"
5829 count (if unmark "unread" "read"))))
5831 (defun gnus-summary-mark-same-subject (subject &optional unmark)
5832 "Mark articles with same SUBJECT as read, and return marked number.
5833 If optional argument UNMARK is positive, remove any kinds of marks.
5834 If optional argument UNMARK is negative, mark articles as unread instead."
5838 ((null unmark) ; Mark as read.
5841 (gnus-summary-mark-article-as-read gnus-killed-mark)
5842 (gnus-summary-show-thread) t)
5843 (gnus-summary-find-subject subject))
5844 (setq count (1+ count))))
5845 ((> unmark 0) ; Tick.
5848 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
5849 (gnus-summary-show-thread) t)
5850 (gnus-summary-find-subject subject))
5851 (setq count (1+ count))))
5852 (t ; Mark as unread.
5855 (gnus-summary-mark-article-as-unread gnus-unread-mark)
5856 (gnus-summary-show-thread) t)
5857 (gnus-summary-find-subject subject))
5858 (setq count (1+ count)))))
5859 (gnus-set-mode-line 'summary)
5860 ;; Return the number of marked articles.
5863 (defun gnus-summary-mark-as-processable (n &optional unmark)
5864 "Set the process mark on the next N articles.
5865 If N is negative, mark backward instead. If UNMARK is non-nil, remove
5866 the process mark instead. The difference between N and the actual
5867 number of articles marked is returned."
5869 (gnus-set-global-variables)
5870 (let ((backward (< n 0))
5875 (gnus-summary-remove-process-mark
5876 (gnus-summary-article-number))
5877 (gnus-summary-set-process-mark (gnus-summary-article-number)))
5878 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
5880 (if (/= 0 n) (gnus-message 7 "No more articles"))
5881 (gnus-summary-recenter)
5882 (gnus-summary-position-point)
5885 (defun gnus-summary-unmark-as-processable (n)
5886 "Remove the process mark from the next N articles.
5887 If N is negative, mark backward instead. The difference between N and
5888 the actual number of articles marked is returned."
5890 (gnus-set-global-variables)
5891 (gnus-summary-mark-as-processable n t))
5893 (defun gnus-summary-unmark-all-processable ()
5894 "Remove the process mark from all articles."
5896 (gnus-set-global-variables)
5898 (while gnus-newsgroup-processable
5899 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
5900 (gnus-summary-position-point))
5902 (defun gnus-summary-mark-as-expirable (n)
5903 "Mark N articles forward as expirable.
5904 If N is negative, mark backward instead. The difference between N and
5905 the actual number of articles marked is returned."
5907 (gnus-set-global-variables)
5908 (gnus-summary-mark-forward n gnus-expirable-mark))
5910 (defun gnus-summary-mark-article-as-replied (article)
5911 "Mark ARTICLE replied and update the summary line."
5912 (setq gnus-newsgroup-replied (cons article gnus-newsgroup-replied))
5913 (let ((buffer-read-only nil))
5914 (when (gnus-summary-goto-subject article)
5915 (gnus-summary-update-secondary-mark article))))
5917 (defun gnus-summary-set-bookmark (article)
5918 "Set a bookmark in current article."
5919 (interactive (list (gnus-summary-article-number)))
5920 (gnus-set-global-variables)
5921 (if (or (not (get-buffer gnus-article-buffer))
5922 (not gnus-current-article)
5923 (not gnus-article-current)
5924 (not (equal gnus-newsgroup-name (car gnus-article-current))))
5925 (error "No current article selected"))
5926 ;; Remove old bookmark, if one exists.
5927 (let ((old (assq article gnus-newsgroup-bookmarks)))
5928 (if old (setq gnus-newsgroup-bookmarks
5929 (delq old gnus-newsgroup-bookmarks))))
5930 ;; Set the new bookmark, which is on the form
5931 ;; (article-number . line-number-in-body).
5932 (setq gnus-newsgroup-bookmarks
5936 (set-buffer gnus-article-buffer)
5940 (goto-char (point-min))
5941 (search-forward "\n\n" nil t)
5944 gnus-newsgroup-bookmarks))
5945 (gnus-message 6 "A bookmark has been added to the current article."))
5947 (defun gnus-summary-remove-bookmark (article)
5948 "Remove the bookmark from the current article."
5949 (interactive (list (gnus-summary-article-number)))
5950 (gnus-set-global-variables)
5951 ;; Remove old bookmark, if one exists.
5952 (let ((old (assq article gnus-newsgroup-bookmarks)))
5955 (setq gnus-newsgroup-bookmarks
5956 (delq old gnus-newsgroup-bookmarks))
5957 (gnus-message 6 "Removed bookmark."))
5958 (gnus-message 6 "No bookmark in current article."))))
5960 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
5961 (defun gnus-summary-mark-as-dormant (n)
5962 "Mark N articles forward as dormant.
5963 If N is negative, mark backward instead. The difference between N and
5964 the actual number of articles marked is returned."
5966 (gnus-set-global-variables)
5967 (gnus-summary-mark-forward n gnus-dormant-mark))
5969 (defun gnus-summary-set-process-mark (article)
5970 "Set the process mark on ARTICLE and update the summary line."
5971 (setq gnus-newsgroup-processable
5973 (delq article gnus-newsgroup-processable)))
5974 (when (gnus-summary-goto-subject article)
5975 (gnus-summary-show-thread)
5976 (gnus-summary-update-secondary-mark article)))
5978 (defun gnus-summary-remove-process-mark (article)
5979 "Remove the process mark from ARTICLE and update the summary line."
5980 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
5981 (when (gnus-summary-goto-subject article)
5982 (gnus-summary-show-thread)
5983 (gnus-summary-update-secondary-mark article)))
5985 (defun gnus-summary-set-saved-mark (article)
5986 "Set the process mark on ARTICLE and update the summary line."
5987 (push article gnus-newsgroup-saved)
5988 (when (gnus-summary-goto-subject article)
5989 (gnus-summary-update-secondary-mark article)))
5991 (defun gnus-summary-mark-forward (n &optional mark no-expire)
5992 "Mark N articles as read forwards.
5993 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
5994 The difference between N and the actual number of articles marked is
5997 (gnus-set-global-variables)
5998 (let ((backward (< n 0))
5999 (gnus-summary-goto-unread
6000 (and gnus-summary-goto-unread
6001 (not (eq gnus-summary-goto-unread 'never))
6002 (not (memq mark (list gnus-unread-mark
6003 gnus-ticked-mark gnus-dormant-mark)))))
6005 (mark (or mark gnus-del-mark)))
6007 (gnus-summary-mark-article nil mark no-expire)
6008 (zerop (gnus-summary-next-subject
6010 (and gnus-summary-goto-unread
6011 (not (eq gnus-summary-goto-unread 'never)))
6014 (if (/= 0 n) (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
6015 (gnus-summary-recenter)
6016 (gnus-summary-position-point)
6017 (gnus-set-mode-line 'summary)
6020 (defun gnus-summary-mark-article-as-read (mark)
6021 "Mark the current article quickly as read with MARK."
6022 (let ((article (gnus-summary-article-number)))
6023 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
6024 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
6025 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
6026 (setq gnus-newsgroup-reads
6027 (cons (cons article mark) gnus-newsgroup-reads))
6028 ;; Possibly remove from cache, if that is used.
6029 (and gnus-use-cache (gnus-cache-enter-remove-article article))
6030 ;; Allow the backend to change the mark.
6031 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
6032 ;; Check for auto-expiry.
6033 (when (and gnus-newsgroup-auto-expire
6034 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
6035 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
6036 (= mark gnus-ancient-mark)
6037 (= mark gnus-read-mark) (= mark gnus-souped-mark)
6038 (= mark gnus-duplicate-mark)))
6039 (setq mark gnus-expirable-mark)
6040 (push article gnus-newsgroup-expirable))
6041 ;; Set the mark in the buffer.
6042 (gnus-summary-update-mark mark 'unread)
6045 (defun gnus-summary-mark-article-as-unread (mark)
6046 "Mark the current article quickly as unread with MARK."
6047 (let ((article (gnus-summary-article-number)))
6049 (gnus-error 1 "Unmarkable article")
6050 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
6051 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
6052 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
6053 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
6054 (cond ((= mark gnus-ticked-mark)
6055 (push article gnus-newsgroup-marked))
6056 ((= mark gnus-dormant-mark)
6057 (push article gnus-newsgroup-dormant))
6059 (push article gnus-newsgroup-unreads)))
6060 (setq gnus-newsgroup-reads
6061 (delq (assq article gnus-newsgroup-reads)
6062 gnus-newsgroup-reads))
6064 ;; See whether the article is to be put in the cache.
6066 (vectorp (gnus-summary-article-header article))
6068 (gnus-cache-possibly-enter-article
6069 gnus-newsgroup-name article
6070 (gnus-summary-article-header article)
6071 (= mark gnus-ticked-mark)
6072 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
6075 (gnus-summary-update-mark mark 'unread))
6078 (defun gnus-summary-mark-article (&optional article mark no-expire)
6079 "Mark ARTICLE with MARK. MARK can be any character.
6080 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
6081 `??' (dormant) and `?E' (expirable).
6082 If MARK is nil, then the default character `?D' is used.
6083 If ARTICLE is nil, then the article on the current line will be
6085 ;; The mark might be a string.
6087 (setq mark (aref mark 0)))
6088 ;; If no mark is given, then we check auto-expiring.
6089 (and (not no-expire)
6090 gnus-newsgroup-auto-expire
6093 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
6094 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
6095 (= mark gnus-read-mark) (= mark gnus-souped-mark)
6096 (= mark gnus-duplicate-mark))))
6097 (setq mark gnus-expirable-mark))
6098 (let* ((mark (or mark gnus-del-mark))
6099 (article (or article (gnus-summary-article-number))))
6100 (or article (error "No article on current line"))
6101 (if (or (= mark gnus-unread-mark)
6102 (= mark gnus-ticked-mark)
6103 (= mark gnus-dormant-mark))
6104 (gnus-mark-article-as-unread article mark)
6105 (gnus-mark-article-as-read article mark))
6107 ;; See whether the article is to be put in the cache.
6109 (not (= mark gnus-canceled-mark))
6110 (vectorp (gnus-summary-article-header article))
6112 (gnus-cache-possibly-enter-article
6113 gnus-newsgroup-name article
6114 (gnus-summary-article-header article)
6115 (= mark gnus-ticked-mark)
6116 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
6118 (if (gnus-summary-goto-subject article nil t)
6119 (let ((buffer-read-only nil))
6120 (gnus-summary-show-thread)
6122 (gnus-summary-update-mark mark 'unread)
6125 (defun gnus-summary-update-secondary-mark (article)
6126 "Update the secondary (read, process, cache) mark."
6127 (gnus-summary-update-mark
6128 (cond ((memq article gnus-newsgroup-processable)
6130 ((memq article gnus-newsgroup-cached)
6132 ((memq article gnus-newsgroup-replied)
6134 ((memq article gnus-newsgroup-saved)
6136 (t gnus-unread-mark))
6138 (when (gnus-visual-p 'summary-highlight 'highlight)
6139 (run-hooks 'gnus-summary-update-hook))
6142 (defun gnus-summary-update-mark (mark type)
6143 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
6144 (buffer-read-only nil))
6145 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
6146 (and (looking-at "\r") (setq forward (1+ forward)))
6148 (<= (+ forward (point)) (point-max)))
6149 ;; Go to the right position on the line.
6150 (goto-char (+ forward (point)))
6151 ;; Replace the old mark with the new mark.
6152 (subst-char-in-region (point) (1+ (point)) (following-char) mark)
6153 ;; Optionally update the marks by some user rule.
6154 (when (eq type 'unread)
6156 (gnus-data-find (gnus-summary-article-number)) mark)
6157 (gnus-summary-update-line (eq mark gnus-unread-mark))))))
6159 (defun gnus-mark-article-as-read (article &optional mark)
6160 "Enter ARTICLE in the pertinent lists and remove it from others."
6161 ;; Make the article expirable.
6162 (let ((mark (or mark gnus-del-mark)))
6163 (if (= mark gnus-expirable-mark)
6164 (setq gnus-newsgroup-expirable (cons article gnus-newsgroup-expirable))
6165 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
6166 ;; Remove from unread and marked lists.
6167 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
6168 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
6169 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
6170 (push (cons article mark) gnus-newsgroup-reads)
6171 ;; Possibly remove from cache, if that is used.
6172 (when gnus-use-cache
6173 (gnus-cache-enter-remove-article article))))
6175 (defun gnus-mark-article-as-unread (article &optional mark)
6176 "Enter ARTICLE in the pertinent lists and remove it from others."
6177 (let ((mark (or mark gnus-ticked-mark)))
6178 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
6179 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
6180 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
6181 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
6182 (cond ((= mark gnus-ticked-mark)
6183 (push article gnus-newsgroup-marked))
6184 ((= mark gnus-dormant-mark)
6185 (push article gnus-newsgroup-dormant))
6187 (push article gnus-newsgroup-unreads)))
6188 (setq gnus-newsgroup-reads
6189 (delq (assq article gnus-newsgroup-reads)
6190 gnus-newsgroup-reads))))
6192 (defalias 'gnus-summary-mark-as-unread-forward
6193 'gnus-summary-tick-article-forward)
6194 (make-obsolete 'gnus-summary-mark-as-unread-forward
6195 'gnus-summary-tick-article-forward)
6196 (defun gnus-summary-tick-article-forward (n)
6197 "Tick N articles forwards.
6198 If N is negative, tick backwards instead.
6199 The difference between N and the number of articles ticked is returned."
6201 (gnus-summary-mark-forward n gnus-ticked-mark))
6203 (defalias 'gnus-summary-mark-as-unread-backward
6204 'gnus-summary-tick-article-backward)
6205 (make-obsolete 'gnus-summary-mark-as-unread-backward
6206 'gnus-summary-tick-article-backward)
6207 (defun gnus-summary-tick-article-backward (n)
6208 "Tick N articles backwards.
6209 The difference between N and the number of articles ticked is returned."
6211 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
6213 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
6214 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
6215 (defun gnus-summary-tick-article (&optional article clear-mark)
6216 "Mark current article as unread.
6217 Optional 1st argument ARTICLE specifies article number to be marked as unread.
6218 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
6220 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
6223 (defun gnus-summary-mark-as-read-forward (n)
6224 "Mark N articles as read forwards.
6225 If N is negative, mark backwards instead.
6226 The difference between N and the actual number of articles marked is
6229 (gnus-summary-mark-forward n gnus-del-mark t))
6231 (defun gnus-summary-mark-as-read-backward (n)
6232 "Mark the N articles as read backwards.
6233 The difference between N and the actual number of articles marked is
6236 (gnus-summary-mark-forward (- n) gnus-del-mark t))
6238 (defun gnus-summary-mark-as-read (&optional article mark)
6239 "Mark current article as read.
6240 ARTICLE specifies the article to be marked as read.
6241 MARK specifies a string to be inserted at the beginning of the line."
6242 (gnus-summary-mark-article article mark))
6244 (defun gnus-summary-clear-mark-forward (n)
6245 "Clear marks from N articles forward.
6246 If N is negative, clear backward instead.
6247 The difference between N and the number of marks cleared is returned."
6249 (gnus-summary-mark-forward n gnus-unread-mark))
6251 (defun gnus-summary-clear-mark-backward (n)
6252 "Clear marks from N articles backward.
6253 The difference between N and the number of marks cleared is returned."
6255 (gnus-summary-mark-forward (- n) gnus-unread-mark))
6257 (defun gnus-summary-mark-unread-as-read ()
6258 "Intended to be used by `gnus-summary-mark-article-hook'."
6259 (when (memq gnus-current-article gnus-newsgroup-unreads)
6260 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
6262 (defun gnus-summary-mark-read-and-unread-as-read ()
6263 "Intended to be used by `gnus-summary-mark-article-hook'."
6264 (let ((mark (gnus-summary-article-mark)))
6265 (when (or (gnus-unread-mark-p mark)
6266 (gnus-read-mark-p mark))
6267 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
6269 (defun gnus-summary-mark-region-as-read (point mark all)
6270 "Mark all unread articles between point and mark as read.
6271 If given a prefix, mark all articles between point and mark as read,
6272 even ticked and dormant ones."
6273 (interactive "r\nP")
6282 (memq (setq article (gnus-summary-article-number))
6283 gnus-newsgroup-unreads))
6284 (gnus-summary-mark-article article gnus-del-mark))
6286 (gnus-summary-find-next))))))
6288 (defun gnus-summary-mark-below (score mark)
6289 "Mark articles with score less than SCORE with MARK."
6290 (interactive "P\ncMark: ")
6291 (gnus-set-global-variables)
6292 (setq score (if score
6293 (prefix-numeric-value score)
6294 (or gnus-summary-default-score 0)))
6296 (set-buffer gnus-summary-buffer)
6297 (goto-char (point-min))
6300 (and (< (gnus-summary-article-score) score)
6301 (gnus-summary-mark-article nil mark))
6302 (gnus-summary-find-next)))))
6304 (defun gnus-summary-kill-below (&optional score)
6305 "Mark articles with score below SCORE as read."
6307 (gnus-set-global-variables)
6308 (gnus-summary-mark-below score gnus-killed-mark))
6310 (defun gnus-summary-clear-above (&optional score)
6311 "Clear all marks from articles with score above SCORE."
6313 (gnus-set-global-variables)
6314 (gnus-summary-mark-above score gnus-unread-mark))
6316 (defun gnus-summary-tick-above (&optional score)
6317 "Tick all articles with score above SCORE."
6319 (gnus-set-global-variables)
6320 (gnus-summary-mark-above score gnus-ticked-mark))
6322 (defun gnus-summary-mark-above (score mark)
6323 "Mark articles with score over SCORE with MARK."
6324 (interactive "P\ncMark: ")
6325 (gnus-set-global-variables)
6326 (setq score (if score
6327 (prefix-numeric-value score)
6328 (or gnus-summary-default-score 0)))
6330 (set-buffer gnus-summary-buffer)
6331 (goto-char (point-min))
6333 (if (> (gnus-summary-article-score) score)
6334 (gnus-summary-mark-article nil mark))
6336 (gnus-summary-find-next)))))
6338 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
6339 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
6340 (defun gnus-summary-limit-include-expunged (&optional no-error)
6341 "Display all the hidden articles that were expunged for low scores."
6343 (gnus-set-global-variables)
6344 (let ((buffer-read-only nil))
6345 (let ((scored gnus-newsgroup-scored)
6348 (or (gnus-summary-goto-subject (caar scored))
6349 (and (setq h (gnus-summary-article-header (caar scored)))
6350 (< (cdar scored) gnus-summary-expunge-below)
6351 (setq headers (cons h headers))))
6352 (setq scored (cdr scored)))
6354 (when (not no-error)
6355 (error "No expunged articles hidden."))
6356 (goto-char (point-min))
6357 (gnus-summary-prepare-unthreaded (nreverse headers))
6358 (goto-char (point-min))
6359 (gnus-summary-position-point)
6362 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
6363 "Mark all articles not marked as unread in this newsgroup as read.
6364 If prefix argument ALL is non-nil, all articles are marked as read.
6365 If QUIETLY is non-nil, no questions will be asked.
6366 If TO-HERE is non-nil, it should be a point in the buffer. All
6367 articles before this point will be marked as read.
6368 The number of articles marked as read is returned."
6370 (gnus-set-global-variables)
6373 (not gnus-interactive-catchup) ;Without confirmation?
6377 "Mark absolutely all articles as read? "
6378 "Mark all unread articles as read? ")))
6380 (not gnus-newsgroup-adaptive)
6381 (not gnus-newsgroup-auto-expire))
6384 (setq gnus-newsgroup-marked nil
6385 gnus-newsgroup-dormant nil))
6386 (setq gnus-newsgroup-unreads nil))
6387 ;; We actually mark all articles as canceled, which we
6388 ;; have to do when using auto-expiry or adaptive scoring.
6389 (gnus-summary-show-all-threads)
6390 (when (gnus-summary-first-subject (not all))
6392 (if to-here (< (point) to-here) t)
6393 (gnus-summary-mark-article-as-read gnus-catchup-mark)
6394 (gnus-summary-find-next (not all)))))
6396 (setq gnus-newsgroup-unreads nil))
6397 (gnus-set-mode-line 'summary)))
6398 (let ((method (gnus-find-method-for-group gnus-newsgroup-name)))
6399 (when (and (not to-here) (eq 'nnvirtual (car method)))
6400 (nnvirtual-catchup-group
6401 (gnus-group-real-name gnus-newsgroup-name) (nth 1 method) all)))
6402 (gnus-summary-position-point)))
6404 (defun gnus-summary-catchup-to-here (&optional all)
6405 "Mark all unticked articles before the current one as read.
6406 If ALL is non-nil, also mark ticked and dormant articles as read."
6408 (gnus-set-global-variables)
6410 (gnus-save-hidden-threads
6411 (let ((beg (point)))
6412 ;; We check that there are unread articles.
6413 (when (or all (gnus-summary-find-prev))
6414 (gnus-summary-catchup all t beg)))))
6415 (gnus-summary-position-point))
6417 (defun gnus-summary-catchup-all (&optional quietly)
6418 "Mark all articles in this newsgroup as read."
6420 (gnus-set-global-variables)
6421 (gnus-summary-catchup t quietly))
6423 (defun gnus-summary-catchup-and-exit (&optional all quietly)
6424 "Mark all articles not marked as unread in this newsgroup as read, then exit.
6425 If prefix argument ALL is non-nil, all articles are marked as read."
6427 (gnus-set-global-variables)
6428 (gnus-summary-catchup all quietly nil 'fast)
6429 ;; Select next newsgroup or exit.
6430 (if (eq gnus-auto-select-next 'quietly)
6431 (gnus-summary-next-group nil)
6432 (gnus-summary-exit)))
6434 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
6435 "Mark all articles in this newsgroup as read, and then exit."
6437 (gnus-set-global-variables)
6438 (gnus-summary-catchup-and-exit t quietly))
6440 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
6441 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
6442 "Mark all articles in this group as read and select the next group.
6443 If given a prefix, mark all articles, unread as well as ticked, as
6446 (gnus-set-global-variables)
6448 (gnus-summary-catchup all))
6449 (gnus-summary-next-article t nil nil t))
6451 ;; Thread-based commands.
6453 (defun gnus-summary-articles-in-thread (&optional article)
6454 "Return a list of all articles in the current thread.
6455 If ARTICLE is non-nil, return all articles in the thread that starts
6457 (let* ((article (or article (gnus-summary-article-number)))
6458 (data (gnus-data-find-list article))
6459 (top-level (gnus-data-level (car data)))
6461 (cond ((null gnus-thread-operation-ignore-subject)
6462 (gnus-simplify-subject-re
6463 (mail-header-subject (gnus-data-header (car data)))))
6464 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
6465 (gnus-simplify-subject-fuzzy
6466 (mail-header-subject (gnus-data-header (car data)))))
6468 (end-point (save-excursion
6469 (if (gnus-summary-go-to-next-thread)
6470 (point) (point-max))))
6473 (< (gnus-data-pos (car data)) end-point))
6474 (when (or (not top-subject)
6475 (string= top-subject
6476 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
6477 (gnus-simplify-subject-fuzzy
6478 (mail-header-subject
6479 (gnus-data-header (car data))))
6480 (gnus-simplify-subject-re
6481 (mail-header-subject
6482 (gnus-data-header (car data)))))))
6483 (push (gnus-data-number (car data)) articles))
6484 (unless (and (setq data (cdr data))
6485 (> (gnus-data-level (car data)) top-level))
6487 ;; Return the list of articles.
6488 (nreverse articles)))
6490 (defun gnus-summary-rethread-current ()
6491 "Rethread the thread the current article is part of."
6493 (gnus-set-global-variables)
6494 (let* ((gnus-show-threads t)
6495 (article (gnus-summary-article-number))
6496 (id (mail-header-id (gnus-summary-article-header)))
6497 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
6499 (error "No article on the current line"))
6500 (gnus-rebuild-thread id)
6501 (gnus-summary-goto-subject article)))
6503 (defun gnus-summary-reparent-thread ()
6504 "Make current article child of the marked (or previous) article.
6506 Note that the re-threading will only work if `gnus-thread-ignore-subject'
6507 is non-nil or the Subject: of both articles are the same."
6509 (or (not (gnus-group-read-only-p))
6510 (error "The current newsgroup does not support article editing."))
6511 (or (<= (length gnus-newsgroup-processable) 1)
6512 (error "No more than one article may be marked."))
6513 (save-window-excursion
6514 (let ((gnus-article-buffer " *reparent*")
6515 (current-article (gnus-summary-article-number))
6516 ; first grab the marked article, otherwise one line up.
6517 (parent-article (if (not (null gnus-newsgroup-processable))
6518 (car gnus-newsgroup-processable)
6520 (if (eq (forward-line -1) 0)
6521 (gnus-summary-article-number)
6522 (error "Beginning of summary buffer."))))))
6523 (or (not (eq current-article parent-article))
6524 (error "An article may not be self-referential."))
6525 (let ((message-id (mail-header-id
6526 (gnus-summary-article-header parent-article))))
6527 (or (and message-id (not (equal message-id "")))
6528 (error "No message-id in desired parent."))
6529 (gnus-summary-select-article t t nil current-article)
6530 (set-buffer gnus-article-buffer)
6531 (setq buffer-read-only nil)
6532 (let ((buf (format "%s" (buffer-string))))
6535 (goto-char (point-min))
6536 (if (search-forward-regexp "^References: " nil t)
6537 (insert message-id " " )
6538 (insert "References: " message-id "\n"))
6539 (or (gnus-request-replace-article current-article
6540 (car gnus-article-current)
6541 gnus-article-buffer)
6542 (error "Couldn't replace article."))
6543 (set-buffer gnus-summary-buffer)
6544 (gnus-summary-unmark-all-processable)
6545 (gnus-summary-rethread-current)
6546 (gnus-message 3 "Article %d is now the child of article %d."
6547 current-article parent-article)))))
6549 (defun gnus-summary-toggle-threads (&optional arg)
6550 "Toggle showing conversation threads.
6551 If ARG is positive number, turn showing conversation threads on."
6553 (gnus-set-global-variables)
6554 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
6555 (setq gnus-show-threads
6556 (if (null arg) (not gnus-show-threads)
6557 (> (prefix-numeric-value arg) 0)))
6558 (gnus-summary-prepare)
6559 (gnus-summary-goto-subject current)
6560 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
6561 (gnus-summary-position-point)))
6563 (defun gnus-summary-show-all-threads ()
6566 (gnus-set-global-variables)
6568 (let ((buffer-read-only nil))
6569 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
6570 (gnus-summary-position-point))
6572 (defun gnus-summary-show-thread ()
6573 "Show thread subtrees.
6574 Returns nil if no thread was there to be shown."
6576 (gnus-set-global-variables)
6577 (let ((buffer-read-only nil)
6579 ;; first goto end then to beg, to have point at beg after let
6580 (end (progn (end-of-line) (point)))
6581 (beg (progn (beginning-of-line) (point))))
6583 ;; Any hidden lines here?
6584 (search-forward "\r" end t)
6585 (subst-char-in-region beg end ?\^M ?\n t)
6587 (gnus-summary-position-point))))
6589 (defun gnus-summary-hide-all-threads ()
6590 "Hide all thread subtrees."
6592 (gnus-set-global-variables)
6594 (goto-char (point-min))
6595 (gnus-summary-hide-thread)
6596 (while (zerop (gnus-summary-next-thread 1 t))
6597 (gnus-summary-hide-thread)))
6598 (gnus-summary-position-point))
6600 (defun gnus-summary-hide-thread ()
6601 "Hide thread subtrees.
6602 Returns nil if no threads were there to be hidden."
6604 (gnus-set-global-variables)
6605 (let ((buffer-read-only nil)
6607 (article (gnus-summary-article-number)))
6609 ;; Go forward until either the buffer ends or the subthread
6611 (when (and (not (eobp))
6612 (or (zerop (gnus-summary-next-thread 1 t))
6613 (goto-char (point-max))))
6615 (if (and (> (point) start)
6616 (search-backward "\n" start t))
6618 (subst-char-in-region start (point) ?\n ?\^M)
6619 (gnus-summary-goto-subject article))
6622 ;;(gnus-summary-position-point)
6625 (defun gnus-summary-go-to-next-thread (&optional previous)
6626 "Go to the same level (or less) next thread.
6627 If PREVIOUS is non-nil, go to previous thread instead.
6628 Return the article number moved to, or nil if moving was impossible."
6629 (let ((level (gnus-summary-thread-level))
6630 (way (if previous -1 1))
6633 (while (and (not (eobp))
6634 (< level (gnus-summary-thread-level)))
6642 (gnus-summary-article-number)
6645 (defun gnus-summary-go-to-next-thread-old (&optional previous)
6646 "Go to the same level (or less) next thread.
6647 If PREVIOUS is non-nil, go to previous thread instead.
6648 Return the article number moved to, or nil if moving was impossible."
6649 (if (and (eq gnus-summary-make-false-root 'dummy)
6650 (gnus-summary-article-intangible-p))
6651 (let ((beg (point)))
6652 (while (and (zerop (forward-line 1))
6653 (not (gnus-summary-article-intangible-p))
6654 (not (zerop (save-excursion
6655 (gnus-summary-thread-level))))))
6661 (let* ((level (gnus-summary-thread-level))
6662 (article (gnus-summary-article-number))
6663 (data (cdr (gnus-data-find-list article (gnus-data-list previous))))
6666 (if (<= (gnus-data-level (car data)) level)
6667 (setq oart (gnus-data-number (car data))
6669 (setq data (cdr data))))
6671 (gnus-summary-goto-subject oart)))))
6673 (defun gnus-summary-next-thread (n &optional silent)
6674 "Go to the same level next N'th thread.
6675 If N is negative, search backward instead.
6676 Returns the difference between N and the number of skips actually
6679 If SILENT, don't output messages."
6681 (gnus-set-global-variables)
6682 (let ((backward (< n 0))
6686 (gnus-summary-go-to-next-thread backward))
6689 (gnus-summary-position-point))
6690 (when (and (not silent) (/= 0 n))
6691 (gnus-message 7 "No more threads"))
6694 (defun gnus-summary-prev-thread (n)
6695 "Go to the same level previous N'th thread.
6696 Returns the difference between N and the number of skips actually
6699 (gnus-set-global-variables)
6700 (gnus-summary-next-thread (- n)))
6702 (defun gnus-summary-go-down-thread ()
6703 "Go down one level in the current thread."
6704 (let ((children (gnus-summary-article-children)))
6706 (gnus-summary-goto-subject (car children)))))
6708 (defun gnus-summary-go-up-thread ()
6709 "Go up one level in the current thread."
6710 (let ((parent (gnus-summary-article-parent)))
6712 (gnus-summary-goto-subject parent))))
6714 (defun gnus-summary-down-thread (n)
6715 "Go down thread N steps.
6716 If N is negative, go up instead.
6717 Returns the difference between N and how many steps down that were
6720 (gnus-set-global-variables)
6724 (if up (gnus-summary-go-up-thread)
6725 (gnus-summary-go-down-thread)))
6727 (gnus-summary-position-point)
6728 (if (/= 0 n) (gnus-message 7 "Can't go further"))
6731 (defun gnus-summary-up-thread (n)
6732 "Go up thread N steps.
6733 If N is negative, go up instead.
6734 Returns the difference between N and how many steps down that were
6737 (gnus-set-global-variables)
6738 (gnus-summary-down-thread (- n)))
6740 (defun gnus-summary-top-thread ()
6741 "Go to the top of the thread."
6743 (gnus-set-global-variables)
6744 (while (gnus-summary-go-up-thread))
6745 (gnus-summary-article-number))
6747 (defun gnus-summary-kill-thread (&optional unmark)
6748 "Mark articles under current thread as read.
6749 If the prefix argument is positive, remove any kinds of marks.
6750 If the prefix argument is negative, tick articles instead."
6752 (gnus-set-global-variables)
6754 (setq unmark (prefix-numeric-value unmark)))
6755 (let ((articles (gnus-summary-articles-in-thread)))
6757 ;; Expand the thread.
6758 (gnus-summary-show-thread)
6759 ;; Mark all the articles.
6761 (gnus-summary-goto-subject (car articles))
6762 (cond ((null unmark)
6763 (gnus-summary-mark-article-as-read gnus-killed-mark))
6765 (gnus-summary-mark-article-as-unread gnus-unread-mark))
6767 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
6768 (setq articles (cdr articles))))
6769 ;; Hide killed subtrees.
6771 gnus-thread-hide-killed
6772 (gnus-summary-hide-thread))
6773 ;; If marked as read, go to next unread subject.
6775 ;; Go to next unread subject.
6776 (gnus-summary-next-subject 1 t)))
6777 (gnus-set-mode-line 'summary))
6779 ;; Summary sorting commands
6781 (defun gnus-summary-sort-by-number (&optional reverse)
6782 "Sort summary buffer by article number.
6783 Argument REVERSE means reverse order."
6785 (gnus-summary-sort 'number reverse))
6787 (defun gnus-summary-sort-by-author (&optional reverse)
6788 "Sort summary buffer by author name alphabetically.
6789 If case-fold-search is non-nil, case of letters is ignored.
6790 Argument REVERSE means reverse order."
6792 (gnus-summary-sort 'author reverse))
6794 (defun gnus-summary-sort-by-subject (&optional reverse)
6795 "Sort summary buffer by subject alphabetically. `Re:'s are ignored.
6796 If case-fold-search is non-nil, case of letters is ignored.
6797 Argument REVERSE means reverse order."
6799 (gnus-summary-sort 'subject reverse))
6801 (defun gnus-summary-sort-by-date (&optional reverse)
6802 "Sort summary buffer by date.
6803 Argument REVERSE means reverse order."
6805 (gnus-summary-sort 'date reverse))
6807 (defun gnus-summary-sort-by-score (&optional reverse)
6808 "Sort summary buffer by score.
6809 Argument REVERSE means reverse order."
6811 (gnus-summary-sort 'score reverse))
6813 (defun gnus-summary-sort (predicate reverse)
6814 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
6815 (gnus-set-global-variables)
6816 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
6817 (article (intern (format "gnus-article-sort-by-%s" predicate)))
6818 (gnus-thread-sort-functions
6824 (gnus-article-sort-functions
6829 (,article t2 t1)))))
6831 (gnus-summary-prepare-hook nil))
6832 ;; We do the sorting by regenerating the threads.
6833 (gnus-summary-prepare)
6834 ;; Hide subthreads if needed.
6835 (when (and gnus-show-threads gnus-thread-hide-subtree)
6836 (gnus-summary-hide-all-threads))))
6838 ;; Summary saving commands.
6840 (defun gnus-summary-save-article (&optional n not-saved)
6841 "Save the current article using the default saver function.
6842 If N is a positive number, save the N next articles.
6843 If N is a negative number, save the N previous articles.
6844 If N is nil and any articles have been marked with the process mark,
6845 save those articles instead.
6846 The variable `gnus-default-article-saver' specifies the saver function."
6848 (gnus-set-global-variables)
6849 (let ((articles (gnus-summary-work-articles n))
6850 (save-buffer (save-excursion
6851 (nnheader-set-temp-buffer " *Gnus Save*")))
6852 header article file)
6854 (setq header (gnus-summary-article-header
6855 (setq article (pop articles))))
6856 (if (not (vectorp header))
6857 ;; This is a pseudo-article.
6858 (if (assq 'name header)
6859 (gnus-copy-file (cdr (assq 'name header)))
6860 (gnus-message 1 "Article %d is unsaveable" article))
6861 ;; This is a real article.
6862 (save-window-excursion
6863 (gnus-summary-select-article t nil nil article))
6865 (set-buffer save-buffer)
6867 (insert-buffer-substring gnus-original-article-buffer))
6868 (setq file (gnus-article-save save-buffer file))
6869 (gnus-summary-remove-process-mark article)
6871 (gnus-summary-set-saved-mark article))))
6872 (gnus-kill-buffer save-buffer)
6873 (gnus-summary-position-point)
6876 (defun gnus-summary-pipe-output (&optional arg)
6877 "Pipe the current article to a subprocess.
6878 If N is a positive number, pipe the N next articles.
6879 If N is a negative number, pipe the N previous articles.
6880 If N is nil and any articles have been marked with the process mark,
6881 pipe those articles instead."
6883 (gnus-set-global-variables)
6884 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
6885 (gnus-summary-save-article arg t))
6886 (gnus-configure-windows 'pipe))
6888 (defun gnus-summary-save-article-mail (&optional arg)
6889 "Append the current article to an mail file.
6890 If N is a positive number, save the N next articles.
6891 If N is a negative number, save the N previous articles.
6892 If N is nil and any articles have been marked with the process mark,
6893 save those articles instead."
6895 (gnus-set-global-variables)
6896 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
6897 (gnus-summary-save-article arg)))
6899 (defun gnus-summary-save-article-rmail (&optional arg)
6900 "Append the current article to an rmail file.
6901 If N is a positive number, save the N next articles.
6902 If N is a negative number, save the N previous articles.
6903 If N is nil and any articles have been marked with the process mark,
6904 save those articles instead."
6906 (gnus-set-global-variables)
6907 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
6908 (gnus-summary-save-article arg)))
6910 (defun gnus-summary-save-article-file (&optional arg)
6911 "Append the current article to a file.
6912 If N is a positive number, save the N next articles.
6913 If N is a negative number, save the N previous articles.
6914 If N is nil and any articles have been marked with the process mark,
6915 save those articles instead."
6917 (gnus-set-global-variables)
6918 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
6919 (gnus-summary-save-article arg)))
6921 (defun gnus-summary-save-article-body-file (&optional arg)
6922 "Append the current article body to a file.
6923 If N is a positive number, save the N next articles.
6924 If N is a negative number, save the N previous articles.
6925 If N is nil and any articles have been marked with the process mark,
6926 save those articles instead."
6928 (gnus-set-global-variables)
6929 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
6930 (gnus-summary-save-article arg)))
6932 (defun gnus-get-split-value (methods)
6933 "Return a value based on the split METHODS."
6934 (let (split-name method result match)
6937 (set-buffer gnus-original-article-buffer)
6939 (nnheader-narrow-to-headers)
6941 (goto-char (point-min))
6942 (setq method (pop methods))
6943 (setq match (car method))
6946 ;; Regular expression.
6948 (re-search-forward match nil t)
6950 ((gnus-functionp match)
6954 (setq result (funcall match gnus-newsgroup-name))))
6959 (setq result (eval match)))))
6960 (setq split-name (append (cdr method) split-name))
6961 (cond ((stringp result)
6962 (push result split-name))
6964 (setq split-name (append result split-name)))))))))
6967 (defun gnus-read-move-group-name (prompt default articles prefix)
6968 "Read a group name."
6969 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
6970 (minibuffer-confirm-incomplete nil) ; XEmacs
6978 (car (gnus-find-method-for-group
6980 gnus-valid-select-methods))
6981 (push (list (symbol-name g)) group-map)))
6982 gnus-active-hashtb))
6986 (if (> (length articles) 1)
6987 (format "these %d articles" (length articles))
6992 (gnus-completing-read default prom
6993 group-map nil nil prefix
6994 'gnus-group-history))
6995 ((= 1 (length split-name))
6996 (gnus-completing-read (car split-name) prom group-map
6998 'gnus-group-history))
7000 (gnus-completing-read nil prom
7001 (mapcar (lambda (el) (list el))
7002 (nreverse split-name))
7004 'gnus-group-history)))))
7006 (if (or (string= to-newsgroup "")
7007 (string= to-newsgroup prefix))
7008 (setq to-newsgroup (or default "")))
7009 (or (gnus-active to-newsgroup)
7010 (gnus-activate-group to-newsgroup)
7011 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
7013 (or (and (gnus-request-create-group
7014 to-newsgroup (gnus-group-name-to-method to-newsgroup))
7015 (gnus-activate-group to-newsgroup nil nil
7016 (gnus-group-name-to-method
7018 (error "Couldn't create group %s" to-newsgroup)))
7019 (error "No such group: %s" to-newsgroup)))
7022 ;; Summary extract commands
7024 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
7025 (let ((buffer-read-only nil)
7026 (article (gnus-summary-article-number))
7028 (or (gnus-summary-goto-subject article)
7029 (error (format "No such article: %d" article)))
7030 (gnus-summary-position-point)
7031 ;; If all commands are to be bunched up on one line, we collect
7033 (if gnus-view-pseudos-separately
7035 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
7038 (setq action (cdr (assq 'action (car ps))))
7039 (setq files (list (cdr (assq 'name (car ps)))))
7040 (while (and ps (cdr ps)
7041 (string= (or action "1")
7042 (or (cdr (assq 'action (cadr ps))) "2")))
7043 (setq files (cons (cdr (assq 'name (cadr ps))) files))
7044 (setcdr ps (cddr ps)))
7047 (if (not (string-match "%s" action))
7048 (setq files (cons " " files)))
7049 (setq files (cons " " files))
7050 (and (assq 'execute (car ps))
7051 (setcdr (assq 'execute (car ps))
7052 (funcall (if (string-match "%s" action)
7055 (mapconcat (lambda (f) f) files " ")))))
7056 (setq ps (cdr ps)))))
7057 (if (and gnus-view-pseudos (not not-view))
7059 (and (assq 'execute (car pslist))
7060 (gnus-execute-command (cdr (assq 'execute (car pslist)))
7061 (eq gnus-view-pseudos 'not-confirm)))
7062 (setq pslist (cdr pslist)))
7065 (setq after-article (or (cdr (assq 'article (car pslist)))
7066 (gnus-summary-article-number)))
7067 (gnus-summary-goto-subject after-article)
7070 (insert " " (file-name-nondirectory
7071 (cdr (assq 'name (car pslist))))
7072 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
7074 (forward-line -1) ; back to `b'
7075 (gnus-add-text-properties
7076 b (1- e) (list 'gnus-number gnus-reffed-article-number
7077 gnus-mouse-face-prop gnus-mouse-face))
7079 after-article gnus-reffed-article-number
7080 gnus-unread-mark b (car pslist) 0 (- e b))
7081 (push gnus-reffed-article-number gnus-newsgroup-unreads)
7082 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
7083 (setq pslist (cdr pslist)))))))
7085 (defun gnus-pseudos< (p1 p2)
7086 (let ((c1 (cdr (assq 'action p1)))
7087 (c2 (cdr (assq 'action p2))))
7088 (and c1 c2 (string< c1 c2))))
7090 (defun gnus-request-pseudo-article (props)
7091 (cond ((assq 'execute props)
7092 (gnus-execute-command (cdr (assq 'execute props)))))
7093 (let ((gnus-current-article (gnus-summary-article-number)))
7094 (run-hooks 'gnus-mark-article-hook)))
7096 (defun gnus-execute-command (command &optional automatic)
7098 (gnus-article-setup-buffer)
7099 (set-buffer gnus-article-buffer)
7100 (setq buffer-read-only nil)
7101 (let ((command (if automatic command (read-string "Command: " command)))
7102 ;; Just binding this here doesn't help, because there might
7103 ;; be output from the process after exiting the scope of
7105 ;; (buffer-read-only nil)
7108 (insert "$ " command "\n\n")
7109 (if gnus-view-pseudo-asynchronously
7110 (start-process "gnus-execute" nil shell-file-name
7111 shell-command-switch command)
7112 (call-process shell-file-name nil t nil
7113 shell-command-switch command)))))
7115 ;; Summary kill commands.
7117 (defun gnus-summary-edit-global-kill (article)
7118 "Edit the \"global\" kill file."
7119 (interactive (list (gnus-summary-article-number)))
7120 (gnus-set-global-variables)
7121 (gnus-group-edit-global-kill article))
7123 (defun gnus-summary-edit-local-kill ()
7124 "Edit a local kill file applied to the current newsgroup."
7126 (gnus-set-global-variables)
7127 (setq gnus-current-headers (gnus-summary-article-header))
7128 (gnus-set-global-variables)
7129 (gnus-group-edit-local-kill
7130 (gnus-summary-article-number) gnus-newsgroup-name))
7134 (defun gnus-read-header (id &optional header)
7135 "Read the headers of article ID and enter them into the Gnus system."
7136 (let ((group gnus-newsgroup-name)
7137 (gnus-override-method
7138 (and (gnus-news-group-p gnus-newsgroup-name)
7139 gnus-refer-article-method))
7141 ;; First we check to see whether the header in question is already
7144 ;; This is a Message-ID.
7145 (setq header (or header (gnus-id-to-header id)))
7146 ;; This is an article number.
7147 (setq header (or header (gnus-summary-article-header id))))
7149 (not (memq (mail-header-number header) gnus-newsgroup-sparse)))
7150 ;; We have found the header.
7152 ;; We have to really fetch the header to this article.
7153 (when (setq where (gnus-request-head id group))
7155 (set-buffer nntp-server-buffer)
7156 (goto-char (point-max))
7158 (goto-char (point-min))
7162 ((cdr where) (cdr where))
7163 (header (mail-header-number header))
7164 (t gnus-reffed-article-number))
7166 (insert " Article retrieved.\n"))
7168 ; (memq (mail-header-number header) gnus-newsgroup-sparse))
7169 ; (setcar (gnus-id-to-thread id) nil))
7170 (if (not (setq header (car (gnus-get-newsgroup-headers))))
7171 () ; Malformed head.
7172 (unless (memq (mail-header-number header) gnus-newsgroup-sparse)
7173 (if (and (stringp id)
7174 (not (string= (gnus-group-real-name group)
7176 ;; If we fetched by Message-ID and the article came
7177 ;; from a different group, we fudge some bogus article
7178 ;; numbers for this article.
7179 (mail-header-set-number header gnus-reffed-article-number))
7180 (decf gnus-reffed-article-number)
7181 (gnus-remove-header (mail-header-number header))
7182 (push header gnus-newsgroup-headers)
7183 (setq gnus-current-headers header)
7184 (push (mail-header-number header) gnus-newsgroup-limit))
7187 (defun gnus-remove-header (number)
7188 "Remove header NUMBER from `gnus-newsgroup-headers'."
7189 (if (and gnus-newsgroup-headers
7190 (= number (mail-header-number (car gnus-newsgroup-headers))))
7191 (pop gnus-newsgroup-headers)
7192 (let ((headers gnus-newsgroup-headers))
7193 (while (and (cdr headers)
7194 (not (= number (mail-header-number (cadr headers)))))
7197 (setcdr headers (cddr headers))))))
7201 ;;; gnus-sum.el ends here