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-menu-hook nil
361 "*Hook run after the creation of the summary mode menu.")
363 (defvar gnus-summary-exit-hook nil
364 "*A hook called on exit from the summary buffer.")
366 (defvar gnus-summary-prepare-hook nil
367 "*A hook called after the summary buffer has been generated.
368 If you want to modify the summary buffer, you can use this hook.")
370 (defvar gnus-summary-generate-hook nil
371 "*A hook run just before generating the summary buffer.
372 This hook is commonly used to customize threading variables and the
375 (defvar gnus-select-group-hook nil
376 "*A hook called when a newsgroup is selected.
378 If you'd like to simplify subjects like the
379 `gnus-summary-next-same-subject' command does, you can use the
382 (setq gnus-select-group-hook
385 (mapcar (lambda (header)
386 (mail-header-set-subject
388 (gnus-simplify-subject
389 (mail-header-subject header) 're-only)))
390 gnus-newsgroup-headers))))")
392 (defvar gnus-select-article-hook nil
393 "*A hook called when an article is selected.")
395 (defvar gnus-visual-mark-article-hook
396 (list 'gnus-highlight-selected-summary)
397 "*Hook run after selecting an article in the summary buffer.
398 It is meant to be used for highlighting the article in some way. It
399 is not run if `gnus-visual' is nil.")
401 (defvar gnus-parse-headers-hook nil
402 "*A hook called before parsing the headers.")
403 (add-hook 'gnus-parse-headers-hook 'gnus-decode-rfc1522)
405 (defvar gnus-exit-group-hook nil
406 "*A hook called when exiting (not quitting) summary mode.")
408 (defvar gnus-summary-update-hook
409 (list 'gnus-summary-highlight-line)
410 "*A hook called when a summary line is changed.
411 The hook will not be called if `gnus-visual' is nil.
413 The default function `gnus-summary-highlight-line' will
414 highlight the line according to the `gnus-summary-highlight'
417 (defvar gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
418 "*A hook called when an article is selected for the first time.
419 The hook is intended to mark an article as read (or unread)
420 automatically when it is selected.")
422 (defvar gnus-group-no-more-groups-hook nil
423 "*A hook run when returning to group mode having no more (unread) groups.")
425 ;;; Internal variables
427 (defvar gnus-scores-exclude-files nil)
429 (defvar gnus-summary-display-table
430 ;; Change the display table. Odd characters have a tendency to mess
431 ;; up nicely formatted displays - we make all possible glyphs
432 ;; display only a single character.
434 ;; We start from the standard display table, if any.
435 (let ((table (or (copy-sequence standard-display-table)
436 (make-display-table)))
437 ;; Nix out all the control chars...
439 (while (>= (setq i (1- i)) 0)
441 ;; ... but not newline and cr, of course. (cr is necessary for the
442 ;; selective display).
445 ;; We nix out any glyphs over 126 that are not set already.
447 (while (>= (setq i (1- i)) 127)
448 ;; Only modify if the entry is nil.
450 (aset table i [??]))))
452 "Display table used in summary mode buffers.")
454 (defvar gnus-original-article nil)
455 (defvar gnus-article-internal-prepare-hook nil)
456 (defvar gnus-newsgroup-process-stack nil)
458 (defvar gnus-thread-indent-array nil)
459 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
461 ;; Avoid highlighting in kill files.
462 (defvar gnus-summary-inhibit-highlight nil)
463 (defvar gnus-newsgroup-selected-overlay nil)
464 (defvar gnus-inhibit-limiting nil)
465 (defvar gnus-newsgroup-adaptive-score-file nil)
466 (defvar gnus-current-score-file nil)
467 (defvar gnus-current-move-group nil)
468 (defvar gnus-current-copy-group nil)
469 (defvar gnus-current-crosspost-group nil)
471 (defvar gnus-newsgroup-dependencies nil)
472 (defvar gnus-newsgroup-adaptive nil)
473 (defvar gnus-summary-display-article-function nil)
474 (defvar gnus-summary-highlight-line-function nil
475 "Function called after highlighting a summary line.")
477 (defvar gnus-summary-line-format-alist
478 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
479 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
480 (?s gnus-tmp-subject-or-nil ?s)
481 (?n gnus-tmp-name ?s)
482 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
484 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
486 (?F gnus-tmp-from ?s)
487 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
488 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
489 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
490 (?o (gnus-date-iso8601 gnus-tmp-header) ?s)
491 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
492 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
493 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
494 (?L gnus-tmp-lines ?d)
495 (?I gnus-tmp-indentation ?s)
496 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
497 (?R gnus-tmp-replied ?c)
498 (?\[ gnus-tmp-opening-bracket ?c)
499 (?\] gnus-tmp-closing-bracket ?c)
500 (?\> (make-string gnus-tmp-level ? ) ?s)
501 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
502 (?i gnus-tmp-score ?d)
503 (?z gnus-tmp-score-char ?c)
504 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
505 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
506 (?U gnus-tmp-unread ?c)
507 (?t (gnus-summary-number-of-articles-in-thread
508 (and (boundp 'thread) (car thread)) gnus-tmp-level)
510 (?e (gnus-summary-number-of-articles-in-thread
511 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
513 (?u gnus-tmp-user-defined ?s)
514 (?P (gnus-pick-line-number) ?d))
515 "An alist of format specifications that can appear in summary lines,
516 and what variables they correspond with, along with the type of the
517 variable (string, integer, character, etc).")
519 (defvar gnus-summary-dummy-line-format-alist
520 `((?S gnus-tmp-subject ?s)
521 (?N gnus-tmp-number ?d)
522 (?u gnus-tmp-user-defined ?s)))
524 (defvar gnus-summary-mode-line-format-alist
525 `((?G gnus-tmp-group-name ?s)
526 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
527 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
528 (?A gnus-tmp-article-number ?d)
529 (?Z gnus-tmp-unread-and-unselected ?s)
531 (?U gnus-tmp-unread-and-unticked ?d)
532 (?S gnus-tmp-subject ?s)
533 (?e gnus-tmp-unselected ?d)
534 (?u gnus-tmp-user-defined ?s)
535 (?d (length gnus-newsgroup-dormant) ?d)
536 (?t (length gnus-newsgroup-marked) ?d)
537 (?r (length gnus-newsgroup-reads) ?d)
538 (?E gnus-newsgroup-expunged-tally ?d)
539 (?s (gnus-current-score-file-nondirectory) ?s)))
541 (defvar gnus-last-search-regexp nil
542 "Default regexp for article search command.")
544 (defvar gnus-last-shell-command nil
545 "Default shell command on article.")
547 (defvar gnus-newsgroup-begin nil)
548 (defvar gnus-newsgroup-end nil)
549 (defvar gnus-newsgroup-last-rmail nil)
550 (defvar gnus-newsgroup-last-mail nil)
551 (defvar gnus-newsgroup-last-folder nil)
552 (defvar gnus-newsgroup-last-file nil)
553 (defvar gnus-newsgroup-auto-expire nil)
554 (defvar gnus-newsgroup-active nil)
556 (defvar gnus-newsgroup-data nil)
557 (defvar gnus-newsgroup-data-reverse nil)
558 (defvar gnus-newsgroup-limit nil)
559 (defvar gnus-newsgroup-limits nil)
561 (defvar gnus-newsgroup-unreads nil
562 "List of unread articles in the current newsgroup.")
564 (defvar gnus-newsgroup-unselected nil
565 "List of unselected unread articles in the current newsgroup.")
567 (defvar gnus-newsgroup-reads nil
568 "Alist of read articles and article marks in the current newsgroup.")
570 (defvar gnus-newsgroup-expunged-tally nil)
572 (defvar gnus-newsgroup-marked nil
573 "List of ticked articles in the current newsgroup (a subset of unread art).")
575 (defvar gnus-newsgroup-killed nil
576 "List of ranges of articles that have been through the scoring process.")
578 (defvar gnus-newsgroup-cached nil
579 "List of articles that come from the article cache.")
581 (defvar gnus-newsgroup-saved nil
582 "List of articles that have been saved.")
584 (defvar gnus-newsgroup-kill-headers nil)
586 (defvar gnus-newsgroup-replied nil
587 "List of articles that have been replied to in the current newsgroup.")
589 (defvar gnus-newsgroup-expirable nil
590 "List of articles in the current newsgroup that can be expired.")
592 (defvar gnus-newsgroup-processable nil
593 "List of articles in the current newsgroup that can be processed.")
595 (defvar gnus-newsgroup-bookmarks nil
596 "List of articles in the current newsgroup that have bookmarks.")
598 (defvar gnus-newsgroup-dormant nil
599 "List of dormant articles in the current newsgroup.")
601 (defvar gnus-newsgroup-scored nil
602 "List of scored articles in the current newsgroup.")
604 (defvar gnus-newsgroup-headers nil
605 "List of article headers in the current newsgroup.")
607 (defvar gnus-newsgroup-threads nil)
609 (defvar gnus-newsgroup-prepared nil
610 "Whether the current group has been prepared properly.")
612 (defvar gnus-newsgroup-ancient nil
613 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
615 (defvar gnus-newsgroup-sparse nil)
617 (defvar gnus-current-article nil)
618 (defvar gnus-article-current nil)
619 (defvar gnus-current-headers nil)
620 (defvar gnus-have-all-headers nil)
621 (defvar gnus-last-article nil)
622 (defvar gnus-newsgroup-history nil)
624 (defconst gnus-summary-local-variables
625 '(gnus-newsgroup-name
626 gnus-newsgroup-begin gnus-newsgroup-end
627 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
628 gnus-newsgroup-last-folder gnus-newsgroup-last-file
629 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
630 gnus-newsgroup-unselected gnus-newsgroup-marked
631 gnus-newsgroup-reads gnus-newsgroup-saved
632 gnus-newsgroup-replied gnus-newsgroup-expirable
633 gnus-newsgroup-processable gnus-newsgroup-killed
634 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
635 gnus-newsgroup-headers gnus-newsgroup-threads
636 gnus-newsgroup-prepared gnus-summary-highlight-line-function
637 gnus-current-article gnus-current-headers gnus-have-all-headers
638 gnus-last-article gnus-article-internal-prepare-hook
639 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
640 gnus-newsgroup-scored gnus-newsgroup-kill-headers
641 gnus-thread-expunge-below
642 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
643 (gnus-summary-mark-below . global)
644 gnus-newsgroup-active gnus-scores-exclude-files
645 gnus-newsgroup-history gnus-newsgroup-ancient
646 gnus-newsgroup-sparse gnus-newsgroup-process-stack
647 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
648 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
649 (gnus-newsgroup-expunged-tally . 0)
650 gnus-cache-removable-articles gnus-newsgroup-cached
651 gnus-newsgroup-data gnus-newsgroup-data-reverse
652 gnus-newsgroup-limit gnus-newsgroup-limits)
653 "Variables that are buffer-local to the summary buffers.")
655 ;; Byte-compiler warning.
656 (defvar gnus-article-mode-map)
658 ;; Subject simplification.
660 (defsubst gnus-simplify-subject-re (subject)
661 "Remove \"Re:\" from subject lines."
662 (if (string-match "^[Rr][Ee]: *" subject)
663 (substring subject (match-end 0))
666 (defun gnus-simplify-subject (subject &optional re-only)
667 "Remove `Re:' and words in parentheses.
668 If RE-ONLY is non-nil, strip leading `Re:'s only."
669 (let ((case-fold-search t)) ;Ignore case.
670 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
671 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
672 (setq subject (substring subject (match-end 0))))
673 ;; Remove uninteresting prefixes.
674 (if (and (not re-only)
675 gnus-simplify-ignored-prefixes
676 (string-match gnus-simplify-ignored-prefixes subject))
677 (setq subject (substring subject (match-end 0))))
678 ;; Remove words in parentheses from end.
680 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
681 (setq subject (substring subject 0 (match-beginning 0)))))
682 ;; Return subject string.
685 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
687 ;; Written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
688 (defun gnus-simplify-buffer-fuzzy ()
689 (let ((case-fold-search t))
690 (goto-char (point-min))
691 (while (search-forward "\t" nil t)
692 (replace-match " " t t))
693 (goto-char (point-min))
694 (re-search-forward "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *" nil t)
695 (goto-char (match-beginning 0))
697 (looking-at "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
698 (looking-at "^[[].*: .*[]]$"))
699 (goto-char (point-min))
700 (while (re-search-forward "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *"
702 (replace-match "" t t))
703 (goto-char (point-min))
704 (while (re-search-forward "^[[].*: .*[]]$" nil t)
705 (goto-char (match-end 0))
708 (progn (goto-char (match-beginning 0)))
709 (re-search-forward ":"))))
710 (goto-char (point-min))
711 (while (re-search-forward " *[[{(][^()\n]*[]})] *$" nil t)
712 (replace-match "" t t))
713 (goto-char (point-min))
714 (while (re-search-forward " +" nil t)
715 (replace-match " " t t))
716 (goto-char (point-min))
717 (while (re-search-forward " $" nil t)
718 (replace-match "" t t))
719 (goto-char (point-min))
720 (while (re-search-forward "^ +" nil t)
721 (replace-match "" t t))
722 (goto-char (point-min))
723 (when gnus-simplify-subject-fuzzy-regexp
724 (if (listp gnus-simplify-subject-fuzzy-regexp)
725 (let ((list gnus-simplify-subject-fuzzy-regexp))
727 (goto-char (point-min))
728 (while (re-search-forward (car list) nil t)
729 (replace-match "" t t))
730 (setq list (cdr list))))
731 (while (re-search-forward gnus-simplify-subject-fuzzy-regexp nil t)
732 (replace-match "" t t))))))
734 (defun gnus-simplify-subject-fuzzy (subject)
735 "Siplify a subject string fuzzily."
737 (gnus-set-work-buffer)
738 (let ((case-fold-search t))
740 (inline (gnus-simplify-buffer-fuzzy))
743 (defsubst gnus-simplify-subject-fully (subject)
744 "Simplify a subject string according to the user's wishes."
746 ((null gnus-summary-gather-subject-limit)
747 (gnus-simplify-subject-re subject))
748 ((eq gnus-summary-gather-subject-limit 'fuzzy)
749 (gnus-simplify-subject-fuzzy subject))
750 ((numberp gnus-summary-gather-subject-limit)
751 (gnus-limit-string (gnus-simplify-subject-re subject)
752 gnus-summary-gather-subject-limit))
756 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
757 "Check whether two subjects are equal. If optional argument
758 simple-first is t, first argument is already simplified."
761 (equal (gnus-simplify-subject-fully s1)
762 (gnus-simplify-subject-fully s2)))
765 (gnus-simplify-subject-fully s2)))))
767 (defun gnus-offer-save-summaries ()
768 "Offer to save all active summary buffers."
770 (let ((buflist (buffer-list))
772 ;; Go through all buffers and find all summaries.
774 (and (setq bufname (buffer-name (car buflist)))
775 (string-match "Summary" bufname)
778 ;; We check that this is, indeed, a summary buffer.
779 (and (eq major-mode 'gnus-summary-mode)
780 ;; Also make sure this isn't bogus.
781 gnus-newsgroup-prepared))
782 (push bufname buffers))
783 (setq buflist (cdr buflist)))
784 ;; Go through all these summary buffers and offer to save them.
787 "Update summary buffer %s? "
788 (lambda (buf) (set-buffer buf) (gnus-summary-exit))
791 (defun gnus-summary-bubble-group ()
792 "Increase the score of the current group.
793 This is a handy function to add to `gnus-summary-exit-hook' to
794 increase the score of each group you read."
795 (gnus-group-add-score gnus-newsgroup-name))
799 ;;; Gnus summary mode
802 (put 'gnus-summary-mode 'mode-class 'special)
805 ;; Non-orthogonal keys
807 (gnus-define-keys gnus-summary-mode-map
808 " " gnus-summary-next-page
809 "\177" gnus-summary-prev-page
810 [delete] gnus-summary-prev-page
811 "\r" gnus-summary-scroll-up
812 "n" gnus-summary-next-unread-article
813 "p" gnus-summary-prev-unread-article
814 "N" gnus-summary-next-article
815 "P" gnus-summary-prev-article
816 "\M-\C-n" gnus-summary-next-same-subject
817 "\M-\C-p" gnus-summary-prev-same-subject
818 "\M-n" gnus-summary-next-unread-subject
819 "\M-p" gnus-summary-prev-unread-subject
820 "." gnus-summary-first-unread-article
821 "," gnus-summary-best-unread-article
822 "\M-s" gnus-summary-search-article-forward
823 "\M-r" gnus-summary-search-article-backward
824 "<" gnus-summary-beginning-of-article
825 ">" gnus-summary-end-of-article
826 "j" gnus-summary-goto-article
827 "^" gnus-summary-refer-parent-article
828 "\M-^" gnus-summary-refer-article
829 "u" gnus-summary-tick-article-forward
830 "!" gnus-summary-tick-article-forward
831 "U" gnus-summary-tick-article-backward
832 "d" gnus-summary-mark-as-read-forward
833 "D" gnus-summary-mark-as-read-backward
834 "E" gnus-summary-mark-as-expirable
835 "\M-u" gnus-summary-clear-mark-forward
836 "\M-U" gnus-summary-clear-mark-backward
837 "k" gnus-summary-kill-same-subject-and-select
838 "\C-k" gnus-summary-kill-same-subject
839 "\M-\C-k" gnus-summary-kill-thread
840 "\M-\C-l" gnus-summary-lower-thread
841 "e" gnus-summary-edit-article
842 "#" gnus-summary-mark-as-processable
843 "\M-#" gnus-summary-unmark-as-processable
844 "\M-\C-t" gnus-summary-toggle-threads
845 "\M-\C-s" gnus-summary-show-thread
846 "\M-\C-h" gnus-summary-hide-thread
847 "\M-\C-f" gnus-summary-next-thread
848 "\M-\C-b" gnus-summary-prev-thread
849 "\M-\C-u" gnus-summary-up-thread
850 "\M-\C-d" gnus-summary-down-thread
851 "&" gnus-summary-execute-command
852 "c" gnus-summary-catchup-and-exit
853 "\C-w" gnus-summary-mark-region-as-read
854 "\C-t" gnus-summary-toggle-truncation
855 "?" gnus-summary-mark-as-dormant
856 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
857 "\C-c\C-s\C-n" gnus-summary-sort-by-number
858 "\C-c\C-s\C-a" gnus-summary-sort-by-author
859 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
860 "\C-c\C-s\C-d" gnus-summary-sort-by-date
861 "\C-c\C-s\C-i" gnus-summary-sort-by-score
862 "=" gnus-summary-expand-window
863 "\C-x\C-s" gnus-summary-reselect-current-group
864 "\M-g" gnus-summary-rescan-group
865 "w" gnus-summary-stop-page-breaking
866 "\C-c\C-r" gnus-summary-caesar-message
867 "\M-t" gnus-summary-toggle-mime
868 "f" gnus-summary-followup
869 "F" gnus-summary-followup-with-original
870 "C" gnus-summary-cancel-article
871 "r" gnus-summary-reply
872 "R" gnus-summary-reply-with-original
873 "\C-c\C-f" gnus-summary-mail-forward
874 "o" gnus-summary-save-article
875 "\C-o" gnus-summary-save-article-mail
876 "|" gnus-summary-pipe-output
877 "\M-k" gnus-summary-edit-local-kill
878 "\M-K" gnus-summary-edit-global-kill
880 "\C-c\C-d" gnus-summary-describe-group
881 "q" gnus-summary-exit
882 "Q" gnus-summary-exit-no-update
883 "\C-c\C-i" gnus-info-find-node
884 gnus-mouse-2 gnus-mouse-pick-article
885 "m" gnus-summary-mail-other-window
886 "a" gnus-summary-post-news
887 "x" gnus-summary-limit-to-unread
888 "s" gnus-summary-isearch-article
889 "t" gnus-article-hide-headers
890 "g" gnus-summary-show-article
891 "l" gnus-summary-goto-last-article
892 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
893 "\C-d" gnus-summary-enter-digest-group
894 "\M-\C-d" gnus-summary-read-document
896 "*" gnus-cache-enter-article
897 "\M-*" gnus-cache-remove-article
898 "\M-&" gnus-summary-universal-argument
900 "I" gnus-summary-increase-score
901 "L" gnus-summary-lower-score
903 "V" gnus-summary-score-map
904 "X" gnus-uu-extract-map
905 "S" gnus-summary-send-map)
907 ;; Sort of orthogonal keymap
908 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
909 "t" gnus-summary-tick-article-forward
910 "!" gnus-summary-tick-article-forward
911 "d" gnus-summary-mark-as-read-forward
912 "r" gnus-summary-mark-as-read-forward
913 "c" gnus-summary-clear-mark-forward
914 " " gnus-summary-clear-mark-forward
915 "e" gnus-summary-mark-as-expirable
916 "x" gnus-summary-mark-as-expirable
917 "?" gnus-summary-mark-as-dormant
918 "b" gnus-summary-set-bookmark
919 "B" gnus-summary-remove-bookmark
920 "#" gnus-summary-mark-as-processable
921 "\M-#" gnus-summary-unmark-as-processable
922 "S" gnus-summary-limit-include-expunged
923 "C" gnus-summary-catchup
924 "H" gnus-summary-catchup-to-here
925 "\C-c" gnus-summary-catchup-all
926 "k" gnus-summary-kill-same-subject-and-select
927 "K" gnus-summary-kill-same-subject
928 "P" gnus-uu-mark-map)
930 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
931 "c" gnus-summary-clear-above
932 "u" gnus-summary-tick-above
933 "m" gnus-summary-mark-above
934 "k" gnus-summary-kill-below)
936 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
937 "/" gnus-summary-limit-to-subject
938 "n" gnus-summary-limit-to-articles
939 "w" gnus-summary-pop-limit
940 "s" gnus-summary-limit-to-subject
941 "a" gnus-summary-limit-to-author
942 "u" gnus-summary-limit-to-unread
943 "m" gnus-summary-limit-to-marks
944 "v" gnus-summary-limit-to-score
945 "D" gnus-summary-limit-include-dormant
946 "d" gnus-summary-limit-exclude-dormant
947 ;; "t" gnus-summary-limit-exclude-thread
948 "E" gnus-summary-limit-include-expunged
949 "c" gnus-summary-limit-exclude-childless-dormant
950 "C" gnus-summary-limit-mark-excluded-as-read)
952 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
953 "n" gnus-summary-next-unread-article
954 "p" gnus-summary-prev-unread-article
955 "N" gnus-summary-next-article
956 "P" gnus-summary-prev-article
957 "\C-n" gnus-summary-next-same-subject
958 "\C-p" gnus-summary-prev-same-subject
959 "\M-n" gnus-summary-next-unread-subject
960 "\M-p" gnus-summary-prev-unread-subject
961 "f" gnus-summary-first-unread-article
962 "b" gnus-summary-best-unread-article
963 "j" gnus-summary-goto-article
964 "g" gnus-summary-goto-subject
965 "l" gnus-summary-goto-last-article
966 "p" gnus-summary-pop-article)
968 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
969 "k" gnus-summary-kill-thread
970 "l" gnus-summary-lower-thread
971 "i" gnus-summary-raise-thread
972 "T" gnus-summary-toggle-threads
973 "t" gnus-summary-rethread-current
974 "^" gnus-summary-reparent-thread
975 "s" gnus-summary-show-thread
976 "S" gnus-summary-show-all-threads
977 "h" gnus-summary-hide-thread
978 "H" gnus-summary-hide-all-threads
979 "n" gnus-summary-next-thread
980 "p" gnus-summary-prev-thread
981 "u" gnus-summary-up-thread
982 "o" gnus-summary-top-thread
983 "d" gnus-summary-down-thread
984 "#" gnus-uu-mark-thread
985 "\M-#" gnus-uu-unmark-thread)
987 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
988 "g" gnus-summary-prepare
989 "c" gnus-summary-insert-cached-articles)
991 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
992 "c" gnus-summary-catchup-and-exit
993 "C" gnus-summary-catchup-all-and-exit
994 "E" gnus-summary-exit-no-update
995 "Q" gnus-summary-exit
996 "Z" gnus-summary-exit
997 "n" gnus-summary-catchup-and-goto-next-group
998 "R" gnus-summary-reselect-current-group
999 "G" gnus-summary-rescan-group
1000 "N" gnus-summary-next-group
1001 "P" gnus-summary-prev-group)
1003 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1004 " " gnus-summary-next-page
1005 "n" gnus-summary-next-page
1006 "\177" gnus-summary-prev-page
1007 [delete] gnus-summary-prev-page
1008 "p" gnus-summary-prev-page
1009 "\r" gnus-summary-scroll-up
1010 "<" gnus-summary-beginning-of-article
1011 ">" gnus-summary-end-of-article
1012 "b" gnus-summary-beginning-of-article
1013 "e" gnus-summary-end-of-article
1014 "^" gnus-summary-refer-parent-article
1015 "r" gnus-summary-refer-parent-article
1016 "R" gnus-summary-refer-references
1017 "g" gnus-summary-show-article
1018 "s" gnus-summary-isearch-article)
1020 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1021 "b" gnus-article-add-buttons
1022 "B" gnus-article-add-buttons-to-head
1023 "o" gnus-article-treat-overstrike
1024 "e" gnus-article-emphasize
1025 "w" gnus-article-fill-cited-article
1026 "c" gnus-article-remove-cr
1027 "q" gnus-article-de-quoted-unreadable
1028 "f" gnus-article-display-x-face
1029 "l" gnus-summary-stop-page-breaking
1030 "r" gnus-summary-caesar-message
1031 "t" gnus-article-hide-headers
1032 "v" gnus-summary-verbose-headers
1033 "m" gnus-summary-toggle-mime)
1035 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1036 "a" gnus-article-hide
1037 "h" gnus-article-hide-headers
1038 "b" gnus-article-hide-boring-headers
1039 "s" gnus-article-hide-signature
1040 "c" gnus-article-hide-citation
1041 "p" gnus-article-hide-pgp
1042 "P" gnus-article-hide-pem
1043 "\C-c" gnus-article-hide-citation-maybe)
1045 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1046 "a" gnus-article-highlight
1047 "h" gnus-article-highlight-headers
1048 "c" gnus-article-highlight-citation
1049 "s" gnus-article-highlight-signature)
1051 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1052 "z" gnus-article-date-ut
1053 "u" gnus-article-date-ut
1054 "l" gnus-article-date-local
1055 "e" gnus-article-date-lapsed
1056 "o" gnus-article-date-original)
1058 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1059 "t" gnus-article-remove-trailing-blank-lines
1060 "l" gnus-article-strip-leading-blank-lines
1061 "m" gnus-article-strip-multiple-blank-lines
1062 "a" gnus-article-strip-blank-lines)
1064 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1066 "f" gnus-summary-fetch-faq
1067 "d" gnus-summary-describe-group
1068 "h" gnus-summary-describe-briefly
1069 "i" gnus-info-find-node)
1071 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1072 "e" gnus-summary-expire-articles
1073 "\M-\C-e" gnus-summary-expire-articles-now
1074 "\177" gnus-summary-delete-article
1075 [delete] gnus-summary-delete-article
1076 "m" gnus-summary-move-article
1077 "r" gnus-summary-respool-article
1078 "w" gnus-summary-edit-article
1079 "c" gnus-summary-copy-article
1080 "B" gnus-summary-crosspost-article
1081 "q" gnus-summary-respool-query
1082 "i" gnus-summary-import-article
1083 "p" gnus-summary-article-posted-p)
1085 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1086 "o" gnus-summary-save-article
1087 "m" gnus-summary-save-article-mail
1088 "r" gnus-summary-save-article-rmail
1089 "f" gnus-summary-save-article-file
1090 "b" gnus-summary-save-article-body-file
1091 "h" gnus-summary-save-article-folder
1092 "v" gnus-summary-save-article-vm
1093 "p" gnus-summary-pipe-output
1094 "s" gnus-soup-add-article))
1096 (defun gnus-summary-make-menu-bar ()
1097 (gnus-turn-off-edit-menu 'summary)
1099 (unless (boundp 'gnus-summary-misc-menu)
1102 gnus-summary-kill-menu gnus-summary-mode-map ""
1107 ["Enter score..." gnus-summary-score-entry t])
1108 (gnus-make-score-map 'increase)
1109 (gnus-make-score-map 'lower)
1111 ["Kill below" gnus-summary-kill-below t]
1112 ["Mark above" gnus-summary-mark-above t]
1113 ["Tick above" gnus-summary-tick-above t]
1114 ["Clear above" gnus-summary-clear-above t])
1115 ["Current score" gnus-summary-current-score t]
1116 ["Set score" gnus-summary-set-score t]
1117 ["Customize score file" gnus-score-customize t]
1118 ["Switch current score file..." gnus-score-change-score-file t]
1119 ["Set mark below..." gnus-score-set-mark-below t]
1120 ["Set expunge below..." gnus-score-set-expunge-below t]
1121 ["Edit current score file" gnus-score-edit-current-scores t]
1122 ["Edit score file" gnus-score-edit-file t]
1123 ["Trace score" gnus-score-find-trace t]
1124 ["Find words" gnus-score-find-favuorite-words t]
1125 ["Rescore buffer" gnus-summary-rescore t]
1126 ["Increase score..." gnus-summary-increase-score t]
1127 ["Lower score..." gnus-summary-lower-score t]))))
1130 ["Ask" (gnus-score-set-default 'gnus-score-default-header nil)
1132 :selected (null gnus-score-default-header)]
1133 ["From" (gnus-score-set-default 'gnus-score-default-header 'a)
1135 :selected (eq gnus-score-default-header 'a)]
1136 ["Subject" (gnus-score-set-default 'gnus-score-default-header 's)
1138 :selected (eq gnus-score-default-header 's)]
1140 (gnus-score-set-default 'gnus-score-default-header 'b)
1142 :selected (eq gnus-score-default-header 'b )]
1144 (gnus-score-set-default 'gnus-score-default-header 'h)
1146 :selected (eq gnus-score-default-header 'h )]
1147 ["Message-Id" (gnus-score-set-default 'gnus-score-default-header 'i)
1149 :selected (eq gnus-score-default-header 'i )]
1150 ["Thread" (gnus-score-set-default 'gnus-score-default-header 't)
1152 :selected (eq gnus-score-default-header 't )]
1154 (gnus-score-set-default 'gnus-score-default-header 'x)
1156 :selected (eq gnus-score-default-header 'x )]
1157 ["Lines" (gnus-score-set-default 'gnus-score-default-header 'l)
1159 :selected (eq gnus-score-default-header 'l )]
1160 ["Date" (gnus-score-set-default 'gnus-score-default-header 'd)
1162 :selected (eq gnus-score-default-header 'd )]
1163 ["Followups to author"
1164 (gnus-score-set-default 'gnus-score-default-header 'f)
1166 :selected (eq gnus-score-default-header 'f )])
1168 ["Ask" (gnus-score-set-default 'gnus-score-default-type nil)
1170 :selected (null gnus-score-default-type)]
1171 ;; The `:active' key is commented out in the following,
1172 ;; because the GNU Emacs hack to support radio buttons use
1173 ;; active to indicate which button is selected.
1174 ["Substring" (gnus-score-set-default 'gnus-score-default-type 's)
1176 ;; :active (not (memq gnus-score-default-header '(l d)))
1177 :selected (eq gnus-score-default-type 's)]
1178 ["Regexp" (gnus-score-set-default 'gnus-score-default-type 'r)
1180 ;; :active (not (memq gnus-score-default-header '(l d)))
1181 :selected (eq gnus-score-default-type 'r)]
1182 ["Exact" (gnus-score-set-default 'gnus-score-default-type 'e)
1184 ;; :active (not (memq gnus-score-default-header '(l d)))
1185 :selected (eq gnus-score-default-type 'e)]
1186 ["Fuzzy" (gnus-score-set-default 'gnus-score-default-type 'f)
1188 ;; :active (not (memq gnus-score-default-header '(l d)))
1189 :selected (eq gnus-score-default-type 'f)]
1190 ["Before date" (gnus-score-set-default 'gnus-score-default-type 'b)
1192 ;; :active (eq (gnus-score-default-header 'd))
1193 :selected (eq gnus-score-default-type 'b)]
1194 ["At date" (gnus-score-set-default 'gnus-score-default-type 'n)
1196 ;; :active (eq (gnus-score-default-header 'd))
1197 :selected (eq gnus-score-default-type 'n)]
1198 ["After date" (gnus-score-set-default 'gnus-score-default-type 'a)
1200 ;; :active (eq (gnus-score-default-header 'd))
1201 :selected (eq gnus-score-default-type 'a)]
1203 (gnus-score-set-default 'gnus-score-default-type '<)
1205 ;; :active (eq (gnus-score-default-header 'l))
1206 :selected (eq gnus-score-default-type '<)]
1208 (gnus-score-set-default 'gnus-score-default-type '=)
1210 ;; :active (eq (gnus-score-default-header 'l))
1211 :selected (eq gnus-score-default-type '=)]
1212 ["Greater than number"
1213 (gnus-score-set-default 'gnus-score-default-type '>)
1215 ;; :active (eq (gnus-score-default-header 'l))
1216 :selected (eq gnus-score-default-type '>)])
1217 ["Default fold" gnus-score-default-fold-toggle
1219 :selected gnus-score-default-fold]
1221 ["Ask" (gnus-score-set-default 'gnus-score-default-duration nil)
1223 :selected (null gnus-score-default-duration)]
1225 (gnus-score-set-default 'gnus-score-default-duration 'p)
1227 :selected (eq gnus-score-default-duration 'p)]
1229 (gnus-score-set-default 'gnus-score-default-duration 't)
1231 :selected (eq gnus-score-default-duration 't)]
1233 (gnus-score-set-default 'gnus-score-default-duration 'i)
1235 :selected (eq gnus-score-default-duration 'i)]))
1238 gnus-summary-article-menu gnus-summary-mode-map ""
1241 ["All" gnus-article-hide t]
1242 ["Headers" gnus-article-hide-headers t]
1243 ["Signature" gnus-article-hide-signature t]
1244 ["Citation" gnus-article-hide-citation t]
1245 ["PGP" gnus-article-hide-pgp t]
1246 ["Boring headers" gnus-article-hide-boring-headers t])
1248 ["All" gnus-article-highlight t]
1249 ["Headers" gnus-article-highlight-headers t]
1250 ["Signature" gnus-article-highlight-signature t]
1251 ["Citation" gnus-article-highlight-citation t])
1253 ["Local" gnus-article-date-local t]
1254 ["UT" gnus-article-date-ut t]
1255 ["Original" gnus-article-date-original t]
1256 ["Lapsed" gnus-article-date-lapsed t])
1259 ["Leading" gnus-article-strip-leading-blank-lines t]
1260 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1261 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1262 ["All of the above" gnus-article-strip-blank-lines t])
1263 ["Overstrike" gnus-article-treat-overstrike t]
1264 ["Emphasis" gnus-article-emphasize t]
1265 ["Word wrap" gnus-article-fill-cited-article t]
1266 ["CR" gnus-article-remove-cr t]
1267 ["Show X-Face" gnus-article-display-x-face t]
1268 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
1269 ["Rot 13" gnus-summary-caesar-message t]
1270 ["Add buttons" gnus-article-add-buttons t]
1271 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1272 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1273 ["Toggle MIME" gnus-summary-toggle-mime t]
1274 ["Verbose header" gnus-summary-verbose-headers t]
1275 ["Toggle header" gnus-summary-toggle-header t])
1277 ["Save in default format" gnus-summary-save-article t]
1278 ["Save in file" gnus-summary-save-article-file t]
1279 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1280 ["Save in MH folder" gnus-summary-save-article-folder t]
1281 ["Save in VM folder" gnus-summary-save-article-vm t]
1282 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1283 ["Save body in file" gnus-summary-save-article-body-file t]
1284 ["Pipe through a filter" gnus-summary-pipe-output t]
1285 ["Add to SOUP packet" gnus-soup-add-article t])
1287 ["Respool article..." gnus-summary-respool-article t]
1288 ["Move article..." gnus-summary-move-article
1289 (gnus-check-backend-function
1290 'request-move-article gnus-newsgroup-name)]
1291 ["Copy article..." gnus-summary-copy-article t]
1292 ["Crosspost article..." gnus-summary-crosspost-article
1293 (gnus-check-backend-function
1294 'request-replace-article gnus-newsgroup-name)]
1295 ["Import file..." gnus-summary-import-article t]
1296 ["Chek if posted" gnus-summary-article-posted-p t]
1297 ["Edit article" gnus-summary-edit-article
1298 (not (gnus-group-read-only-p))]
1299 ["Delete article" gnus-summary-delete-article
1300 (gnus-check-backend-function
1301 'request-expire-articles gnus-newsgroup-name)]
1302 ["Query respool" gnus-summary-respool-query t]
1303 ["Delete expirable articles" gnus-summary-expire-articles-now
1304 (gnus-check-backend-function
1305 'request-expire-articles gnus-newsgroup-name)])
1307 ["Uudecode" gnus-uu-decode-uu t]
1308 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1309 ["Unshar" gnus-uu-decode-unshar t]
1310 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1311 ["Save" gnus-uu-decode-save t]
1312 ["Binhex" gnus-uu-decode-binhex t]
1313 ["Postscript" gnus-uu-decode-postscript t])
1314 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1315 ["Isearch article..." gnus-summary-isearch-article t]
1316 ["Search articles forward..." gnus-summary-search-article-forward t]
1317 ["Search articles backward..." gnus-summary-search-article-backward t]
1318 ["Beginning of the article" gnus-summary-beginning-of-article t]
1319 ["End of the article" gnus-summary-end-of-article t]
1320 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1321 ["Fetch referenced articles" gnus-summary-refer-references t]
1322 ["Fetch article with id..." gnus-summary-refer-article t]
1323 ["Redisplay" gnus-summary-show-article t]))
1326 gnus-summary-thread-menu gnus-summary-mode-map ""
1328 ["Toggle threading" gnus-summary-toggle-threads t]
1329 ["Hide threads" gnus-summary-hide-all-threads t]
1330 ["Show threads" gnus-summary-show-all-threads t]
1331 ["Hide thread" gnus-summary-hide-thread t]
1332 ["Show thread" gnus-summary-show-thread t]
1333 ["Go to next thread" gnus-summary-next-thread t]
1334 ["Go to previous thread" gnus-summary-prev-thread t]
1335 ["Go down thread" gnus-summary-down-thread t]
1336 ["Go up thread" gnus-summary-up-thread t]
1337 ["Top of thread" gnus-summary-top-thread t]
1338 ["Mark thread as read" gnus-summary-kill-thread t]
1339 ["Lower thread score" gnus-summary-lower-thread t]
1340 ["Raise thread score" gnus-summary-raise-thread t]
1341 ["Rethread current" gnus-summary-rethread-current t]
1345 gnus-summary-post-menu gnus-summary-mode-map ""
1347 ["Post an article" gnus-summary-post-news t]
1348 ["Followup" gnus-summary-followup t]
1349 ["Followup and yank" gnus-summary-followup-with-original t]
1350 ["Supersede article" gnus-summary-supersede-article t]
1351 ["Cancel article" gnus-summary-cancel-article t]
1352 ["Reply" gnus-summary-reply t]
1353 ["Reply and yank" gnus-summary-reply-with-original t]
1354 ["Mail forward" gnus-summary-mail-forward t]
1355 ["Post forward" gnus-summary-post-forward t]
1356 ["Digest and mail" gnus-uu-digest-mail-forward t]
1357 ["Digest and post" gnus-uu-digest-post-forward t]
1358 ["Resend message" gnus-summary-resend-message t]
1359 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
1360 ["Send a mail" gnus-summary-mail-other-window t]
1361 ["Uuencode and post" gnus-uu-post-news t]
1363 ;;["Send" gnus-summary-send-draft t]
1364 ;;["Send bounced" gnus-resend-bounced-mail t])
1368 gnus-summary-misc-menu gnus-summary-mode-map ""
1372 ["Mark as read" gnus-summary-mark-as-read-forward t]
1373 ["Mark same subject and select"
1374 gnus-summary-kill-same-subject-and-select t]
1375 ["Mark same subject" gnus-summary-kill-same-subject t]
1376 ["Catchup" gnus-summary-catchup t]
1377 ["Catchup all" gnus-summary-catchup-all t]
1378 ["Catchup to here" gnus-summary-catchup-to-here t]
1379 ["Catchup region" gnus-summary-mark-region-as-read t]
1380 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
1382 ["Tick" gnus-summary-tick-article-forward t]
1383 ["Mark as dormant" gnus-summary-mark-as-dormant t]
1384 ["Remove marks" gnus-summary-clear-mark-forward t]
1385 ["Set expirable mark" gnus-summary-mark-as-expirable t]
1386 ["Set bookmark" gnus-summary-set-bookmark t]
1387 ["Remove bookmark" gnus-summary-remove-bookmark t])
1389 ["Marks..." gnus-summary-limit-to-marks t]
1390 ["Subject..." gnus-summary-limit-to-subject t]
1391 ["Author..." gnus-summary-limit-to-author t]
1392 ["Score" gnus-summary-limit-to-score t]
1393 ["Unread" gnus-summary-limit-to-unread t]
1394 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
1395 ["Articles" gnus-summary-limit-to-articles t]
1396 ["Pop limit" gnus-summary-pop-limit t]
1397 ["Show dormant" gnus-summary-limit-include-dormant t]
1398 ["Hide childless dormant"
1399 gnus-summary-limit-exclude-childless-dormant t]
1400 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
1401 ["Show expunged" gnus-summary-show-all-expunged t])
1403 ["Set mark" gnus-summary-mark-as-processable t]
1404 ["Remove mark" gnus-summary-unmark-as-processable t]
1405 ["Remove all marks" gnus-summary-unmark-all-processable t]
1406 ["Mark above" gnus-uu-mark-over t]
1407 ["Mark series" gnus-uu-mark-series t]
1408 ["Mark region" gnus-uu-mark-region t]
1409 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
1410 ["Mark all" gnus-uu-mark-all t]
1411 ["Mark buffer" gnus-uu-mark-buffer t]
1412 ["Mark sparse" gnus-uu-mark-sparse t]
1413 ["Mark thread" gnus-uu-mark-thread t]
1414 ["Unmark thread" gnus-uu-unmark-thread t]
1415 ("Process Mark Sets"
1416 ["Kill" gnus-summary-kill-process-mark t]
1417 ["Yank" gnus-summary-yank-process-mark
1418 gnus-newsgroup-process-stack]
1419 ["Save" gnus-summary-save-process-mark t])))
1421 ["Page forward" gnus-summary-next-page t]
1422 ["Page backward" gnus-summary-prev-page t]
1423 ["Line forward" gnus-summary-scroll-up t])
1425 ["Next unread article" gnus-summary-next-unread-article t]
1426 ["Previous unread article" gnus-summary-prev-unread-article t]
1427 ["Next article" gnus-summary-next-article t]
1428 ["Previous article" gnus-summary-prev-article t]
1429 ["Next unread subject" gnus-summary-next-unread-subject t]
1430 ["Previous unread subject" gnus-summary-prev-unread-subject t]
1431 ["Next article same subject" gnus-summary-next-same-subject t]
1432 ["Previous article same subject" gnus-summary-prev-same-subject t]
1433 ["First unread article" gnus-summary-first-unread-article t]
1434 ["Best unread article" gnus-summary-best-unread-article t]
1435 ["Go to subject number..." gnus-summary-goto-subject t]
1436 ["Go to article number..." gnus-summary-goto-article t]
1437 ["Go to the last article" gnus-summary-goto-last-article t]
1438 ["Pop article off history" gnus-summary-pop-article t])
1440 ["Sort by number" gnus-summary-sort-by-number t]
1441 ["Sort by author" gnus-summary-sort-by-author t]
1442 ["Sort by subject" gnus-summary-sort-by-subject t]
1443 ["Sort by date" gnus-summary-sort-by-date t]
1444 ["Sort by score" gnus-summary-sort-by-score t])
1446 ["Fetch group FAQ" gnus-summary-fetch-faq t]
1447 ["Describe group" gnus-summary-describe-group t]
1448 ["Read manual" gnus-info-find-node t])
1450 ["Enter article" gnus-cache-enter-article t]
1451 ["Remove article" gnus-cache-remove-article t])
1453 ["Pick and read" gnus-pick-mode t]
1454 ["Binary" gnus-binary-mode t])
1455 ["Filter articles..." gnus-summary-execute-command t]
1456 ["Run command on subjects..." gnus-summary-universal-argument t]
1457 ["Toggle line truncation" gnus-summary-toggle-truncation t]
1458 ["Expand window" gnus-summary-expand-window t]
1459 ["Expire expirable articles" gnus-summary-expire-articles
1460 (gnus-check-backend-function
1461 'request-expire-articles gnus-newsgroup-name)]
1462 ["Regenerate buffer" gnus-summary-prepare t]
1463 ["Edit local kill file" gnus-summary-edit-local-kill t]
1464 ["Edit main kill file" gnus-summary-edit-global-kill t]
1466 ["Catchup and exit" gnus-summary-catchup-and-exit t]
1467 ["Catchup all and exit" gnus-summary-catchup-and-exit t]
1468 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
1469 ["Exit group" gnus-summary-exit t]
1470 ["Exit group without updating" gnus-summary-exit-no-update t]
1471 ["Exit and goto next group" gnus-summary-next-group t]
1472 ["Exit and goto prev group" gnus-summary-prev-group t]
1473 ["Reselect group" gnus-summary-reselect-current-group t]
1474 ["Rescan group" gnus-summary-rescan-group t])))
1476 (run-hooks 'gnus-summary-menu-hook)))
1478 (defun gnus-score-set-default (var value)
1479 "A version of set that updates the GNU Emacs menu-bar."
1481 ;; It is the message that forces the active status to be updated.
1484 (defun gnus-make-score-map (type)
1485 "Make a summary score map of type TYPE."
1488 (let ((headers '(("author" "from" string)
1489 ("subject" "subject" string)
1490 ("article body" "body" string)
1491 ("article head" "head" string)
1492 ("xref" "xref" string)
1493 ("lines" "lines" number)
1494 ("followups to author" "followup" string)))
1495 (types '((number ("less than" <)
1498 (string ("substring" s)
1502 (perms '(("temporary" (current-time-string))
1510 (if (eq type 'lower)
1515 (setq header (car headers))
1521 (let ((ts (cdr (assoc (nth 2 header) types)))
1537 'gnus-summary-score-entry
1539 (if (or (string= (nth 1 header)
1541 (string= (nth 1 header)
1544 (list 'gnus-summary-header
1546 (list 'quote (nth 1 (car ts)))
1547 (list 'gnus-score-default nil)
1553 (list (nreverse outp))))
1556 (list (nreverse outt))))
1558 (setq headers (cdr headers)))
1559 (list (nreverse outh))))))))
1563 (defun gnus-summary-mode (&optional group)
1564 "Major mode for reading articles.
1566 All normal editing commands are switched off.
1567 \\<gnus-summary-mode-map>
1568 Each line in this buffer represents one article. To read an
1569 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
1570 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
1573 You can also post articles and send mail from this buffer. To
1574 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
1575 of an article, type `\\[gnus-summary-reply]'.
1577 There are approx. one gazillion commands you can execute in this
1578 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
1580 The following commands are available:
1582 \\{gnus-summary-mode-map}"
1584 (when (and menu-bar-mode
1585 (gnus-visual-p 'summary-menu 'menu))
1586 (gnus-summary-make-menu-bar))
1587 (kill-all-local-variables)
1588 (gnus-summary-make-local-variables)
1589 (gnus-make-thread-indent-array)
1590 (gnus-simplify-mode-line)
1591 (setq major-mode 'gnus-summary-mode)
1592 (setq mode-name "Summary")
1593 (make-local-variable 'minor-mode-alist)
1594 (use-local-map gnus-summary-mode-map)
1595 (buffer-disable-undo (current-buffer))
1596 (setq buffer-read-only t) ;Disable modification
1597 (setq truncate-lines t)
1598 (setq selective-display t)
1599 (setq selective-display-ellipses t) ;Display `...'
1600 (setq buffer-display-table gnus-summary-display-table)
1601 (gnus-set-default-directory)
1602 (setq gnus-newsgroup-name group)
1603 (make-local-variable 'gnus-summary-line-format)
1604 (make-local-variable 'gnus-summary-line-format-spec)
1605 (make-local-variable 'gnus-summary-mark-positions)
1606 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
1607 (gnus-update-summary-mark-positions)
1608 (gnus-make-local-hook 'post-command-hook)
1609 (gnus-add-hook 'post-command-hook 'gnus-clear-inboxes-moved nil t)
1610 (run-hooks 'gnus-summary-mode-hook))
1612 (defun gnus-summary-make-local-variables ()
1613 "Make all the local summary buffer variables."
1614 (let ((locals gnus-summary-local-variables)
1616 (while (setq local (pop locals))
1619 (if (eq (cdr local) 'global)
1620 ;; Copy the global value of the variable.
1621 (setq global (symbol-value (car local)))
1622 ;; Use the value from the list.
1623 (setq global (eval (cdr local))))
1624 (make-local-variable (car local))
1625 (set (car local) global))
1626 ;; Simple nil-valued local variable.
1627 (make-local-variable local)
1630 (defun gnus-summary-clear-local-variables ()
1631 (let ((locals gnus-summary-local-variables))
1633 (if (consp (car locals))
1634 (and (vectorp (caar locals))
1635 (set (caar locals) nil))
1636 (and (vectorp (car locals))
1637 (set (car locals) nil)))
1638 (setq locals (cdr locals)))))
1640 ;; Summary data functions.
1642 (defmacro gnus-data-number (data)
1645 (defmacro gnus-data-set-number (data number)
1646 `(setcar ,data ,number))
1648 (defmacro gnus-data-mark (data)
1651 (defmacro gnus-data-set-mark (data mark)
1652 `(setcar (nthcdr 1 ,data) ,mark))
1654 (defmacro gnus-data-pos (data)
1657 (defmacro gnus-data-set-pos (data pos)
1658 `(setcar (nthcdr 2 ,data) ,pos))
1660 (defmacro gnus-data-header (data)
1663 (defmacro gnus-data-level (data)
1666 (defmacro gnus-data-unread-p (data)
1667 `(= (nth 1 ,data) gnus-unread-mark))
1669 (defmacro gnus-data-read-p (data)
1670 `(/= (nth 1 ,data) gnus-unread-mark))
1672 (defmacro gnus-data-pseudo-p (data)
1673 `(consp (nth 3 ,data)))
1675 (defmacro gnus-data-find (number)
1676 `(assq ,number gnus-newsgroup-data))
1678 (defmacro gnus-data-find-list (number &optional data)
1679 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
1680 (memq (assq ,number bdata)
1683 (defmacro gnus-data-make (number mark pos header level)
1684 `(list ,number ,mark ,pos ,header ,level))
1686 (defun gnus-data-enter (after-article number mark pos header level offset)
1687 (let ((data (gnus-data-find-list after-article)))
1688 (or data (error "No such article: %d" after-article))
1689 (setcdr data (cons (gnus-data-make number mark pos header level)
1691 (setq gnus-newsgroup-data-reverse nil)
1692 (gnus-data-update-list (cddr data) offset)))
1694 (defun gnus-data-enter-list (after-article list &optional offset)
1696 (let ((data (and after-article (gnus-data-find-list after-article)))
1698 (or data (not after-article) (error "No such article: %d" after-article))
1699 ;; Find the last element in the list to be spliced into the main
1702 (setq list (cdr list)))
1705 (setcdr list gnus-newsgroup-data)
1706 (setq gnus-newsgroup-data ilist)
1707 (and offset (gnus-data-update-list (cdr list) offset)))
1708 (setcdr list (cdr data))
1710 (and offset (gnus-data-update-list (cdr data) offset)))
1711 (setq gnus-newsgroup-data-reverse nil))))
1713 (defun gnus-data-remove (article &optional offset)
1714 (let ((data gnus-newsgroup-data))
1715 (if (= (gnus-data-number (car data)) article)
1716 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
1717 gnus-newsgroup-data-reverse nil)
1719 (and (= (gnus-data-number (cadr data)) article)
1721 (setcdr data (cddr data))
1722 (and offset (gnus-data-update-list (cdr data) offset))
1724 gnus-newsgroup-data-reverse nil)))
1725 (setq data (cdr data))))))
1727 (defmacro gnus-data-list (backward)
1729 (or gnus-newsgroup-data-reverse
1730 (setq gnus-newsgroup-data-reverse
1731 (reverse gnus-newsgroup-data)))
1732 gnus-newsgroup-data))
1734 (defun gnus-data-update-list (data offset)
1735 "Add OFFSET to the POS of all data entries in DATA."
1737 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
1738 (setq data (cdr data))))
1740 (defun gnus-data-compute-positions ()
1741 "Compute the positions of all articles."
1742 (let ((data gnus-newsgroup-data)
1745 (when (setq pos (text-property-any
1746 (point-min) (point-max)
1747 'gnus-number (gnus-data-number (car data))))
1748 (gnus-data-set-pos (car data) (+ pos 3)))
1749 (setq data (cdr data)))))
1751 (defun gnus-summary-article-pseudo-p (article)
1752 "Say whether this article is a pseudo article or not."
1753 (not (vectorp (gnus-data-header (gnus-data-find article)))))
1755 (defun gnus-article-parent-p (number)
1756 "Say whether this article is a parent or not."
1757 (let ((data (gnus-data-find-list number)))
1758 (and (cdr data) ; There has to be an article after...
1759 (< (gnus-data-level (car data)) ; And it has to have a higher level.
1760 (gnus-data-level (nth 1 data))))))
1762 (defun gnus-article-children (number)
1763 "Return a list of all children to NUMBER."
1764 (let* ((data (gnus-data-find-list number))
1765 (level (gnus-data-level (car data)))
1767 (setq data (cdr data))
1769 (= (gnus-data-level (car data)) (1+ level)))
1770 (push (gnus-data-number (car data)) children)
1771 (setq data (cdr data)))
1774 (defmacro gnus-summary-skip-intangible ()
1775 "If the current article is intangible, then jump to a different article."
1776 '(let ((to (get-text-property (point) 'gnus-intangible)))
1777 (and to (gnus-summary-goto-subject to))))
1779 (defmacro gnus-summary-article-intangible-p ()
1780 "Say whether this article is intangible or not."
1781 '(get-text-property (point) 'gnus-intangible))
1783 (defun gnus-article-read-p (article)
1784 "Say whether ARTICLE is read or not."
1785 (not (or (memq article gnus-newsgroup-marked)
1786 (memq article gnus-newsgroup-unreads)
1787 (memq article gnus-newsgroup-unselected)
1788 (memq article gnus-newsgroup-dormant))))
1790 ;; Some summary mode macros.
1792 (defmacro gnus-summary-article-number ()
1793 "The article number of the article on the current line.
1794 If there isn's an article number here, then we return the current
1797 (gnus-summary-skip-intangible)
1798 (or (get-text-property (point) 'gnus-number)
1799 (gnus-summary-last-subject))))
1801 (defmacro gnus-summary-article-header (&optional number)
1802 `(gnus-data-header (gnus-data-find
1803 ,(or number '(gnus-summary-article-number)))))
1805 (defmacro gnus-summary-thread-level (&optional number)
1806 `(if (and (eq gnus-summary-make-false-root 'dummy)
1807 (get-text-property (point) 'gnus-intangible))
1809 (gnus-data-level (gnus-data-find
1810 ,(or number '(gnus-summary-article-number))))))
1812 (defmacro gnus-summary-article-mark (&optional number)
1813 `(gnus-data-mark (gnus-data-find
1814 ,(or number '(gnus-summary-article-number)))))
1816 (defmacro gnus-summary-article-pos (&optional number)
1817 `(gnus-data-pos (gnus-data-find
1818 ,(or number '(gnus-summary-article-number)))))
1820 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
1821 (defmacro gnus-summary-article-subject (&optional number)
1822 "Return current subject string or nil if nothing."
1825 `(gnus-data-header (assq ,number gnus-newsgroup-data))
1826 '(gnus-data-header (assq (gnus-summary-article-number)
1827 gnus-newsgroup-data)))))
1830 (mail-header-subject headers))))
1832 (defmacro gnus-summary-article-score (&optional number)
1833 "Return current article score."
1834 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
1835 gnus-newsgroup-scored))
1836 gnus-summary-default-score 0))
1838 (defun gnus-summary-article-children (&optional number)
1839 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
1840 (level (gnus-data-level (car data)))
1842 (while (and (setq data (cdr data))
1843 (> (setq l (gnus-data-level (car data))) level))
1844 (and (= (1+ level) l)
1845 (setq children (cons (gnus-data-number (car data))
1847 (nreverse children)))
1849 (defun gnus-summary-article-parent (&optional number)
1850 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
1851 (gnus-data-list t)))
1852 (level (gnus-data-level (car data))))
1854 () ; This is a root.
1855 ;; We search until we find an article with a level less than
1856 ;; this one. That function has to be the parent.
1857 (while (and (setq data (cdr data))
1858 (not (< (gnus-data-level (car data)) level))))
1859 (and data (gnus-data-number (car data))))))
1861 (defun gnus-unread-mark-p (mark)
1862 "Say whether MARK is the unread mark."
1863 (= mark gnus-unread-mark))
1865 (defun gnus-read-mark-p (mark)
1866 "Say whether MARK is one of the marks that mark as read.
1867 This is all marks except unread, ticked, dormant, and expirable."
1868 (not (or (= mark gnus-unread-mark)
1869 (= mark gnus-ticked-mark)
1870 (= mark gnus-dormant-mark)
1871 (= mark gnus-expirable-mark))))
1873 (defmacro gnus-article-mark (number)
1875 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
1876 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
1877 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
1878 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
1879 (t (or (cdr (assq ,number gnus-newsgroup-reads))
1880 gnus-ancient-mark))))
1882 ;; Saving hidden threads.
1884 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
1885 (put 'gnus-save-hidden-threads 'lisp-indent-hook 0)
1886 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
1888 (defmacro gnus-save-hidden-threads (&rest forms)
1889 "Save hidden threads, eval FORMS, and restore the hidden threads."
1890 (let ((config (make-symbol "config")))
1891 `(let ((,config (gnus-hidden-threads-configuration)))
1895 (gnus-restore-hidden-threads-configuration ,config)))))
1897 (defun gnus-hidden-threads-configuration ()
1898 "Return the current hidden threads configuration."
1901 (goto-char (point-min))
1902 (while (search-forward "\r" nil t)
1903 (push (1- (point)) config))
1906 (defun gnus-restore-hidden-threads-configuration (config)
1907 "Restore hidden threads configuration from CONFIG."
1908 (let (point buffer-read-only)
1909 (while (setq point (pop config))
1910 (when (and (< point (point-max))
1912 (= (following-char) ?\n))
1913 (subst-char-in-region point (1+ point) ?\n ?\r)))))
1915 ;; Various summary mode internalish functions.
1917 (defun gnus-mouse-pick-article (e)
1920 (gnus-summary-next-page nil t))
1922 (defun gnus-summary-setup-buffer (group)
1923 "Initialize summary buffer."
1924 (let ((buffer (concat "*Summary " group "*")))
1925 (if (get-buffer buffer)
1928 (setq gnus-summary-buffer (current-buffer))
1929 (not gnus-newsgroup-prepared))
1930 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
1931 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
1932 (gnus-add-current-to-buffer-list)
1933 (gnus-summary-mode group)
1935 (gnus-carpal-setup-buffer 'summary))
1936 (unless gnus-single-article-buffer
1937 (make-local-variable 'gnus-article-buffer)
1938 (make-local-variable 'gnus-article-current)
1939 (make-local-variable 'gnus-original-article-buffer))
1940 (setq gnus-newsgroup-name group)
1943 (defun gnus-set-global-variables ()
1944 ;; Set the global equivalents of the summary buffer-local variables
1945 ;; to the latest values they had. These reflect the summary buffer
1946 ;; that was in action when the last article was fetched.
1947 (when (eq major-mode 'gnus-summary-mode)
1948 (setq gnus-summary-buffer (current-buffer))
1949 (let ((name gnus-newsgroup-name)
1950 (marked gnus-newsgroup-marked)
1951 (unread gnus-newsgroup-unreads)
1952 (headers gnus-current-headers)
1953 (data gnus-newsgroup-data)
1954 (summary gnus-summary-buffer)
1955 (article-buffer gnus-article-buffer)
1956 (original gnus-original-article-buffer)
1957 (gac gnus-article-current)
1958 (reffed gnus-reffed-article-number)
1959 (score-file gnus-current-score-file))
1961 (set-buffer gnus-group-buffer)
1962 (setq gnus-newsgroup-name name)
1963 (setq gnus-newsgroup-marked marked)
1964 (setq gnus-newsgroup-unreads unread)
1965 (setq gnus-current-headers headers)
1966 (setq gnus-newsgroup-data data)
1967 (setq gnus-article-current gac)
1968 (setq gnus-summary-buffer summary)
1969 (setq gnus-article-buffer article-buffer)
1970 (setq gnus-original-article-buffer original)
1971 (setq gnus-reffed-article-number reffed)
1972 (setq gnus-current-score-file score-file)
1973 ;; The article buffer also has local variables.
1974 (when (gnus-buffer-live-p gnus-article-buffer)
1975 (set-buffer gnus-article-buffer)
1976 (setq gnus-summary-buffer summary))))))
1978 (defun gnus-summary-last-article-p (&optional article)
1979 "Return whether ARTICLE is the last article in the buffer."
1980 (if (not (setq article (or article (gnus-summary-article-number))))
1981 t ; All non-existant numbers are the last article. :-)
1982 (not (cdr (gnus-data-find-list article)))))
1984 (defun gnus-make-thread-indent-array ()
1986 (unless (and gnus-thread-indent-array
1987 (= gnus-thread-indent-level gnus-thread-indent-array-level))
1988 (setq gnus-thread-indent-array (make-vector 201 "")
1989 gnus-thread-indent-array-level gnus-thread-indent-level)
1991 (aset gnus-thread-indent-array n
1992 (make-string (* n gnus-thread-indent-level) ? ))
1995 (defun gnus-update-summary-mark-positions ()
1996 "Compute where the summary marks are to go."
1998 (when (and gnus-summary-buffer
1999 (get-buffer gnus-summary-buffer)
2000 (buffer-name (get-buffer gnus-summary-buffer)))
2001 (set-buffer gnus-summary-buffer))
2002 (let ((gnus-replied-mark 129)
2003 (gnus-score-below-mark 130)
2004 (gnus-score-over-mark 130)
2007 (spec gnus-summary-line-format-spec)
2010 (gnus-set-work-buffer)
2011 (let ((gnus-summary-line-format-spec spec))
2012 (gnus-summary-insert-line
2013 [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
2014 (goto-char (point-min))
2015 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2017 (goto-char (point-min))
2018 (push (cons 'replied (and (search-forward "\201" nil t)
2021 (goto-char (point-min))
2022 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2024 (setq gnus-summary-mark-positions pos))))
2026 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2027 "Insert a dummy root in the summary buffer."
2029 (gnus-add-text-properties
2030 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2031 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2033 (defun gnus-summary-insert-line
2034 (gnus-tmp-header gnus-tmp-level gnus-tmp-current gnus-tmp-unread
2035 gnus-tmp-replied gnus-tmp-expirable gnus-tmp-subject-or-nil
2036 &optional gnus-tmp-dummy gnus-tmp-score gnus-tmp-process)
2037 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2038 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2039 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2040 (gnus-tmp-score-char
2041 (if (or (null gnus-summary-default-score)
2042 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2043 gnus-summary-zcore-fuzz)) ?
2044 (if (< gnus-tmp-score gnus-summary-default-score)
2045 gnus-score-below-mark gnus-score-over-mark)))
2046 (gnus-tmp-replied (cond (gnus-tmp-process gnus-process-mark)
2047 ((memq gnus-tmp-current gnus-newsgroup-cached)
2049 (gnus-tmp-replied gnus-replied-mark)
2050 ((memq gnus-tmp-current gnus-newsgroup-saved)
2052 (t gnus-unread-mark)))
2053 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2056 ((string-match "(.+)" gnus-tmp-from)
2057 (substring gnus-tmp-from
2058 (1+ (match-beginning 0)) (1- (match-end 0))))
2059 ((string-match "<[^>]+> *$" gnus-tmp-from)
2060 (let ((beg (match-beginning 0)))
2061 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
2062 (substring gnus-tmp-from (1+ (match-beginning 0))
2063 (1- (match-end 0))))
2064 (substring gnus-tmp-from 0 beg))))
2066 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2067 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2068 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2069 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
2070 (buffer-read-only nil))
2071 (when (string= gnus-tmp-name "")
2072 (setq gnus-tmp-name gnus-tmp-from))
2073 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
2074 (gnus-put-text-property
2076 (progn (eval gnus-summary-line-format-spec) (point))
2077 'gnus-number gnus-tmp-number)
2078 (when (gnus-visual-p 'summary-highlight 'highlight)
2080 (run-hooks 'gnus-summary-update-hook)
2083 (defun gnus-summary-update-line (&optional dont-update)
2084 ;; Update summary line after change.
2085 (when (and gnus-summary-default-score
2086 (not gnus-summary-inhibit-highlight))
2087 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
2088 (article (gnus-summary-article-number))
2089 (score (gnus-summary-article-score article)))
2091 (if (and gnus-summary-mark-below
2092 (< (gnus-summary-article-score)
2093 gnus-summary-mark-below))
2094 ;; This article has a low score, so we mark it as read.
2095 (when (memq article gnus-newsgroup-unreads)
2096 (gnus-summary-mark-article-as-read gnus-low-score-mark))
2097 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
2098 ;; This article was previously marked as read on account
2099 ;; of a low score, but now it has risen, so we mark it as
2101 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
2102 (gnus-summary-update-mark
2103 (if (or (null gnus-summary-default-score)
2104 (<= (abs (- score gnus-summary-default-score))
2105 gnus-summary-zcore-fuzz)) ?
2106 (if (< score gnus-summary-default-score)
2107 gnus-score-below-mark gnus-score-over-mark)) 'score))
2108 ;; Do visual highlighting.
2109 (when (gnus-visual-p 'summary-highlight 'highlight)
2110 (run-hooks 'gnus-summary-update-hook)))))
2112 (defvar gnus-tmp-new-adopts nil)
2114 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
2115 "Return the number of articles in THREAD.
2116 This may be 0 in some cases -- if none of the articles in
2117 the thread are to be displayed."
2119 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
2121 ((not (listp thread))
2123 ((and (consp thread) (cdr thread))
2126 'gnus-summary-number-of-articles-in-thread (cdr thread))))
2129 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
2132 (when (and level (zerop level) gnus-tmp-new-adopts)
2135 'gnus-summary-number-of-articles-in-thread
2136 gnus-tmp-new-adopts))))
2138 (if (> number 1) gnus-not-empty-thread-mark
2139 gnus-empty-thread-mark)
2142 (defun gnus-summary-set-local-parameters (group)
2143 "Go through the local params of GROUP and set all variable specs in that list."
2144 (let ((params (gnus-group-find-parameter group))
2147 (setq elem (car params)
2148 params (cdr params))
2149 (and (consp elem) ; Has to be a cons.
2150 (consp (cdr elem)) ; The cdr has to be a list.
2151 (symbolp (car elem)) ; Has to be a symbol in there.
2152 (not (memq (car elem)
2153 '(quit-config to-address to-list to-group)))
2154 (progn ; So we set it.
2155 (make-local-variable (car elem))
2156 (set (car elem) (eval (nth 1 elem))))))))
2158 (defun gnus-summary-read-group (group &optional show-all no-article
2159 kill-buffer no-display)
2160 "Start reading news in newsgroup GROUP.
2161 If SHOW-ALL is non-nil, already read articles are also listed.
2162 If NO-ARTICLE is non-nil, no article is selected initially.
2163 If NO-DISPLAY, don't generate a summary buffer."
2164 (gnus-message 5 "Retrieving newsgroup: %s..." group)
2165 (let* ((new-group (gnus-summary-setup-buffer group))
2166 (quit-config (gnus-group-quit-config group))
2167 (did-select (and new-group (gnus-select-newsgroup group show-all))))
2169 ;; This summary buffer exists already, so we just select it.
2171 (gnus-set-global-variables)
2173 (gnus-kill-or-deaden-summary kill-buffer))
2174 (gnus-configure-windows 'summary 'force)
2175 (gnus-set-mode-line 'summary)
2176 (gnus-summary-position-point)
2179 ;; We couldn't select this group.
2181 (when (and (eq major-mode 'gnus-summary-mode)
2182 (not (equal (current-buffer) kill-buffer)))
2183 (kill-buffer (current-buffer))
2184 (if (not quit-config)
2186 (set-buffer gnus-group-buffer)
2187 (gnus-group-jump-to-group group)
2188 (gnus-group-next-unread-group 1))
2189 (if (not (buffer-name (car quit-config)))
2190 (gnus-configure-windows 'group 'force)
2191 (set-buffer (car quit-config))
2192 (and (eq major-mode 'gnus-summary-mode)
2193 (gnus-set-global-variables))
2194 (gnus-configure-windows (cdr quit-config)))))
2195 (gnus-message 3 "Can't select group")
2197 ;; The user did a `C-g' while prompting for number of articles,
2198 ;; so we exit this group.
2199 ((eq did-select 'quit)
2200 (and (eq major-mode 'gnus-summary-mode)
2201 (not (equal (current-buffer) kill-buffer))
2202 (kill-buffer (current-buffer)))
2204 (gnus-kill-or-deaden-summary kill-buffer))
2205 (if (not quit-config)
2207 (set-buffer gnus-group-buffer)
2208 (gnus-group-jump-to-group group)
2209 (gnus-group-next-unread-group 1)
2210 (gnus-configure-windows 'group 'force))
2211 (if (not (buffer-name (car quit-config)))
2212 (gnus-configure-windows 'group 'force)
2213 (set-buffer (car quit-config))
2214 (and (eq major-mode 'gnus-summary-mode)
2215 (gnus-set-global-variables))
2216 (gnus-configure-windows (cdr quit-config))))
2217 ;; Finally signal the quit.
2219 ;; The group was successfully selected.
2221 (gnus-set-global-variables)
2222 ;; Save the active value in effect when the group was entered.
2223 (setq gnus-newsgroup-active
2225 (gnus-active gnus-newsgroup-name)))
2226 ;; You can change the summary buffer in some way with this hook.
2227 (run-hooks 'gnus-select-group-hook)
2228 ;; Set any local variables in the group parameters.
2229 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2230 (gnus-update-format-specifications
2231 nil 'summary 'summary-mode 'summary-dummy)
2232 ;; Do score processing.
2233 (when gnus-use-scoring
2234 (gnus-possibly-score-headers))
2235 ;; Check whether to fill in the gaps in the threads.
2236 (when gnus-build-sparse-threads
2237 (gnus-build-sparse-threads))
2238 ;; Find the initial limit.
2239 (if gnus-show-threads
2241 (let ((gnus-newsgroup-dormant nil))
2242 (gnus-summary-initial-limit show-all))
2243 (gnus-summary-initial-limit show-all))
2244 (setq gnus-newsgroup-limit
2246 (lambda (header) (mail-header-number header))
2247 gnus-newsgroup-headers)))
2248 ;; Generate the summary buffer.
2250 (gnus-summary-prepare))
2251 (when gnus-use-trees
2252 (gnus-tree-open group)
2253 (setq gnus-summary-highlight-line-function
2254 'gnus-tree-highlight-article))
2255 ;; If the summary buffer is empty, but there are some low-scored
2256 ;; articles or some excluded dormants, we include these in the
2258 (when (and (zerop (buffer-size))
2260 (cond (gnus-newsgroup-dormant
2261 (gnus-summary-limit-include-dormant))
2262 ((and gnus-newsgroup-scored show-all)
2263 (gnus-summary-limit-include-expunged t))))
2264 ;; Function `gnus-apply-kill-file' must be called in this hook.
2265 (run-hooks 'gnus-apply-kill-hook)
2266 (if (and (zerop (buffer-size))
2269 ;; This newsgroup is empty.
2270 (gnus-summary-catchup-and-exit nil t) ;Without confirmations.
2271 (gnus-message 6 "No unread news")
2273 (gnus-kill-or-deaden-summary kill-buffer))
2274 ;; Return nil from this function.
2276 ;; Hide conversation thread subtrees. We cannot do this in
2277 ;; gnus-summary-prepare-hook since kill processing may not
2278 ;; work with hidden articles.
2279 (and gnus-show-threads
2280 gnus-thread-hide-subtree
2281 (gnus-summary-hide-all-threads))
2282 ;; Show first unread article if requested.
2283 (if (and (not no-article)
2285 gnus-newsgroup-unreads
2286 gnus-auto-select-first)
2287 (unless (if (eq gnus-auto-select-first 'best)
2288 (gnus-summary-best-unread-article)
2289 (gnus-summary-first-unread-article))
2290 (gnus-configure-windows 'summary))
2291 ;; Don't select any articles, just move point to the first
2292 ;; article in the group.
2293 (goto-char (point-min))
2294 (gnus-summary-position-point)
2295 (gnus-set-mode-line 'summary)
2296 (gnus-configure-windows 'summary 'force))
2298 (gnus-kill-or-deaden-summary kill-buffer))
2299 (when (get-buffer-window gnus-group-buffer t)
2300 ;; Gotta use windows, because recenter does wierd stuff if
2301 ;; the current buffer ain't the displayed window.
2302 (let ((owin (selected-window)))
2303 (select-window (get-buffer-window gnus-group-buffer t))
2304 (when (gnus-group-goto-group group)
2306 (select-window owin))))
2307 ;; Mark this buffer as "prepared".
2308 (setq gnus-newsgroup-prepared t)
2311 (defun gnus-summary-prepare ()
2312 "Generate the summary buffer."
2314 (let ((buffer-read-only nil))
2316 (setq gnus-newsgroup-data nil
2317 gnus-newsgroup-data-reverse nil)
2318 (run-hooks 'gnus-summary-generate-hook)
2319 ;; Generate the buffer, either with threads or without.
2320 (when gnus-newsgroup-headers
2321 (gnus-summary-prepare-threads
2322 (if gnus-show-threads
2323 (gnus-sort-gathered-threads
2324 (funcall gnus-summary-thread-gathering-function
2326 (gnus-cut-threads (gnus-make-threads)))))
2327 ;; Unthreaded display.
2328 (gnus-sort-articles gnus-newsgroup-headers))))
2329 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
2330 ;; Call hooks for modifying summary buffer.
2331 (goto-char (point-min))
2332 (run-hooks 'gnus-summary-prepare-hook)))
2334 (defsubst gnus-general-simplify-subject (subject)
2335 "Simply subject by the same rules as gnus-gather-threads-by-subject."
2338 ;; Truncate the subject.
2339 ((numberp gnus-summary-gather-subject-limit)
2340 (setq subject (gnus-simplify-subject-re subject))
2341 (if (> (length subject) gnus-summary-gather-subject-limit)
2342 (substring subject 0 gnus-summary-gather-subject-limit)
2344 ;; Fuzzily simplify it.
2345 ((eq 'fuzzy gnus-summary-gather-subject-limit)
2346 (gnus-simplify-subject-fuzzy subject))
2347 ;; Just remove the leading "Re:".
2349 (gnus-simplify-subject-re subject))))
2351 (if (and gnus-summary-gather-exclude-subject
2352 (string-match gnus-summary-gather-exclude-subject subject))
2353 nil ; This article shouldn't be gathered
2356 (defun gnus-summary-simplify-subject-query ()
2357 "Query where the respool algorithm would put this article."
2359 (gnus-set-global-variables)
2360 (gnus-summary-select-article)
2361 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
2363 (defun gnus-gather-threads-by-subject (threads)
2364 "Gather threads by looking at Subject headers."
2365 (if (not gnus-summary-make-false-root)
2367 (let ((hashtb (gnus-make-hashtable 1023))
2370 subject hthread whole-subject)
2372 (setq subject (gnus-general-simplify-subject
2373 (setq whole-subject (mail-header-subject
2376 (if (setq hthread (gnus-gethash subject hashtb))
2378 ;; We enter a dummy root into the thread, if we
2379 ;; haven't done that already.
2380 (unless (stringp (caar hthread))
2381 (setcar hthread (list whole-subject (car hthread))))
2382 ;; We add this new gathered thread to this gathered
2384 (setcdr (car hthread)
2385 (nconc (cdar hthread) (list (car threads))))
2386 ;; Remove it from the list of threads.
2387 (setcdr prev (cdr threads))
2388 (setq threads prev))
2389 ;; Enter this thread into the hash table.
2390 (gnus-sethash subject threads hashtb)))
2392 (setq threads (cdr threads)))
2395 (defun gnus-gather-threads-by-references (threads)
2396 "Gather threads by looking at References headers."
2397 (let ((idhashtb (gnus-make-hashtable 1023))
2398 (thhashtb (gnus-make-hashtable 1023))
2401 ids references id gthread gid entered ref)
2403 (when (setq references (mail-header-references (caar threads)))
2404 (setq id (mail-header-id (caar threads))
2405 ids (gnus-split-references references)
2407 (while (setq ref (pop ids))
2408 (setq ids (delete ref ids))
2409 (if (not (setq gid (gnus-gethash ref idhashtb)))
2411 (gnus-sethash ref id idhashtb)
2412 (gnus-sethash id threads thhashtb))
2413 (setq gthread (gnus-gethash gid thhashtb))
2415 ;; We enter a dummy root into the thread, if we
2416 ;; haven't done that already.
2417 (unless (stringp (caar gthread))
2418 (setcar gthread (list (mail-header-subject (caar gthread))
2420 ;; We add this new gathered thread to this gathered
2422 (setcdr (car gthread)
2423 (nconc (cdar gthread) (list (car threads)))))
2424 ;; Add it into the thread hash table.
2425 (gnus-sethash id gthread thhashtb)
2427 ;; Remove it from the list of threads.
2428 (setcdr prev (cdr threads))
2429 (setq threads prev))))
2431 (setq threads (cdr threads)))
2434 (defun gnus-sort-gathered-threads (threads)
2435 "Sort subtreads inside each gathered thread by article number."
2436 (let ((result threads))
2438 (when (stringp (caar threads))
2439 (setcdr (car threads)
2440 (sort (cdar threads) 'gnus-thread-sort-by-number)))
2441 (setq threads (cdr threads)))
2444 (defun gnus-make-threads ()
2445 "Go through the dependency hashtb and find the roots. Return all threads."
2449 (unless (car (symbol-value refs))
2450 ;; These threads do not refer back to any other articles,
2451 ;; so they're roots.
2452 (setq threads (append (cdr (symbol-value refs)) threads))))
2453 gnus-newsgroup-dependencies)
2456 (defun gnus-build-sparse-threads ()
2457 (let ((headers gnus-newsgroup-headers)
2458 (deps gnus-newsgroup-dependencies)
2459 header references generation relations
2460 cthread subject child end pthread relation)
2461 ;; First we create an alist of generations/relations, where
2462 ;; generations is how much we trust the ralation, and the relation
2464 (gnus-message 7 "Making sparse threads...")
2466 (nnheader-set-temp-buffer " *gnus sparse threads*")
2467 (while (setq header (pop headers))
2468 (when (and (setq references (mail-header-references header))
2469 (not (string= references "")))
2471 (setq child (mail-header-id header)
2472 subject (mail-header-subject header))
2474 (while (search-backward ">" nil t)
2475 (setq end (1+ (point)))
2476 (when (search-backward "<" nil t)
2477 (push (list (incf generation)
2478 child (setq child (buffer-substring (point) end))
2481 (push (list (1+ generation) child nil subject) relations)
2483 (kill-buffer (current-buffer)))
2484 ;; Sort over trustworthiness.
2485 (setq relations (sort relations (lambda (r1 r2) (< (car r1) (car r2)))))
2486 (while (setq relation (pop relations))
2487 (when (if (boundp (setq cthread (intern (cadr relation) deps)))
2488 (unless (car (symbol-value cthread))
2489 ;; Make this article the parent of these threads.
2490 (setcar (symbol-value cthread)
2491 (vector gnus-reffed-article-number
2495 (or (caddr relation) "") 0 0 "")))
2496 (set cthread (list (vector gnus-reffed-article-number
2498 "" "" (cadr relation)
2499 (or (caddr relation) "") 0 0 ""))))
2500 (push gnus-reffed-article-number gnus-newsgroup-limit)
2501 (push gnus-reffed-article-number gnus-newsgroup-sparse)
2502 (push (cons gnus-reffed-article-number gnus-sparse-mark)
2503 gnus-newsgroup-reads)
2504 (decf gnus-reffed-article-number)
2505 ;; Make this new thread the child of its parent.
2506 (if (boundp (setq pthread (intern (or (caddr relation) "none") deps)))
2507 (setcdr (symbol-value pthread)
2508 (nconc (cdr (symbol-value pthread))
2509 (list (symbol-value cthread))))
2510 (set pthread (list nil (symbol-value cthread))))))
2511 (gnus-message 7 "Making sparse threads...done")))
2513 (defun gnus-build-old-threads ()
2514 ;; Look at all the articles that refer back to old articles, and
2515 ;; fetch the headers for the articles that aren't there. This will
2516 ;; build complete threads - if the roots haven't been expired by the
2521 (when (not (car (symbol-value refs)))
2522 (setq heads (cdr (symbol-value refs)))
2524 (if (memq (mail-header-number (caar heads))
2525 gnus-newsgroup-dormant)
2526 (setq heads (cdr heads))
2527 (setq id (symbol-name refs))
2528 (while (and (setq id (gnus-build-get-header id))
2529 (not (car (gnus-gethash
2530 id gnus-newsgroup-dependencies)))))
2531 (setq heads nil)))))
2532 gnus-newsgroup-dependencies)))
2534 (defun gnus-build-get-header (id)
2535 ;; Look through the buffer of NOV lines and find the header to
2536 ;; ID. Enter this line into the dependencies hash table, and return
2537 ;; the id of the parent article (if any).
2538 (let ((deps gnus-newsgroup-dependencies)
2542 (set-buffer nntp-server-buffer)
2543 (goto-char (point-min))
2544 (while (and (not found) (search-forward id nil t))
2546 (setq found (looking-at
2547 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
2548 (regexp-quote id))))
2549 (or found (beginning-of-line 2)))
2553 (setq header (gnus-nov-parse-line
2554 (read (current-buffer)) deps))
2555 (gnus-parent-id (mail-header-references header)))))
2557 (let ((number (mail-header-number header)))
2558 (push number gnus-newsgroup-limit)
2559 (push header gnus-newsgroup-headers)
2560 (if (memq number gnus-newsgroup-unselected)
2562 (push number gnus-newsgroup-unreads)
2563 (setq gnus-newsgroup-unselected
2564 (delq number gnus-newsgroup-unselected)))
2565 (push number gnus-newsgroup-ancient)))))))
2567 (defun gnus-summary-update-article-line (article header)
2568 "Update the line for ARTICLE using HEADERS."
2569 (let* ((id (mail-header-id header))
2570 (thread (gnus-id-to-thread id)))
2572 (error "Article in no thread"))
2573 ;; Update the thread.
2574 (setcar thread header)
2575 (gnus-summary-goto-subject article)
2576 (let* ((datal (gnus-data-find-list article))
2578 (length (when (cdr datal)
2579 (- (gnus-data-pos data)
2580 (gnus-data-pos (cadr datal)))))
2581 (buffer-read-only nil)
2582 (level (gnus-summary-thread-level)))
2584 (gnus-summary-insert-line
2585 header level nil (gnus-article-mark article)
2586 (memq article gnus-newsgroup-replied)
2587 (memq article gnus-newsgroup-expirable)
2588 (mail-header-subject header)
2589 nil (cdr (assq article gnus-newsgroup-scored))
2590 (memq article gnus-newsgroup-processable))
2592 (gnus-data-update-list
2593 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
2595 (defun gnus-summary-update-article (article &optional iheader)
2596 "Update ARTICLE in the summary buffer."
2597 (set-buffer gnus-summary-buffer)
2598 (let* ((header (or iheader (gnus-summary-article-header article)))
2599 (id (mail-header-id header))
2600 (data (gnus-data-find article))
2601 (thread (gnus-id-to-thread id))
2602 (references (mail-header-references header))
2607 (not (equal "" references)))
2610 (buffer-read-only nil)
2612 (number (mail-header-number header))
2615 ;; !!! Should this be in or not?
2617 (setcar thread nil))
2619 (delq thread parent))
2620 (if (gnus-summary-insert-subject id header iheader)
2621 ;; Set the (possibly) new article number in the data structure.
2622 (gnus-data-set-number data (gnus-id-to-article id))
2626 (defun gnus-rebuild-thread (id)
2627 "Rebuild the thread containing ID."
2628 (let ((buffer-read-only nil)
2629 current thread data)
2630 (if (not gnus-show-threads)
2631 (setq thread (list (car (gnus-id-to-thread id))))
2632 ;; Get the thread this article is part of.
2633 (setq thread (gnus-remove-thread id)))
2634 (setq current (save-excursion
2635 (and (zerop (forward-line -1))
2636 (gnus-summary-article-number))))
2637 ;; If this is a gathered thread, we have to go some re-gathering.
2638 (when (stringp (car thread))
2639 (let ((subject (car thread))
2641 (setq thread (cdr thread))
2643 (unless (memq (setq thr (gnus-id-to-thread
2645 (mail-header-id (caar thread)))))
2648 (setq thread (cdr thread)))
2649 ;; We now have all (unique) roots.
2650 (if (= (length roots) 1)
2651 ;; All the loose roots are now one solid root.
2652 (setq thread (car roots))
2653 (setq thread (cons subject (gnus-sort-threads roots))))))
2655 ;; We then insert this thread into the summary buffer.
2656 (let (gnus-newsgroup-data gnus-newsgroup-threads)
2657 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
2658 (setq data (nreverse gnus-newsgroup-data))
2659 (setq threads gnus-newsgroup-threads))
2660 ;; We splice the new data into the data structure.
2661 (gnus-data-enter-list current data)
2662 (gnus-data-compute-positions)
2663 (setq gnus-newsgroup-threads (nconc threads gnus-newsgroup-threads)))))
2665 (defun gnus-number-to-header (number)
2666 "Return the header for article NUMBER."
2667 (let ((headers gnus-newsgroup-headers))
2669 (not (= number (mail-header-number (car headers)))))
2674 (defun gnus-parent-headers (headers &optional generation)
2675 "Return the headers of the GENERATIONeth parent of HEADERS."
2677 (setq generation 1))
2678 (let (references parent)
2679 (while (and headers (not (zerop generation)))
2680 (setq references (mail-header-references headers))
2681 (when (and references
2682 (setq parent (gnus-parent-id references))
2683 (setq headers (car (gnus-id-to-thread parent))))
2687 (defun gnus-id-to-thread (id)
2688 "Return the (sub-)thread where ID appears."
2689 (gnus-gethash id gnus-newsgroup-dependencies))
2691 (defun gnus-id-to-article (id)
2692 "Return the article number of ID."
2693 (let ((thread (gnus-id-to-thread id)))
2696 (mail-header-number (car thread)))))
2698 (defun gnus-id-to-header (id)
2699 "Return the article headers of ID."
2700 (car (gnus-id-to-thread id)))
2702 (defun gnus-article-displayed-root-p (article)
2703 "Say whether ARTICLE is a root(ish) article."
2704 (let ((level (gnus-summary-thread-level article))
2705 (refs (mail-header-references (gnus-summary-article-header article)))
2711 ((null (gnus-parent-id refs)) t)
2713 (null (setq particle (gnus-id-to-article
2714 (gnus-parent-id refs))))
2715 (null (gnus-summary-thread-level particle)))))))
2717 (defun gnus-root-id (id)
2718 "Return the id of the root of the thread where ID appears."
2720 (while (and id (setq prev (car (gnus-gethash
2721 id gnus-newsgroup-dependencies))))
2723 id (gnus-parent-id (mail-header-references prev))))
2726 (defun gnus-remove-thread (id &optional dont-remove)
2727 "Remove the thread that has ID in it."
2728 (let ((dep gnus-newsgroup-dependencies)
2729 headers thread last-id)
2730 ;; First go up in this thread until we find the root.
2731 (setq last-id (gnus-root-id id))
2732 (setq headers (list (car (gnus-id-to-thread last-id))
2733 (caadr (gnus-id-to-thread last-id))))
2734 ;; We have now found the real root of this thread. It might have
2735 ;; been gathered into some loose thread, so we have to search
2736 ;; through the threads to find the thread we wanted.
2737 (let ((threads gnus-newsgroup-threads)
2740 (setq sub (car threads))
2741 (if (stringp (car sub))
2742 ;; This is a gathered thread, so we look at the roots
2743 ;; below it to find whether this article is in this
2746 (setq sub (cdr sub))
2748 (when (member (caar sub) headers)
2749 (setq thread (car threads)
2752 (setq sub (cdr sub))))
2753 ;; It's an ordinary thread, so we check it.
2754 (when (eq (car sub) (car headers))
2757 (setq threads (cdr threads)))
2758 ;; If this article is in no thread, then it's a root.
2761 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
2762 (setq thread (gnus-gethash last-id dep)))
2765 thread ; We return this thread.
2767 (if (stringp (car thread))
2769 ;; If we use dummy roots, then we have to remove the
2770 ;; dummy root as well.
2771 (when (eq gnus-summary-make-false-root 'dummy)
2774 (setq thread (cdr thread))
2776 (gnus-remove-thread-1 (car thread))
2777 (setq thread (cdr thread))))
2778 (gnus-remove-thread-1 thread))))))))
2780 (defun gnus-remove-thread-1 (thread)
2781 "Remove the thread THREAD recursively."
2782 (let ((number (mail-header-number (car thread)))
2784 (when (setq pos (text-property-any
2785 (point-min) (point-max) 'gnus-number number))
2788 (gnus-data-remove number))
2789 (setq thread (cdr thread))
2791 (gnus-remove-thread-1 (pop thread)))))
2793 (defun gnus-sort-threads (threads)
2795 (if (not gnus-thread-sort-functions)
2797 (gnus-message 7 "Sorting threads...")
2799 (sort threads (gnus-make-sort-function gnus-thread-sort-functions))
2800 (gnus-message 7 "Sorting threads...done"))))
2802 (defun gnus-sort-articles (articles)
2804 (when gnus-article-sort-functions
2805 (gnus-message 7 "Sorting articles...")
2807 (setq gnus-newsgroup-headers
2808 (sort articles (gnus-make-sort-function
2809 gnus-article-sort-functions)))
2810 (gnus-message 7 "Sorting articles...done"))))
2812 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
2813 (defmacro gnus-thread-header (thread)
2814 ;; Return header of first article in THREAD.
2815 ;; Note that THREAD must never, ever be anything else than a variable -
2816 ;; using some other form will lead to serious barfage.
2817 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
2818 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
2819 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
2822 (defsubst gnus-article-sort-by-number (h1 h2)
2823 "Sort articles by article number."
2824 (< (mail-header-number h1)
2825 (mail-header-number h2)))
2827 (defun gnus-thread-sort-by-number (h1 h2)
2828 "Sort threads by root article number."
2829 (gnus-article-sort-by-number
2830 (gnus-thread-header h1) (gnus-thread-header h2)))
2832 (defsubst gnus-article-sort-by-author (h1 h2)
2833 "Sort articles by root author."
2835 (let ((extract (funcall
2836 gnus-extract-address-components
2837 (mail-header-from h1))))
2838 (or (car extract) (cdr extract)))
2839 (let ((extract (funcall
2840 gnus-extract-address-components
2841 (mail-header-from h2))))
2842 (or (car extract) (cdr extract)))))
2844 (defun gnus-thread-sort-by-author (h1 h2)
2845 "Sort threads by root author."
2846 (gnus-article-sort-by-author
2847 (gnus-thread-header h1) (gnus-thread-header h2)))
2849 (defsubst gnus-article-sort-by-subject (h1 h2)
2850 "Sort articles by root subject."
2852 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
2853 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
2855 (defun gnus-thread-sort-by-subject (h1 h2)
2856 "Sort threads by root subject."
2857 (gnus-article-sort-by-subject
2858 (gnus-thread-header h1) (gnus-thread-header h2)))
2860 (defsubst gnus-article-sort-by-date (h1 h2)
2861 "Sort articles by root article date."
2863 (inline (gnus-sortable-date (mail-header-date h1)))
2864 (inline (gnus-sortable-date (mail-header-date h2)))))
2866 (defun gnus-thread-sort-by-date (h1 h2)
2867 "Sort threads by root article date."
2868 (gnus-article-sort-by-date
2869 (gnus-thread-header h1) (gnus-thread-header h2)))
2871 (defsubst gnus-article-sort-by-score (h1 h2)
2872 "Sort articles by root article score.
2873 Unscored articles will be counted as having a score of zero."
2874 (> (or (cdr (assq (mail-header-number h1)
2875 gnus-newsgroup-scored))
2876 gnus-summary-default-score 0)
2877 (or (cdr (assq (mail-header-number h2)
2878 gnus-newsgroup-scored))
2879 gnus-summary-default-score 0)))
2881 (defun gnus-thread-sort-by-score (h1 h2)
2882 "Sort threads by root article score."
2883 (gnus-article-sort-by-score
2884 (gnus-thread-header h1) (gnus-thread-header h2)))
2886 (defun gnus-thread-sort-by-total-score (h1 h2)
2887 "Sort threads by the sum of all scores in the thread.
2888 Unscored articles will be counted as having a score of zero."
2889 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
2891 (defun gnus-thread-total-score (thread)
2892 ;; This function find the total score of THREAD.
2893 (cond ((null thread)
2896 (if (stringp (car thread))
2897 (apply gnus-thread-score-function 0
2898 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
2899 (gnus-thread-total-score-1 thread)))
2901 (gnus-thread-total-score-1 (list thread)))))
2903 (defun gnus-thread-total-score-1 (root)
2904 ;; This function find the total score of the thread below ROOT.
2905 (setq root (car root))
2906 (apply gnus-thread-score-function
2908 (mapcar 'gnus-thread-total-score
2909 (cdr (gnus-gethash (mail-header-id root)
2910 gnus-newsgroup-dependencies)))
2911 (if (> (mail-header-number root) 0)
2912 (list (or (cdr (assq (mail-header-number root)
2913 gnus-newsgroup-scored))
2914 gnus-summary-default-score 0))))
2915 (list gnus-summary-default-score)
2918 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
2919 (defvar gnus-tmp-prev-subject nil)
2920 (defvar gnus-tmp-false-parent nil)
2921 (defvar gnus-tmp-root-expunged nil)
2922 (defvar gnus-tmp-dummy-line nil)
2924 (defun gnus-summary-prepare-threads (threads)
2925 "Prepare summary buffer from THREADS and indentation LEVEL.
2926 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
2927 or a straight list of headers."
2928 (gnus-message 7 "Generating summary...")
2930 (setq gnus-newsgroup-threads threads)
2933 (let ((gnus-tmp-level 0)
2934 (default-score (or gnus-summary-default-score 0))
2935 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
2936 thread number subject stack state gnus-tmp-gathered beg-match
2937 new-roots gnus-tmp-new-adopts thread-end
2938 gnus-tmp-header gnus-tmp-unread
2939 gnus-tmp-replied gnus-tmp-subject-or-nil
2940 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
2941 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
2942 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
2944 (setq gnus-tmp-prev-subject nil)
2946 (if (vectorp (car threads))
2947 ;; If this is a straight (sic) list of headers, then a
2948 ;; threaded summary display isn't required, so we just create
2949 ;; an unthreaded one.
2950 (gnus-summary-prepare-unthreaded threads)
2952 ;; Do the threaded display.
2954 (while (or threads stack gnus-tmp-new-adopts new-roots)
2956 (if (and (= gnus-tmp-level 0)
2957 (not (setq gnus-tmp-dummy-line nil))
2960 (not gnus-tmp-false-parent)
2961 (or gnus-tmp-new-adopts new-roots))
2962 (if gnus-tmp-new-adopts
2963 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
2964 thread (list (car gnus-tmp-new-adopts))
2965 gnus-tmp-header (caar thread)
2966 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
2968 (setq thread (list (car new-roots))
2969 gnus-tmp-header (caar thread)
2970 new-roots (cdr new-roots))))
2973 ;; If there are some threads, we do them before the
2974 ;; threads on the stack.
2975 (setq thread threads
2976 gnus-tmp-header (caar thread))
2977 ;; There were no current threads, so we pop something off
2979 (setq state (car stack)
2980 gnus-tmp-level (car state)
2983 gnus-tmp-header (caar thread))))
2985 (setq gnus-tmp-false-parent nil)
2986 (setq gnus-tmp-root-expunged nil)
2987 (setq thread-end nil)
2989 (if (stringp gnus-tmp-header)
2990 ;; The header is a dummy root.
2992 ((eq gnus-summary-make-false-root 'adopt)
2993 ;; We let the first article adopt the rest.
2994 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
2996 (setq gnus-tmp-gathered
2998 (lambda (h) (mail-header-number (car h)))
3001 (setq thread (cons (list (caar thread)
3004 (setq gnus-tmp-level -1
3005 gnus-tmp-false-parent t))
3006 ((eq gnus-summary-make-false-root 'empty)
3007 ;; We print adopted articles with empty subject fields.
3008 (setq gnus-tmp-gathered
3010 (lambda (h) (mail-header-number (car h)))
3013 (setq gnus-tmp-level -1))
3014 ((eq gnus-summary-make-false-root 'dummy)
3015 ;; We remember that we probably want to output a dummy
3017 (setq gnus-tmp-dummy-line gnus-tmp-header)
3018 (setq gnus-tmp-prev-subject gnus-tmp-header))
3020 ;; We do not make a root for the gathered
3021 ;; sub-threads at all.
3022 (setq gnus-tmp-level -1)))
3024 (setq number (mail-header-number gnus-tmp-header)
3025 subject (mail-header-subject gnus-tmp-header))
3028 ;; If the thread has changed subject, we might want to make
3029 ;; this subthread into a root.
3030 ((and (null gnus-thread-ignore-subject)
3031 (not (zerop gnus-tmp-level))
3032 gnus-tmp-prev-subject
3034 (gnus-subject-equal gnus-tmp-prev-subject subject))))
3035 (setq new-roots (nconc new-roots (list (car thread)))
3037 gnus-tmp-header nil))
3038 ;; If the article lies outside the current limit,
3039 ;; then we do not display it.
3040 ((and (not (memq number gnus-newsgroup-limit))
3041 (not gnus-tmp-dummy-line))
3042 (setq gnus-tmp-gathered
3044 (lambda (h) (mail-header-number (car h)))
3047 (setq gnus-tmp-new-adopts (if (cdar thread)
3048 (append gnus-tmp-new-adopts
3050 gnus-tmp-new-adopts)
3052 gnus-tmp-header nil)
3053 (when (zerop gnus-tmp-level)
3054 (setq gnus-tmp-root-expunged t)))
3055 ;; Perhaps this article is to be marked as read?
3056 ((and gnus-summary-mark-below
3057 (< (or (cdr (assq number gnus-newsgroup-scored))
3059 gnus-summary-mark-below)
3060 ;; Don't touch sparse articles.
3061 (not (memq number gnus-newsgroup-sparse))
3062 (not (memq number gnus-newsgroup-ancient)))
3063 (setq gnus-newsgroup-unreads
3064 (delq number gnus-newsgroup-unreads))
3065 (if gnus-newsgroup-auto-expire
3066 (push number gnus-newsgroup-expirable)
3067 (push (cons number gnus-low-score-mark)
3068 gnus-newsgroup-reads))))
3070 (when gnus-tmp-header
3071 ;; We may have an old dummy line to output before this
3073 (when gnus-tmp-dummy-line
3074 (gnus-summary-insert-dummy-line
3075 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
3076 (setq gnus-tmp-dummy-line nil))
3078 ;; Compute the mark.
3079 (setq gnus-tmp-unread (gnus-article-mark number))
3081 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
3082 gnus-tmp-header gnus-tmp-level)
3083 gnus-newsgroup-data)
3085 ;; Actually insert the line.
3087 gnus-tmp-subject-or-nil
3089 ((and gnus-thread-ignore-subject
3090 gnus-tmp-prev-subject
3091 (not (inline (gnus-subject-equal
3092 gnus-tmp-prev-subject subject))))
3094 ((zerop gnus-tmp-level)
3095 (if (and (eq gnus-summary-make-false-root 'empty)
3096 (memq number gnus-tmp-gathered)
3097 gnus-tmp-prev-subject
3098 (inline (gnus-subject-equal
3099 gnus-tmp-prev-subject subject)))
3100 gnus-summary-same-subject
3102 (t gnus-summary-same-subject)))
3103 (if (and (eq gnus-summary-make-false-root 'adopt)
3104 (= gnus-tmp-level 1)
3105 (memq number gnus-tmp-gathered))
3106 (setq gnus-tmp-opening-bracket ?\<
3107 gnus-tmp-closing-bracket ?\>)
3108 (setq gnus-tmp-opening-bracket ?\[
3109 gnus-tmp-closing-bracket ?\]))
3111 gnus-tmp-indentation
3112 (aref gnus-thread-indent-array gnus-tmp-level)
3113 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
3114 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
3115 gnus-summary-default-score 0)
3117 (if (or (null gnus-summary-default-score)
3118 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3119 gnus-summary-zcore-fuzz)) ?
3120 (if (< gnus-tmp-score gnus-summary-default-score)
3121 gnus-score-below-mark gnus-score-over-mark))
3123 (cond ((memq number gnus-newsgroup-processable)
3125 ((memq number gnus-newsgroup-cached)
3127 ((memq number gnus-newsgroup-replied)
3129 ((memq number gnus-newsgroup-saved)
3131 (t gnus-unread-mark))
3132 gnus-tmp-from (mail-header-from gnus-tmp-header)
3135 ((string-match "(.+)" gnus-tmp-from)
3136 (substring gnus-tmp-from
3137 (1+ (match-beginning 0)) (1- (match-end 0))))
3138 ((string-match "<[^>]+> *$" gnus-tmp-from)
3139 (setq beg-match (match-beginning 0))
3140 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
3141 (substring gnus-tmp-from (1+ (match-beginning 0))
3142 (1- (match-end 0))))
3143 (substring gnus-tmp-from 0 beg-match)))
3145 (when (string= gnus-tmp-name "")
3146 (setq gnus-tmp-name gnus-tmp-from))
3147 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
3148 (gnus-put-text-property
3150 (progn (eval gnus-summary-line-format-spec) (point))
3151 'gnus-number number)
3154 (run-hooks 'gnus-summary-update-hook)
3157 (setq gnus-tmp-prev-subject subject)))
3159 (when (nth 1 thread)
3160 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
3161 (incf gnus-tmp-level)
3162 (setq threads (if thread-end nil (cdar thread)))
3164 (setq gnus-tmp-level 0)))))
3165 (gnus-message 7 "Generating summary...done"))
3167 (defun gnus-summary-prepare-unthreaded (headers)
3168 "Generate an unthreaded summary buffer based on HEADERS."
3169 (let (header number mark)
3172 ;; We may have to root out some bad articles...
3173 (when (memq (setq number (mail-header-number
3174 (setq header (pop headers))))
3175 gnus-newsgroup-limit)
3176 ;; Mark article as read when it has a low score.
3177 (when (and gnus-summary-mark-below
3178 (< (or (cdr (assq number gnus-newsgroup-scored))
3179 gnus-summary-default-score 0)
3180 gnus-summary-mark-below)
3181 (not (memq number gnus-newsgroup-ancient)))
3182 (setq gnus-newsgroup-unreads
3183 (delq number gnus-newsgroup-unreads))
3184 (if gnus-newsgroup-auto-expire
3185 (push number gnus-newsgroup-expirable)
3186 (push (cons number gnus-low-score-mark)
3187 gnus-newsgroup-reads)))
3189 (setq mark (gnus-article-mark number))
3190 (setq gnus-newsgroup-data
3191 (cons (gnus-data-make number mark (1+ (point)) header 0)
3192 gnus-newsgroup-data))
3193 (gnus-summary-insert-line
3194 header 0 nil mark (memq number gnus-newsgroup-replied)
3195 (memq number gnus-newsgroup-expirable)
3196 (mail-header-subject header) nil
3197 (cdr (assq number gnus-newsgroup-scored))
3198 (memq number gnus-newsgroup-processable))))))
3200 (defun gnus-select-newsgroup (group &optional read-all)
3201 "Select newsgroup GROUP.
3202 If READ-ALL is non-nil, all articles in the group are selected."
3203 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
3204 (info (nth 2 entry))
3205 articles fetched-articles cached)
3207 (or (gnus-check-server
3208 (setq gnus-current-select-method (gnus-find-method-for-group group)))
3209 (error "Couldn't open server"))
3211 (or (and entry (not (eq (car entry) t))) ; Either it's active...
3212 (gnus-activate-group group) ; Or we can activate it...
3213 (progn ; Or we bug out.
3214 (when (equal major-mode 'gnus-summary-mode)
3215 (kill-buffer (current-buffer)))
3216 (error "Couldn't request group %s: %s"
3217 group (gnus-status-message group))))
3219 (unless (gnus-request-group group t)
3220 (when (equal major-mode 'gnus-summary-mode)
3221 (kill-buffer (current-buffer)))
3222 (error "Couldn't request group %s: %s"
3223 group (gnus-status-message group)))
3225 (setq gnus-newsgroup-name group)
3226 (setq gnus-newsgroup-unselected nil)
3227 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
3229 ;; Adjust and set lists of article marks.
3231 (gnus-adjust-marked-articles info))
3233 ;; Kludge to avoid having cached articles nixed out in virtual groups.
3234 (when (gnus-virtual-group-p group)
3235 (setq cached gnus-newsgroup-cached))
3237 (setq gnus-newsgroup-unreads
3238 (gnus-set-difference
3239 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
3240 gnus-newsgroup-dormant))
3242 (setq gnus-newsgroup-processable nil)
3244 (setq articles (gnus-articles-to-read group read-all))
3248 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
3250 ((eq articles 0) nil)
3252 ;; Init the dependencies hash table.
3253 (setq gnus-newsgroup-dependencies
3254 (gnus-make-hashtable (length articles)))
3255 ;; Retrieve the headers and read them in.
3256 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
3257 (setq gnus-newsgroup-headers
3259 (setq gnus-headers-retrieved-by
3260 (gnus-retrieve-headers
3261 articles gnus-newsgroup-name
3262 ;; We might want to fetch old headers, but
3263 ;; not if there is only 1 article.
3264 (and gnus-fetch-old-headers
3266 (not (eq gnus-fetch-old-headers 'some))
3267 (not (numberp gnus-fetch-old-headers)))
3268 (> (length articles) 1))))))
3269 (gnus-get-newsgroup-headers-xover articles)
3270 (gnus-get-newsgroup-headers)))
3271 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
3273 ;; Kludge to avoid having cached articles nixed out in virtual groups.
3275 (setq gnus-newsgroup-cached cached))
3277 ;; Suppress duplicates?
3278 (when gnus-suppress-duplicates
3279 (gnus-dup-suppress-articles))
3281 ;; Set the initial limit.
3282 (setq gnus-newsgroup-limit (copy-sequence articles))
3283 ;; Remove canceled articles from the list of unread articles.
3284 (setq gnus-newsgroup-unreads
3285 (gnus-set-sorted-intersection
3286 gnus-newsgroup-unreads
3287 (setq fetched-articles
3288 (mapcar (lambda (headers) (mail-header-number headers))
3289 gnus-newsgroup-headers))))
3290 ;; Removed marked articles that do not exist.
3291 (gnus-update-missing-marks
3292 (gnus-sorted-complement fetched-articles articles))
3293 ;; We might want to build some more threads first.
3294 (and gnus-fetch-old-headers
3295 (eq gnus-headers-retrieved-by 'nov)
3296 (gnus-build-old-threads))
3297 ;; Check whether auto-expire is to be done in this group.
3298 (setq gnus-newsgroup-auto-expire
3299 (gnus-group-auto-expirable-p group))
3300 ;; Set up the article buffer now, if necessary.
3301 (unless gnus-single-article-buffer
3302 (gnus-article-setup-buffer))
3303 ;; First and last article in this newsgroup.
3304 (when gnus-newsgroup-headers
3305 (setq gnus-newsgroup-begin
3306 (mail-header-number (car gnus-newsgroup-headers))
3309 (gnus-last-element gnus-newsgroup-headers))))
3310 ;; GROUP is successfully selected.
3311 (or gnus-newsgroup-headers t)))))
3313 (defun gnus-articles-to-read (group read-all)
3314 ;; Find out what articles the user wants to read.
3316 ;; Select all articles if `read-all' is non-nil, or if there
3317 ;; are no unread articles.
3319 (and (zerop (length gnus-newsgroup-marked))
3320 (zerop (length gnus-newsgroup-unreads)))
3321 (eq (gnus-group-find-parameter group 'display)
3323 (gnus-uncompress-range (gnus-active group))
3324 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
3325 (copy-sequence gnus-newsgroup-unreads))
3327 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
3328 (scored (length scored-list))
3329 (number (length articles))
3330 (marked (+ (length gnus-newsgroup-marked)
3331 (length gnus-newsgroup-dormant)))
3339 ((and (or (<= scored marked) (= scored number))
3340 (numberp gnus-large-newsgroup)
3341 (> number gnus-large-newsgroup))
3345 "How many articles from %s (default %d): "
3346 gnus-newsgroup-name number))))
3347 (if (string-match "^[ \t]*$" input) number input)))
3348 ((and (> scored marked) (< scored number)
3349 (> (- scored number) 20))
3352 (format "%s %s (%d scored, %d total): "
3353 "How many articles from"
3354 group scored number))))
3355 (if (string-match "^[ \t]*$" input)
3359 (setq select (if (stringp select) (string-to-number select) select))
3360 (if (or (null select) (zerop select))
3362 (if (and (not (zerop scored)) (<= (abs select) scored))
3364 (setq articles (sort scored-list '<))
3365 (setq number (length articles)))
3366 (setq articles (copy-sequence articles)))
3368 (if (< (abs select) number)
3370 ;; Select the N oldest articles.
3371 (setcdr (nthcdr (1- (abs select)) articles) nil)
3372 ;; Select the N most recent articles.
3373 (setq articles (nthcdr (- number select) articles))))
3374 (setq gnus-newsgroup-unselected
3375 (gnus-sorted-intersection
3376 gnus-newsgroup-unreads
3377 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
3380 (defun gnus-killed-articles (killed articles)
3383 (if (inline (gnus-member-of-range (car articles) killed))
3384 (setq out (cons (car articles) out)))
3385 (setq articles (cdr articles)))
3388 (defun gnus-uncompress-marks (marks)
3389 "Uncompress the mark ranges in MARKS."
3390 (let ((uncompressed '(score bookmark))
3393 (if (memq (caar marks) uncompressed)
3394 (push (car marks) out)
3395 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
3396 (setq marks (cdr marks)))
3399 (defun gnus-adjust-marked-articles (info)
3400 "Set all article lists and remove all marks that are no longer legal."
3401 (let* ((marked-lists (gnus-info-marks info))
3402 (active (gnus-active (gnus-info-group info)))
3405 (types gnus-article-mark-lists)
3406 (uncompressed '(score bookmark killed))
3407 marks var articles article mark)
3410 (setq marks (pop marked-lists))
3411 (set (setq var (intern (format "gnus-newsgroup-%s"
3412 (car (rassq (setq mark (car marks))
3414 (if (memq (car marks) uncompressed) (cdr marks)
3415 (gnus-uncompress-range (cdr marks))))
3417 (setq articles (symbol-value var))
3419 ;; All articles have to be subsets of the active articles.
3421 ;; Adjust "simple" lists.
3422 ((memq mark '(tick dormant expirable reply save))
3424 (when (or (< (setq article (pop articles)) min) (> article max))
3425 (set var (delq article (symbol-value var))))))
3427 ((memq mark uncompressed)
3429 (when (or (not (consp (setq article (pop articles))))
3430 (< (car article) min)
3431 (> (car article) max))
3432 (set var (delq article (symbol-value var))))))))))
3434 (defun gnus-update-missing-marks (missing)
3435 "Go through the list of MISSING articles and remove them mark lists."
3437 (let ((types gnus-article-mark-lists)
3439 ;; Go through all types.
3441 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
3442 (when (symbol-value var)
3443 ;; This list has articles. So we delete all missing articles
3447 (set var (delq (pop m) (symbol-value var)))))))))
3449 (defun gnus-update-marks ()
3450 "Enter the various lists of marked articles into the newsgroup info list."
3451 (let ((types gnus-article-mark-lists)
3452 (info (gnus-get-info gnus-newsgroup-name))
3453 (uncompressed '(score bookmark killed))
3454 type list newmarked symbol)
3456 ;; Add all marks lists that are non-nil to the list of marks lists.
3458 (setq type (pop types))
3459 (when (setq list (symbol-value
3461 (intern (format "gnus-newsgroup-%s"
3463 (push (cons (cdr type)
3464 (if (memq (cdr type) uncompressed) list
3465 (gnus-compress-sequence
3466 (set symbol (sort list '<)) t)))
3469 ;; Enter these new marks into the info of the group.
3471 (setcar (nthcdr 3 info) newmarked)
3472 ;; Add the marks lists to the end of the info.
3474 (setcdr (nthcdr 2 info) (list newmarked))))
3476 ;; Cut off the end of the info if there's nothing else there.
3480 (when (nthcdr (decf i) info)
3481 (setcdr (nthcdr i info) nil)))))))
3483 (defun gnus-set-mode-line (where)
3484 "This function sets the mode line of the article or summary buffers.
3485 If WHERE is `summary', the summary mode line format will be used."
3486 ;; Is this mode line one we keep updated?
3487 (when (memq where gnus-updated-mode-lines)
3490 ;; We evaluate this in the summary buffer since these
3491 ;; variables are buffer-local to that buffer.
3492 (set-buffer gnus-summary-buffer)
3493 ;; We bind all these variables that are used in the `eval' form
3495 (let* ((mformat (symbol-value
3497 (format "gnus-%s-mode-line-format-spec" where))))
3498 (gnus-tmp-group-name gnus-newsgroup-name)
3499 (gnus-tmp-article-number (or gnus-current-article 0))
3500 (gnus-tmp-unread gnus-newsgroup-unreads)
3501 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
3502 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
3503 (gnus-tmp-unread-and-unselected
3504 (cond ((and (zerop gnus-tmp-unread-and-unticked)
3505 (zerop gnus-tmp-unselected)) "")
3506 ((zerop gnus-tmp-unselected)
3507 (format "{%d more}" gnus-tmp-unread-and-unticked))
3508 (t (format "{%d(+%d) more}"
3509 gnus-tmp-unread-and-unticked
3510 gnus-tmp-unselected))))
3512 (if (and gnus-current-headers
3513 (vectorp gnus-current-headers))
3514 (gnus-mode-string-quote
3515 (mail-header-subject gnus-current-headers)) ""))
3517 gnus-tmp-header);; passed as argument to any user-format-funcs
3518 (setq mode-string (eval mformat))
3519 (setq max-len (max 4 (if gnus-mode-non-string-length
3521 gnus-mode-non-string-length)
3522 (length mode-string))))
3523 ;; We might have to chop a bit of the string off...
3524 (when (> (length mode-string) max-len)
3526 (concat (gnus-truncate-string mode-string (- max-len 3))
3528 ;; Pad the mode string a bit.
3529 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
3530 ;; Update the mode line.
3531 (setq mode-line-buffer-identification
3532 (gnus-mode-line-buffer-identification
3533 (list mode-string)))
3534 (set-buffer-modified-p t))))
3536 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
3537 "Go through the HEADERS list and add all Xrefs to a hash table.
3538 The resulting hash table is returned, or nil if no Xrefs were found."
3539 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
3540 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
3541 (xref-hashtb (make-vector 63 0))
3542 start group entry number xrefs header)
3544 (setq header (pop headers))
3545 (when (and (setq xrefs (mail-header-xref header))
3546 (not (memq (setq number (mail-header-number header))
3549 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
3550 (setq start (match-end 0))
3551 (setq group (if prefix
3552 (concat prefix (substring xrefs (match-beginning 1)
3554 (substring xrefs (match-beginning 1) (match-end 1))))
3556 (string-to-int (substring xrefs (match-beginning 2)
3558 (if (setq entry (gnus-gethash group xref-hashtb))
3559 (setcdr entry (cons number (cdr entry)))
3560 (gnus-sethash group (cons number nil) xref-hashtb)))))
3561 (and start xref-hashtb)))
3563 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
3564 "Look through all the headers and mark the Xrefs as read."
3565 (let ((virtual (gnus-virtual-group-p from-newsgroup))
3566 name entry info xref-hashtb idlist method nth4)
3568 (set-buffer gnus-group-buffer)
3569 (when (setq xref-hashtb
3570 (gnus-create-xref-hashtb from-newsgroup headers unreads))
3573 (unless (string= from-newsgroup (setq name (symbol-name group)))
3574 (setq idlist (symbol-value group))
3575 ;; Dead groups are not updated.
3577 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
3579 (if (stringp (setq nth4 (gnus-info-method info)))
3580 (setq nth4 (gnus-server-to-method nth4))))
3581 ;; Only do the xrefs if the group has the same
3582 ;; select method as the group we have just read.
3583 (or (gnus-methods-equal-p
3584 nth4 (gnus-find-method-for-group from-newsgroup))
3586 (equal nth4 (setq method (gnus-find-method-for-group
3588 (and (equal (car nth4) (car method))
3589 (equal (nth 1 nth4) (nth 1 method))))
3590 gnus-use-cross-reference
3591 (or (not (eq gnus-use-cross-reference t))
3593 ;; Only do cross-references on subscribed
3594 ;; groups, if that is what is wanted.
3595 (<= (gnus-info-level info) gnus-level-subscribed))
3596 (gnus-group-make-articles-read name idlist))))
3599 (defun gnus-group-make-articles-read (group articles)
3600 "Update the info of GROUP to say that only ARTICLES are unread."
3602 (entry (gnus-gethash group gnus-newsrc-hashtb))
3603 (info (nth 2 entry))
3604 (active (gnus-active group))
3606 ;; First peel off all illegal article numbers.
3608 (let ((ids articles)
3610 (while (setq id (pop ids))
3611 (when (and first (> id (cdr active)))
3612 ;; We'll end up in this situation in one particular
3613 ;; obscure situation. If you re-scan a group and get
3614 ;; a new article that is cross-posted to a different
3615 ;; group that has not been re-scanned, you might get
3616 ;; crossposted article that has a higher number than
3617 ;; Gnus believes possible. So we re-activate this
3618 ;; group as well. This might mean doing the
3619 ;; crossposting thingy will *increase* the number
3620 ;; of articles in some groups. Tsk, tsk.
3621 (setq active (or (gnus-activate-group group) active)))
3622 (when (or (> id (cdr active))
3623 (< id (car active)))
3624 (setq articles (delq id articles))))))
3627 (gnus-info-set-marks ,info ,(gnus-info-marks info))
3628 (gnus-info-set-read ,info ,(gnus-info-read info))
3629 (gnus-group-update-group group t)))
3630 ;; If the read list is nil, we init it.
3632 (null (gnus-info-read info))
3634 (gnus-info-set-read info (cons 1 (1- (car active)))))
3635 ;; Then we add the read articles to the range.
3640 (gnus-info-read info) (setq articles (sort articles '<)))))
3641 ;; Then we have to re-compute how many unread
3642 ;; articles there are in this group.
3646 (setq num (- (1+ (cdr active)) (car active))))
3647 ((not (listp (cdr range)))
3648 (setq num (- (cdr active) (- (1+ (cdr range))
3652 (if (numberp (car range))
3654 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
3655 (setq range (cdr range)))
3656 (setq num (- (cdr active) num))))
3657 ;; Update the number of unread articles.
3659 ;; Update the group buffer.
3660 (gnus-group-update-group group t))))
3662 (defun gnus-methods-equal-p (m1 m2)
3663 (let ((m1 (or m1 gnus-select-method))
3664 (m2 (or m2 gnus-select-method)))
3666 (and (eq (car m1) (car m2))
3667 (or (not (memq 'address (assoc (symbol-name (car m1))
3668 gnus-valid-select-methods)))
3669 (equal (nth 1 m1) (nth 1 m2)))))))
3671 (defsubst gnus-header-value ()
3672 (buffer-substring (match-end 0) (gnus-point-at-eol)))
3674 (defvar gnus-newsgroup-none-id 0)
3676 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
3677 (let ((cur nntp-server-buffer)
3680 (save-excursion (set-buffer gnus-summary-buffer)
3681 gnus-newsgroup-dependencies)))
3682 headers id id-dep ref-dep end ref)
3684 (set-buffer nntp-server-buffer)
3685 ;; Translate all TAB characters into SPACE characters.
3686 (subst-char-in-region (point-min) (point-max) ?\t ? t)
3687 (run-hooks 'gnus-parse-headers-hook)
3688 (let ((case-fold-search t)
3689 in-reply-to header p lines)
3690 (goto-char (point-min))
3691 ;; Search to the beginning of the next header. Error messages
3692 ;; do not begin with 2 or 3.
3693 (while (re-search-forward "^[23][0-9]+ " nil t)
3696 ;; This implementation of this function, with nine
3697 ;; search-forwards instead of the one re-search-forward and
3698 ;; a case (which basically was the old function) is actually
3699 ;; about twice as fast, even though it looks messier. You
3700 ;; can't have everything, I guess. Speed and elegance
3701 ;; doesn't always go hand in hand.
3710 (narrow-to-region (point)
3711 (or (and (search-forward "\n.\n" nil t)
3717 (if (search-forward "\nsubject: " nil t)
3718 (gnus-header-value) "(none)"))
3722 (if (search-forward "\nfrom: " nil t)
3723 (gnus-header-value) "(nobody)"))
3727 (if (search-forward "\ndate: " nil t)
3728 (gnus-header-value) ""))
3732 (if (search-forward "\nmessage-id: " nil t)
3733 (setq id (gnus-header-value))
3734 ;; If there was no message-id, we just fake one to make
3735 ;; subsequent routines simpler.
3736 (setq id (concat "none+"
3738 (setq gnus-newsgroup-none-id
3739 (1+ gnus-newsgroup-none-id)))))))
3743 (if (search-forward "\nreferences: " nil t)
3752 (search-backward ">" end t)
3755 (search-backward "<" end t)
3757 ;; Get the references from the in-reply-to header if there
3758 ;; were no references and the in-reply-to header looks
3760 (if (and (search-forward "\nin-reply-to: " nil t)
3761 (setq in-reply-to (gnus-header-value))
3762 (string-match "<[^>]+>" in-reply-to))
3763 (setq ref (substring in-reply-to (match-beginning 0)
3771 (if (search-forward "\nlines: " nil t)
3772 (if (numberp (setq lines (read cur)))
3778 (and (search-forward "\nxref: " nil t)
3779 (gnus-header-value)))))
3780 (when (equal id ref)
3782 ;; We do the threading while we read the headers. The
3783 ;; message-id and the last reference are both entered into
3784 ;; the same hash table. Some tippy-toeing around has to be
3785 ;; done in case an article has arrived before the article
3786 ;; which it refers to.
3787 (if (boundp (setq id-dep (intern id dependencies)))
3788 (if (and (car (symbol-value id-dep))
3790 ;; An article with this Message-ID has already
3791 ;; been seen, so we ignore this one, except we add
3792 ;; any additional Xrefs (in case the two articles
3793 ;; came from different servers).
3795 (mail-header-set-xref
3796 (car (symbol-value id-dep))
3797 (concat (or (mail-header-xref
3798 (car (symbol-value id-dep))) "")
3799 (or (mail-header-xref header) "")))
3801 (setcar (symbol-value id-dep) header))
3802 (set id-dep (list header)))
3804 (if (boundp (setq ref-dep (intern ref dependencies)))
3805 (setcdr (symbol-value ref-dep)
3806 (nconc (cdr (symbol-value ref-dep))
3807 (list (symbol-value id-dep))))
3808 (set ref-dep (list nil (symbol-value id-dep))))
3809 (setq headers (cons header headers)))
3810 (goto-char (point-max))
3812 (nreverse headers)))))
3814 ;; The following macros and functions were written by Felix Lee
3815 ;; <flee@cse.psu.edu>.
3817 (defmacro gnus-nov-read-integer ()
3819 (if (= (following-char) ?\t)
3821 (let ((num (condition-case nil (read buffer) (error nil))))
3822 (if (numberp num) num 0)))
3823 (or (eobp) (forward-char 1))))
3825 (defmacro gnus-nov-skip-field ()
3826 '(search-forward "\t" eol 'move))
3828 (defmacro gnus-nov-field ()
3829 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
3831 ;; Goes through the xover lines and returns a list of vectors
3832 (defun gnus-get-newsgroup-headers-xover (sequence &optional
3833 force-new dependencies)
3834 "Parse the news overview data in the server buffer, and return a
3835 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
3836 ;; Get the Xref when the users reads the articles since most/some
3837 ;; NNTP servers do not include Xrefs when using XOVER.
3838 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
3839 (let ((cur nntp-server-buffer)
3840 (dependencies (or dependencies gnus-newsgroup-dependencies))
3841 number headers header)
3843 (set-buffer nntp-server-buffer)
3844 ;; Allow the user to mangle the headers before parsing them.
3845 (run-hooks 'gnus-parse-headers-hook)
3846 (goto-char (point-min))
3847 (while (and sequence (not (eobp)))
3848 (setq number (read cur))
3849 (while (and sequence (< (car sequence) number))
3850 (setq sequence (cdr sequence)))
3852 (eq number (car sequence))
3854 (setq sequence (cdr sequence))
3856 (inline (gnus-nov-parse-line
3857 number dependencies force-new)))
3858 (setq headers (cons header headers)))))
3860 (setq headers (nreverse headers)))
3863 ;; This function has to be called with point after the article number
3864 ;; on the beginning of the line.
3865 (defun gnus-nov-parse-line (number dependencies &optional force-new)
3867 (eol (gnus-point-at-eol))
3868 (buffer (current-buffer))
3869 header ref id id-dep ref-dep)
3871 ;; overview: [num subject from date id refs chars lines misc]
3872 (narrow-to-region (point) eol)
3873 (or (eobp) (forward-char))
3879 (gnus-nov-field) ; subject
3880 (gnus-nov-field) ; from
3881 (gnus-nov-field) ; date
3882 (setq id (or (gnus-nov-field)
3885 (setq none (1+ none)))))) ; id
3888 (let ((beg (point)))
3889 (search-forward "\t" eol)
3890 (if (search-backward ">" beg t)
3894 (search-backward "<" beg t)))
3896 (gnus-nov-field)) ; refs
3897 (gnus-nov-read-integer) ; chars
3898 (gnus-nov-read-integer) ; lines
3899 (if (= (following-char) ?\n)
3901 (gnus-nov-field)) ; misc
3904 (gnus-error 4 "Strange nov line")
3910 ;; We build the thread tree.
3912 (when (equal id ref)
3913 ;; This article refers back to itself. Naughty, naughty.
3915 (if (boundp (setq id-dep (intern id dependencies)))
3916 (if (and (car (symbol-value id-dep))
3918 ;; An article with this Message-ID has already been seen,
3919 ;; so we ignore this one, except we add any additional
3920 ;; Xrefs (in case the two articles came from different
3923 (mail-header-set-xref
3924 (car (symbol-value id-dep))
3925 (concat (or (mail-header-xref
3926 (car (symbol-value id-dep))) "")
3927 (or (mail-header-xref header) "")))
3929 (setcar (symbol-value id-dep) header))
3930 (set id-dep (list header))))
3932 (if (boundp (setq ref-dep (intern (or ref "none") dependencies)))
3933 (setcdr (symbol-value ref-dep)
3934 (nconc (cdr (symbol-value ref-dep))
3935 (list (symbol-value id-dep))))
3936 (set ref-dep (list nil (symbol-value id-dep)))))
3939 (defun gnus-article-get-xrefs ()
3940 "Fill in the Xref value in `gnus-current-headers', if necessary.
3941 This is meant to be called in `gnus-article-internal-prepare-hook'."
3942 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
3943 gnus-current-headers)))
3944 (or (not gnus-use-cross-reference)
3946 (and (mail-header-xref headers)
3947 (not (string= (mail-header-xref headers) "")))
3948 (let ((case-fold-search t)
3951 (nnheader-narrow-to-headers)
3952 (goto-char (point-min))
3953 (if (or (and (eq (downcase (following-char)) ?x)
3954 (looking-at "Xref:"))
3955 (search-forward "\nXref:" nil t))
3957 (goto-char (1+ (match-end 0)))
3958 (setq xref (buffer-substring (point)
3959 (progn (end-of-line) (point))))
3960 (mail-header-set-xref headers xref))))))))
3962 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
3963 "Find article ID and insert the summary line for that article."
3964 (let ((header (if (and old-header use-old-header)
3965 old-header (gnus-read-header id)))
3966 (number (and (numberp id) id))
3969 ;; Rebuild the thread that this article is part of and go to the
3970 ;; article we have fetched.
3971 (when (and (not gnus-show-threads)
3973 (when (setq pos (text-property-any
3974 (point-min) (point-max) 'gnus-number
3975 (mail-header-number old-header)))
3978 (gnus-data-remove (mail-header-number old-header))))
3980 (mail-header-set-number header (mail-header-number old-header)))
3981 (setq gnus-newsgroup-sparse
3982 (delq (setq number (mail-header-number header))
3983 gnus-newsgroup-sparse))
3984 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
3985 (gnus-rebuild-thread (mail-header-id header))
3986 (gnus-summary-goto-subject number nil t))
3987 (when (and (numberp number)
3989 ;; We have to update the boundaries even if we can't fetch the
3990 ;; article if ID is a number -- so that the next `P' or `N'
3991 ;; command will fetch the previous (or next) article even
3992 ;; if the one we tried to fetch this time has been canceled.
3993 (and (> number gnus-newsgroup-end)
3994 (setq gnus-newsgroup-end number))
3995 (and (< number gnus-newsgroup-begin)
3996 (setq gnus-newsgroup-begin number))
3997 (setq gnus-newsgroup-unselected
3998 (delq number gnus-newsgroup-unselected)))
3999 ;; Report back a success?
4000 (and header (mail-header-number header))))
4002 ;;; Process/prefix in the summary buffer
4004 (defun gnus-summary-work-articles (n)
4005 "Return a list of articles to be worked upon. The prefix argument,
4006 the list of process marked articles, and the current article will be
4007 taken into consideration."
4010 ;; A numerical prefix has been given.
4011 (let ((backward (< n 0))
4012 (n (abs (prefix-numeric-value n)))
4017 (push (setq article (gnus-summary-article-number))
4020 (gnus-summary-find-prev nil article)
4021 (gnus-summary-find-next nil article)))
4023 (nreverse articles)))
4024 ((and (boundp 'transient-mark-mode)
4027 ;; Work on the region between point and mark.
4028 (let ((max (max (point) (mark)))
4031 (goto-char (min (point) (mark)))
4034 (push (setq article (gnus-summary-article-number)) articles)
4035 (gnus-summary-find-next nil article)
4037 (nreverse articles))))
4038 (gnus-newsgroup-processable
4039 ;; There are process-marked articles present.
4040 ;; Save current state.
4041 (gnus-summary-save-process-mark)
4043 (reverse gnus-newsgroup-processable))
4045 ;; Just return the current article.
4046 (list (gnus-summary-article-number)))))
4048 (defun gnus-summary-save-process-mark ()
4049 "Push the current set of process marked articles on the stack."
4051 (push (copy-sequence gnus-newsgroup-processable)
4052 gnus-newsgroup-process-stack))
4054 (defun gnus-summary-kill-process-mark ()
4055 "Push the current set of process marked articles on the stack and unmark."
4057 (gnus-summary-save-process-mark)
4058 (gnus-summary-unmark-all-processable))
4060 (defun gnus-summary-yank-process-mark ()
4061 "Pop the last process mark state off the stack and restore it."
4063 (unless gnus-newsgroup-process-stack
4064 (error "Empty mark stack"))
4065 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
4067 (defun gnus-summary-process-mark-set (set)
4068 "Make SET into the current process marked articles."
4069 (gnus-summary-unmark-all-processable)
4071 (gnus-summary-set-process-mark (pop set))))
4073 ;;; Searching and stuff
4075 (defun gnus-summary-search-group (&optional backward use-level)
4076 "Search for next unread newsgroup.
4077 If optional argument BACKWARD is non-nil, search backward instead."
4079 (set-buffer gnus-group-buffer)
4080 (if (gnus-group-search-forward
4081 backward nil (if use-level (gnus-group-group-level) nil))
4082 (gnus-group-group-name))))
4084 (defun gnus-summary-best-group (&optional exclude-group)
4085 "Find the name of the best unread group.
4086 If EXCLUDE-GROUP, do not go to this group."
4088 (set-buffer gnus-group-buffer)
4090 (gnus-group-best-unread-group exclude-group))))
4092 (defun gnus-summary-find-next (&optional unread article backward)
4093 (if backward (gnus-summary-find-prev)
4094 (let* ((dummy (gnus-summary-article-intangible-p))
4095 (article (or article (gnus-summary-article-number)))
4096 (arts (gnus-data-find-list article))
4098 (when (and (not dummy)
4099 (or (not gnus-summary-check-current)
4101 (not (gnus-data-unread-p (car arts)))))
4102 (setq arts (cdr arts)))
4107 (when (gnus-data-unread-p (car arts))
4108 (setq result (car arts)
4110 (setq arts (cdr arts)))
4113 (goto-char (gnus-data-pos result))
4114 (gnus-data-number result)))))
4116 (defun gnus-summary-find-prev (&optional unread article)
4117 (let* ((eobp (eobp))
4118 (article (or article (gnus-summary-article-number)))
4119 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
4121 (when (and (not eobp)
4122 (or (not gnus-summary-check-current)
4124 (not (gnus-data-unread-p (car arts)))))
4125 (setq arts (cdr arts)))
4130 (and (gnus-data-unread-p (car arts))
4131 (setq result (car arts)
4133 (setq arts (cdr arts)))
4137 (goto-char (gnus-data-pos result))
4138 (gnus-data-number result)))))
4140 (defun gnus-summary-find-subject (subject &optional unread backward article)
4141 (let* ((simp-subject (gnus-simplify-subject-fully subject))
4142 (article (or article (gnus-summary-article-number)))
4143 (articles (gnus-data-list backward))
4144 (arts (gnus-data-find-list article articles))
4146 (when (or (not gnus-summary-check-current)
4148 (not (gnus-data-unread-p (car arts))))
4149 (setq arts (cdr arts)))
4151 (and (or (not unread)
4152 (gnus-data-unread-p (car arts)))
4153 (vectorp (gnus-data-header (car arts)))
4155 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
4156 (setq result (car arts)
4158 (setq arts (cdr arts)))
4160 (goto-char (gnus-data-pos result))
4161 (gnus-data-number result))))
4163 (defun gnus-summary-search-forward (&optional unread subject backward)
4164 "Search forward for an article.
4165 If UNREAD, look for unread articles. If SUBJECT, look for
4166 articles with that subject. If BACKWARD, search backward instead."
4167 (cond (subject (gnus-summary-find-subject subject unread backward))
4168 (backward (gnus-summary-find-prev unread))
4169 (t (gnus-summary-find-next unread))))
4171 (defun gnus-recenter (&optional n)
4172 "Center point in window and redisplay frame.
4173 Also do horizontal recentering."
4175 (when (and gnus-auto-center-summary
4176 (not (eq gnus-auto-center-summary 'vertical)))
4177 (gnus-horizontal-recenter))
4180 (defun gnus-summary-recenter ()
4181 "Center point in the summary window.
4182 If `gnus-auto-center-summary' is nil, or the article buffer isn't
4183 displayed, no centering will be performed."
4184 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
4185 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
4186 (let* ((top (cond ((< (window-height) 4) 0)
4187 ((< (window-height) 7) 1)
4189 (height (1- (window-height)))
4190 (bottom (save-excursion (goto-char (point-max))
4191 (forward-line (- height))
4193 (window (get-buffer-window (current-buffer))))
4194 ;; The user has to want it.
4195 (when gnus-auto-center-summary
4196 (when (get-buffer-window gnus-article-buffer)
4197 ;; Only do recentering when the article buffer is displayed,
4198 ;; Set the window start to either `bottom', which is the biggest
4199 ;; possible valid number, or the second line from the top,
4200 ;; whichever is the least.
4202 window (min bottom (save-excursion
4203 (forward-line (- top)) (point)))))
4204 ;; Do horizontal recentering while we're at it.
4205 (when (and (get-buffer-window (current-buffer) t)
4206 (not (eq gnus-auto-center-summary 'vertical)))
4207 (let ((selected (selected-window)))
4208 (select-window (get-buffer-window (current-buffer) t))
4209 (gnus-summary-position-point)
4210 (gnus-horizontal-recenter)
4211 (select-window selected))))))
4213 (defun gnus-summary-jump-to-group (newsgroup)
4214 "Move point to NEWSGROUP in group mode buffer."
4215 ;; Keep update point of group mode buffer if visible.
4216 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
4217 (save-window-excursion
4218 ;; Take care of tree window mode.
4219 (if (get-buffer-window gnus-group-buffer)
4220 (pop-to-buffer gnus-group-buffer))
4221 (gnus-group-jump-to-group newsgroup))
4223 ;; Take care of tree window mode.
4224 (if (get-buffer-window gnus-group-buffer)
4225 (pop-to-buffer gnus-group-buffer)
4226 (set-buffer gnus-group-buffer))
4227 (gnus-group-jump-to-group newsgroup))))
4229 ;; This function returns a list of article numbers based on the
4230 ;; difference between the ranges of read articles in this group and
4231 ;; the range of active articles.
4232 (defun gnus-list-of-unread-articles (group)
4233 (let* ((read (gnus-info-read (gnus-get-info group)))
4234 (active (or (gnus-active group) (gnus-activate-group group)))
4237 ;; If none are read, then all are unread.
4239 (setq first (car active))
4240 ;; If the range of read articles is a single range, then the
4241 ;; first unread article is the article after the last read
4242 ;; article. Sounds logical, doesn't it?
4243 (if (not (listp (cdr read)))
4244 (setq first (1+ (cdr read)))
4245 ;; `read' is a list of ranges.
4246 (if (/= (setq nlast (or (and (numberp (car read)) (car read))
4251 (while (< first nlast)
4252 (setq unread (cons first unread))
4253 (setq first (1+ first))))
4254 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
4255 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
4256 (setq read (cdr read)))))
4257 ;; And add the last unread articles.
4258 (while (<= first last)
4259 (setq unread (cons first unread))
4260 (setq first (1+ first)))
4261 ;; Return the list of unread articles.
4264 (defun gnus-list-of-read-articles (group)
4265 "Return a list of unread, unticked and non-dormant articles."
4266 (let* ((info (gnus-get-info group))
4267 (marked (gnus-info-marks info))
4268 (active (gnus-active group)))
4270 (gnus-set-difference
4271 (gnus-sorted-complement
4272 (gnus-uncompress-range active)
4273 (gnus-list-of-unread-articles group))
4275 (gnus-uncompress-range (cdr (assq 'dormant marked)))
4276 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
4278 ;; Various summary commands
4280 (defun gnus-summary-universal-argument (arg)
4281 "Perform any operation on all articles that are process/prefixed."
4283 (gnus-set-global-variables)
4284 (let ((articles (gnus-summary-work-articles arg))
4291 (substitute-command-keys
4292 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
4295 (gnus-error 1 "Undefined key")
4298 (gnus-summary-goto-subject (setq article (pop articles)))
4299 (command-execute func)
4300 (gnus-summary-remove-process-mark article)))))
4301 (gnus-summary-position-point))
4303 (defun gnus-summary-toggle-truncation (&optional arg)
4304 "Toggle truncation of summary lines.
4305 With arg, turn line truncation on iff arg is positive."
4307 (setq truncate-lines
4308 (if (null arg) (not truncate-lines)
4309 (> (prefix-numeric-value arg) 0)))
4312 (defun gnus-summary-reselect-current-group (&optional all rescan)
4313 "Exit and then reselect the current newsgroup.
4314 The prefix argument ALL means to select all articles."
4316 (gnus-set-global-variables)
4317 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
4318 (error "Ephemeral groups can't be reselected"))
4319 (let ((current-subject (gnus-summary-article-number))
4320 (group gnus-newsgroup-name))
4321 (setq gnus-newsgroup-begin nil)
4323 ;; We have to adjust the point of group mode buffer because the
4324 ;; current point was moved to the next unread newsgroup by
4326 (gnus-summary-jump-to-group group)
4329 (gnus-group-get-new-news-this-group 1)))
4330 (gnus-group-read-group all t)
4331 (gnus-summary-goto-subject current-subject nil t)))
4333 (defun gnus-summary-rescan-group (&optional all)
4334 "Exit the newsgroup, ask for new articles, and select the newsgroup."
4336 (gnus-summary-reselect-current-group all t))
4338 (defun gnus-summary-update-info ()
4339 (let ((group gnus-newsgroup-name))
4340 (when gnus-newsgroup-kill-headers
4341 (setq gnus-newsgroup-killed
4342 (gnus-compress-sequence
4344 (gnus-set-sorted-intersection
4345 (gnus-uncompress-range gnus-newsgroup-killed)
4346 (setq gnus-newsgroup-unselected
4347 (sort gnus-newsgroup-unselected '<)))
4348 (setq gnus-newsgroup-unreads
4349 (sort gnus-newsgroup-unreads '<))) t)))
4350 (unless (listp (cdr gnus-newsgroup-killed))
4351 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
4352 (let ((headers gnus-newsgroup-headers))
4353 (run-hooks 'gnus-exit-group-hook)
4354 (unless gnus-save-score
4355 (setq gnus-newsgroup-scored nil))
4356 ;; Set the new ranges of read articles.
4357 (gnus-update-read-articles
4358 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
4359 ;; Set the current article marks.
4361 ;; Do the cross-ref thing.
4362 (when gnus-use-cross-reference
4363 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
4364 ;; Do adaptive scoring, and possibly save score files.
4365 (when gnus-newsgroup-adaptive
4366 (gnus-score-adaptive))
4367 (when gnus-use-scoring
4369 ;; Do not switch windows but change the buffer to work.
4370 (set-buffer gnus-group-buffer)
4371 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
4372 (gnus-group-update-group group)))))
4374 (defun gnus-summary-exit (&optional temporary)
4375 "Exit reading current newsgroup, and then return to group selection mode.
4376 gnus-exit-group-hook is called with no arguments if that value is non-nil."
4378 (gnus-set-global-variables)
4379 (gnus-kill-save-kill-buffer)
4380 (let* ((group gnus-newsgroup-name)
4381 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
4383 (buf (current-buffer)))
4384 (run-hooks 'gnus-summary-prepare-exit-hook)
4385 ;; If we have several article buffers, we kill them at exit.
4386 (unless gnus-single-article-buffer
4387 (gnus-kill-buffer gnus-original-article-buffer)
4388 (setq gnus-article-current nil))
4389 (when gnus-use-cache
4390 (gnus-cache-possibly-remove-articles)
4391 (gnus-cache-save-buffers))
4392 (gnus-async-prefetch-remove-group group)
4393 (when gnus-suppress-duplicates
4394 (gnus-dup-enter-articles))
4395 (when gnus-use-trees
4396 (gnus-tree-close group))
4397 ;; Make all changes in this group permanent.
4399 (gnus-summary-update-info))
4400 (gnus-close-group group)
4401 ;; Make sure where I was, and go to next newsgroup.
4402 (set-buffer gnus-group-buffer)
4404 (gnus-group-jump-to-group group))
4405 (run-hooks 'gnus-summary-exit-hook)
4407 (gnus-group-next-unread-group 1))
4410 ;; If we have several article buffers, we kill them at exit.
4411 (unless gnus-single-article-buffer
4412 (gnus-kill-buffer gnus-article-buffer)
4413 (gnus-kill-buffer gnus-original-article-buffer)
4414 (setq gnus-article-current nil))
4416 (if (not gnus-kill-summary-on-exit)
4417 (gnus-deaden-summary)
4418 ;; We set all buffer-local variables to nil. It is unclear why
4419 ;; this is needed, but if we don't, buffer-local variables are
4420 ;; not garbage-collected, it seems. This would the lead to en
4421 ;; ever-growing Emacs.
4422 (gnus-summary-clear-local-variables)
4423 (when (get-buffer gnus-article-buffer)
4424 (bury-buffer gnus-article-buffer))
4425 ;; We clear the global counterparts of the buffer-local
4426 ;; variables as well, just to be on the safe side.
4427 (set-buffer gnus-group-buffer)
4428 (gnus-summary-clear-local-variables)
4429 ;; Return to group mode buffer.
4430 (if (eq mode 'gnus-summary-mode)
4431 (gnus-kill-buffer buf)))
4432 (setq gnus-current-select-method gnus-select-method)
4433 (pop-to-buffer gnus-group-buffer)
4434 ;; Clear the current group name.
4435 (if (not quit-config)
4437 (gnus-group-jump-to-group group)
4438 (gnus-group-next-unread-group 1)
4439 (gnus-configure-windows 'group 'force))
4440 (if (not (buffer-name (car quit-config)))
4441 (gnus-configure-windows 'group 'force)
4442 (set-buffer (car quit-config))
4443 (cond ((eq major-mode 'gnus-summary-mode)
4444 (gnus-set-global-variables))
4445 ((eq major-mode 'gnus-article-mode)
4447 ;; The `gnus-summary-buffer' variable may point
4448 ;; to the old summary buffer when using a single
4450 (unless (gnus-buffer-live-p gnus-summary-buffer)
4451 (set-buffer gnus-group-buffer))
4452 (set-buffer gnus-summary-buffer)
4453 (gnus-set-global-variables))))
4454 (gnus-configure-windows (cdr quit-config) 'force)))
4456 (setq gnus-newsgroup-name nil)))))
4458 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
4459 (defun gnus-summary-exit-no-update (&optional no-questions)
4460 "Quit reading current newsgroup without updating read article info."
4462 (gnus-set-global-variables)
4463 (let* ((group gnus-newsgroup-name)
4464 (quit-config (gnus-group-quit-config group)))
4465 (when (or no-questions
4467 (gnus-y-or-n-p "Do you really wanna quit reading this group? "))
4468 ;; If we have several article buffers, we kill them at exit.
4469 (unless gnus-single-article-buffer
4470 (gnus-kill-buffer gnus-article-buffer)
4471 (gnus-kill-buffer gnus-original-article-buffer)
4472 (setq gnus-article-current nil))
4473 (if (not gnus-kill-summary-on-exit)
4474 (gnus-deaden-summary)
4475 (gnus-close-group group)
4476 (gnus-summary-clear-local-variables)
4477 (set-buffer gnus-group-buffer)
4478 (gnus-summary-clear-local-variables)
4479 (when (get-buffer gnus-summary-buffer)
4480 (kill-buffer gnus-summary-buffer)))
4481 (unless gnus-single-article-buffer
4482 (setq gnus-article-current nil))
4483 (when gnus-use-trees
4484 (gnus-tree-close group))
4485 (gnus-async-prefetch-remove-group group)
4486 (when (get-buffer gnus-article-buffer)
4487 (bury-buffer gnus-article-buffer))
4488 ;; Return to the group buffer.
4489 (gnus-configure-windows 'group 'force)
4490 ;; Clear the current group name.
4491 (setq gnus-newsgroup-name nil)
4492 (when (equal (gnus-group-group-name) group)
4493 (gnus-group-next-unread-group 1))
4495 (if (not (buffer-name (car quit-config)))
4496 (gnus-configure-windows 'group 'force)
4497 (set-buffer (car quit-config))
4498 (when (eq major-mode 'gnus-summary-mode)
4499 (gnus-set-global-variables))
4500 (gnus-configure-windows (cdr quit-config)))))))
4504 (defvar gnus-dead-summary-mode-map nil)
4506 (unless gnus-dead-summary-mode-map
4507 (setq gnus-dead-summary-mode-map (make-keymap))
4508 (suppress-keymap gnus-dead-summary-mode-map)
4509 (substitute-key-definition
4510 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
4511 (let ((keys '("\C-d" "\r" "\177")))
4513 (define-key gnus-dead-summary-mode-map
4514 (pop keys) 'gnus-summary-wake-up-the-dead))))
4516 (defvar gnus-dead-summary-mode nil
4517 "Minor mode for Gnus summary buffers.")
4519 (defun gnus-dead-summary-mode (&optional arg)
4520 "Minor mode for Gnus summary buffers."
4522 (when (eq major-mode 'gnus-summary-mode)
4523 (make-local-variable 'gnus-dead-summary-mode)
4524 (setq gnus-dead-summary-mode
4525 (if (null arg) (not gnus-dead-summary-mode)
4526 (> (prefix-numeric-value arg) 0)))
4527 (when gnus-dead-summary-mode
4528 (unless (assq 'gnus-dead-summary-mode minor-mode-alist)
4529 (push '(gnus-dead-summary-mode " Dead") minor-mode-alist))
4530 (unless (assq 'gnus-dead-summary-mode minor-mode-map-alist)
4531 (push (cons 'gnus-dead-summary-mode gnus-dead-summary-mode-map)
4532 minor-mode-map-alist)))))
4534 (defun gnus-deaden-summary ()
4535 "Make the current summary buffer into a dead summary buffer."
4536 ;; Kill any previous dead summary buffer.
4537 (when (and gnus-dead-summary
4538 (buffer-name gnus-dead-summary))
4540 (set-buffer gnus-dead-summary)
4541 (when gnus-dead-summary-mode
4542 (kill-buffer (current-buffer)))))
4543 ;; Make this the current dead summary.
4544 (setq gnus-dead-summary (current-buffer))
4545 (gnus-dead-summary-mode 1)
4546 (let ((name (buffer-name)))
4547 (when (string-match "Summary" name)
4549 (concat (substring name 0 (match-beginning 0)) "Dead "
4550 (substring name (match-beginning 0))) t))))
4552 (defun gnus-kill-or-deaden-summary (buffer)
4553 "Kill or deaden the summary BUFFER."
4554 (when (and (buffer-name buffer)
4555 (not gnus-single-article-buffer))
4558 (gnus-kill-buffer gnus-article-buffer)
4559 (gnus-kill-buffer gnus-original-article-buffer)))
4560 (cond (gnus-kill-summary-on-exit
4561 (when (and gnus-use-trees
4562 (and (get-buffer buffer)
4563 (buffer-name (get-buffer buffer))))
4565 (set-buffer (get-buffer buffer))
4566 (gnus-tree-close gnus-newsgroup-name)))
4567 (gnus-kill-buffer buffer))
4568 ((and (get-buffer buffer)
4569 (buffer-name (get-buffer buffer)))
4572 (gnus-deaden-summary)))))
4574 (defun gnus-summary-wake-up-the-dead (&rest args)
4575 "Wake up the dead summary buffer."
4577 (gnus-dead-summary-mode -1)
4578 (let ((name (buffer-name)))
4579 (when (string-match "Dead " name)
4581 (concat (substring name 0 (match-beginning 0))
4582 (substring name (match-end 0))) t)))
4583 (gnus-message 3 "This dead summary is now alive again"))
4585 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
4586 (defun gnus-summary-fetch-faq (&optional faq-dir)
4587 "Fetch the FAQ for the current group.
4588 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
4592 (if current-prefix-arg
4594 "Faq dir: " (and (listp gnus-group-faq-directory)
4595 gnus-group-faq-directory)))))
4596 (let (gnus-faq-buffer)
4597 (and (setq gnus-faq-buffer
4598 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
4599 (gnus-configure-windows 'summary-faq))))
4601 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
4602 (defun gnus-summary-describe-group (&optional force)
4603 "Describe the current newsgroup."
4605 (gnus-group-describe-group force gnus-newsgroup-name))
4607 (defun gnus-summary-describe-briefly ()
4608 "Describe summary mode commands briefly."
4611 (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")))
4613 ;; Walking around group mode buffer from summary mode.
4615 (defun gnus-summary-next-group (&optional no-article target-group backward)
4616 "Exit current newsgroup and then select next unread newsgroup.
4617 If prefix argument NO-ARTICLE is non-nil, no article is selected
4618 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
4619 previous group instead."
4621 (gnus-set-global-variables)
4622 (let ((current-group gnus-newsgroup-name)
4623 (current-buffer (current-buffer))
4625 ;; First we semi-exit this group to update Xrefs and all variables.
4626 ;; We can't do a real exit, because the window conf must remain
4627 ;; the same in case the user is prompted for info, and we don't
4628 ;; want the window conf to change before that...
4629 (gnus-summary-exit t)
4630 (while (not entered)
4631 ;; Then we find what group we are supposed to enter.
4632 (set-buffer gnus-group-buffer)
4633 (gnus-group-jump-to-group current-group)
4636 (if (eq gnus-keep-same-level 'best)
4637 (gnus-summary-best-group gnus-newsgroup-name)
4638 (gnus-summary-search-group backward gnus-keep-same-level))))
4639 (if (not target-group)
4640 ;; There are no further groups, so we return to the group
4643 (gnus-message 5 "Returning to the group buffer")
4645 (set-buffer current-buffer)
4647 (run-hooks 'gnus-group-no-more-groups-hook))
4648 ;; We try to enter the target group.
4649 (gnus-group-jump-to-group target-group)
4650 (let ((unreads (gnus-group-group-unread)))
4651 (if (and (or (eq t unreads)
4652 (and unreads (not (zerop unreads))))
4653 (gnus-summary-read-group
4654 target-group nil no-article current-buffer))
4656 (setq current-group target-group
4657 target-group nil)))))))
4659 (defun gnus-summary-prev-group (&optional no-article)
4660 "Exit current newsgroup and then select previous unread newsgroup.
4661 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
4663 (gnus-summary-next-group no-article nil t))
4665 ;; Walking around summary lines.
4667 (defun gnus-summary-first-subject (&optional unread)
4668 "Go to the first unread subject.
4669 If UNREAD is non-nil, go to the first unread article.
4670 Returns the article selected or nil if there are no unread articles."
4675 ((null gnus-newsgroup-data)
4676 (gnus-message 3 "No articles in the group")
4678 ;; Pick the first article.
4680 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
4681 (gnus-data-number (car gnus-newsgroup-data)))
4682 ;; No unread articles.
4683 ((null gnus-newsgroup-unreads)
4684 (gnus-message 3 "No more unread articles")
4686 ;; Find the first unread article.
4688 (let ((data gnus-newsgroup-data))
4690 (not (gnus-data-unread-p (car data))))
4691 (setq data (cdr data)))
4694 (goto-char (gnus-data-pos (car data)))
4695 (gnus-data-number (car data)))))))
4696 (gnus-summary-position-point)))
4698 (defun gnus-summary-next-subject (n &optional unread dont-display)
4699 "Go to next N'th summary line.
4700 If N is negative, go to the previous N'th subject line.
4701 If UNREAD is non-nil, only unread articles are selected.
4702 The difference between N and the actual number of steps taken is
4705 (let ((backward (< n 0))
4709 (gnus-summary-find-prev unread)
4710 (gnus-summary-find-next unread)))
4712 (if (/= 0 n) (gnus-message 7 "No more%s articles"
4713 (if unread " unread" "")))
4714 (unless dont-display
4715 (gnus-summary-recenter)
4716 (gnus-summary-position-point))
4719 (defun gnus-summary-next-unread-subject (n)
4720 "Go to next N'th unread summary line."
4722 (gnus-summary-next-subject n t))
4724 (defun gnus-summary-prev-subject (n &optional unread)
4725 "Go to previous N'th summary line.
4726 If optional argument UNREAD is non-nil, only unread article is selected."
4728 (gnus-summary-next-subject (- n) unread))
4730 (defun gnus-summary-prev-unread-subject (n)
4731 "Go to previous N'th unread summary line."
4733 (gnus-summary-next-subject (- n) t))
4735 (defun gnus-summary-goto-subject (article &optional force silent)
4736 "Go the subject line of ARTICLE.
4737 If FORCE, also allow jumping to articles not currently shown."
4739 (data (gnus-data-find article)))
4740 ;; We read in the article if we have to.
4743 (gnus-summary-insert-subject article (and (vectorp force) force) t)
4744 (setq data (gnus-data-find article)))
4749 (gnus-message 3 "Can't find article %d" article))
4751 (goto-char (gnus-data-pos data))
4754 ;; Walking around summary lines with displaying articles.
4756 (defun gnus-summary-expand-window (&optional arg)
4757 "Make the summary buffer take up the entire Emacs frame.
4758 Given a prefix, will force an `article' buffer configuration."
4760 (gnus-set-global-variables)
4762 (gnus-configure-windows 'article 'force)
4763 (gnus-configure-windows 'summary 'force)))
4765 (defun gnus-summary-display-article (article &optional all-header)
4766 "Display ARTICLE in article buffer."
4767 (gnus-set-global-variables)
4771 (if gnus-summary-display-article-function
4772 (funcall gnus-summary-display-article-function article all-header)
4773 (gnus-article-prepare article all-header))
4774 (run-hooks 'gnus-select-article-hook)
4775 (when (and gnus-current-article
4776 (not (zerop gnus-current-article)))
4777 (gnus-summary-goto-subject gnus-current-article))
4778 (gnus-summary-recenter)
4779 (when gnus-use-trees
4780 (gnus-possibly-generate-tree article)
4781 (gnus-highlight-selected-tree article))
4782 ;; Successfully display article.
4783 (gnus-article-set-window-start
4784 (cdr (assq article gnus-newsgroup-bookmarks))))))
4786 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
4787 "Select the current article.
4788 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
4789 non-nil, the article will be re-fetched even if it already present in
4790 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
4792 ;; Make sure we are in the summary buffer to work around bbdb bug.
4793 (unless (eq major-mode 'gnus-summary-mode)
4794 (set-buffer gnus-summary-buffer))
4795 (let ((article (or article (gnus-summary-article-number)))
4796 (all-headers (not (not all-headers))) ;Must be T or NIL.
4797 gnus-summary-display-article-function
4800 (gnus-summary-article-pseudo-p article)
4801 (error "This is a pseudo-article."))
4804 (set-buffer gnus-summary-buffer)
4805 (if (or (and gnus-single-article-buffer
4806 (or (null gnus-current-article)
4807 (null gnus-article-current)
4808 (null (get-buffer gnus-article-buffer))
4809 (not (eq article (cdr gnus-article-current)))
4810 (not (equal (car gnus-article-current)
4811 gnus-newsgroup-name))))
4812 (and (not gnus-single-article-buffer)
4813 (or (null gnus-current-article)
4814 (not (eq gnus-current-article article))))
4816 ;; The requested article is different from the current article.
4818 (gnus-summary-display-article article all-headers)
4820 (if (or all-headers gnus-show-all-headers)
4821 (gnus-article-show-all-headers))
4824 (gnus-article-set-window-start
4825 (cdr (assq article gnus-newsgroup-bookmarks)))))))
4827 (defun gnus-summary-set-current-mark (&optional current-mark)
4828 "Obsolete function."
4831 (defun gnus-summary-next-article (&optional unread subject backward push)
4832 "Select the next article.
4833 If UNREAD, only unread articles are selected.
4834 If SUBJECT, only articles with SUBJECT are selected.
4835 If BACKWARD, the previous article is selected instead of the next."
4837 (gnus-set-global-variables)
4839 ;; Is there such an article?
4840 ((and (gnus-summary-search-forward unread subject backward)
4841 (or (gnus-summary-display-article (gnus-summary-article-number))
4842 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
4843 (gnus-summary-position-point))
4844 ;; If not, we try the first unread, if that is wanted.
4846 gnus-auto-select-same
4847 ;; Make sure that we don't select the current article.
4848 (not (eq (gnus-summary-article-number)
4850 (gnus-summary-first-subject t)
4851 (gnus-summary-article-number))))
4852 (gnus-summary-first-unread-article))
4853 (gnus-summary-position-point)
4854 (gnus-message 6 "Wrapped"))
4855 ;; Try to get next/previous article not displayed in this group.
4856 ((and gnus-auto-extend-newsgroup
4857 (not unread) (not subject))
4858 (gnus-summary-goto-article
4859 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
4861 ;; Go to next/previous group.
4863 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
4864 (gnus-summary-jump-to-group gnus-newsgroup-name))
4865 (let ((cmd last-command-char)
4867 (if (eq gnus-keep-same-level 'best)
4868 (gnus-summary-best-group gnus-newsgroup-name)
4869 (gnus-summary-search-group backward gnus-keep-same-level))))
4870 ;; For some reason, the group window gets selected. We change
4872 (select-window (get-buffer-window (current-buffer)))
4873 ;; Select next unread newsgroup automagically.
4875 ((or (not gnus-auto-select-next)
4877 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
4878 ((or (eq gnus-auto-select-next 'quietly)
4879 (and (eq gnus-auto-select-next 'slightly-quietly)
4881 (and (eq gnus-auto-select-next 'almost-quietly)
4882 (gnus-summary-last-article-p)))
4884 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
4886 (gnus-message 7 "No more%s articles (%s)..."
4887 (if unread " unread" "")
4888 (if group (concat "selecting " group)
4890 (gnus-summary-next-group nil group backward)))
4892 (gnus-summary-walk-group-buffer
4893 gnus-newsgroup-name cmd unread backward)))))))
4895 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward)
4896 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
4897 (?\C-p (gnus-group-prev-unread-group 1))))
4898 (cursor-in-echo-area t)
4899 keve key group ended)
4901 (set-buffer gnus-group-buffer)
4902 (gnus-summary-jump-to-group from-group)
4904 (if (eq gnus-keep-same-level 'best)
4905 (gnus-summary-best-group gnus-newsgroup-name)
4906 (gnus-summary-search-group backward gnus-keep-same-level))))
4909 5 "No more%s articles%s" (if unread " unread" "")
4911 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
4912 (format " (Type %s for %s [%s])"
4913 (single-key-description cmd) group
4914 (car (gnus-gethash group gnus-newsrc-hashtb)))
4915 (format " (Type %s to exit %s)"
4916 (single-key-description cmd)
4917 gnus-newsgroup-name)))
4918 ;; Confirm auto selection.
4919 (setq key (car (setq keve (gnus-read-event-char))))
4922 ((assq key keystrokes)
4923 (let ((obuf (current-buffer)))
4924 (switch-to-buffer gnus-group-buffer)
4926 (gnus-group-jump-to-group group))
4927 (eval (cadr (assq key keystrokes)))
4928 (setq group (gnus-group-group-name))
4929 (switch-to-buffer obuf))
4933 (gnus-ephemeral-group-p gnus-newsgroup-name))
4935 (gnus-summary-next-group nil group backward)))
4937 (push (cdr keve) unread-command-events))))))
4939 (defun gnus-summary-next-unread-article ()
4940 "Select unread article after current one."
4942 (gnus-summary-next-article t (and gnus-auto-select-same
4943 (gnus-summary-article-subject))))
4945 (defun gnus-summary-prev-article (&optional unread subject)
4946 "Select the article after the current one.
4947 If UNREAD is non-nil, only unread articles are selected."
4949 (gnus-summary-next-article unread subject t))
4951 (defun gnus-summary-prev-unread-article ()
4952 "Select unread article before current one."
4954 (gnus-summary-prev-article t (and gnus-auto-select-same
4955 (gnus-summary-article-subject))))
4957 (defun gnus-summary-next-page (&optional lines circular)
4958 "Show next page of the selected article.
4959 If at the end of the current article, select the next article.
4960 LINES says how many lines should be scrolled up.
4962 If CIRCULAR is non-nil, go to the start of the article instead of
4963 selecting the next article when reaching the end of the current
4966 (setq gnus-summary-buffer (current-buffer))
4967 (gnus-set-global-variables)
4968 (let ((article (gnus-summary-article-number))
4970 (gnus-configure-windows 'article)
4971 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
4972 (if (and (eq gnus-summary-goto-unread 'never)
4973 (not (gnus-summary-last-article-p article)))
4974 (gnus-summary-next-article)
4975 (gnus-summary-next-unread-article))
4976 (if (or (null gnus-current-article)
4977 (null gnus-article-current)
4978 (/= article (cdr gnus-article-current))
4979 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
4980 ;; Selected subject is different from current article's.
4981 (gnus-summary-display-article article)
4982 (gnus-eval-in-buffer-window gnus-article-buffer
4983 (setq endp (gnus-article-next-page lines)))
4986 (gnus-summary-beginning-of-article))
4988 (gnus-message 3 "End of message"))
4990 (if (and (eq gnus-summary-goto-unread 'never)
4991 (not (gnus-summary-last-article-p article)))
4992 (gnus-summary-next-article)
4993 (gnus-summary-next-unread-article)))))))
4994 (gnus-summary-recenter)
4995 (gnus-summary-position-point)))
4997 (defun gnus-summary-prev-page (&optional lines)
4998 "Show previous page of selected article.
4999 Argument LINES specifies lines to be scrolled down."
5001 (gnus-set-global-variables)
5002 (let ((article (gnus-summary-article-number)))
5003 (gnus-configure-windows 'article)
5004 (if (or (null gnus-current-article)
5005 (null gnus-article-current)
5006 (/= article (cdr gnus-article-current))
5007 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5008 ;; Selected subject is different from current article's.
5009 (gnus-summary-display-article article)
5010 (gnus-summary-recenter)
5011 (gnus-eval-in-buffer-window gnus-article-buffer
5012 (gnus-article-prev-page lines))))
5013 (gnus-summary-position-point))
5015 (defun gnus-summary-scroll-up (lines)
5016 "Scroll up (or down) one line current article.
5017 Argument LINES specifies lines to be scrolled up (or down if negative)."
5019 (gnus-set-global-variables)
5020 (gnus-configure-windows 'article)
5021 (gnus-summary-show-thread)
5022 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
5023 (gnus-eval-in-buffer-window gnus-article-buffer
5025 (if (gnus-article-next-page lines)
5026 (gnus-message 3 "End of message")))
5028 (gnus-article-prev-page (- lines))))))
5029 (gnus-summary-recenter)
5030 (gnus-summary-position-point))
5032 (defun gnus-summary-next-same-subject ()
5033 "Select next article which has the same subject as current one."
5035 (gnus-set-global-variables)
5036 (gnus-summary-next-article nil (gnus-summary-article-subject)))
5038 (defun gnus-summary-prev-same-subject ()
5039 "Select previous article which has the same subject as current one."
5041 (gnus-set-global-variables)
5042 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
5044 (defun gnus-summary-next-unread-same-subject ()
5045 "Select next unread article which has the same subject as current one."
5047 (gnus-set-global-variables)
5048 (gnus-summary-next-article t (gnus-summary-article-subject)))
5050 (defun gnus-summary-prev-unread-same-subject ()
5051 "Select previous unread article which has the same subject as current one."
5053 (gnus-set-global-variables)
5054 (gnus-summary-prev-article t (gnus-summary-article-subject)))
5056 (defun gnus-summary-first-unread-article ()
5057 "Select the first unread article.
5058 Return nil if there are no unread articles."
5060 (gnus-set-global-variables)
5062 (when (gnus-summary-first-subject t)
5063 (gnus-summary-show-thread)
5064 (gnus-summary-first-subject t)
5065 (gnus-summary-display-article (gnus-summary-article-number)))
5066 (gnus-summary-position-point)))
5068 (defun gnus-summary-best-unread-article ()
5069 "Select the unread article with the highest score."
5071 (gnus-set-global-variables)
5072 (let ((best -1000000)
5073 (data gnus-newsgroup-data)
5076 (and (gnus-data-unread-p (car data))
5078 (gnus-summary-article-score (gnus-data-number (car data))))
5081 article (gnus-data-number (car data))))
5082 (setq data (cdr data)))
5085 (gnus-summary-goto-article article)
5086 (error "No unread articles"))
5087 (gnus-summary-position-point))))
5089 (defun gnus-summary-last-subject ()
5090 "Go to the last displayed subject line in the group."
5091 (let ((article (gnus-data-number (car (gnus-data-list t)))))
5093 (gnus-summary-goto-subject article))))
5095 (defun gnus-summary-goto-article (article &optional all-headers force)
5096 "Fetch ARTICLE and display it if it exists.
5097 If ALL-HEADERS is non-nil, no header lines are hidden."
5103 (mapcar (lambda (number) (list (int-to-string number)))
5104 gnus-newsgroup-limit)))
5108 (if (gnus-summary-goto-subject article force)
5109 (gnus-summary-display-article article all-headers)
5110 (gnus-message 4 "Couldn't go to article %s" article) nil)
5111 (gnus-summary-position-point)))
5113 (defun gnus-summary-goto-last-article ()
5114 "Go to the previously read article."
5117 (and gnus-last-article
5118 (gnus-summary-goto-article gnus-last-article))
5119 (gnus-summary-position-point)))
5121 (defun gnus-summary-pop-article (number)
5122 "Pop one article off the history and go to the previous.
5123 NUMBER articles will be popped off."
5126 (setq gnus-newsgroup-history
5127 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
5129 (gnus-summary-goto-article (car to))
5130 (error "Article history empty")))
5131 (gnus-summary-position-point))
5133 ;; Summary commands and functions for limiting the summary buffer.
5135 (defun gnus-summary-limit-to-articles (n)
5136 "Limit the summary buffer to the next N articles.
5137 If not given a prefix, use the process marked articles instead."
5139 (gnus-set-global-variables)
5141 (let ((articles (gnus-summary-work-articles n)))
5142 (setq gnus-newsgroup-processable nil)
5143 (gnus-summary-limit articles))
5144 (gnus-summary-position-point)))
5146 (defun gnus-summary-pop-limit (&optional total)
5147 "Restore the previous limit.
5148 If given a prefix, remove all limits."
5150 (gnus-set-global-variables)
5152 (setq gnus-newsgroup-limits
5153 (list (mapcar (lambda (h) (mail-header-number h))
5154 gnus-newsgroup-headers))))
5155 (unless gnus-newsgroup-limits
5156 (error "No limit to pop"))
5158 (gnus-summary-limit nil 'pop)
5159 (gnus-summary-position-point)))
5161 (defun gnus-summary-limit-to-subject (subject &optional header)
5162 "Limit the summary buffer to articles that have subjects that match a regexp."
5163 (interactive "sRegexp: ")
5165 (setq header "subject"))
5166 (when (not (equal "" subject))
5168 (let ((articles (gnus-summary-find-matching
5169 (or header "subject") subject 'all)))
5170 (or articles (error "Found no matches for \"%s\"" subject))
5171 (gnus-summary-limit articles))
5172 (gnus-summary-position-point))))
5174 (defun gnus-summary-limit-to-author (from)
5175 "Limit the summary buffer to articles that have authors that match a regexp."
5176 (interactive "sRegexp: ")
5177 (gnus-summary-limit-to-subject from "from"))
5179 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
5181 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
5183 (defun gnus-summary-limit-to-unread (&optional all)
5184 "Limit the summary buffer to articles that are not marked as read.
5185 If ALL is non-nil, limit strictly to unread articles."
5188 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
5189 (gnus-summary-limit-to-marks
5190 ;; Concat all the marks that say that an article is read and have
5192 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
5193 gnus-killed-mark gnus-kill-file-mark
5194 gnus-low-score-mark gnus-expirable-mark
5195 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
5196 gnus-duplicate-mark)
5199 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
5200 (make-obsolete 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
5202 (defun gnus-summary-limit-to-marks (marks &optional reverse)
5203 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
5204 If REVERSE, limit the summary buffer to articles that are not marked
5205 with MARKS. MARKS can either be a string of marks or a list of marks.
5206 Returns how many articles were removed."
5207 (interactive "sMarks: ")
5208 (gnus-set-global-variables)
5210 (let ((data gnus-newsgroup-data)
5211 (marks (if (listp marks) marks
5212 (append marks nil))) ; Transform to list.
5215 (and (if reverse (not (memq (gnus-data-mark (car data)) marks))
5216 (memq (gnus-data-mark (car data)) marks))
5217 (setq articles (cons (gnus-data-number (car data)) articles)))
5218 (setq data (cdr data)))
5219 (gnus-summary-limit articles))
5220 (gnus-summary-position-point)))
5222 (defun gnus-summary-limit-to-score (&optional score)
5223 "Limit to articles with score at or above SCORE."
5225 (gnus-set-global-variables)
5226 (setq score (if score
5227 (prefix-numeric-value score)
5228 (or gnus-summary-default-score 0)))
5229 (let ((data gnus-newsgroup-data)
5232 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
5234 (push (gnus-data-number (car data)) articles))
5235 (setq data (cdr data)))
5237 (gnus-summary-limit articles)
5238 (gnus-summary-position-point))))
5240 (defun gnus-summary-limit-include-dormant ()
5241 "Display all the hidden articles that are marked as dormant."
5243 (gnus-set-global-variables)
5244 (or gnus-newsgroup-dormant
5245 (error "There are no dormant articles in this group"))
5247 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
5248 (gnus-summary-position-point)))
5250 (defun gnus-summary-limit-exclude-dormant ()
5251 "Hide all dormant articles."
5253 (gnus-set-global-variables)
5255 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
5256 (gnus-summary-position-point)))
5258 (defun gnus-summary-limit-exclude-childless-dormant ()
5259 "Hide all dormant articles that have no children."
5261 (gnus-set-global-variables)
5262 (let ((data (gnus-data-list t))
5263 articles d children)
5264 ;; Find all articles that are either not dormant or have
5266 (while (setq d (pop data))
5267 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
5269 (gnus-article-children (gnus-data-number d)))
5272 (when (memq (car children) articles)
5277 (push (gnus-data-number d) articles)))
5280 (gnus-summary-limit articles)
5281 (gnus-summary-position-point))))
5283 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
5284 "Mark all unread excluded articles as read.
5285 If ALL, mark even excluded ticked and dormants as read."
5287 (let ((articles (gnus-sorted-complement
5289 (mapcar (lambda (h) (mail-header-number h))
5290 gnus-newsgroup-headers)
5292 (sort gnus-newsgroup-limit '<)))
5294 (setq gnus-newsgroup-unreads nil)
5296 (setq gnus-newsgroup-dormant nil
5297 gnus-newsgroup-marked nil
5298 gnus-newsgroup-reads
5300 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
5301 gnus-newsgroup-reads))
5302 (while (setq article (pop articles))
5303 (unless (or (memq article gnus-newsgroup-dormant)
5304 (memq article gnus-newsgroup-marked))
5305 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
5307 (defun gnus-summary-limit (articles &optional pop)
5309 ;; We pop the previous limit off the stack and use that.
5310 (setq articles (car gnus-newsgroup-limits)
5311 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
5312 ;; We use the new limit, so we push the old limit on the stack.
5313 (setq gnus-newsgroup-limits
5314 (cons gnus-newsgroup-limit gnus-newsgroup-limits)))
5316 (setq gnus-newsgroup-limit articles)
5317 (let ((total (length gnus-newsgroup-data))
5318 (data (gnus-data-find-list (gnus-summary-article-number)))
5319 (gnus-summary-mark-below nil) ; Inhibit this.
5321 ;; This will do all the work of generating the new summary buffer
5322 ;; according to the new limit.
5323 (gnus-summary-prepare)
5324 ;; Hide any threads, possibly.
5325 (and gnus-show-threads
5326 gnus-thread-hide-subtree
5327 (gnus-summary-hide-all-threads))
5328 ;; Try to return to the article you were at, or one in the
5331 ;; We try to find some article after the current one.
5333 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
5336 (setq data (cdr data))))
5338 ;; If there is no data, that means that we were after the last
5339 ;; article. The same goes when we can't find any articles
5340 ;; after the current one.
5341 (goto-char (point-max))
5342 (gnus-summary-find-prev))
5343 ;; We return how many articles were removed from the summary
5344 ;; buffer as a result of the new limit.
5345 (- total (length gnus-newsgroup-data))))
5347 (defsubst gnus-invisible-cut-children (threads)
5350 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
5355 (defsubst gnus-cut-thread (thread)
5356 "Go forwards in the thread until we find an article that we want to display."
5357 (when (or (eq gnus-fetch-old-headers 'some)
5358 (eq gnus-build-sparse-threads 'some)
5359 (eq gnus-build-sparse-threads 'more))
5360 ;; Deal with old-fetched headers and sparse threads.
5364 (memq (mail-header-number (car thread)) gnus-newsgroup-sparse)
5365 (memq (mail-header-number (car thread)) gnus-newsgroup-ancient))
5366 (or (<= (length (cdr thread)) 1)
5367 (gnus-invisible-cut-children (cdr thread))))
5368 (setq thread (cadr thread))))
5371 (defun gnus-cut-threads (threads)
5372 "Cut off all uninteresting articles from the beginning of threads."
5373 (when (or (eq gnus-fetch-old-headers 'some)
5374 (eq gnus-build-sparse-threads 'some)
5375 (eq gnus-build-sparse-threads 'more))
5378 (setcar th (gnus-cut-thread (car th)))
5379 (setq th (cdr th)))))
5380 ;; Remove nixed out threads.
5383 (defun gnus-summary-initial-limit (&optional show-if-empty)
5384 "Figure out what the initial limit is supposed to be on group entry.
5385 This entails weeding out unwanted dormants, low-scored articles,
5386 fetch-old-headers verbiage, and so on."
5387 ;; Most groups have nothing to remove.
5388 (if (or gnus-inhibit-limiting
5389 (and (null gnus-newsgroup-dormant)
5390 (not (eq gnus-fetch-old-headers 'some))
5391 (null gnus-summary-expunge-below)
5392 (not (eq gnus-build-sparse-threads 'some))
5393 (not (eq gnus-build-sparse-threads 'more))
5394 (null gnus-thread-expunge-below)
5395 (not gnus-use-nocem)))
5397 (push gnus-newsgroup-limit gnus-newsgroup-limits)
5398 (setq gnus-newsgroup-limit nil)
5401 (unless (car (symbol-value node))
5402 ;; These threads have no parents -- they are roots.
5403 (let ((nodes (cdr (symbol-value node)))
5406 (if (and gnus-thread-expunge-below
5407 (< (gnus-thread-total-score (car nodes))
5408 gnus-thread-expunge-below))
5409 (gnus-expunge-thread (pop nodes))
5410 (setq thread (pop nodes))
5411 (gnus-summary-limit-children thread))))))
5412 gnus-newsgroup-dependencies)
5413 ;; If this limitation resulted in an empty group, we might
5414 ;; pop the previous limit and use it instead.
5415 (when (and (not gnus-newsgroup-limit)
5417 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
5418 gnus-newsgroup-limit))
5420 (defun gnus-summary-limit-children (thread)
5421 "Return 1 if this subthread is visible and 0 if it is not."
5422 ;; First we get the number of visible children to this thread. This
5423 ;; is done by recursing down the thread using this function, so this
5424 ;; will really go down to a leaf article first, before slowly
5425 ;; working its way up towards the root.
5429 (apply '+ (mapcar 'gnus-summary-limit-children
5432 (number (mail-header-number (car thread)))
5435 (not (memq number gnus-newsgroup-marked))
5437 ;; If this article is dormant and has absolutely no visible
5438 ;; children, then this article isn't visible.
5439 (and (memq number gnus-newsgroup-dormant)
5441 ;; If this is "fetch-old-headered" and there is only one
5442 ;; visible child (or less), then we don't want this article.
5443 (and (eq gnus-fetch-old-headers 'some)
5444 (memq number gnus-newsgroup-ancient)
5446 ;; If this is a sparsely inserted article with no children,
5447 ;; we don't want it.
5448 (and (eq gnus-build-sparse-threads 'some)
5449 (memq number gnus-newsgroup-sparse)
5451 ;; If we use expunging, and this article is really
5452 ;; low-scored, then we don't want this article.
5453 (when (and gnus-summary-expunge-below
5455 (or (cdr (assq number gnus-newsgroup-scored))
5456 gnus-summary-default-score))
5457 gnus-summary-expunge-below))
5458 ;; We increase the expunge-tally here, but that has
5459 ;; nothing to do with the limits, really.
5460 (incf gnus-newsgroup-expunged-tally)
5461 ;; We also mark as read here, if that's wanted.
5462 (when (and gnus-summary-mark-below
5463 (< score gnus-summary-mark-below))
5464 (setq gnus-newsgroup-unreads
5465 (delq number gnus-newsgroup-unreads))
5466 (if gnus-newsgroup-auto-expire
5467 (push number gnus-newsgroup-expirable)
5468 (push (cons number gnus-low-score-mark)
5469 gnus-newsgroup-reads)))
5471 ;; Check NoCeM things.
5473 (gnus-nocem-unwanted-article-p
5474 (mail-header-id (car thread))))))
5475 ;; Nope, invisible article.
5477 ;; Ok, this article is to be visible, so we add it to the limit
5479 (setq gnus-newsgroup-limit (cons number gnus-newsgroup-limit))
5482 (defun gnus-expunge-thread (thread)
5483 "Mark all articles in THREAD as read."
5484 (let* ((number (mail-header-number (car thread))))
5485 (incf gnus-newsgroup-expunged-tally)
5486 ;; We also mark as read here, if that's wanted.
5487 (setq gnus-newsgroup-unreads
5488 (delq number gnus-newsgroup-unreads))
5489 (if gnus-newsgroup-auto-expire
5490 (push number gnus-newsgroup-expirable)
5491 (push (cons number gnus-low-score-mark)
5492 gnus-newsgroup-reads)))
5493 ;; Go recursively through all subthreads.
5494 (mapcar 'gnus-expunge-thread (cdr thread)))
5496 ;; Summary article oriented commands
5498 (defun gnus-summary-refer-parent-article (n)
5499 "Refer parent article N times.
5500 If N is negative, go to ancestor -N instead.
5501 The difference between N and the number of articles fetched is returned."
5503 (gnus-set-global-variables)
5506 (when (not (natnump n))
5511 (setq header (gnus-summary-article-header))
5513 ;; If we try to find the parent of the currently
5514 ;; displayed article, then we take a look at the actual
5515 ;; References header, since this is slightly more
5516 ;; reliable than the References field we got from the
5518 (if (and (eq (mail-header-number header)
5519 (cdr gnus-article-current))
5520 (equal gnus-newsgroup-name
5521 (car gnus-article-current)))
5523 (set-buffer gnus-original-article-buffer)
5524 (nnheader-narrow-to-headers)
5526 (message-fetch-field "references")
5528 ;; It's not the current article, so we take a bet on
5529 ;; the value we got from the server.
5530 (mail-header-references header)))
5532 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
5533 (gnus-message 1 "Couldn't find parent"))
5534 (gnus-message 1 "No references in article %d"
5535 (gnus-summary-article-number))
5538 (gnus-summary-position-point)
5541 (defun gnus-summary-refer-references ()
5542 "Fetch all articles mentioned in the References header.
5543 Return how many articles were fetched."
5545 (gnus-set-global-variables)
5546 (let ((ref (mail-header-references (gnus-summary-article-header)))
5547 (current (gnus-summary-article-number))
5549 ;; For each Message-ID in the References header...
5550 (while (string-match "<[^>]*>" ref)
5552 ;; ... fetch that article.
5553 (gnus-summary-refer-article
5554 (prog1 (match-string 0 ref)
5555 (setq ref (substring ref (match-end 0))))))
5556 (gnus-summary-goto-subject current)
5557 (gnus-summary-position-point)
5560 (defun gnus-summary-refer-article (message-id)
5561 "Fetch an article specified by MESSAGE-ID."
5562 (interactive "sMessage-ID: ")
5563 (when (and (stringp message-id)
5564 (not (zerop (length message-id))))
5565 ;; Construct the correct Message-ID if necessary.
5566 ;; Suggested by tale@pawl.rpi.edu.
5567 (unless (string-match "^<" message-id)
5568 (setq message-id (concat "<" message-id)))
5569 (unless (string-match ">$" message-id)
5570 (setq message-id (concat message-id ">")))
5571 (let* ((header (gnus-id-to-header message-id))
5573 (memq (mail-header-number header)
5574 gnus-newsgroup-sparse))))
5577 ;; The article is present in the buffer, to we just go to it.
5578 (gnus-summary-goto-article
5579 (mail-header-number header) nil header)
5581 (gnus-summary-update-article (mail-header-number header))))
5582 ;; We fetch the article
5583 (let ((gnus-override-method
5584 (and (gnus-news-group-p gnus-newsgroup-name)
5585 gnus-refer-article-method))
5587 ;; Start the special refer-article method, if necessary.
5588 (when (and gnus-refer-article-method
5589 (gnus-news-group-p gnus-newsgroup-name))
5590 (gnus-check-server gnus-refer-article-method))
5591 ;; Fetch the header, and display the article.
5592 (if (setq number (gnus-summary-insert-subject message-id))
5593 (gnus-summary-select-article nil nil nil number)
5594 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
5596 (defun gnus-summary-enter-digest-group (&optional force)
5597 "Enter an nndoc group based on the current article.
5598 If FORCE, force a digest interpretation. If not, try
5599 to guess what the document format is."
5601 (gnus-set-global-variables)
5602 (let ((conf gnus-current-window-configuration))
5604 (gnus-summary-select-article))
5605 (setq gnus-current-window-configuration conf)
5606 (let* ((name (format "%s-%d"
5607 (gnus-group-prefixed-name
5608 gnus-newsgroup-name (list 'nndoc ""))
5610 (set-buffer gnus-summary-buffer)
5611 gnus-current-article)))
5612 (ogroup gnus-newsgroup-name)
5613 (params (append (gnus-info-params (gnus-get-info ogroup))
5614 (list (cons 'to-group ogroup))))
5615 (case-fold-search t)
5616 (buf (current-buffer))
5619 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
5620 (insert-buffer-substring gnus-original-article-buffer)
5621 ;; Remove lines that may lead nndoc to misinterpret the
5624 (goto-char (point-min))
5625 (or (search-forward "\n\n" nil t) (point)))
5626 (goto-char (point-min))
5627 (delete-matching-lines "^\\(Path\\):\\|^From ")
5630 (if (gnus-group-read-ephemeral-group
5631 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
5632 (nndoc-article-type ,(if force 'digest 'guess))) t)
5633 ;; Make all postings to this group go to the parent group.
5634 (nconc (gnus-info-params (gnus-get-info name))
5636 ;; Couldn't select this doc group.
5637 (switch-to-buffer buf)
5638 (gnus-set-global-variables)
5639 (gnus-configure-windows 'summary)
5640 (gnus-message 3 "Article couldn't be entered?"))
5641 (kill-buffer dig)))))
5643 (defun gnus-summary-read-document (n)
5644 "Open a new group based on the current article(s).
5645 Obeys the standard process/prefix convention."
5647 (let* ((articles (gnus-summary-work-articles n))
5648 (ogroup gnus-newsgroup-name)
5649 (params (append (gnus-info-params (gnus-get-info ogroup))
5650 (list (cons 'to-group ogroup))))
5651 article group egroup groups vgroup)
5652 (while (setq article (pop articles))
5653 (setq group (format "%s-%d" gnus-newsgroup-name article))
5654 (gnus-summary-remove-process-mark article)
5655 (when (gnus-summary-display-article article)
5657 (nnheader-temp-write nil
5658 (insert-buffer-substring gnus-original-article-buffer)
5659 ;; Remove some headers that may lead nndoc to make
5661 (message-narrow-to-head)
5662 (goto-char (point-min))
5663 (delete-matching-lines "^\\(Path\\):\\|^From ")
5666 (gnus-group-read-ephemeral-group
5667 group `(nndoc ,group (nndoc-address ,(current-buffer))
5668 (nndoc-article-type guess))
5671 ;; Make all postings to this group go to the parent group.
5672 (nconc (gnus-info-params (gnus-get-info egroup))
5674 (push egroup groups))
5675 ;; Couldn't select this doc group.
5676 (gnus-error 3 "Article couldn't be entered"))))))
5677 ;; Now we have selected all the documents.
5680 (error "None of the articles could be interpreted as documents"))
5681 ((gnus-group-read-ephemeral-group
5682 (setq vgroup (format
5683 "nnvirtual:%s-%s" gnus-newsgroup-name
5684 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
5685 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
5687 (cons (current-buffer) 'summary)))
5689 (error "Couldn't select virtual nndoc group")))))
5691 (defun gnus-summary-isearch-article (&optional regexp-p)
5692 "Do incremental search forward on the current article.
5693 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
5695 (gnus-set-global-variables)
5696 (gnus-summary-select-article)
5697 (gnus-configure-windows 'article)
5698 (gnus-eval-in-buffer-window gnus-article-buffer
5699 ;;(goto-char (point-min))
5700 (isearch-forward regexp-p)))
5702 (defun gnus-summary-search-article-forward (regexp &optional backward)
5703 "Search for an article containing REGEXP forward.
5704 If BACKWARD, search backward instead."
5707 (format "Search article %s (regexp%s): "
5708 (if current-prefix-arg "backward" "forward")
5709 (if gnus-last-search-regexp
5710 (concat ", default " gnus-last-search-regexp)
5712 current-prefix-arg))
5713 (gnus-set-global-variables)
5714 (if (string-equal regexp "")
5715 (setq regexp (or gnus-last-search-regexp ""))
5716 (setq gnus-last-search-regexp regexp))
5717 (if (gnus-summary-search-article regexp backward)
5718 (gnus-summary-show-thread)
5719 (error "Search failed: \"%s\"" regexp)))
5721 (defun gnus-summary-search-article-backward (regexp)
5722 "Search for an article containing REGEXP backward."
5725 (format "Search article backward (regexp%s): "
5726 (if gnus-last-search-regexp
5727 (concat ", default " gnus-last-search-regexp)
5729 (gnus-summary-search-article-forward regexp 'backward))
5731 (defun gnus-summary-search-article (regexp &optional backward)
5732 "Search for an article containing REGEXP.
5733 Optional argument BACKWARD means do search for backward.
5734 `gnus-select-article-hook' is not called during the search."
5735 (let ((gnus-select-article-hook nil) ;Disable hook.
5736 (gnus-article-display-hook nil)
5737 (gnus-mark-article-hook nil) ;Inhibit marking as read.
5738 (gnus-use-article-prefetch nil)
5739 (sum (current-buffer))
5742 (gnus-save-hidden-threads
5743 (gnus-summary-select-article)
5744 (set-buffer gnus-article-buffer)
5748 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
5750 (re-search-backward regexp nil t)
5751 (re-search-forward regexp nil t))
5752 ;; We found the regexp.
5757 (get-buffer-window (current-buffer))
5761 (setq point (point)))
5762 ;; We didn't find it, so we go to the next article.
5764 (if (not (if backward (gnus-summary-find-prev)
5765 (gnus-summary-find-next)))
5766 ;; No more articles.
5768 ;; Select the next article and adjust point.
5769 (gnus-summary-select-article)
5770 (set-buffer gnus-article-buffer)
5772 (goto-char (if backward (point-max) (point-min))))))
5773 (gnus-message 7 ""))
5774 ;; Return whether we found the regexp.
5775 (when (eq found 'found)
5777 (gnus-summary-show-thread)
5778 (gnus-summary-goto-subject gnus-current-article)
5779 (gnus-summary-position-point)
5782 (defun gnus-summary-find-matching (header regexp &optional backward unread
5784 "Return a list of all articles that match REGEXP on HEADER.
5785 The search stars on the current article and goes forwards unless
5786 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
5787 If UNREAD is non-nil, only unread articles will
5788 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
5789 in the comparisons."
5790 (let ((data (if (eq backward 'all) gnus-newsgroup-data
5791 (gnus-data-find-list
5792 (gnus-summary-article-number) (gnus-data-list backward))))
5793 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
5794 (case-fold-search (not not-case-fold))
5796 (or (fboundp (intern (concat "mail-header-" header)))
5797 (error "%s is not a valid header" header))
5800 (and (or (not unread) ; We want all articles...
5801 (gnus-data-unread-p d)) ; Or just unreads.
5802 (vectorp (gnus-data-header d)) ; It's not a pseudo.
5803 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
5804 (setq articles (cons (gnus-data-number d) articles))) ; Success!
5805 (setq data (cdr data)))
5806 (nreverse articles)))
5808 (defun gnus-summary-execute-command (header regexp command &optional backward)
5809 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
5810 If HEADER is an empty string (or nil), the match is done on the entire
5811 article. If BACKWARD (the prefix) is non-nil, search backward instead."
5813 (list (let ((completion-ignore-case t))
5816 (mapcar (lambda (string) (list string))
5817 '("Number" "Subject" "From" "Lines" "Date"
5818 "Message-ID" "Xref" "References" "Body"))
5819 nil 'require-match))
5820 (read-string "Regexp: ")
5821 (read-key-sequence "Command: ")
5822 current-prefix-arg))
5823 (when (equal header "Body")
5825 (gnus-set-global-variables)
5826 ;; Hidden thread subtrees must be searched as well.
5827 (gnus-summary-show-all-threads)
5828 ;; We don't want to change current point nor window configuration.
5830 (save-window-excursion
5831 (gnus-message 6 "Executing %s..." (key-description command))
5832 ;; We'd like to execute COMMAND interactively so as to give arguments.
5833 (gnus-execute header regexp
5834 `(call-interactively ',(key-binding command))
5836 (gnus-message 6 "Executing %s...done" (key-description command)))))
5838 (defun gnus-summary-beginning-of-article ()
5839 "Scroll the article back to the beginning."
5841 (gnus-set-global-variables)
5842 (gnus-summary-select-article)
5843 (gnus-configure-windows 'article)
5844 (gnus-eval-in-buffer-window gnus-article-buffer
5846 (goto-char (point-min))
5847 (and gnus-break-pages (gnus-narrow-to-page))))
5849 (defun gnus-summary-end-of-article ()
5850 "Scroll to the end of the article."
5852 (gnus-set-global-variables)
5853 (gnus-summary-select-article)
5854 (gnus-configure-windows 'article)
5855 (gnus-eval-in-buffer-window gnus-article-buffer
5857 (goto-char (point-max))
5859 (and gnus-break-pages (gnus-narrow-to-page))))
5861 (defun gnus-summary-show-article (&optional arg)
5862 "Force re-fetching of the current article.
5863 If ARG (the prefix) is non-nil, show the raw article without any
5864 article massaging functions being run."
5866 (gnus-set-global-variables)
5868 ;; Select the article the normal way.
5869 (gnus-summary-select-article nil 'force)
5870 ;; Bind the article treatment functions to nil.
5871 (let ((gnus-have-all-headers t)
5872 gnus-article-display-hook
5873 gnus-article-prepare-hook
5876 (gnus-summary-select-article nil 'force)))
5877 (gnus-summary-goto-subject gnus-current-article)
5878 ; (gnus-configure-windows 'article)
5879 (gnus-summary-position-point))
5881 (defun gnus-summary-verbose-headers (&optional arg)
5882 "Toggle permanent full header display.
5883 If ARG is a positive number, turn header display on.
5884 If ARG is a negative number, turn header display off."
5886 (gnus-set-global-variables)
5887 (setq gnus-show-all-headers
5888 (cond ((or (not (numberp arg))
5890 (not gnus-show-all-headers))
5893 (gnus-summary-show-article))
5895 (defun gnus-summary-toggle-header (&optional arg)
5896 "Show the headers if they are hidden, or hide them if they are shown.
5897 If ARG is a positive number, show the entire header.
5898 If ARG is a negative number, hide the unwanted header lines."
5900 (gnus-set-global-variables)
5902 (set-buffer gnus-article-buffer)
5903 (let* ((buffer-read-only nil)
5904 (inhibit-point-motion-hooks t)
5905 (hidden (text-property-any
5906 (goto-char (point-min)) (search-forward "\n\n")
5909 (goto-char (point-min))
5910 (when (search-forward "\n\n" nil t)
5911 (delete-region (point-min) (1- (point))))
5912 (goto-char (point-min))
5914 (set-buffer gnus-original-article-buffer)
5915 (goto-char (point-min))
5916 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
5917 (insert-buffer-substring gnus-original-article-buffer 1 e)
5918 (let ((article-inhibit-hiding t))
5919 (run-hooks 'gnus-article-display-hook))
5920 (if (or (not hidden) (and (numberp arg) (< arg 0)))
5921 (gnus-article-hide-headers)))))
5923 (defun gnus-summary-show-all-headers ()
5924 "Make all header lines visible."
5926 (gnus-set-global-variables)
5927 (gnus-article-show-all-headers))
5929 (defun gnus-summary-toggle-mime (&optional arg)
5930 "Toggle MIME processing.
5931 If ARG is a positive number, turn MIME processing on."
5933 (gnus-set-global-variables)
5934 (setq gnus-show-mime
5935 (if (null arg) (not gnus-show-mime)
5936 (> (prefix-numeric-value arg) 0)))
5937 (gnus-summary-select-article t 'force))
5939 (defun gnus-summary-caesar-message (&optional arg)
5940 "Caesar rotate the current article by 13.
5941 The numerical prefix specifies how manu places to rotate each letter
5944 (gnus-set-global-variables)
5945 (gnus-summary-select-article)
5946 (let ((mail-header-separator ""))
5947 (gnus-eval-in-buffer-window gnus-article-buffer
5950 (let ((start (window-start))
5952 (message-caesar-buffer-body arg)
5953 (set-window-start (get-buffer-window (current-buffer)) start))))))
5955 (defun gnus-summary-stop-page-breaking ()
5956 "Stop page breaking in the current article."
5958 (gnus-set-global-variables)
5959 (gnus-summary-select-article)
5960 (gnus-eval-in-buffer-window gnus-article-buffer
5963 (defun gnus-summary-move-article (&optional n to-newsgroup select-method action)
5964 "Move the current article to a different newsgroup.
5965 If N is a positive number, move the N next articles.
5966 If N is a negative number, move the N previous articles.
5967 If N is nil and any articles have been marked with the process mark,
5968 move those articles instead.
5969 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
5970 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
5971 re-spool using this method.
5973 For this function to work, both the current newsgroup and the
5974 newsgroup that you want to move to have to support the `request-move'
5975 and `request-accept' functions."
5977 (unless action (setq action 'move))
5978 (gnus-set-global-variables)
5979 ;; Check whether the source group supports the required functions.
5980 (cond ((and (eq action 'move)
5981 (not (gnus-check-backend-function
5982 'request-move-article gnus-newsgroup-name)))
5983 (error "The current group does not support article moving"))
5984 ((and (eq action 'crosspost)
5985 (not (gnus-check-backend-function
5986 'request-replace-article gnus-newsgroup-name)))
5987 (error "The current group does not support article editing")))
5988 (let ((articles (gnus-summary-work-articles n))
5989 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
5990 (names '((move "Move" "Moving")
5991 (copy "Copy" "Copying")
5992 (crosspost "Crosspost" "Crossposting")))
5993 (copy-buf (save-excursion
5994 (nnheader-set-temp-buffer " *copy article*")))
5995 art-group to-method new-xref article to-groups)
5996 (unless (assq action names)
5997 (error "Unknown action %s" action))
5998 ;; Read the newsgroup name.
5999 (when (and (not to-newsgroup)
6000 (not select-method))
6002 (gnus-read-move-group-name
6003 (cadr (assq action names))
6004 (symbol-value (intern (format "gnus-current-%s-group" action)))
6006 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
6007 (setq to-method (or select-method
6008 (gnus-group-name-to-method to-newsgroup)))
6009 ;; Check the method we are to move this article to...
6010 (or (gnus-check-backend-function 'request-accept-article (car to-method))
6011 (error "%s does not support article copying" (car to-method)))
6012 (or (gnus-check-server to-method)
6013 (error "Can't open server %s" (car to-method)))
6014 (gnus-message 6 "%s to %s: %s..."
6015 (caddr (assq action names))
6016 (or (car select-method) to-newsgroup) articles)
6018 (setq article (pop articles))
6022 ;; Move the article.
6024 (gnus-request-move-article
6025 article ; Article to move
6026 gnus-newsgroup-name ; From newsgrouo
6027 (nth 1 (gnus-find-method-for-group
6028 gnus-newsgroup-name)) ; Server
6029 (list 'gnus-request-accept-article
6030 to-newsgroup (list 'quote select-method)
6031 (not articles)) ; Accept form
6032 (not articles))) ; Only save nov last time
6033 ;; Copy the article.
6036 (set-buffer copy-buf)
6037 (gnus-request-article-this-buffer article gnus-newsgroup-name)
6038 (gnus-request-accept-article
6039 to-newsgroup select-method (not articles))))
6040 ;; Crosspost the article.
6041 ((eq action 'crosspost)
6042 (let ((xref (mail-header-xref (gnus-summary-article-header article))))
6043 (setq new-xref (concat gnus-newsgroup-name ":" article))
6044 (if (and xref (not (string= xref "")))
6046 (when (string-match "^Xref: " xref)
6047 (setq xref (substring xref (match-end 0))))
6048 (setq new-xref (concat xref " " new-xref)))
6049 (setq new-xref (concat (system-name) " " new-xref)))
6051 (set-buffer copy-buf)
6052 (gnus-request-article-this-buffer article gnus-newsgroup-name)
6053 (nnheader-replace-header "xref" new-xref)
6054 (gnus-request-accept-article
6055 to-newsgroup select-method (not articles)))))))
6057 (gnus-message 1 "Couldn't %s article %s"
6058 (cadr (assq action names)) article)
6061 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
6063 (gnus-group-prefixed-name
6066 (gnus-find-method-for-group to-newsgroup)))
6067 gnus-newsrc-hashtb)))
6068 (info (nth 2 entry))
6069 (to-group (gnus-info-group info)))
6070 ;; Update the group that has been moved to.
6072 (memq action '(move copy)))
6073 (unless (member to-group to-groups)
6074 (push to-group to-groups))
6076 (unless (memq article gnus-newsgroup-unreads)
6078 info (gnus-add-to-range (gnus-info-read info)
6079 (list (cdr art-group)))))
6081 ;; Copy any marks over to the new group.
6082 (let ((marks gnus-article-mark-lists)
6083 (to-article (cdr art-group)))
6085 ;; See whether the article is to be put in the cache.
6086 (when gnus-use-cache
6087 (gnus-cache-possibly-enter-article
6089 (let ((header (copy-sequence
6090 (gnus-summary-article-header article))))
6091 (mail-header-set-number header to-article)
6093 (memq article gnus-newsgroup-marked)
6094 (memq article gnus-newsgroup-dormant)
6095 (memq article gnus-newsgroup-unreads)))
6098 (when (memq article (symbol-value
6099 (intern (format "gnus-newsgroup-%s"
6101 ;; If the other group is the same as this group,
6102 ;; then we have to add the mark to the list.
6103 (when (equal to-group gnus-newsgroup-name)
6104 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
6107 (intern (format "gnus-newsgroup-%s"
6109 ;; Copy mark to other group.
6110 (gnus-add-marked-articles
6111 to-group (cdar marks) (list to-article) info))
6112 (setq marks (cdr marks)))))
6114 ;; Update the Xref header in this article to point to
6115 ;; the new crossposted article we have just created.
6116 (when (eq action 'crosspost)
6118 (set-buffer copy-buf)
6119 (gnus-request-article-this-buffer article gnus-newsgroup-name)
6120 (nnheader-replace-header
6121 "xref" (concat new-xref " " (gnus-group-prefixed-name
6122 (car art-group) to-method)
6123 ":" (cdr art-group)))
6124 (gnus-request-replace-article
6125 article gnus-newsgroup-name (current-buffer)))))
6127 (gnus-summary-goto-subject article)
6128 (when (eq action 'move)
6129 (gnus-summary-mark-article article gnus-canceled-mark)))
6130 (gnus-summary-remove-process-mark article))
6131 ;; Re-activate all groups that have been moved to.
6133 (gnus-activate-group (pop to-groups)))
6135 (gnus-kill-buffer copy-buf)
6136 (gnus-summary-position-point)
6137 (gnus-set-mode-line 'summary)))
6139 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
6140 "Move the current article to a different newsgroup.
6141 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
6142 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
6143 re-spool using this method."
6145 (gnus-summary-move-article n nil select-method 'copy))
6147 (defun gnus-summary-crosspost-article (&optional n)
6148 "Crosspost the current article to some other group."
6150 (gnus-summary-move-article n nil nil 'crosspost))
6152 (defvar gnus-summary-respool-default-method nil
6153 "Default method for respooling an article.
6154 If nil, use to the current newsgroup method.")
6156 (defun gnus-summary-respool-article (&optional n method)
6157 "Respool the current article.
6158 The article will be squeezed through the mail spooling process again,
6159 which means that it will be put in some mail newsgroup or other
6160 depending on `nnmail-split-methods'.
6161 If N is a positive number, respool the N next articles.
6162 If N is a negative number, respool the N previous articles.
6163 If N is nil and any articles have been marked with the process mark,
6164 respool those articles instead.
6166 Respooling can be done both from mail groups and \"real\" newsgroups.
6167 In the former case, the articles in question will be moved from the
6168 current group into whatever groups they are destined to. In the
6169 latter case, they will be copied into the relevant groups."
6171 (list current-prefix-arg
6172 (let* ((methods (gnus-methods-using 'respool))
6174 (symbol-name (or gnus-summary-respool-default-method
6175 (car (gnus-find-method-for-group
6176 gnus-newsgroup-name)))))
6178 (gnus-completing-read
6179 methname "What backend do you want to use when respooling?"
6180 methods nil t nil 'gnus-method-history))
6183 ((zerop (length (setq ms (gnus-servers-using-backend method))))
6184 (list (intern method) ""))
6188 (cdr (completing-read
6190 (mapcar (lambda (m) (cons (cadr m) m)) ms) nil t)))))))
6191 (gnus-set-global-variables)
6193 (error "No method given for respooling"))
6194 (if (assoc (symbol-name
6195 (car (gnus-find-method-for-group gnus-newsgroup-name)))
6196 (gnus-methods-using 'respool))
6197 (gnus-summary-move-article n nil method)
6198 (gnus-summary-copy-article n nil method)))
6200 (defun gnus-summary-import-article (file)
6201 "Import a random file into a mail newsgroup."
6202 (interactive "fImport file: ")
6203 (gnus-set-global-variables)
6204 (let ((group gnus-newsgroup-name)
6205 (now (current-time))
6207 (or (gnus-check-backend-function 'request-accept-article group)
6208 (error "%s does not support article importing" group))
6209 (or (file-readable-p file)
6210 (not (file-regular-p file))
6211 (error "Can't read %s" file))
6213 (set-buffer (get-buffer-create " *import file*"))
6214 (buffer-disable-undo (current-buffer))
6216 (insert-file-contents file)
6217 (goto-char (point-min))
6218 (unless (nnheader-article-p)
6219 ;; This doesn't look like an article, so we fudge some headers.
6220 (setq atts (file-attributes file)
6221 lines (count-lines (point-min) (point-max)))
6222 (insert "From: " (read-string "From: ") "\n"
6223 "Subject: " (read-string "Subject: ") "\n"
6224 "Date: " (timezone-make-date-arpa-standard
6225 (current-time-string (nth 5 atts))
6226 (current-time-zone now)
6227 (current-time-zone now)) "\n"
6228 "Message-ID: " (message-make-message-id) "\n"
6229 "Lines: " (int-to-string lines) "\n"
6230 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
6231 (gnus-request-accept-article group nil t)
6232 (kill-buffer (current-buffer)))))
6234 (defun gnus-summary-article-posted-p ()
6235 "Say whether the current (mail) article is available from `gnus-select-method' as well.
6236 This will be the case if the article has both been mailed and posted."
6238 (let ((id (mail-header-references (gnus-summary-article-header)))
6239 (gnus-override-method
6240 (or gnus-refer-article-method gnus-select-method)))
6241 (if (gnus-request-head id "")
6242 (gnus-message 2 "The current message was found on %s"
6243 gnus-override-method)
6244 (gnus-message 2 "The current message couldn't be found on %s"
6245 gnus-override-method)
6248 (defun gnus-summary-expire-articles (&optional now)
6249 "Expire all articles that are marked as expirable in the current group."
6251 (gnus-set-global-variables)
6252 (when (gnus-check-backend-function
6253 'request-expire-articles gnus-newsgroup-name)
6254 ;; This backend supports expiry.
6255 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
6256 (expirable (if total
6257 (gnus-list-of-read-articles gnus-newsgroup-name)
6258 (setq gnus-newsgroup-expirable
6259 (sort gnus-newsgroup-expirable '<))))
6260 (expiry-wait (if now 'immediate
6261 (gnus-group-find-parameter
6262 gnus-newsgroup-name 'expiry-wait)))
6265 ;; There are expirable articles in this group, so we run them
6266 ;; through the expiry process.
6267 (gnus-message 6 "Expiring articles...")
6268 ;; The list of articles that weren't expired is returned.
6270 (let ((nnmail-expiry-wait-function nil)
6271 (nnmail-expiry-wait expiry-wait))
6272 (setq es (gnus-request-expire-articles
6273 expirable gnus-newsgroup-name)))
6274 (setq es (gnus-request-expire-articles
6275 expirable gnus-newsgroup-name)))
6277 (setq gnus-newsgroup-expirable es))
6278 ;; We go through the old list of expirable, and mark all
6279 ;; really expired articles as nonexistent.
6280 (unless (eq es expirable) ;If nothing was expired, we don't mark.
6281 (let ((gnus-use-cache nil))
6283 (unless (memq (car expirable) es)
6284 (when (gnus-data-find (car expirable))
6285 (gnus-summary-mark-article
6286 (car expirable) gnus-canceled-mark)))
6287 (setq expirable (cdr expirable)))))
6288 (gnus-message 6 "Expiring articles...done")))))
6290 (defun gnus-summary-expire-articles-now ()
6291 "Expunge all expirable articles in the current group.
6292 This means that *all* articles that are marked as expirable will be
6293 deleted forever, right now."
6295 (gnus-set-global-variables)
6296 (or gnus-expert-user
6298 "Are you really, really, really sure you want to delete all these messages? ")
6300 (gnus-summary-expire-articles t))
6302 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
6303 (defun gnus-summary-delete-article (&optional n)
6304 "Delete the N next (mail) articles.
6305 This command actually deletes articles. This is not a marking
6306 command. The article will disappear forever from your life, never to
6308 If N is negative, delete backwards.
6309 If N is nil and articles have been marked with the process mark,
6310 delete these instead."
6312 (gnus-set-global-variables)
6313 (or (gnus-check-backend-function 'request-expire-articles
6314 gnus-newsgroup-name)
6315 (error "The current newsgroup does not support article deletion."))
6316 ;; Compute the list of articles to delete.
6317 (let ((articles (gnus-summary-work-articles n))
6319 (if (and gnus-novice-user
6321 (format "Do you really want to delete %s forever? "
6322 (if (> (length articles) 1)
6323 (format "these %s articles" (length articles))
6326 ;; Delete the articles.
6327 (setq not-deleted (gnus-request-expire-articles
6328 articles gnus-newsgroup-name 'force))
6330 (gnus-summary-remove-process-mark (car articles))
6331 ;; The backend might not have been able to delete the article
6333 (or (memq (car articles) not-deleted)
6334 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
6335 (setq articles (cdr articles))))
6336 (gnus-summary-position-point)
6337 (gnus-set-mode-line 'summary)
6340 (defun gnus-summary-edit-article (&optional force)
6341 "Edit the current article.
6342 This will have permanent effect only in mail groups.
6343 If FORCE is non-nil, allow editing of articles even in read-only
6347 (set-buffer gnus-summary-buffer)
6348 (gnus-set-global-variables)
6349 (when (and (not force)
6350 (gnus-group-read-only-p))
6351 (error "The current newsgroup does not support article editing."))
6352 ;; Select article if needed.
6353 (unless (eq (gnus-summary-article-number)
6354 gnus-current-article)
6355 (gnus-summary-select-article t))
6356 (gnus-article-edit-article
6358 (gnus-summary-edit-article-done
6359 ,(or (mail-header-references gnus-current-headers) "")
6360 ,(gnus-group-read-only-p) ,gnus-summary-buffer)))))
6362 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
6364 (defun gnus-summary-edit-article-done (&optional references read-only buffer)
6365 "Make edits to the current article permanent."
6367 ;; Replace the article.
6368 (if (and (not read-only)
6369 (not (gnus-request-replace-article
6370 (cdr gnus-article-current) (car gnus-article-current)
6372 (error "Couldn't replace article.")
6373 ;; Update the summary buffer.
6375 (equal (message-tokenize-header references " ")
6376 (message-tokenize-header
6377 (or (message-fetch-field "references") "") " ")))
6378 ;; We only have to update this line.
6381 (message-narrow-to-head)
6382 (let ((header (nnheader-parse-head t)))
6384 (mail-header-set-number header (cdr gnus-article-current))
6385 (gnus-summary-update-article-line
6386 (cdr gnus-article-current) header))))
6388 (set-buffer (or buffer gnus-summary-buffer))
6389 (gnus-summary-update-article (cdr gnus-article-current)))
6390 ;; Prettify the article buffer again.
6392 (set-buffer gnus-article-buffer)
6393 (run-hooks 'gnus-article-display-hook))
6394 ;; Prettify the summary buffer line.
6395 (when (gnus-visual-p 'summary-highlight 'highlight)
6396 (run-hooks 'gnus-visual-mark-article-hook))))
6398 (defun gnus-summary-edit-wash (key)
6399 "Perform editing command in the article buffer."
6403 (message "%s" (concat (this-command-keys) "- "))
6406 (gnus-summary-edit-article)
6407 (execute-kbd-macro (concat (this-command-keys) key))
6408 (gnus-article-edit-done))
6412 (defun gnus-summary-respool-query ()
6413 "Query where the respool algorithm would put this article."
6415 (gnus-set-global-variables)
6416 (gnus-summary-select-article)
6418 (set-buffer gnus-article-buffer)
6420 (goto-char (point-min))
6421 (search-forward "\n\n")
6422 (narrow-to-region (point-min) (point))
6424 (list 'quote (mapcar 'car (nnmail-article-group 'identity)))))))
6426 ;; Summary marking commands.
6428 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
6429 "Mark articles which has the same subject as read, and then select the next.
6430 If UNMARK is positive, remove any kind of mark.
6431 If UNMARK is negative, tick articles."
6433 (gnus-set-global-variables)
6435 (setq unmark (prefix-numeric-value unmark)))
6437 (gnus-summary-mark-same-subject
6438 (gnus-summary-article-subject) unmark)))
6439 ;; Select next unread article. If auto-select-same mode, should
6440 ;; select the first unread article.
6441 (gnus-summary-next-article t (and gnus-auto-select-same
6442 (gnus-summary-article-subject)))
6443 (gnus-message 7 "%d article%s marked as %s"
6444 count (if (= count 1) " is" "s are")
6445 (if unmark "unread" "read"))))
6447 (defun gnus-summary-kill-same-subject (&optional unmark)
6448 "Mark articles which has the same subject as read.
6449 If UNMARK is positive, remove any kind of mark.
6450 If UNMARK is negative, tick articles."
6452 (gnus-set-global-variables)
6454 (setq unmark (prefix-numeric-value unmark)))
6456 (gnus-summary-mark-same-subject
6457 (gnus-summary-article-subject) unmark)))
6458 ;; If marked as read, go to next unread subject.
6460 ;; Go to next unread subject.
6461 (gnus-summary-next-subject 1 t))
6462 (gnus-message 7 "%d articles are marked as %s"
6463 count (if unmark "unread" "read"))))
6465 (defun gnus-summary-mark-same-subject (subject &optional unmark)
6466 "Mark articles with same SUBJECT as read, and return marked number.
6467 If optional argument UNMARK is positive, remove any kinds of marks.
6468 If optional argument UNMARK is negative, mark articles as unread instead."
6472 ((null unmark) ; Mark as read.
6475 (gnus-summary-mark-article-as-read gnus-killed-mark)
6476 (gnus-summary-show-thread) t)
6477 (gnus-summary-find-subject subject))
6478 (setq count (1+ count))))
6479 ((> unmark 0) ; Tick.
6482 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
6483 (gnus-summary-show-thread) t)
6484 (gnus-summary-find-subject subject))
6485 (setq count (1+ count))))
6486 (t ; Mark as unread.
6489 (gnus-summary-mark-article-as-unread gnus-unread-mark)
6490 (gnus-summary-show-thread) t)
6491 (gnus-summary-find-subject subject))
6492 (setq count (1+ count)))))
6493 (gnus-set-mode-line 'summary)
6494 ;; Return the number of marked articles.
6497 (defun gnus-summary-mark-as-processable (n &optional unmark)
6498 "Set the process mark on the next N articles.
6499 If N is negative, mark backward instead. If UNMARK is non-nil, remove
6500 the process mark instead. The difference between N and the actual
6501 number of articles marked is returned."
6503 (gnus-set-global-variables)
6504 (let ((backward (< n 0))
6509 (gnus-summary-remove-process-mark
6510 (gnus-summary-article-number))
6511 (gnus-summary-set-process-mark (gnus-summary-article-number)))
6512 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
6514 (if (/= 0 n) (gnus-message 7 "No more articles"))
6515 (gnus-summary-recenter)
6516 (gnus-summary-position-point)
6519 (defun gnus-summary-unmark-as-processable (n)
6520 "Remove the process mark from the next N articles.
6521 If N is negative, mark backward instead. The difference between N and
6522 the actual number of articles marked is returned."
6524 (gnus-set-global-variables)
6525 (gnus-summary-mark-as-processable n t))
6527 (defun gnus-summary-unmark-all-processable ()
6528 "Remove the process mark from all articles."
6530 (gnus-set-global-variables)
6532 (while gnus-newsgroup-processable
6533 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
6534 (gnus-summary-position-point))
6536 (defun gnus-summary-mark-as-expirable (n)
6537 "Mark N articles forward as expirable.
6538 If N is negative, mark backward instead. The difference between N and
6539 the actual number of articles marked is returned."
6541 (gnus-set-global-variables)
6542 (gnus-summary-mark-forward n gnus-expirable-mark))
6544 (defun gnus-summary-mark-article-as-replied (article)
6545 "Mark ARTICLE replied and update the summary line."
6546 (setq gnus-newsgroup-replied (cons article gnus-newsgroup-replied))
6547 (let ((buffer-read-only nil))
6548 (when (gnus-summary-goto-subject article)
6549 (gnus-summary-update-secondary-mark article))))
6551 (defun gnus-summary-set-bookmark (article)
6552 "Set a bookmark in current article."
6553 (interactive (list (gnus-summary-article-number)))
6554 (gnus-set-global-variables)
6555 (if (or (not (get-buffer gnus-article-buffer))
6556 (not gnus-current-article)
6557 (not gnus-article-current)
6558 (not (equal gnus-newsgroup-name (car gnus-article-current))))
6559 (error "No current article selected"))
6560 ;; Remove old bookmark, if one exists.
6561 (let ((old (assq article gnus-newsgroup-bookmarks)))
6562 (if old (setq gnus-newsgroup-bookmarks
6563 (delq old gnus-newsgroup-bookmarks))))
6564 ;; Set the new bookmark, which is on the form
6565 ;; (article-number . line-number-in-body).
6566 (setq gnus-newsgroup-bookmarks
6570 (set-buffer gnus-article-buffer)
6574 (goto-char (point-min))
6575 (search-forward "\n\n" nil t)
6578 gnus-newsgroup-bookmarks))
6579 (gnus-message 6 "A bookmark has been added to the current article."))
6581 (defun gnus-summary-remove-bookmark (article)
6582 "Remove the bookmark from the current article."
6583 (interactive (list (gnus-summary-article-number)))
6584 (gnus-set-global-variables)
6585 ;; Remove old bookmark, if one exists.
6586 (let ((old (assq article gnus-newsgroup-bookmarks)))
6589 (setq gnus-newsgroup-bookmarks
6590 (delq old gnus-newsgroup-bookmarks))
6591 (gnus-message 6 "Removed bookmark."))
6592 (gnus-message 6 "No bookmark in current article."))))
6594 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
6595 (defun gnus-summary-mark-as-dormant (n)
6596 "Mark N articles forward as dormant.
6597 If N is negative, mark backward instead. The difference between N and
6598 the actual number of articles marked is returned."
6600 (gnus-set-global-variables)
6601 (gnus-summary-mark-forward n gnus-dormant-mark))
6603 (defun gnus-summary-set-process-mark (article)
6604 "Set the process mark on ARTICLE and update the summary line."
6605 (setq gnus-newsgroup-processable
6607 (delq article gnus-newsgroup-processable)))
6608 (when (gnus-summary-goto-subject article)
6609 (gnus-summary-show-thread)
6610 (gnus-summary-update-secondary-mark article)))
6612 (defun gnus-summary-remove-process-mark (article)
6613 "Remove the process mark from ARTICLE and update the summary line."
6614 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
6615 (when (gnus-summary-goto-subject article)
6616 (gnus-summary-show-thread)
6617 (gnus-summary-update-secondary-mark article)))
6619 (defun gnus-summary-set-saved-mark (article)
6620 "Set the process mark on ARTICLE and update the summary line."
6621 (push article gnus-newsgroup-saved)
6622 (when (gnus-summary-goto-subject article)
6623 (gnus-summary-update-secondary-mark article)))
6625 (defun gnus-summary-mark-forward (n &optional mark no-expire)
6626 "Mark N articles as read forwards.
6627 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
6628 The difference between N and the actual number of articles marked is
6631 (gnus-set-global-variables)
6632 (let ((backward (< n 0))
6633 (gnus-summary-goto-unread
6634 (and gnus-summary-goto-unread
6635 (not (eq gnus-summary-goto-unread 'never))
6636 (not (memq mark (list gnus-unread-mark
6637 gnus-ticked-mark gnus-dormant-mark)))))
6639 (mark (or mark gnus-del-mark)))
6641 (gnus-summary-mark-article nil mark no-expire)
6642 (zerop (gnus-summary-next-subject
6644 (and gnus-summary-goto-unread
6645 (not (eq gnus-summary-goto-unread 'never)))
6648 (if (/= 0 n) (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
6649 (gnus-summary-recenter)
6650 (gnus-summary-position-point)
6651 (gnus-set-mode-line 'summary)
6654 (defun gnus-summary-mark-article-as-read (mark)
6655 "Mark the current article quickly as read with MARK."
6656 (let ((article (gnus-summary-article-number)))
6657 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
6658 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
6659 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
6660 (setq gnus-newsgroup-reads
6661 (cons (cons article mark) gnus-newsgroup-reads))
6662 ;; Possibly remove from cache, if that is used.
6663 (and gnus-use-cache (gnus-cache-enter-remove-article article))
6664 ;; Allow the backend to change the mark.
6665 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
6666 ;; Check for auto-expiry.
6667 (when (and gnus-newsgroup-auto-expire
6668 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
6669 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
6670 (= mark gnus-ancient-mark)
6671 (= mark gnus-read-mark) (= mark gnus-souped-mark)
6672 (= mark gnus-duplicate-mark)))
6673 (setq mark gnus-expirable-mark)
6674 (push article gnus-newsgroup-expirable))
6675 ;; Set the mark in the buffer.
6676 (gnus-summary-update-mark mark 'unread)
6679 (defun gnus-summary-mark-article-as-unread (mark)
6680 "Mark the current article quickly as unread with MARK."
6681 (let ((article (gnus-summary-article-number)))
6683 (gnus-error 1 "Unmarkable article")
6684 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
6685 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
6686 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
6687 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
6688 (cond ((= mark gnus-ticked-mark)
6689 (push article gnus-newsgroup-marked))
6690 ((= mark gnus-dormant-mark)
6691 (push article gnus-newsgroup-dormant))
6693 (push article gnus-newsgroup-unreads)))
6694 (setq gnus-newsgroup-reads
6695 (delq (assq article gnus-newsgroup-reads)
6696 gnus-newsgroup-reads))
6698 ;; See whether the article is to be put in the cache.
6700 (vectorp (gnus-summary-article-header article))
6702 (gnus-cache-possibly-enter-article
6703 gnus-newsgroup-name article
6704 (gnus-summary-article-header article)
6705 (= mark gnus-ticked-mark)
6706 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
6709 (gnus-summary-update-mark mark 'unread))
6712 (defun gnus-summary-mark-article (&optional article mark no-expire)
6713 "Mark ARTICLE with MARK. MARK can be any character.
6714 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
6715 `??' (dormant) and `?E' (expirable).
6716 If MARK is nil, then the default character `?D' is used.
6717 If ARTICLE is nil, then the article on the current line will be
6719 ;; The mark might be a string.
6721 (setq mark (aref mark 0)))
6722 ;; If no mark is given, then we check auto-expiring.
6723 (and (not no-expire)
6724 gnus-newsgroup-auto-expire
6727 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
6728 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
6729 (= mark gnus-read-mark) (= mark gnus-souped-mark)
6730 (= mark gnus-duplicate-mark))))
6731 (setq mark gnus-expirable-mark))
6732 (let* ((mark (or mark gnus-del-mark))
6733 (article (or article (gnus-summary-article-number))))
6734 (or article (error "No article on current line"))
6735 (if (or (= mark gnus-unread-mark)
6736 (= mark gnus-ticked-mark)
6737 (= mark gnus-dormant-mark))
6738 (gnus-mark-article-as-unread article mark)
6739 (gnus-mark-article-as-read article mark))
6741 ;; See whether the article is to be put in the cache.
6743 (not (= mark gnus-canceled-mark))
6744 (vectorp (gnus-summary-article-header article))
6746 (gnus-cache-possibly-enter-article
6747 gnus-newsgroup-name article
6748 (gnus-summary-article-header article)
6749 (= mark gnus-ticked-mark)
6750 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
6752 (if (gnus-summary-goto-subject article nil t)
6753 (let ((buffer-read-only nil))
6754 (gnus-summary-show-thread)
6756 (gnus-summary-update-mark mark 'unread)
6759 (defun gnus-summary-update-secondary-mark (article)
6760 "Update the secondary (read, process, cache) mark."
6761 (gnus-summary-update-mark
6762 (cond ((memq article gnus-newsgroup-processable)
6764 ((memq article gnus-newsgroup-cached)
6766 ((memq article gnus-newsgroup-replied)
6768 ((memq article gnus-newsgroup-saved)
6770 (t gnus-unread-mark))
6772 (when (gnus-visual-p 'summary-highlight 'highlight)
6773 (run-hooks 'gnus-summary-update-hook))
6776 (defun gnus-summary-update-mark (mark type)
6777 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
6778 (buffer-read-only nil))
6779 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
6780 (and (looking-at "\r") (setq forward (1+ forward)))
6782 (<= (+ forward (point)) (point-max)))
6783 ;; Go to the right position on the line.
6784 (goto-char (+ forward (point)))
6785 ;; Replace the old mark with the new mark.
6786 (subst-char-in-region (point) (1+ (point)) (following-char) mark)
6787 ;; Optionally update the marks by some user rule.
6788 (when (eq type 'unread)
6790 (gnus-data-find (gnus-summary-article-number)) mark)
6791 (gnus-summary-update-line (eq mark gnus-unread-mark))))))
6793 (defun gnus-mark-article-as-read (article &optional mark)
6794 "Enter ARTICLE in the pertinent lists and remove it from others."
6795 ;; Make the article expirable.
6796 (let ((mark (or mark gnus-del-mark)))
6797 (if (= mark gnus-expirable-mark)
6798 (setq gnus-newsgroup-expirable (cons article gnus-newsgroup-expirable))
6799 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
6800 ;; Remove from unread and marked lists.
6801 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
6802 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
6803 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
6804 (push (cons article mark) gnus-newsgroup-reads)
6805 ;; Possibly remove from cache, if that is used.
6806 (when gnus-use-cache
6807 (gnus-cache-enter-remove-article article))))
6809 (defun gnus-mark-article-as-unread (article &optional mark)
6810 "Enter ARTICLE in the pertinent lists and remove it from others."
6811 (let ((mark (or mark gnus-ticked-mark)))
6812 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
6813 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
6814 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
6815 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
6817 ;; Unsuppress duplicates?
6818 (when gnus-suppress-duplicates
6819 (gnus-dup-unsuppress-article article))
6821 (cond ((= mark gnus-ticked-mark)
6822 (push article gnus-newsgroup-marked))
6823 ((= mark gnus-dormant-mark)
6824 (push article gnus-newsgroup-dormant))
6826 (push article gnus-newsgroup-unreads)))
6827 (setq gnus-newsgroup-reads
6828 (delq (assq article gnus-newsgroup-reads)
6829 gnus-newsgroup-reads))))
6831 (defalias 'gnus-summary-mark-as-unread-forward
6832 'gnus-summary-tick-article-forward)
6833 (make-obsolete 'gnus-summary-mark-as-unread-forward
6834 'gnus-summary-tick-article-forward)
6835 (defun gnus-summary-tick-article-forward (n)
6836 "Tick N articles forwards.
6837 If N is negative, tick backwards instead.
6838 The difference between N and the number of articles ticked is returned."
6840 (gnus-summary-mark-forward n gnus-ticked-mark))
6842 (defalias 'gnus-summary-mark-as-unread-backward
6843 'gnus-summary-tick-article-backward)
6844 (make-obsolete 'gnus-summary-mark-as-unread-backward
6845 'gnus-summary-tick-article-backward)
6846 (defun gnus-summary-tick-article-backward (n)
6847 "Tick N articles backwards.
6848 The difference between N and the number of articles ticked is returned."
6850 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
6852 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
6853 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
6854 (defun gnus-summary-tick-article (&optional article clear-mark)
6855 "Mark current article as unread.
6856 Optional 1st argument ARTICLE specifies article number to be marked as unread.
6857 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
6859 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
6862 (defun gnus-summary-mark-as-read-forward (n)
6863 "Mark N articles as read forwards.
6864 If N is negative, mark backwards instead.
6865 The difference between N and the actual number of articles marked is
6868 (gnus-summary-mark-forward n gnus-del-mark t))
6870 (defun gnus-summary-mark-as-read-backward (n)
6871 "Mark the N articles as read backwards.
6872 The difference between N and the actual number of articles marked is
6875 (gnus-summary-mark-forward (- n) gnus-del-mark t))
6877 (defun gnus-summary-mark-as-read (&optional article mark)
6878 "Mark current article as read.
6879 ARTICLE specifies the article to be marked as read.
6880 MARK specifies a string to be inserted at the beginning of the line."
6881 (gnus-summary-mark-article article mark))
6883 (defun gnus-summary-clear-mark-forward (n)
6884 "Clear marks from N articles forward.
6885 If N is negative, clear backward instead.
6886 The difference between N and the number of marks cleared is returned."
6888 (gnus-summary-mark-forward n gnus-unread-mark))
6890 (defun gnus-summary-clear-mark-backward (n)
6891 "Clear marks from N articles backward.
6892 The difference between N and the number of marks cleared is returned."
6894 (gnus-summary-mark-forward (- n) gnus-unread-mark))
6896 (defun gnus-summary-mark-unread-as-read ()
6897 "Intended to be used by `gnus-summary-mark-article-hook'."
6898 (when (memq gnus-current-article gnus-newsgroup-unreads)
6899 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
6901 (defun gnus-summary-mark-read-and-unread-as-read ()
6902 "Intended to be used by `gnus-summary-mark-article-hook'."
6903 (let ((mark (gnus-summary-article-mark)))
6904 (when (or (gnus-unread-mark-p mark)
6905 (gnus-read-mark-p mark))
6906 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
6908 (defun gnus-summary-mark-region-as-read (point mark all)
6909 "Mark all unread articles between point and mark as read.
6910 If given a prefix, mark all articles between point and mark as read,
6911 even ticked and dormant ones."
6912 (interactive "r\nP")
6921 (memq (setq article (gnus-summary-article-number))
6922 gnus-newsgroup-unreads))
6923 (gnus-summary-mark-article article gnus-del-mark))
6925 (gnus-summary-find-next))))))
6927 (defun gnus-summary-mark-below (score mark)
6928 "Mark articles with score less than SCORE with MARK."
6929 (interactive "P\ncMark: ")
6930 (gnus-set-global-variables)
6931 (setq score (if score
6932 (prefix-numeric-value score)
6933 (or gnus-summary-default-score 0)))
6935 (set-buffer gnus-summary-buffer)
6936 (goto-char (point-min))
6939 (and (< (gnus-summary-article-score) score)
6940 (gnus-summary-mark-article nil mark))
6941 (gnus-summary-find-next)))))
6943 (defun gnus-summary-kill-below (&optional score)
6944 "Mark articles with score below SCORE as read."
6946 (gnus-set-global-variables)
6947 (gnus-summary-mark-below score gnus-killed-mark))
6949 (defun gnus-summary-clear-above (&optional score)
6950 "Clear all marks from articles with score above SCORE."
6952 (gnus-set-global-variables)
6953 (gnus-summary-mark-above score gnus-unread-mark))
6955 (defun gnus-summary-tick-above (&optional score)
6956 "Tick all articles with score above SCORE."
6958 (gnus-set-global-variables)
6959 (gnus-summary-mark-above score gnus-ticked-mark))
6961 (defun gnus-summary-mark-above (score mark)
6962 "Mark articles with score over SCORE with MARK."
6963 (interactive "P\ncMark: ")
6964 (gnus-set-global-variables)
6965 (setq score (if score
6966 (prefix-numeric-value score)
6967 (or gnus-summary-default-score 0)))
6969 (set-buffer gnus-summary-buffer)
6970 (goto-char (point-min))
6972 (if (> (gnus-summary-article-score) score)
6973 (gnus-summary-mark-article nil mark))
6975 (gnus-summary-find-next)))))
6977 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
6978 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
6979 (defun gnus-summary-limit-include-expunged (&optional no-error)
6980 "Display all the hidden articles that were expunged for low scores."
6982 (gnus-set-global-variables)
6983 (let ((buffer-read-only nil))
6984 (let ((scored gnus-newsgroup-scored)
6987 (or (gnus-summary-goto-subject (caar scored))
6988 (and (setq h (gnus-summary-article-header (caar scored)))
6989 (< (cdar scored) gnus-summary-expunge-below)
6990 (setq headers (cons h headers))))
6991 (setq scored (cdr scored)))
6993 (when (not no-error)
6994 (error "No expunged articles hidden."))
6995 (goto-char (point-min))
6996 (gnus-summary-prepare-unthreaded (nreverse headers))
6997 (goto-char (point-min))
6998 (gnus-summary-position-point)
7001 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
7002 "Mark all articles not marked as unread in this newsgroup as read.
7003 If prefix argument ALL is non-nil, all articles are marked as read.
7004 If QUIETLY is non-nil, no questions will be asked.
7005 If TO-HERE is non-nil, it should be a point in the buffer. All
7006 articles before this point will be marked as read.
7007 The number of articles marked as read is returned."
7009 (gnus-set-global-variables)
7012 (not gnus-interactive-catchup) ;Without confirmation?
7016 "Mark absolutely all articles as read? "
7017 "Mark all unread articles as read? ")))
7019 (not gnus-newsgroup-adaptive)
7020 (not gnus-newsgroup-auto-expire)
7021 (not gnus-suppress-duplicates))
7024 (setq gnus-newsgroup-marked nil
7025 gnus-newsgroup-dormant nil))
7026 (setq gnus-newsgroup-unreads nil))
7027 ;; We actually mark all articles as canceled, which we
7028 ;; have to do when using auto-expiry or adaptive scoring.
7029 (gnus-summary-show-all-threads)
7030 (when (gnus-summary-first-subject (not all))
7032 (if to-here (< (point) to-here) t)
7033 (gnus-summary-mark-article-as-read gnus-catchup-mark)
7034 (gnus-summary-find-next (not all)))))
7036 (setq gnus-newsgroup-unreads nil))
7037 (gnus-set-mode-line 'summary)))
7038 (let ((method (gnus-find-method-for-group gnus-newsgroup-name)))
7039 (when (and (not to-here) (eq 'nnvirtual (car method)))
7040 (nnvirtual-catchup-group
7041 (gnus-group-real-name gnus-newsgroup-name) (nth 1 method) all)))
7042 (gnus-summary-position-point)))
7044 (defun gnus-summary-catchup-to-here (&optional all)
7045 "Mark all unticked articles before the current one as read.
7046 If ALL is non-nil, also mark ticked and dormant articles as read."
7048 (gnus-set-global-variables)
7050 (gnus-save-hidden-threads
7051 (let ((beg (point)))
7052 ;; We check that there are unread articles.
7053 (when (or all (gnus-summary-find-prev))
7054 (gnus-summary-catchup all t beg)))))
7055 (gnus-summary-position-point))
7057 (defun gnus-summary-catchup-all (&optional quietly)
7058 "Mark all articles in this newsgroup as read."
7060 (gnus-set-global-variables)
7061 (gnus-summary-catchup t quietly))
7063 (defun gnus-summary-catchup-and-exit (&optional all quietly)
7064 "Mark all articles not marked as unread in this newsgroup as read, then exit.
7065 If prefix argument ALL is non-nil, all articles are marked as read."
7067 (gnus-set-global-variables)
7068 (gnus-summary-catchup all quietly nil 'fast)
7069 ;; Select next newsgroup or exit.
7070 (if (eq gnus-auto-select-next 'quietly)
7071 (gnus-summary-next-group nil)
7072 (gnus-summary-exit)))
7074 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
7075 "Mark all articles in this newsgroup as read, and then exit."
7077 (gnus-set-global-variables)
7078 (gnus-summary-catchup-and-exit t quietly))
7080 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
7081 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
7082 "Mark all articles in this group as read and select the next group.
7083 If given a prefix, mark all articles, unread as well as ticked, as
7086 (gnus-set-global-variables)
7088 (gnus-summary-catchup all))
7089 (gnus-summary-next-article t nil nil t))
7091 ;; Thread-based commands.
7093 (defun gnus-summary-articles-in-thread (&optional article)
7094 "Return a list of all articles in the current thread.
7095 If ARTICLE is non-nil, return all articles in the thread that starts
7097 (let* ((article (or article (gnus-summary-article-number)))
7098 (data (gnus-data-find-list article))
7099 (top-level (gnus-data-level (car data)))
7101 (cond ((null gnus-thread-operation-ignore-subject)
7102 (gnus-simplify-subject-re
7103 (mail-header-subject (gnus-data-header (car data)))))
7104 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
7105 (gnus-simplify-subject-fuzzy
7106 (mail-header-subject (gnus-data-header (car data)))))
7108 (end-point (save-excursion
7109 (if (gnus-summary-go-to-next-thread)
7110 (point) (point-max))))
7113 (< (gnus-data-pos (car data)) end-point))
7114 (when (or (not top-subject)
7115 (string= top-subject
7116 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
7117 (gnus-simplify-subject-fuzzy
7118 (mail-header-subject
7119 (gnus-data-header (car data))))
7120 (gnus-simplify-subject-re
7121 (mail-header-subject
7122 (gnus-data-header (car data)))))))
7123 (push (gnus-data-number (car data)) articles))
7124 (unless (and (setq data (cdr data))
7125 (> (gnus-data-level (car data)) top-level))
7127 ;; Return the list of articles.
7128 (nreverse articles)))
7130 (defun gnus-summary-rethread-current ()
7131 "Rethread the thread the current article is part of."
7133 (gnus-set-global-variables)
7134 (let* ((gnus-show-threads t)
7135 (article (gnus-summary-article-number))
7136 (id (mail-header-id (gnus-summary-article-header)))
7137 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
7139 (error "No article on the current line"))
7140 (gnus-rebuild-thread id)
7141 (gnus-summary-goto-subject article)))
7143 (defun gnus-summary-reparent-thread ()
7144 "Make current article child of the marked (or previous) article.
7146 Note that the re-threading will only work if `gnus-thread-ignore-subject'
7147 is non-nil or the Subject: of both articles are the same."
7149 (or (not (gnus-group-read-only-p))
7150 (error "The current newsgroup does not support article editing."))
7151 (or (<= (length gnus-newsgroup-processable) 1)
7152 (error "No more than one article may be marked."))
7153 (save-window-excursion
7154 (let ((gnus-article-buffer " *reparent*")
7155 (current-article (gnus-summary-article-number))
7156 ; first grab the marked article, otherwise one line up.
7157 (parent-article (if (not (null gnus-newsgroup-processable))
7158 (car gnus-newsgroup-processable)
7160 (if (eq (forward-line -1) 0)
7161 (gnus-summary-article-number)
7162 (error "Beginning of summary buffer."))))))
7163 (or (not (eq current-article parent-article))
7164 (error "An article may not be self-referential."))
7165 (let ((message-id (mail-header-id
7166 (gnus-summary-article-header parent-article))))
7167 (or (and message-id (not (equal message-id "")))
7168 (error "No message-id in desired parent."))
7169 (gnus-summary-select-article t t nil current-article)
7170 (set-buffer gnus-article-buffer)
7171 (setq buffer-read-only nil)
7172 (let ((buf (format "%s" (buffer-string))))
7175 (goto-char (point-min))
7176 (if (search-forward-regexp "^References: " nil t)
7177 (insert message-id " " )
7178 (insert "References: " message-id "\n"))
7179 (or (gnus-request-replace-article current-article
7180 (car gnus-article-current)
7181 gnus-article-buffer)
7182 (error "Couldn't replace article."))
7183 (set-buffer gnus-summary-buffer)
7184 (gnus-summary-unmark-all-processable)
7185 (gnus-summary-rethread-current)
7186 (gnus-message 3 "Article %d is now the child of article %d."
7187 current-article parent-article)))))
7189 (defun gnus-summary-toggle-threads (&optional arg)
7190 "Toggle showing conversation threads.
7191 If ARG is positive number, turn showing conversation threads on."
7193 (gnus-set-global-variables)
7194 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
7195 (setq gnus-show-threads
7196 (if (null arg) (not gnus-show-threads)
7197 (> (prefix-numeric-value arg) 0)))
7198 (gnus-summary-prepare)
7199 (gnus-summary-goto-subject current)
7200 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
7201 (gnus-summary-position-point)))
7203 (defun gnus-summary-show-all-threads ()
7206 (gnus-set-global-variables)
7208 (let ((buffer-read-only nil))
7209 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
7210 (gnus-summary-position-point))
7212 (defun gnus-summary-show-thread ()
7213 "Show thread subtrees.
7214 Returns nil if no thread was there to be shown."
7216 (gnus-set-global-variables)
7217 (let ((buffer-read-only nil)
7219 ;; first goto end then to beg, to have point at beg after let
7220 (end (progn (end-of-line) (point)))
7221 (beg (progn (beginning-of-line) (point))))
7223 ;; Any hidden lines here?
7224 (search-forward "\r" end t)
7225 (subst-char-in-region beg end ?\^M ?\n t)
7227 (gnus-summary-position-point))))
7229 (defun gnus-summary-hide-all-threads ()
7230 "Hide all thread subtrees."
7232 (gnus-set-global-variables)
7234 (goto-char (point-min))
7235 (gnus-summary-hide-thread)
7236 (while (zerop (gnus-summary-next-thread 1 t))
7237 (gnus-summary-hide-thread)))
7238 (gnus-summary-position-point))
7240 (defun gnus-summary-hide-thread ()
7241 "Hide thread subtrees.
7242 Returns nil if no threads were there to be hidden."
7244 (gnus-set-global-variables)
7245 (let ((buffer-read-only nil)
7247 (article (gnus-summary-article-number)))
7249 ;; Go forward until either the buffer ends or the subthread
7251 (when (and (not (eobp))
7252 (or (zerop (gnus-summary-next-thread 1 t))
7253 (goto-char (point-max))))
7255 (if (and (> (point) start)
7256 (search-backward "\n" start t))
7258 (subst-char-in-region start (point) ?\n ?\^M)
7259 (gnus-summary-goto-subject article))
7262 ;;(gnus-summary-position-point)
7265 (defun gnus-summary-go-to-next-thread (&optional previous)
7266 "Go to the same level (or less) next thread.
7267 If PREVIOUS is non-nil, go to previous thread instead.
7268 Return the article number moved to, or nil if moving was impossible."
7269 (let ((level (gnus-summary-thread-level))
7270 (way (if previous -1 1))
7273 (while (and (not (eobp))
7274 (< level (gnus-summary-thread-level)))
7282 (gnus-summary-article-number)
7285 (defun gnus-summary-next-thread (n &optional silent)
7286 "Go to the same level next N'th thread.
7287 If N is negative, search backward instead.
7288 Returns the difference between N and the number of skips actually
7291 If SILENT, don't output messages."
7293 (gnus-set-global-variables)
7294 (let ((backward (< n 0))
7297 (gnus-summary-go-to-next-thread backward))
7300 (gnus-summary-position-point))
7301 (when (and (not silent) (/= 0 n))
7302 (gnus-message 7 "No more threads"))
7305 (defun gnus-summary-prev-thread (n)
7306 "Go to the same level previous N'th thread.
7307 Returns the difference between N and the number of skips actually
7310 (gnus-set-global-variables)
7311 (gnus-summary-next-thread (- n)))
7313 (defun gnus-summary-go-down-thread ()
7314 "Go down one level in the current thread."
7315 (let ((children (gnus-summary-article-children)))
7317 (gnus-summary-goto-subject (car children)))))
7319 (defun gnus-summary-go-up-thread ()
7320 "Go up one level in the current thread."
7321 (let ((parent (gnus-summary-article-parent)))
7323 (gnus-summary-goto-subject parent))))
7325 (defun gnus-summary-down-thread (n)
7326 "Go down thread N steps.
7327 If N is negative, go up instead.
7328 Returns the difference between N and how many steps down that were
7331 (gnus-set-global-variables)
7335 (if up (gnus-summary-go-up-thread)
7336 (gnus-summary-go-down-thread)))
7338 (gnus-summary-position-point)
7339 (if (/= 0 n) (gnus-message 7 "Can't go further"))
7342 (defun gnus-summary-up-thread (n)
7343 "Go up thread N steps.
7344 If N is negative, go up instead.
7345 Returns the difference between N and how many steps down that were
7348 (gnus-set-global-variables)
7349 (gnus-summary-down-thread (- n)))
7351 (defun gnus-summary-top-thread ()
7352 "Go to the top of the thread."
7354 (gnus-set-global-variables)
7355 (while (gnus-summary-go-up-thread))
7356 (gnus-summary-article-number))
7358 (defun gnus-summary-kill-thread (&optional unmark)
7359 "Mark articles under current thread as read.
7360 If the prefix argument is positive, remove any kinds of marks.
7361 If the prefix argument is negative, tick articles instead."
7363 (gnus-set-global-variables)
7365 (setq unmark (prefix-numeric-value unmark)))
7366 (let ((articles (gnus-summary-articles-in-thread)))
7368 ;; Expand the thread.
7369 (gnus-summary-show-thread)
7370 ;; Mark all the articles.
7372 (gnus-summary-goto-subject (car articles))
7373 (cond ((null unmark)
7374 (gnus-summary-mark-article-as-read gnus-killed-mark))
7376 (gnus-summary-mark-article-as-unread gnus-unread-mark))
7378 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
7379 (setq articles (cdr articles))))
7380 ;; Hide killed subtrees.
7382 gnus-thread-hide-killed
7383 (gnus-summary-hide-thread))
7384 ;; If marked as read, go to next unread subject.
7386 ;; Go to next unread subject.
7387 (gnus-summary-next-subject 1 t)))
7388 (gnus-set-mode-line 'summary))
7390 ;; Summary sorting commands
7392 (defun gnus-summary-sort-by-number (&optional reverse)
7393 "Sort summary buffer by article number.
7394 Argument REVERSE means reverse order."
7396 (gnus-summary-sort 'number reverse))
7398 (defun gnus-summary-sort-by-author (&optional reverse)
7399 "Sort summary buffer by author name alphabetically.
7400 If case-fold-search is non-nil, case of letters is ignored.
7401 Argument REVERSE means reverse order."
7403 (gnus-summary-sort 'author reverse))
7405 (defun gnus-summary-sort-by-subject (&optional reverse)
7406 "Sort summary buffer by subject alphabetically. `Re:'s are ignored.
7407 If case-fold-search is non-nil, case of letters is ignored.
7408 Argument REVERSE means reverse order."
7410 (gnus-summary-sort 'subject reverse))
7412 (defun gnus-summary-sort-by-date (&optional reverse)
7413 "Sort summary buffer by date.
7414 Argument REVERSE means reverse order."
7416 (gnus-summary-sort 'date reverse))
7418 (defun gnus-summary-sort-by-score (&optional reverse)
7419 "Sort summary buffer by score.
7420 Argument REVERSE means reverse order."
7422 (gnus-summary-sort 'score reverse))
7424 (defun gnus-summary-sort (predicate reverse)
7425 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
7426 (gnus-set-global-variables)
7427 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
7428 (article (intern (format "gnus-article-sort-by-%s" predicate)))
7429 (gnus-thread-sort-functions
7435 (gnus-article-sort-functions
7440 (,article t2 t1)))))
7442 (gnus-summary-prepare-hook nil))
7443 ;; We do the sorting by regenerating the threads.
7444 (gnus-summary-prepare)
7445 ;; Hide subthreads if needed.
7446 (when (and gnus-show-threads gnus-thread-hide-subtree)
7447 (gnus-summary-hide-all-threads))))
7449 ;; Summary saving commands.
7451 (defun gnus-summary-save-article (&optional n not-saved)
7452 "Save the current article using the default saver function.
7453 If N is a positive number, save the N next articles.
7454 If N is a negative number, save the N previous articles.
7455 If N is nil and any articles have been marked with the process mark,
7456 save those articles instead.
7457 The variable `gnus-default-article-saver' specifies the saver function."
7459 (gnus-set-global-variables)
7460 (let* ((articles (gnus-summary-work-articles n))
7461 (save-buffer (save-excursion
7462 (nnheader-set-temp-buffer " *Gnus Save*")))
7463 (num (length articles))
7464 header article file)
7466 (setq header (gnus-summary-article-header
7467 (setq article (pop articles))))
7468 (if (not (vectorp header))
7469 ;; This is a pseudo-article.
7470 (if (assq 'name header)
7471 (gnus-copy-file (cdr (assq 'name header)))
7472 (gnus-message 1 "Article %d is unsaveable" article))
7473 ;; This is a real article.
7474 (save-window-excursion
7475 (gnus-summary-select-article t nil nil article))
7477 (set-buffer save-buffer)
7479 (insert-buffer-substring gnus-original-article-buffer))
7480 (setq file (gnus-article-save save-buffer file num))
7481 (gnus-summary-remove-process-mark article)
7483 (gnus-summary-set-saved-mark article))))
7484 (gnus-kill-buffer save-buffer)
7485 (gnus-summary-position-point)
7488 (defun gnus-summary-pipe-output (&optional arg)
7489 "Pipe the current article to a subprocess.
7490 If N is a positive number, pipe the N next articles.
7491 If N is a negative number, pipe the N previous articles.
7492 If N is nil and any articles have been marked with the process mark,
7493 pipe those articles instead."
7495 (gnus-set-global-variables)
7496 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
7497 (gnus-summary-save-article arg t))
7498 (gnus-configure-windows 'pipe))
7500 (defun gnus-summary-save-article-mail (&optional arg)
7501 "Append the current article to an mail file.
7502 If N is a positive number, save the N next articles.
7503 If N is a negative number, save the N previous articles.
7504 If N is nil and any articles have been marked with the process mark,
7505 save those articles instead."
7507 (gnus-set-global-variables)
7508 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
7509 (gnus-summary-save-article arg)))
7511 (defun gnus-summary-save-article-rmail (&optional arg)
7512 "Append the current article to an rmail file.
7513 If N is a positive number, save the N next articles.
7514 If N is a negative number, save the N previous articles.
7515 If N is nil and any articles have been marked with the process mark,
7516 save those articles instead."
7518 (gnus-set-global-variables)
7519 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
7520 (gnus-summary-save-article arg)))
7522 (defun gnus-summary-save-article-file (&optional arg)
7523 "Append the current article to a file.
7524 If N is a positive number, save the N next articles.
7525 If N is a negative number, save the N previous articles.
7526 If N is nil and any articles have been marked with the process mark,
7527 save those articles instead."
7529 (gnus-set-global-variables)
7530 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
7531 (gnus-summary-save-article arg)))
7533 (defun gnus-summary-save-article-body-file (&optional arg)
7534 "Append the current article body to a file.
7535 If N is a positive number, save the N next articles.
7536 If N is a negative number, save the N previous articles.
7537 If N is nil and any articles have been marked with the process mark,
7538 save those articles instead."
7540 (gnus-set-global-variables)
7541 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
7542 (gnus-summary-save-article arg)))
7544 (defun gnus-get-split-value (methods)
7545 "Return a value based on the split METHODS."
7546 (let (split-name method result match)
7549 (set-buffer gnus-original-article-buffer)
7551 (nnheader-narrow-to-headers)
7553 (goto-char (point-min))
7554 (setq method (pop methods))
7555 (setq match (car method))
7558 ;; Regular expression.
7560 (re-search-forward match nil t)
7562 ((gnus-functionp match)
7566 (setq result (funcall match gnus-newsgroup-name))))
7571 (setq result (eval match)))))
7572 (setq split-name (append (cdr method) split-name))
7573 (cond ((stringp result)
7574 (push result split-name))
7576 (setq split-name (append result split-name)))))))))
7579 (defun gnus-read-move-group-name (prompt default articles prefix)
7580 "Read a group name."
7581 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
7582 (minibuffer-confirm-incomplete nil) ; XEmacs
7590 (car (gnus-find-method-for-group
7592 gnus-valid-select-methods))
7593 (push (list (symbol-name g)) group-map)))
7594 gnus-active-hashtb))
7598 (if (> (length articles) 1)
7599 (format "these %d articles" (length articles))
7604 (gnus-completing-read default prom
7605 group-map nil nil prefix
7606 'gnus-group-history))
7607 ((= 1 (length split-name))
7608 (gnus-completing-read (car split-name) prom group-map
7610 'gnus-group-history))
7612 (gnus-completing-read nil prom
7613 (mapcar (lambda (el) (list el))
7614 (nreverse split-name))
7616 'gnus-group-history)))))
7618 (if (or (string= to-newsgroup "")
7619 (string= to-newsgroup prefix))
7620 (setq to-newsgroup (or default "")))
7621 (or (gnus-active to-newsgroup)
7622 (gnus-activate-group to-newsgroup)
7623 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
7625 (or (and (gnus-request-create-group
7626 to-newsgroup (gnus-group-name-to-method to-newsgroup))
7627 (gnus-activate-group to-newsgroup nil nil
7628 (gnus-group-name-to-method
7630 (error "Couldn't create group %s" to-newsgroup)))
7631 (error "No such group: %s" to-newsgroup)))
7634 ;; Summary extract commands
7636 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
7637 (let ((buffer-read-only nil)
7638 (article (gnus-summary-article-number))
7640 (or (gnus-summary-goto-subject article)
7641 (error (format "No such article: %d" article)))
7642 (gnus-summary-position-point)
7643 ;; If all commands are to be bunched up on one line, we collect
7645 (if gnus-view-pseudos-separately
7647 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
7650 (setq action (cdr (assq 'action (car ps))))
7651 (setq files (list (cdr (assq 'name (car ps)))))
7652 (while (and ps (cdr ps)
7653 (string= (or action "1")
7654 (or (cdr (assq 'action (cadr ps))) "2")))
7655 (setq files (cons (cdr (assq 'name (cadr ps))) files))
7656 (setcdr ps (cddr ps)))
7659 (if (not (string-match "%s" action))
7660 (setq files (cons " " files)))
7661 (setq files (cons " " files))
7662 (and (assq 'execute (car ps))
7663 (setcdr (assq 'execute (car ps))
7664 (funcall (if (string-match "%s" action)
7667 (mapconcat (lambda (f) f) files " ")))))
7668 (setq ps (cdr ps)))))
7669 (if (and gnus-view-pseudos (not not-view))
7671 (and (assq 'execute (car pslist))
7672 (gnus-execute-command (cdr (assq 'execute (car pslist)))
7673 (eq gnus-view-pseudos 'not-confirm)))
7674 (setq pslist (cdr pslist)))
7677 (setq after-article (or (cdr (assq 'article (car pslist)))
7678 (gnus-summary-article-number)))
7679 (gnus-summary-goto-subject after-article)
7682 (insert " " (file-name-nondirectory
7683 (cdr (assq 'name (car pslist))))
7684 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
7686 (forward-line -1) ; back to `b'
7687 (gnus-add-text-properties
7688 b (1- e) (list 'gnus-number gnus-reffed-article-number
7689 gnus-mouse-face-prop gnus-mouse-face))
7691 after-article gnus-reffed-article-number
7692 gnus-unread-mark b (car pslist) 0 (- e b))
7693 (push gnus-reffed-article-number gnus-newsgroup-unreads)
7694 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
7695 (setq pslist (cdr pslist)))))))
7697 (defun gnus-pseudos< (p1 p2)
7698 (let ((c1 (cdr (assq 'action p1)))
7699 (c2 (cdr (assq 'action p2))))
7700 (and c1 c2 (string< c1 c2))))
7702 (defun gnus-request-pseudo-article (props)
7703 (cond ((assq 'execute props)
7704 (gnus-execute-command (cdr (assq 'execute props)))))
7705 (let ((gnus-current-article (gnus-summary-article-number)))
7706 (run-hooks 'gnus-mark-article-hook)))
7708 (defun gnus-execute-command (command &optional automatic)
7710 (gnus-article-setup-buffer)
7711 (set-buffer gnus-article-buffer)
7712 (setq buffer-read-only nil)
7713 (let ((command (if automatic command (read-string "Command: " command)))
7714 ;; Just binding this here doesn't help, because there might
7715 ;; be output from the process after exiting the scope of
7717 ;; (buffer-read-only nil)
7720 (insert "$ " command "\n\n")
7721 (if gnus-view-pseudo-asynchronously
7722 (start-process "gnus-execute" nil shell-file-name
7723 shell-command-switch command)
7724 (call-process shell-file-name nil t nil
7725 shell-command-switch command)))))
7727 ;; Summary kill commands.
7729 (defun gnus-summary-edit-global-kill (article)
7730 "Edit the \"global\" kill file."
7731 (interactive (list (gnus-summary-article-number)))
7732 (gnus-set-global-variables)
7733 (gnus-group-edit-global-kill article))
7735 (defun gnus-summary-edit-local-kill ()
7736 "Edit a local kill file applied to the current newsgroup."
7738 (gnus-set-global-variables)
7739 (setq gnus-current-headers (gnus-summary-article-header))
7740 (gnus-set-global-variables)
7741 (gnus-group-edit-local-kill
7742 (gnus-summary-article-number) gnus-newsgroup-name))
7746 (defun gnus-read-header (id &optional header)
7747 "Read the headers of article ID and enter them into the Gnus system."
7748 (let ((group gnus-newsgroup-name)
7749 (gnus-override-method
7750 (and (gnus-news-group-p gnus-newsgroup-name)
7751 gnus-refer-article-method))
7753 ;; First we check to see whether the header in question is already
7756 ;; This is a Message-ID.
7757 (setq header (or header (gnus-id-to-header id)))
7758 ;; This is an article number.
7759 (setq header (or header (gnus-summary-article-header id))))
7761 (not (memq (mail-header-number header) gnus-newsgroup-sparse)))
7762 ;; We have found the header.
7764 ;; We have to really fetch the header to this article.
7765 (when (setq where (gnus-request-head id group))
7767 (set-buffer nntp-server-buffer)
7768 (goto-char (point-max))
7770 (goto-char (point-min))
7774 ((cdr where) (cdr where))
7775 (header (mail-header-number header))
7776 (t gnus-reffed-article-number))
7778 (insert " Article retrieved.\n"))
7780 ; (memq (mail-header-number header) gnus-newsgroup-sparse))
7781 ; (setcar (gnus-id-to-thread id) nil))
7782 (if (not (setq header (car (gnus-get-newsgroup-headers))))
7783 () ; Malformed head.
7784 (unless (memq (mail-header-number header) gnus-newsgroup-sparse)
7785 (if (and (stringp id)
7786 (not (string= (gnus-group-real-name group)
7788 ;; If we fetched by Message-ID and the article came
7789 ;; from a different group, we fudge some bogus article
7790 ;; numbers for this article.
7791 (mail-header-set-number header gnus-reffed-article-number))
7792 (decf gnus-reffed-article-number)
7793 (gnus-remove-header (mail-header-number header))
7794 (push header gnus-newsgroup-headers)
7795 (setq gnus-current-headers header)
7796 (push (mail-header-number header) gnus-newsgroup-limit))
7799 (defun gnus-remove-header (number)
7800 "Remove header NUMBER from `gnus-newsgroup-headers'."
7801 (if (and gnus-newsgroup-headers
7802 (= number (mail-header-number (car gnus-newsgroup-headers))))
7803 (pop gnus-newsgroup-headers)
7804 (let ((headers gnus-newsgroup-headers))
7805 (while (and (cdr headers)
7806 (not (= number (mail-header-number (cadr headers)))))
7809 (setcdr headers (cddr headers))))))
7812 ;;; summary highlights
7815 (defun gnus-highlight-selected-summary ()
7816 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
7817 ;; Highlight selected article in summary buffer
7818 (when gnus-summary-selected-face
7820 (let* ((beg (progn (beginning-of-line) (point)))
7821 (end (progn (end-of-line) (point)))
7822 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
7823 (from (if (get-text-property beg gnus-mouse-face-prop)
7825 (or (next-single-property-change
7826 beg gnus-mouse-face-prop nil end)
7831 (or (next-single-property-change
7832 from gnus-mouse-face-prop nil end)
7834 ;; If no mouse-face prop on line we will have to = from = end,
7835 ;; so we highlight the entire line instead.
7836 (when (= (+ to 2) from)
7839 (if gnus-newsgroup-selected-overlay
7840 ;; Move old overlay.
7842 gnus-newsgroup-selected-overlay from to (current-buffer))
7843 ;; Create new overlay.
7845 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
7846 'face gnus-summary-selected-face))))))
7848 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
7849 (defun gnus-summary-highlight-line ()
7850 "Highlight current line according to `gnus-summary-highlight'."
7851 (let* ((list gnus-summary-highlight)
7853 (end (progn (end-of-line) (point)))
7854 ;; now find out where the line starts and leave point there.
7855 (beg (progn (beginning-of-line) (point)))
7856 (article (gnus-summary-article-number))
7857 (score (or (cdr (assq (or article gnus-current-article)
7858 gnus-newsgroup-scored))
7859 gnus-summary-default-score 0))
7860 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
7861 (inhibit-read-only t))
7862 ;; Eval the cars of the lists until we find a match.
7863 (let ((default gnus-summary-default-score))
7865 (not (eval (caar list))))
7866 (setq list (cdr list))))
7867 (let ((face (cdar list)))
7868 (unless (eq face (get-text-property beg 'face))
7869 (gnus-put-text-property
7871 (setq face (if (boundp face) (symbol-value face) face)))
7872 (when gnus-summary-highlight-line-function
7873 (funcall gnus-summary-highlight-line-function article face))))
7876 (defun gnus-update-read-articles (group unread)
7877 "Update the list of read articles in GROUP."
7878 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
7879 (entry (gnus-gethash group gnus-newsrc-hashtb))
7880 (info (nth 2 entry))
7882 (unread (sort (copy-sequence unread) '<))
7884 (if (or (not info) (not active))
7885 ;; There is no info on this group if it was, in fact,
7886 ;; killed. Gnus stores no information on killed groups, so
7887 ;; there's nothing to be done.
7888 ;; One could store the information somewhere temporarily,
7889 ;; perhaps... Hmmm...
7891 ;; Remove any negative articles numbers.
7892 (while (and unread (< (car unread) 0))
7893 (setq unread (cdr unread)))
7894 ;; Remove any expired article numbers
7895 (while (and unread (< (car unread) (car active)))
7896 (setq unread (cdr unread)))
7897 ;; Compute the ranges of read articles by looking at the list of
7900 (if (/= (car unread) prev)
7901 (setq read (cons (if (= prev (1- (car unread))) prev
7902 (cons prev (1- (car unread)))) read)))
7903 (setq prev (1+ (car unread)))
7904 (setq unread (cdr unread)))
7905 (when (<= prev (cdr active))
7906 (setq read (cons (cons prev (cdr active)) read)))
7909 (gnus-info-set-marks ,info ,(gnus-info-marks info))
7910 (gnus-info-set-read ,info ,(gnus-info-read info))
7911 (gnus-get-unread-articles-in-group ,info (gnus-active ,group))))
7912 ;; Enter this list into the group info.
7914 info (if (> (length read) 1) (nreverse read) read))
7915 ;; Set the number of unread articles in gnus-newsrc-hashtb.
7916 (gnus-get-unread-articles-in-group info (gnus-active group))
7921 ;;; gnus-sum.el ends here