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 ;;; Internal variables
424 (defvar gnus-summary-display-table
425 ;; Change the display table. Odd characters have a tendency to mess
426 ;; up nicely formatted displays - we make all possible glyphs
427 ;; display only a single character.
429 ;; We start from the standard display table, if any.
430 (let ((table (or (copy-sequence standard-display-table)
431 (make-display-table)))
432 ;; Nix out all the control chars...
434 (while (>= (setq i (1- i)) 0)
436 ;; ... but not newline and cr, of course. (cr is necessary for the
437 ;; selective display).
440 ;; We nix out any glyphs over 126 that are not set already.
442 (while (>= (setq i (1- i)) 127)
443 ;; Only modify if the entry is nil.
445 (aset table i [??]))))
447 "Display table used in summary mode buffers.")
449 (defvar gnus-original-article nil)
450 (defvar gnus-article-internal-prepare-hook nil)
451 (defvar gnus-newsgroup-process-stack nil)
453 (defvar gnus-thread-indent-array nil)
454 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
456 ;; Avoid highlighting in kill files.
457 (defvar gnus-summary-inhibit-highlight nil)
458 (defvar gnus-newsgroup-selected-overlay nil)
459 (defvar gnus-inhibit-limiting nil)
460 (defvar gnus-newsgroup-adaptive-score-file nil)
461 (defvar gnus-current-score-file nil)
462 (defvar gnus-current-move-group nil)
463 (defvar gnus-current-copy-group nil)
464 (defvar gnus-current-crosspost-group nil)
466 (defvar gnus-newsgroup-dependencies nil)
467 (defvar gnus-newsgroup-adaptive nil)
468 (defvar gnus-summary-display-article-function nil)
469 (defvar gnus-summary-highlight-line-function nil
470 "Function called after highlighting a summary line.")
472 (defvar gnus-summary-line-format-alist
473 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
474 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
475 (?s gnus-tmp-subject-or-nil ?s)
476 (?n gnus-tmp-name ?s)
477 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
479 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
481 (?F gnus-tmp-from ?s)
482 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
483 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
484 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
485 (?o (gnus-date-iso8601 gnus-tmp-header) ?s)
486 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
487 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
488 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
489 (?L gnus-tmp-lines ?d)
490 (?I gnus-tmp-indentation ?s)
491 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
492 (?R gnus-tmp-replied ?c)
493 (?\[ gnus-tmp-opening-bracket ?c)
494 (?\] gnus-tmp-closing-bracket ?c)
495 (?\> (make-string gnus-tmp-level ? ) ?s)
496 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
497 (?i gnus-tmp-score ?d)
498 (?z gnus-tmp-score-char ?c)
499 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
500 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
501 (?U gnus-tmp-unread ?c)
502 (?t (gnus-summary-number-of-articles-in-thread
503 (and (boundp 'thread) (car thread)) gnus-tmp-level)
505 (?e (gnus-summary-number-of-articles-in-thread
506 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
508 (?u gnus-tmp-user-defined ?s)
509 (?P (gnus-pick-line-number) ?d))
510 "An alist of format specifications that can appear in summary lines,
511 and what variables they correspond with, along with the type of the
512 variable (string, integer, character, etc).")
514 (defvar gnus-summary-dummy-line-format-alist
515 `((?S gnus-tmp-subject ?s)
516 (?N gnus-tmp-number ?d)
517 (?u gnus-tmp-user-defined ?s)))
519 (defvar gnus-summary-mode-line-format-alist
520 `((?G gnus-tmp-group-name ?s)
521 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
522 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
523 (?A gnus-tmp-article-number ?d)
524 (?Z gnus-tmp-unread-and-unselected ?s)
526 (?U gnus-tmp-unread-and-unticked ?d)
527 (?S gnus-tmp-subject ?s)
528 (?e gnus-tmp-unselected ?d)
529 (?u gnus-tmp-user-defined ?s)
530 (?d (length gnus-newsgroup-dormant) ?d)
531 (?t (length gnus-newsgroup-marked) ?d)
532 (?r (length gnus-newsgroup-reads) ?d)
533 (?E gnus-newsgroup-expunged-tally ?d)
534 (?s (gnus-current-score-file-nondirectory) ?s)))
536 (defvar gnus-last-search-regexp nil
537 "Default regexp for article search command.")
539 (defvar gnus-last-shell-command nil
540 "Default shell command on article.")
542 (defvar gnus-newsgroup-begin nil)
543 (defvar gnus-newsgroup-end nil)
544 (defvar gnus-newsgroup-last-rmail nil)
545 (defvar gnus-newsgroup-last-mail nil)
546 (defvar gnus-newsgroup-last-folder nil)
547 (defvar gnus-newsgroup-last-file nil)
548 (defvar gnus-newsgroup-auto-expire nil)
549 (defvar gnus-newsgroup-active nil)
551 (defvar gnus-newsgroup-data nil)
552 (defvar gnus-newsgroup-data-reverse nil)
553 (defvar gnus-newsgroup-limit nil)
554 (defvar gnus-newsgroup-limits nil)
556 (defvar gnus-newsgroup-unreads nil
557 "List of unread articles in the current newsgroup.")
559 (defvar gnus-newsgroup-unselected nil
560 "List of unselected unread articles in the current newsgroup.")
562 (defvar gnus-newsgroup-reads nil
563 "Alist of read articles and article marks in the current newsgroup.")
565 (defvar gnus-newsgroup-expunged-tally nil)
567 (defvar gnus-newsgroup-marked nil
568 "List of ticked articles in the current newsgroup (a subset of unread art).")
570 (defvar gnus-newsgroup-killed nil
571 "List of ranges of articles that have been through the scoring process.")
573 (defvar gnus-newsgroup-cached nil
574 "List of articles that come from the article cache.")
576 (defvar gnus-newsgroup-saved nil
577 "List of articles that have been saved.")
579 (defvar gnus-newsgroup-kill-headers nil)
581 (defvar gnus-newsgroup-replied nil
582 "List of articles that have been replied to in the current newsgroup.")
584 (defvar gnus-newsgroup-expirable nil
585 "List of articles in the current newsgroup that can be expired.")
587 (defvar gnus-newsgroup-processable nil
588 "List of articles in the current newsgroup that can be processed.")
590 (defvar gnus-newsgroup-bookmarks nil
591 "List of articles in the current newsgroup that have bookmarks.")
593 (defvar gnus-newsgroup-dormant nil
594 "List of dormant articles in the current newsgroup.")
596 (defvar gnus-newsgroup-scored nil
597 "List of scored articles in the current newsgroup.")
599 (defvar gnus-newsgroup-headers nil
600 "List of article headers in the current newsgroup.")
602 (defvar gnus-newsgroup-threads nil)
604 (defvar gnus-newsgroup-prepared nil
605 "Whether the current group has been prepared properly.")
607 (defvar gnus-newsgroup-ancient nil
608 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
610 (defvar gnus-newsgroup-sparse nil)
612 (defvar gnus-current-article nil)
613 (defvar gnus-article-current nil)
614 (defvar gnus-current-headers nil)
615 (defvar gnus-have-all-headers nil)
616 (defvar gnus-last-article nil)
617 (defvar gnus-newsgroup-history nil)
619 (defconst gnus-summary-local-variables
620 '(gnus-newsgroup-name
621 gnus-newsgroup-begin gnus-newsgroup-end
622 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
623 gnus-newsgroup-last-folder gnus-newsgroup-last-file
624 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
625 gnus-newsgroup-unselected gnus-newsgroup-marked
626 gnus-newsgroup-reads gnus-newsgroup-saved
627 gnus-newsgroup-replied gnus-newsgroup-expirable
628 gnus-newsgroup-processable gnus-newsgroup-killed
629 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
630 gnus-newsgroup-headers gnus-newsgroup-threads
631 gnus-newsgroup-prepared gnus-summary-highlight-line-function
632 gnus-current-article gnus-current-headers gnus-have-all-headers
633 gnus-last-article gnus-article-internal-prepare-hook
634 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
635 gnus-newsgroup-scored gnus-newsgroup-kill-headers
636 gnus-thread-expunge-below
637 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
638 (gnus-summary-mark-below . global)
639 gnus-newsgroup-active gnus-scores-exclude-files
640 gnus-newsgroup-history gnus-newsgroup-ancient
641 gnus-newsgroup-sparse gnus-newsgroup-process-stack
642 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
643 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
644 (gnus-newsgroup-expunged-tally . 0)
645 gnus-cache-removable-articles gnus-newsgroup-cached
646 gnus-newsgroup-data gnus-newsgroup-data-reverse
647 gnus-newsgroup-limit gnus-newsgroup-limits)
648 "Variables that are buffer-local to the summary buffers.")
650 ;; Byte-compiler warning.
651 (defvar gnus-article-mode-map)
653 ;; Subject simplification.
655 (defsubst gnus-simplify-subject-re (subject)
656 "Remove \"Re:\" from subject lines."
657 (if (string-match "^[Rr][Ee]: *" subject)
658 (substring subject (match-end 0))
661 (defun gnus-simplify-subject (subject &optional re-only)
662 "Remove `Re:' and words in parentheses.
663 If RE-ONLY is non-nil, strip leading `Re:'s only."
664 (let ((case-fold-search t)) ;Ignore case.
665 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
666 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
667 (setq subject (substring subject (match-end 0))))
668 ;; Remove uninteresting prefixes.
669 (if (and (not re-only)
670 gnus-simplify-ignored-prefixes
671 (string-match gnus-simplify-ignored-prefixes subject))
672 (setq subject (substring subject (match-end 0))))
673 ;; Remove words in parentheses from end.
675 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
676 (setq subject (substring subject 0 (match-beginning 0)))))
677 ;; Return subject string.
680 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
682 ;; Written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
683 (defun gnus-simplify-buffer-fuzzy ()
684 (let ((case-fold-search t))
685 (goto-char (point-min))
686 (while (search-forward "\t" nil t)
687 (replace-match " " t t))
688 (goto-char (point-min))
689 (re-search-forward "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *" nil t)
690 (goto-char (match-beginning 0))
692 (looking-at "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
693 (looking-at "^[[].*: .*[]]$"))
694 (goto-char (point-min))
695 (while (re-search-forward "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *"
697 (replace-match "" t t))
698 (goto-char (point-min))
699 (while (re-search-forward "^[[].*: .*[]]$" nil t)
700 (goto-char (match-end 0))
703 (progn (goto-char (match-beginning 0)))
704 (re-search-forward ":"))))
705 (goto-char (point-min))
706 (while (re-search-forward " *[[{(][^()\n]*[]})] *$" nil t)
707 (replace-match "" t t))
708 (goto-char (point-min))
709 (while (re-search-forward " +" nil t)
710 (replace-match " " t t))
711 (goto-char (point-min))
712 (while (re-search-forward " $" nil t)
713 (replace-match "" t t))
714 (goto-char (point-min))
715 (while (re-search-forward "^ +" nil t)
716 (replace-match "" t t))
717 (goto-char (point-min))
718 (when gnus-simplify-subject-fuzzy-regexp
719 (if (listp gnus-simplify-subject-fuzzy-regexp)
720 (let ((list gnus-simplify-subject-fuzzy-regexp))
722 (goto-char (point-min))
723 (while (re-search-forward (car list) nil t)
724 (replace-match "" t t))
725 (setq list (cdr list))))
726 (while (re-search-forward gnus-simplify-subject-fuzzy-regexp nil t)
727 (replace-match "" t t))))))
729 (defun gnus-simplify-subject-fuzzy (subject)
730 "Siplify a subject string fuzzily."
732 (gnus-set-work-buffer)
733 (let ((case-fold-search t))
735 (inline (gnus-simplify-buffer-fuzzy))
738 (defsubst gnus-simplify-subject-fully (subject)
739 "Simplify a subject string according to the user's wishes."
741 ((null gnus-summary-gather-subject-limit)
742 (gnus-simplify-subject-re subject))
743 ((eq gnus-summary-gather-subject-limit 'fuzzy)
744 (gnus-simplify-subject-fuzzy subject))
745 ((numberp gnus-summary-gather-subject-limit)
746 (gnus-limit-string (gnus-simplify-subject-re subject)
747 gnus-summary-gather-subject-limit))
751 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
752 "Check whether two subjects are equal. If optional argument
753 simple-first is t, first argument is already simplified."
756 (equal (gnus-simplify-subject-fully s1)
757 (gnus-simplify-subject-fully s2)))
760 (gnus-simplify-subject-fully s2)))))
762 (defun gnus-offer-save-summaries ()
763 "Offer to save all active summary buffers."
765 (let ((buflist (buffer-list))
767 ;; Go through all buffers and find all summaries.
769 (and (setq bufname (buffer-name (car buflist)))
770 (string-match "Summary" bufname)
773 ;; We check that this is, indeed, a summary buffer.
774 (and (eq major-mode 'gnus-summary-mode)
775 ;; Also make sure this isn't bogus.
776 gnus-newsgroup-prepared))
777 (push bufname buffers))
778 (setq buflist (cdr buflist)))
779 ;; Go through all these summary buffers and offer to save them.
782 "Update summary buffer %s? "
783 (lambda (buf) (set-buffer buf) (gnus-summary-exit))
786 (defun gnus-summary-bubble-group ()
787 "Increase the score of the current group.
788 This is a handy function to add to `gnus-summary-exit-hook' to
789 increase the score of each group you read."
790 (gnus-group-add-score gnus-newsgroup-name))
794 ;;; Gnus summary mode
797 (put 'gnus-summary-mode 'mode-class 'special)
800 ;; Non-orthogonal keys
802 (gnus-define-keys gnus-summary-mode-map
803 " " gnus-summary-next-page
804 "\177" gnus-summary-prev-page
805 [delete] gnus-summary-prev-page
806 "\r" gnus-summary-scroll-up
807 "n" gnus-summary-next-unread-article
808 "p" gnus-summary-prev-unread-article
809 "N" gnus-summary-next-article
810 "P" gnus-summary-prev-article
811 "\M-\C-n" gnus-summary-next-same-subject
812 "\M-\C-p" gnus-summary-prev-same-subject
813 "\M-n" gnus-summary-next-unread-subject
814 "\M-p" gnus-summary-prev-unread-subject
815 "." gnus-summary-first-unread-article
816 "," gnus-summary-best-unread-article
817 "\M-s" gnus-summary-search-article-forward
818 "\M-r" gnus-summary-search-article-backward
819 "<" gnus-summary-beginning-of-article
820 ">" gnus-summary-end-of-article
821 "j" gnus-summary-goto-article
822 "^" gnus-summary-refer-parent-article
823 "\M-^" gnus-summary-refer-article
824 "u" gnus-summary-tick-article-forward
825 "!" gnus-summary-tick-article-forward
826 "U" gnus-summary-tick-article-backward
827 "d" gnus-summary-mark-as-read-forward
828 "D" gnus-summary-mark-as-read-backward
829 "E" gnus-summary-mark-as-expirable
830 "\M-u" gnus-summary-clear-mark-forward
831 "\M-U" gnus-summary-clear-mark-backward
832 "k" gnus-summary-kill-same-subject-and-select
833 "\C-k" gnus-summary-kill-same-subject
834 "\M-\C-k" gnus-summary-kill-thread
835 "\M-\C-l" gnus-summary-lower-thread
836 "e" gnus-summary-edit-article
837 "#" gnus-summary-mark-as-processable
838 "\M-#" gnus-summary-unmark-as-processable
839 "\M-\C-t" gnus-summary-toggle-threads
840 "\M-\C-s" gnus-summary-show-thread
841 "\M-\C-h" gnus-summary-hide-thread
842 "\M-\C-f" gnus-summary-next-thread
843 "\M-\C-b" gnus-summary-prev-thread
844 "\M-\C-u" gnus-summary-up-thread
845 "\M-\C-d" gnus-summary-down-thread
846 "&" gnus-summary-execute-command
847 "c" gnus-summary-catchup-and-exit
848 "\C-w" gnus-summary-mark-region-as-read
849 "\C-t" gnus-summary-toggle-truncation
850 "?" gnus-summary-mark-as-dormant
851 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
852 "\C-c\C-s\C-n" gnus-summary-sort-by-number
853 "\C-c\C-s\C-a" gnus-summary-sort-by-author
854 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
855 "\C-c\C-s\C-d" gnus-summary-sort-by-date
856 "\C-c\C-s\C-i" gnus-summary-sort-by-score
857 "=" gnus-summary-expand-window
858 "\C-x\C-s" gnus-summary-reselect-current-group
859 "\M-g" gnus-summary-rescan-group
860 "w" gnus-summary-stop-page-breaking
861 "\C-c\C-r" gnus-summary-caesar-message
862 "\M-t" gnus-summary-toggle-mime
863 "f" gnus-summary-followup
864 "F" gnus-summary-followup-with-original
865 "C" gnus-summary-cancel-article
866 "r" gnus-summary-reply
867 "R" gnus-summary-reply-with-original
868 "\C-c\C-f" gnus-summary-mail-forward
869 "o" gnus-summary-save-article
870 "\C-o" gnus-summary-save-article-mail
871 "|" gnus-summary-pipe-output
872 "\M-k" gnus-summary-edit-local-kill
873 "\M-K" gnus-summary-edit-global-kill
875 "\C-c\C-d" gnus-summary-describe-group
876 "q" gnus-summary-exit
877 "Q" gnus-summary-exit-no-update
878 "\C-c\C-i" gnus-info-find-node
879 gnus-mouse-2 gnus-mouse-pick-article
880 "m" gnus-summary-mail-other-window
881 "a" gnus-summary-post-news
882 "x" gnus-summary-limit-to-unread
883 "s" gnus-summary-isearch-article
884 "t" gnus-article-hide-headers
885 "g" gnus-summary-show-article
886 "l" gnus-summary-goto-last-article
887 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
888 "\C-d" gnus-summary-enter-digest-group
889 "\M-\C-d" gnus-summary-read-document
891 "*" gnus-cache-enter-article
892 "\M-*" gnus-cache-remove-article
893 "\M-&" gnus-summary-universal-argument
895 "I" gnus-summary-increase-score
896 "L" gnus-summary-lower-score
898 "V" gnus-summary-score-map
899 "X" gnus-uu-extract-map
900 "S" gnus-summary-send-map)
902 ;; Sort of orthogonal keymap
903 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
904 "t" gnus-summary-tick-article-forward
905 "!" gnus-summary-tick-article-forward
906 "d" gnus-summary-mark-as-read-forward
907 "r" gnus-summary-mark-as-read-forward
908 "c" gnus-summary-clear-mark-forward
909 " " gnus-summary-clear-mark-forward
910 "e" gnus-summary-mark-as-expirable
911 "x" gnus-summary-mark-as-expirable
912 "?" gnus-summary-mark-as-dormant
913 "b" gnus-summary-set-bookmark
914 "B" gnus-summary-remove-bookmark
915 "#" gnus-summary-mark-as-processable
916 "\M-#" gnus-summary-unmark-as-processable
917 "S" gnus-summary-limit-include-expunged
918 "C" gnus-summary-catchup
919 "H" gnus-summary-catchup-to-here
920 "\C-c" gnus-summary-catchup-all
921 "k" gnus-summary-kill-same-subject-and-select
922 "K" gnus-summary-kill-same-subject
923 "P" gnus-uu-mark-map)
925 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mode-map)
926 "c" gnus-summary-clear-above
927 "u" gnus-summary-tick-above
928 "m" gnus-summary-mark-above
929 "k" gnus-summary-kill-below)
931 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
932 "/" gnus-summary-limit-to-subject
933 "n" gnus-summary-limit-to-articles
934 "w" gnus-summary-pop-limit
935 "s" gnus-summary-limit-to-subject
936 "a" gnus-summary-limit-to-author
937 "u" gnus-summary-limit-to-unread
938 "m" gnus-summary-limit-to-marks
939 "v" gnus-summary-limit-to-score
940 "D" gnus-summary-limit-include-dormant
941 "d" gnus-summary-limit-exclude-dormant
942 ;; "t" gnus-summary-limit-exclude-thread
943 "E" gnus-summary-limit-include-expunged
944 "c" gnus-summary-limit-exclude-childless-dormant
945 "C" gnus-summary-limit-mark-excluded-as-read)
947 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
948 "n" gnus-summary-next-unread-article
949 "p" gnus-summary-prev-unread-article
950 "N" gnus-summary-next-article
951 "P" gnus-summary-prev-article
952 "\C-n" gnus-summary-next-same-subject
953 "\C-p" gnus-summary-prev-same-subject
954 "\M-n" gnus-summary-next-unread-subject
955 "\M-p" gnus-summary-prev-unread-subject
956 "f" gnus-summary-first-unread-article
957 "b" gnus-summary-best-unread-article
958 "j" gnus-summary-goto-article
959 "g" gnus-summary-goto-subject
960 "l" gnus-summary-goto-last-article
961 "p" gnus-summary-pop-article)
963 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
964 "k" gnus-summary-kill-thread
965 "l" gnus-summary-lower-thread
966 "i" gnus-summary-raise-thread
967 "T" gnus-summary-toggle-threads
968 "t" gnus-summary-rethread-current
969 "^" gnus-summary-reparent-thread
970 "s" gnus-summary-show-thread
971 "S" gnus-summary-show-all-threads
972 "h" gnus-summary-hide-thread
973 "H" gnus-summary-hide-all-threads
974 "n" gnus-summary-next-thread
975 "p" gnus-summary-prev-thread
976 "u" gnus-summary-up-thread
977 "o" gnus-summary-top-thread
978 "d" gnus-summary-down-thread
979 "#" gnus-uu-mark-thread
980 "\M-#" gnus-uu-unmark-thread)
982 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
983 "c" gnus-summary-catchup-and-exit
984 "C" gnus-summary-catchup-all-and-exit
985 "E" gnus-summary-exit-no-update
986 "Q" gnus-summary-exit
987 "Z" gnus-summary-exit
988 "n" gnus-summary-catchup-and-goto-next-group
989 "R" gnus-summary-reselect-current-group
990 "G" gnus-summary-rescan-group
991 "N" gnus-summary-next-group
992 "P" gnus-summary-prev-group)
994 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
995 " " gnus-summary-next-page
996 "n" gnus-summary-next-page
997 "\177" gnus-summary-prev-page
998 [delete] gnus-summary-prev-page
999 "p" gnus-summary-prev-page
1000 "\r" gnus-summary-scroll-up
1001 "<" gnus-summary-beginning-of-article
1002 ">" gnus-summary-end-of-article
1003 "b" gnus-summary-beginning-of-article
1004 "e" gnus-summary-end-of-article
1005 "^" gnus-summary-refer-parent-article
1006 "r" gnus-summary-refer-parent-article
1007 "R" gnus-summary-refer-references
1008 "g" gnus-summary-show-article
1009 "s" gnus-summary-isearch-article)
1011 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1012 "b" gnus-article-add-buttons
1013 "B" gnus-article-add-buttons-to-head
1014 "o" gnus-article-treat-overstrike
1015 "e" gnus-article-emphasize
1016 "w" gnus-article-fill-cited-article
1017 "c" gnus-article-remove-cr
1018 "q" gnus-article-de-quoted-unreadable
1019 "f" gnus-article-display-x-face
1020 "l" gnus-summary-stop-page-breaking
1021 "r" gnus-summary-caesar-message
1022 "t" gnus-article-hide-headers
1023 "v" gnus-summary-verbose-headers
1024 "m" gnus-summary-toggle-mime)
1026 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1027 "a" gnus-article-hide
1028 "h" gnus-article-hide-headers
1029 "b" gnus-article-hide-boring-headers
1030 "s" gnus-article-hide-signature
1031 "c" gnus-article-hide-citation
1032 "p" gnus-article-hide-pgp
1033 "P" gnus-article-hide-pem
1034 "\C-c" gnus-article-hide-citation-maybe)
1036 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1037 "a" gnus-article-highlight
1038 "h" gnus-article-highlight-headers
1039 "c" gnus-article-highlight-citation
1040 "s" gnus-article-highlight-signature)
1042 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1043 "z" gnus-article-date-ut
1044 "u" gnus-article-date-ut
1045 "l" gnus-article-date-local
1046 "e" gnus-article-date-lapsed
1047 "o" gnus-article-date-original)
1049 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1050 "t" gnus-article-remove-trailing-blank-lines
1051 "l" gnus-article-strip-leading-blank-lines
1052 "m" gnus-article-strip-multiple-blank-lines
1053 "a" gnus-article-strip-blank-lines)
1055 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1057 "f" gnus-summary-fetch-faq
1058 "d" gnus-summary-describe-group
1059 "h" gnus-summary-describe-briefly
1060 "i" gnus-info-find-node)
1062 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1063 "e" gnus-summary-expire-articles
1064 "\M-\C-e" gnus-summary-expire-articles-now
1065 "\177" gnus-summary-delete-article
1066 [delete] gnus-summary-delete-article
1067 "m" gnus-summary-move-article
1068 "r" gnus-summary-respool-article
1069 "w" gnus-summary-edit-article
1070 "c" gnus-summary-copy-article
1071 "B" gnus-summary-crosspost-article
1072 "q" gnus-summary-respool-query
1073 "i" gnus-summary-import-article
1074 "p" gnus-summary-article-posted-p)
1076 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1077 "o" gnus-summary-save-article
1078 "m" gnus-summary-save-article-mail
1079 "r" gnus-summary-save-article-rmail
1080 "f" gnus-summary-save-article-file
1081 "b" gnus-summary-save-article-body-file
1082 "h" gnus-summary-save-article-folder
1083 "v" gnus-summary-save-article-vm
1084 "p" gnus-summary-pipe-output
1085 "s" gnus-soup-add-article))
1087 (defun gnus-summary-make-menu-bar ()
1088 (gnus-turn-off-edit-menu 'summary)
1090 (unless (boundp 'gnus-summary-misc-menu)
1093 gnus-summary-kill-menu gnus-summary-mode-map ""
1098 ["Enter score..." gnus-summary-score-entry t])
1099 (gnus-make-score-map 'increase)
1100 (gnus-make-score-map 'lower)
1102 ["Kill below" gnus-summary-kill-below t]
1103 ["Mark above" gnus-summary-mark-above t]
1104 ["Tick above" gnus-summary-tick-above t]
1105 ["Clear above" gnus-summary-clear-above t])
1106 ["Current score" gnus-summary-current-score t]
1107 ["Set score" gnus-summary-set-score t]
1108 ["Customize score file" gnus-score-customize t]
1109 ["Switch current score file..." gnus-score-change-score-file t]
1110 ["Set mark below..." gnus-score-set-mark-below t]
1111 ["Set expunge below..." gnus-score-set-expunge-below t]
1112 ["Edit current score file" gnus-score-edit-current-scores t]
1113 ["Edit score file" gnus-score-edit-file t]
1114 ["Trace score" gnus-score-find-trace t]
1115 ["Find words" gnus-score-find-favuorite-words t]
1116 ["Rescore buffer" gnus-summary-rescore t]
1117 ["Increase score..." gnus-summary-increase-score t]
1118 ["Lower score..." gnus-summary-lower-score t]))))
1121 ["Ask" (gnus-score-set-default 'gnus-score-default-header nil)
1123 :selected (null gnus-score-default-header)]
1124 ["From" (gnus-score-set-default 'gnus-score-default-header 'a)
1126 :selected (eq gnus-score-default-header 'a)]
1127 ["Subject" (gnus-score-set-default 'gnus-score-default-header 's)
1129 :selected (eq gnus-score-default-header 's)]
1131 (gnus-score-set-default 'gnus-score-default-header 'b)
1133 :selected (eq gnus-score-default-header 'b )]
1135 (gnus-score-set-default 'gnus-score-default-header 'h)
1137 :selected (eq gnus-score-default-header 'h )]
1138 ["Message-Id" (gnus-score-set-default 'gnus-score-default-header 'i)
1140 :selected (eq gnus-score-default-header 'i )]
1141 ["Thread" (gnus-score-set-default 'gnus-score-default-header 't)
1143 :selected (eq gnus-score-default-header 't )]
1145 (gnus-score-set-default 'gnus-score-default-header 'x)
1147 :selected (eq gnus-score-default-header 'x )]
1148 ["Lines" (gnus-score-set-default 'gnus-score-default-header 'l)
1150 :selected (eq gnus-score-default-header 'l )]
1151 ["Date" (gnus-score-set-default 'gnus-score-default-header 'd)
1153 :selected (eq gnus-score-default-header 'd )]
1154 ["Followups to author"
1155 (gnus-score-set-default 'gnus-score-default-header 'f)
1157 :selected (eq gnus-score-default-header 'f )])
1159 ["Ask" (gnus-score-set-default 'gnus-score-default-type nil)
1161 :selected (null gnus-score-default-type)]
1162 ;; The `:active' key is commented out in the following,
1163 ;; because the GNU Emacs hack to support radio buttons use
1164 ;; active to indicate which button is selected.
1165 ["Substring" (gnus-score-set-default 'gnus-score-default-type 's)
1167 ;; :active (not (memq gnus-score-default-header '(l d)))
1168 :selected (eq gnus-score-default-type 's)]
1169 ["Regexp" (gnus-score-set-default 'gnus-score-default-type 'r)
1171 ;; :active (not (memq gnus-score-default-header '(l d)))
1172 :selected (eq gnus-score-default-type 'r)]
1173 ["Exact" (gnus-score-set-default 'gnus-score-default-type 'e)
1175 ;; :active (not (memq gnus-score-default-header '(l d)))
1176 :selected (eq gnus-score-default-type 'e)]
1177 ["Fuzzy" (gnus-score-set-default 'gnus-score-default-type 'f)
1179 ;; :active (not (memq gnus-score-default-header '(l d)))
1180 :selected (eq gnus-score-default-type 'f)]
1181 ["Before date" (gnus-score-set-default 'gnus-score-default-type 'b)
1183 ;; :active (eq (gnus-score-default-header 'd))
1184 :selected (eq gnus-score-default-type 'b)]
1185 ["At date" (gnus-score-set-default 'gnus-score-default-type 'n)
1187 ;; :active (eq (gnus-score-default-header 'd))
1188 :selected (eq gnus-score-default-type 'n)]
1189 ["After date" (gnus-score-set-default 'gnus-score-default-type 'a)
1191 ;; :active (eq (gnus-score-default-header 'd))
1192 :selected (eq gnus-score-default-type 'a)]
1194 (gnus-score-set-default 'gnus-score-default-type '<)
1196 ;; :active (eq (gnus-score-default-header 'l))
1197 :selected (eq gnus-score-default-type '<)]
1199 (gnus-score-set-default 'gnus-score-default-type '=)
1201 ;; :active (eq (gnus-score-default-header 'l))
1202 :selected (eq gnus-score-default-type '=)]
1203 ["Greater than number"
1204 (gnus-score-set-default 'gnus-score-default-type '>)
1206 ;; :active (eq (gnus-score-default-header 'l))
1207 :selected (eq gnus-score-default-type '>)])
1208 ["Default fold" gnus-score-default-fold-toggle
1210 :selected gnus-score-default-fold]
1212 ["Ask" (gnus-score-set-default 'gnus-score-default-duration nil)
1214 :selected (null gnus-score-default-duration)]
1216 (gnus-score-set-default 'gnus-score-default-duration 'p)
1218 :selected (eq gnus-score-default-duration 'p)]
1220 (gnus-score-set-default 'gnus-score-default-duration 't)
1222 :selected (eq gnus-score-default-duration 't)]
1224 (gnus-score-set-default 'gnus-score-default-duration 'i)
1226 :selected (eq gnus-score-default-duration 'i)]))
1229 gnus-summary-article-menu gnus-summary-mode-map ""
1232 ["All" gnus-article-hide t]
1233 ["Headers" gnus-article-hide-headers t]
1234 ["Signature" gnus-article-hide-signature t]
1235 ["Citation" gnus-article-hide-citation t]
1236 ["PGP" gnus-article-hide-pgp t]
1237 ["Boring headers" gnus-article-hide-boring-headers t])
1239 ["All" gnus-article-highlight t]
1240 ["Headers" gnus-article-highlight-headers t]
1241 ["Signature" gnus-article-highlight-signature t]
1242 ["Citation" gnus-article-highlight-citation t])
1244 ["Local" gnus-article-date-local t]
1245 ["UT" gnus-article-date-ut t]
1246 ["Original" gnus-article-date-original t]
1247 ["Lapsed" gnus-article-date-lapsed t])
1250 ["Leading" gnus-article-strip-leading-blank-lines t]
1251 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1252 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1253 ["All of the above" gnus-article-strip-blank-lines t])
1254 ["Overstrike" gnus-article-treat-overstrike t]
1255 ["Emphasis" gnus-article-emphasize t]
1256 ["Word wrap" gnus-article-fill-cited-article t]
1257 ["CR" gnus-article-remove-cr t]
1258 ["Show X-Face" gnus-article-display-x-face t]
1259 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
1260 ["Rot 13" gnus-summary-caesar-message t]
1261 ["Add buttons" gnus-article-add-buttons t]
1262 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1263 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1264 ["Toggle MIME" gnus-summary-toggle-mime t]
1265 ["Verbose header" gnus-summary-verbose-headers t]
1266 ["Toggle header" gnus-summary-toggle-header t])
1268 ["Save in default format" gnus-summary-save-article t]
1269 ["Save in file" gnus-summary-save-article-file t]
1270 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1271 ["Save in MH folder" gnus-summary-save-article-folder t]
1272 ["Save in VM folder" gnus-summary-save-article-vm t]
1273 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1274 ["Save body in file" gnus-summary-save-article-body-file t]
1275 ["Pipe through a filter" gnus-summary-pipe-output t]
1276 ["Add to SOUP packet" gnus-soup-add-article t])
1278 ["Respool article..." gnus-summary-respool-article t]
1279 ["Move article..." gnus-summary-move-article
1280 (gnus-check-backend-function
1281 'request-move-article gnus-newsgroup-name)]
1282 ["Copy article..." gnus-summary-copy-article t]
1283 ["Crosspost article..." gnus-summary-crosspost-article
1284 (gnus-check-backend-function
1285 'request-replace-article gnus-newsgroup-name)]
1286 ["Import file..." gnus-summary-import-article t]
1287 ["Chek if posted" gnus-summary-article-posted-p t]
1288 ["Edit article" gnus-summary-edit-article
1289 (not (gnus-group-read-only-p))]
1290 ["Delete article" gnus-summary-delete-article
1291 (gnus-check-backend-function
1292 'request-expire-articles gnus-newsgroup-name)]
1293 ["Query respool" gnus-summary-respool-query t]
1294 ["Delete expirable articles" gnus-summary-expire-articles-now
1295 (gnus-check-backend-function
1296 'request-expire-articles gnus-newsgroup-name)])
1298 ["Uudecode" gnus-uu-decode-uu t]
1299 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1300 ["Unshar" gnus-uu-decode-unshar t]
1301 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1302 ["Save" gnus-uu-decode-save t]
1303 ["Binhex" gnus-uu-decode-binhex t]
1304 ["Postscript" gnus-uu-decode-postscript t])
1305 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1306 ["Isearch article..." gnus-summary-isearch-article t]
1307 ["Search articles forward..." gnus-summary-search-article-forward t]
1308 ["Search articles backward..." gnus-summary-search-article-backward t]
1309 ["Beginning of the article" gnus-summary-beginning-of-article t]
1310 ["End of the article" gnus-summary-end-of-article t]
1311 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1312 ["Fetch referenced articles" gnus-summary-refer-references t]
1313 ["Fetch article with id..." gnus-summary-refer-article t]
1314 ["Redisplay" gnus-summary-show-article t]))
1317 gnus-summary-thread-menu gnus-summary-mode-map ""
1319 ["Toggle threading" gnus-summary-toggle-threads t]
1320 ["Hide threads" gnus-summary-hide-all-threads t]
1321 ["Show threads" gnus-summary-show-all-threads t]
1322 ["Hide thread" gnus-summary-hide-thread t]
1323 ["Show thread" gnus-summary-show-thread t]
1324 ["Go to next thread" gnus-summary-next-thread t]
1325 ["Go to previous thread" gnus-summary-prev-thread t]
1326 ["Go down thread" gnus-summary-down-thread t]
1327 ["Go up thread" gnus-summary-up-thread t]
1328 ["Top of thread" gnus-summary-top-thread t]
1329 ["Mark thread as read" gnus-summary-kill-thread t]
1330 ["Lower thread score" gnus-summary-lower-thread t]
1331 ["Raise thread score" gnus-summary-raise-thread t]
1332 ["Rethread current" gnus-summary-rethread-current t]
1336 gnus-summary-post-menu gnus-summary-mode-map ""
1338 ["Post an article" gnus-summary-post-news t]
1339 ["Followup" gnus-summary-followup t]
1340 ["Followup and yank" gnus-summary-followup-with-original t]
1341 ["Supersede article" gnus-summary-supersede-article t]
1342 ["Cancel article" gnus-summary-cancel-article t]
1343 ["Reply" gnus-summary-reply t]
1344 ["Reply and yank" gnus-summary-reply-with-original t]
1345 ["Mail forward" gnus-summary-mail-forward t]
1346 ["Post forward" gnus-summary-post-forward t]
1347 ["Digest and mail" gnus-uu-digest-mail-forward t]
1348 ["Digest and post" gnus-uu-digest-post-forward t]
1349 ["Resend message" gnus-summary-resend-message t]
1350 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
1351 ["Send a mail" gnus-summary-mail-other-window t]
1352 ["Uuencode and post" gnus-uu-post-news t]
1354 ;;["Send" gnus-summary-send-draft t]
1355 ;;["Send bounced" gnus-resend-bounced-mail t])
1359 gnus-summary-misc-menu gnus-summary-mode-map ""
1363 ["Mark as read" gnus-summary-mark-as-read-forward t]
1364 ["Mark same subject and select"
1365 gnus-summary-kill-same-subject-and-select t]
1366 ["Mark same subject" gnus-summary-kill-same-subject t]
1367 ["Catchup" gnus-summary-catchup t]
1368 ["Catchup all" gnus-summary-catchup-all t]
1369 ["Catchup to here" gnus-summary-catchup-to-here t]
1370 ["Catchup region" gnus-summary-mark-region-as-read t]
1371 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
1373 ["Tick" gnus-summary-tick-article-forward t]
1374 ["Mark as dormant" gnus-summary-mark-as-dormant t]
1375 ["Remove marks" gnus-summary-clear-mark-forward t]
1376 ["Set expirable mark" gnus-summary-mark-as-expirable t]
1377 ["Set bookmark" gnus-summary-set-bookmark t]
1378 ["Remove bookmark" gnus-summary-remove-bookmark t])
1380 ["Marks..." gnus-summary-limit-to-marks t]
1381 ["Subject..." gnus-summary-limit-to-subject t]
1382 ["Author..." gnus-summary-limit-to-author t]
1383 ["Score" gnus-summary-limit-to-score t]
1384 ["Unread" gnus-summary-limit-to-unread t]
1385 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
1386 ["Articles" gnus-summary-limit-to-articles t]
1387 ["Pop limit" gnus-summary-pop-limit t]
1388 ["Show dormant" gnus-summary-limit-include-dormant t]
1389 ["Hide childless dormant"
1390 gnus-summary-limit-exclude-childless-dormant t]
1391 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
1392 ["Show expunged" gnus-summary-show-all-expunged t])
1394 ["Set mark" gnus-summary-mark-as-processable t]
1395 ["Remove mark" gnus-summary-unmark-as-processable t]
1396 ["Remove all marks" gnus-summary-unmark-all-processable t]
1397 ["Mark above" gnus-uu-mark-over t]
1398 ["Mark series" gnus-uu-mark-series t]
1399 ["Mark region" gnus-uu-mark-region t]
1400 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
1401 ["Mark all" gnus-uu-mark-all t]
1402 ["Mark buffer" gnus-uu-mark-buffer t]
1403 ["Mark sparse" gnus-uu-mark-sparse t]
1404 ["Mark thread" gnus-uu-mark-thread t]
1405 ["Unmark thread" gnus-uu-unmark-thread t]
1406 ("Process Mark Sets"
1407 ["Kill" gnus-summary-kill-process-mark t]
1408 ["Yank" gnus-summary-yank-process-mark
1409 gnus-newsgroup-process-stack]
1410 ["Save" gnus-summary-save-process-mark t])))
1412 ["Page forward" gnus-summary-next-page t]
1413 ["Page backward" gnus-summary-prev-page t]
1414 ["Line forward" gnus-summary-scroll-up t])
1416 ["Next unread article" gnus-summary-next-unread-article t]
1417 ["Previous unread article" gnus-summary-prev-unread-article t]
1418 ["Next article" gnus-summary-next-article t]
1419 ["Previous article" gnus-summary-prev-article t]
1420 ["Next unread subject" gnus-summary-next-unread-subject t]
1421 ["Previous unread subject" gnus-summary-prev-unread-subject t]
1422 ["Next article same subject" gnus-summary-next-same-subject t]
1423 ["Previous article same subject" gnus-summary-prev-same-subject t]
1424 ["First unread article" gnus-summary-first-unread-article t]
1425 ["Best unread article" gnus-summary-best-unread-article t]
1426 ["Go to subject number..." gnus-summary-goto-subject t]
1427 ["Go to article number..." gnus-summary-goto-article t]
1428 ["Go to the last article" gnus-summary-goto-last-article t]
1429 ["Pop article off history" gnus-summary-pop-article t])
1431 ["Sort by number" gnus-summary-sort-by-number t]
1432 ["Sort by author" gnus-summary-sort-by-author t]
1433 ["Sort by subject" gnus-summary-sort-by-subject t]
1434 ["Sort by date" gnus-summary-sort-by-date t]
1435 ["Sort by score" gnus-summary-sort-by-score t])
1437 ["Fetch group FAQ" gnus-summary-fetch-faq t]
1438 ["Describe group" gnus-summary-describe-group t]
1439 ["Read manual" gnus-info-find-node t])
1441 ["Enter article" gnus-cache-enter-article t]
1442 ["Remove article" gnus-cache-remove-article t])
1444 ["Pick and read" gnus-pick-mode t]
1445 ["Binary" gnus-binary-mode t])
1446 ["Filter articles..." gnus-summary-execute-command t]
1447 ["Run command on subjects..." gnus-summary-universal-argument t]
1448 ["Toggle line truncation" gnus-summary-toggle-truncation t]
1449 ["Expand window" gnus-summary-expand-window t]
1450 ["Expire expirable articles" gnus-summary-expire-articles
1451 (gnus-check-backend-function
1452 'request-expire-articles gnus-newsgroup-name)]
1453 ["Edit local kill file" gnus-summary-edit-local-kill t]
1454 ["Edit main kill file" gnus-summary-edit-global-kill t]
1456 ["Catchup and exit" gnus-summary-catchup-and-exit t]
1457 ["Catchup all and exit" gnus-summary-catchup-and-exit t]
1458 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
1459 ["Exit group" gnus-summary-exit t]
1460 ["Exit group without updating" gnus-summary-exit-no-update t]
1461 ["Exit and goto next group" gnus-summary-next-group t]
1462 ["Exit and goto prev group" gnus-summary-prev-group t]
1463 ["Reselect group" gnus-summary-reselect-current-group t]
1464 ["Rescan group" gnus-summary-rescan-group t])))
1466 (run-hooks 'gnus-summary-menu-hook)))
1468 (defun gnus-score-set-default (var value)
1469 "A version of set that updates the GNU Emacs menu-bar."
1471 ;; It is the message that forces the active status to be updated.
1474 (defun gnus-make-score-map (type)
1475 "Make a summary score map of type TYPE."
1478 (let ((headers '(("author" "from" string)
1479 ("subject" "subject" string)
1480 ("article body" "body" string)
1481 ("article head" "head" string)
1482 ("xref" "xref" string)
1483 ("lines" "lines" number)
1484 ("followups to author" "followup" string)))
1485 (types '((number ("less than" <)
1488 (string ("substring" s)
1492 (perms '(("temporary" (current-time-string))
1500 (if (eq type 'lower)
1505 (setq header (car headers))
1511 (let ((ts (cdr (assoc (nth 2 header) types)))
1527 'gnus-summary-score-entry
1529 (if (or (string= (nth 1 header)
1531 (string= (nth 1 header)
1534 (list 'gnus-summary-header
1536 (list 'quote (nth 1 (car ts)))
1537 (list 'gnus-score-default nil)
1543 (list (nreverse outp))))
1546 (list (nreverse outt))))
1548 (setq headers (cdr headers)))
1549 (list (nreverse outh))))))))
1553 (defun gnus-summary-mode (&optional group)
1554 "Major mode for reading articles.
1556 All normal editing commands are switched off.
1557 \\<gnus-summary-mode-map>
1558 Each line in this buffer represents one article. To read an
1559 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
1560 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
1563 You can also post articles and send mail from this buffer. To
1564 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
1565 of an article, type `\\[gnus-summary-reply]'.
1567 There are approx. one gazillion commands you can execute in this
1568 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
1570 The following commands are available:
1572 \\{gnus-summary-mode-map}"
1574 (when (and menu-bar-mode
1575 (gnus-visual-p 'summary-menu 'menu))
1576 (gnus-summary-make-menu-bar))
1577 (kill-all-local-variables)
1578 (gnus-summary-make-local-variables)
1579 (gnus-make-thread-indent-array)
1580 (gnus-simplify-mode-line)
1581 (setq major-mode 'gnus-summary-mode)
1582 (setq mode-name "Summary")
1583 (make-local-variable 'minor-mode-alist)
1584 (use-local-map gnus-summary-mode-map)
1585 (buffer-disable-undo (current-buffer))
1586 (setq buffer-read-only t) ;Disable modification
1587 (setq truncate-lines t)
1588 (setq selective-display t)
1589 (setq selective-display-ellipses t) ;Display `...'
1590 (setq buffer-display-table gnus-summary-display-table)
1591 (gnus-set-default-directory)
1592 (setq gnus-newsgroup-name group)
1593 (make-local-variable 'gnus-summary-line-format)
1594 (make-local-variable 'gnus-summary-line-format-spec)
1595 (make-local-variable 'gnus-summary-mark-positions)
1596 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
1597 (gnus-update-summary-mark-positions)
1598 (gnus-make-local-hook 'post-command-hook)
1599 (gnus-add-hook 'post-command-hook 'gnus-clear-inboxes-moved nil t)
1600 (run-hooks 'gnus-summary-mode-hook))
1602 (defun gnus-summary-make-local-variables ()
1603 "Make all the local summary buffer variables."
1604 (let ((locals gnus-summary-local-variables)
1606 (while (setq local (pop locals))
1609 (if (eq (cdr local) 'global)
1610 ;; Copy the global value of the variable.
1611 (setq global (symbol-value (car local)))
1612 ;; Use the value from the list.
1613 (setq global (eval (cdr local))))
1614 (make-local-variable (car local))
1615 (set (car local) global))
1616 ;; Simple nil-valued local variable.
1617 (make-local-variable local)
1620 (defun gnus-summary-clear-local-variables ()
1621 (let ((locals gnus-summary-local-variables))
1623 (if (consp (car locals))
1624 (and (vectorp (caar locals))
1625 (set (caar locals) nil))
1626 (and (vectorp (car locals))
1627 (set (car locals) nil)))
1628 (setq locals (cdr locals)))))
1630 ;; Summary data functions.
1632 (defmacro gnus-data-number (data)
1635 (defmacro gnus-data-set-number (data number)
1636 `(setcar ,data ,number))
1638 (defmacro gnus-data-mark (data)
1641 (defmacro gnus-data-set-mark (data mark)
1642 `(setcar (nthcdr 1 ,data) ,mark))
1644 (defmacro gnus-data-pos (data)
1647 (defmacro gnus-data-set-pos (data pos)
1648 `(setcar (nthcdr 2 ,data) ,pos))
1650 (defmacro gnus-data-header (data)
1653 (defmacro gnus-data-level (data)
1656 (defmacro gnus-data-unread-p (data)
1657 `(= (nth 1 ,data) gnus-unread-mark))
1659 (defmacro gnus-data-read-p (data)
1660 `(/= (nth 1 ,data) gnus-unread-mark))
1662 (defmacro gnus-data-pseudo-p (data)
1663 `(consp (nth 3 ,data)))
1665 (defmacro gnus-data-find (number)
1666 `(assq ,number gnus-newsgroup-data))
1668 (defmacro gnus-data-find-list (number &optional data)
1669 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
1670 (memq (assq ,number bdata)
1673 (defmacro gnus-data-make (number mark pos header level)
1674 `(list ,number ,mark ,pos ,header ,level))
1676 (defun gnus-data-enter (after-article number mark pos header level offset)
1677 (let ((data (gnus-data-find-list after-article)))
1678 (or data (error "No such article: %d" after-article))
1679 (setcdr data (cons (gnus-data-make number mark pos header level)
1681 (setq gnus-newsgroup-data-reverse nil)
1682 (gnus-data-update-list (cddr data) offset)))
1684 (defun gnus-data-enter-list (after-article list &optional offset)
1686 (let ((data (and after-article (gnus-data-find-list after-article)))
1688 (or data (not after-article) (error "No such article: %d" after-article))
1689 ;; Find the last element in the list to be spliced into the main
1692 (setq list (cdr list)))
1695 (setcdr list gnus-newsgroup-data)
1696 (setq gnus-newsgroup-data ilist)
1697 (and offset (gnus-data-update-list (cdr list) offset)))
1698 (setcdr list (cdr data))
1700 (and offset (gnus-data-update-list (cdr data) offset)))
1701 (setq gnus-newsgroup-data-reverse nil))))
1703 (defun gnus-data-remove (article &optional offset)
1704 (let ((data gnus-newsgroup-data))
1705 (if (= (gnus-data-number (car data)) article)
1706 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
1707 gnus-newsgroup-data-reverse nil)
1709 (and (= (gnus-data-number (cadr data)) article)
1711 (setcdr data (cddr data))
1712 (and offset (gnus-data-update-list (cdr data) offset))
1714 gnus-newsgroup-data-reverse nil)))
1715 (setq data (cdr data))))))
1717 (defmacro gnus-data-list (backward)
1719 (or gnus-newsgroup-data-reverse
1720 (setq gnus-newsgroup-data-reverse
1721 (reverse gnus-newsgroup-data)))
1722 gnus-newsgroup-data))
1724 (defun gnus-data-update-list (data offset)
1725 "Add OFFSET to the POS of all data entries in DATA."
1727 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
1728 (setq data (cdr data))))
1730 (defun gnus-data-compute-positions ()
1731 "Compute the positions of all articles."
1732 (let ((data gnus-newsgroup-data)
1735 (when (setq pos (text-property-any
1736 (point-min) (point-max)
1737 'gnus-number (gnus-data-number (car data))))
1738 (gnus-data-set-pos (car data) (+ pos 3)))
1739 (setq data (cdr data)))))
1741 (defun gnus-summary-article-pseudo-p (article)
1742 "Say whether this article is a pseudo article or not."
1743 (not (vectorp (gnus-data-header (gnus-data-find article)))))
1745 (defun gnus-article-parent-p (number)
1746 "Say whether this article is a parent or not."
1747 (let ((data (gnus-data-find-list number)))
1748 (and (cdr data) ; There has to be an article after...
1749 (< (gnus-data-level (car data)) ; And it has to have a higher level.
1750 (gnus-data-level (nth 1 data))))))
1752 (defun gnus-article-children (number)
1753 "Return a list of all children to NUMBER."
1754 (let* ((data (gnus-data-find-list number))
1755 (level (gnus-data-level (car data)))
1757 (setq data (cdr data))
1759 (= (gnus-data-level (car data)) (1+ level)))
1760 (push (gnus-data-number (car data)) children)
1761 (setq data (cdr data)))
1764 (defmacro gnus-summary-skip-intangible ()
1765 "If the current article is intangible, then jump to a different article."
1766 '(let ((to (get-text-property (point) 'gnus-intangible)))
1767 (and to (gnus-summary-goto-subject to))))
1769 (defmacro gnus-summary-article-intangible-p ()
1770 "Say whether this article is intangible or not."
1771 '(get-text-property (point) 'gnus-intangible))
1773 ;; Some summary mode macros.
1775 (defmacro gnus-summary-article-number ()
1776 "The article number of the article on the current line.
1777 If there isn's an article number here, then we return the current
1780 (gnus-summary-skip-intangible)
1781 (or (get-text-property (point) 'gnus-number)
1782 (gnus-summary-last-subject))))
1784 (defmacro gnus-summary-article-header (&optional number)
1785 `(gnus-data-header (gnus-data-find
1786 ,(or number '(gnus-summary-article-number)))))
1788 (defmacro gnus-summary-thread-level (&optional number)
1789 `(if (and (eq gnus-summary-make-false-root 'dummy)
1790 (get-text-property (point) 'gnus-intangible))
1792 (gnus-data-level (gnus-data-find
1793 ,(or number '(gnus-summary-article-number))))))
1795 (defmacro gnus-summary-article-mark (&optional number)
1796 `(gnus-data-mark (gnus-data-find
1797 ,(or number '(gnus-summary-article-number)))))
1799 (defmacro gnus-summary-article-pos (&optional number)
1800 `(gnus-data-pos (gnus-data-find
1801 ,(or number '(gnus-summary-article-number)))))
1803 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
1804 (defmacro gnus-summary-article-subject (&optional number)
1805 "Return current subject string or nil if nothing."
1808 `(gnus-data-header (assq ,number gnus-newsgroup-data))
1809 '(gnus-data-header (assq (gnus-summary-article-number)
1810 gnus-newsgroup-data)))))
1813 (mail-header-subject headers))))
1815 (defmacro gnus-summary-article-score (&optional number)
1816 "Return current article score."
1817 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
1818 gnus-newsgroup-scored))
1819 gnus-summary-default-score 0))
1821 (defun gnus-summary-article-children (&optional number)
1822 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
1823 (level (gnus-data-level (car data)))
1825 (while (and (setq data (cdr data))
1826 (> (setq l (gnus-data-level (car data))) level))
1827 (and (= (1+ level) l)
1828 (setq children (cons (gnus-data-number (car data))
1830 (nreverse children)))
1832 (defun gnus-summary-article-parent (&optional number)
1833 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
1834 (gnus-data-list t)))
1835 (level (gnus-data-level (car data))))
1837 () ; This is a root.
1838 ;; We search until we find an article with a level less than
1839 ;; this one. That function has to be the parent.
1840 (while (and (setq data (cdr data))
1841 (not (< (gnus-data-level (car data)) level))))
1842 (and data (gnus-data-number (car data))))))
1844 (defun gnus-unread-mark-p (mark)
1845 "Say whether MARK is the unread mark."
1846 (= mark gnus-unread-mark))
1848 (defun gnus-read-mark-p (mark)
1849 "Say whether MARK is one of the marks that mark as read.
1850 This is all marks except unread, ticked, dormant, and expirable."
1851 (not (or (= mark gnus-unread-mark)
1852 (= mark gnus-ticked-mark)
1853 (= mark gnus-dormant-mark)
1854 (= mark gnus-expirable-mark))))
1856 (defmacro gnus-article-mark (number)
1858 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
1859 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
1860 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
1861 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
1862 (t (or (cdr (assq ,number gnus-newsgroup-reads))
1863 gnus-ancient-mark))))
1865 ;; Saving hidden threads.
1867 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
1868 (put 'gnus-save-hidden-threads 'lisp-indent-hook 0)
1869 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
1871 (defmacro gnus-save-hidden-threads (&rest forms)
1872 "Save hidden threads, eval FORMS, and restore the hidden threads."
1873 (let ((config (make-symbol "config")))
1874 `(let ((,config (gnus-hidden-threads-configuration)))
1878 (gnus-restore-hidden-threads-configuration ,config)))))
1880 (defun gnus-hidden-threads-configuration ()
1881 "Return the current hidden threads configuration."
1884 (goto-char (point-min))
1885 (while (search-forward "\r" nil t)
1886 (push (1- (point)) config))
1889 (defun gnus-restore-hidden-threads-configuration (config)
1890 "Restore hidden threads configuration from CONFIG."
1891 (let (point buffer-read-only)
1892 (while (setq point (pop config))
1893 (when (and (< point (point-max))
1895 (= (following-char) ?\n))
1896 (subst-char-in-region point (1+ point) ?\n ?\r)))))
1898 ;; Various summary mode internalish functions.
1900 (defun gnus-mouse-pick-article (e)
1903 (gnus-summary-next-page nil t))
1905 (defun gnus-summary-setup-buffer (group)
1906 "Initialize summary buffer."
1907 (let ((buffer (concat "*Summary " group "*")))
1908 (if (get-buffer buffer)
1911 (setq gnus-summary-buffer (current-buffer))
1912 (not gnus-newsgroup-prepared))
1913 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
1914 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
1915 (gnus-add-current-to-buffer-list)
1916 (gnus-summary-mode group)
1918 (gnus-carpal-setup-buffer 'summary))
1919 (unless gnus-single-article-buffer
1920 (make-local-variable 'gnus-article-buffer)
1921 (make-local-variable 'gnus-article-current)
1922 (make-local-variable 'gnus-original-article-buffer))
1923 (setq gnus-newsgroup-name group)
1926 (defun gnus-set-global-variables ()
1927 ;; Set the global equivalents of the summary buffer-local variables
1928 ;; to the latest values they had. These reflect the summary buffer
1929 ;; that was in action when the last article was fetched.
1930 (when (eq major-mode 'gnus-summary-mode)
1931 (setq gnus-summary-buffer (current-buffer))
1932 (let ((name gnus-newsgroup-name)
1933 (marked gnus-newsgroup-marked)
1934 (unread gnus-newsgroup-unreads)
1935 (headers gnus-current-headers)
1936 (data gnus-newsgroup-data)
1937 (summary gnus-summary-buffer)
1938 (article-buffer gnus-article-buffer)
1939 (original gnus-original-article-buffer)
1940 (gac gnus-article-current)
1941 (reffed gnus-reffed-article-number)
1942 (score-file gnus-current-score-file))
1944 (set-buffer gnus-group-buffer)
1945 (setq gnus-newsgroup-name name)
1946 (setq gnus-newsgroup-marked marked)
1947 (setq gnus-newsgroup-unreads unread)
1948 (setq gnus-current-headers headers)
1949 (setq gnus-newsgroup-data data)
1950 (setq gnus-article-current gac)
1951 (setq gnus-summary-buffer summary)
1952 (setq gnus-article-buffer article-buffer)
1953 (setq gnus-original-article-buffer original)
1954 (setq gnus-reffed-article-number reffed)
1955 (setq gnus-current-score-file score-file)))))
1957 (defun gnus-summary-last-article-p (&optional article)
1958 "Return whether ARTICLE is the last article in the buffer."
1959 (if (not (setq article (or article (gnus-summary-article-number))))
1960 t ; All non-existant numbers are the last article. :-)
1961 (not (cdr (gnus-data-find-list article)))))
1963 (defun gnus-make-thread-indent-array ()
1965 (unless (and gnus-thread-indent-array
1966 (= gnus-thread-indent-level gnus-thread-indent-array-level))
1967 (setq gnus-thread-indent-array (make-vector 201 "")
1968 gnus-thread-indent-array-level gnus-thread-indent-level)
1970 (aset gnus-thread-indent-array n
1971 (make-string (* n gnus-thread-indent-level) ? ))
1974 (defun gnus-update-summary-mark-positions ()
1975 "Compute where the summary marks are to go."
1977 (when (and gnus-summary-buffer
1978 (get-buffer gnus-summary-buffer)
1979 (buffer-name (get-buffer gnus-summary-buffer)))
1980 (set-buffer gnus-summary-buffer))
1981 (let ((gnus-replied-mark 129)
1982 (gnus-score-below-mark 130)
1983 (gnus-score-over-mark 130)
1986 (spec gnus-summary-line-format-spec)
1989 (gnus-set-work-buffer)
1990 (let ((gnus-summary-line-format-spec spec))
1991 (gnus-summary-insert-line
1992 [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
1993 (goto-char (point-min))
1994 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
1996 (goto-char (point-min))
1997 (push (cons 'replied (and (search-forward "\201" nil t)
2000 (goto-char (point-min))
2001 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2003 (setq gnus-summary-mark-positions pos))))
2005 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2006 "Insert a dummy root in the summary buffer."
2008 (gnus-add-text-properties
2009 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2010 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2012 (defun gnus-summary-insert-line
2013 (gnus-tmp-header gnus-tmp-level gnus-tmp-current gnus-tmp-unread
2014 gnus-tmp-replied gnus-tmp-expirable gnus-tmp-subject-or-nil
2015 &optional gnus-tmp-dummy gnus-tmp-score gnus-tmp-process)
2016 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2017 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2018 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2019 (gnus-tmp-score-char
2020 (if (or (null gnus-summary-default-score)
2021 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2022 gnus-summary-zcore-fuzz)) ?
2023 (if (< gnus-tmp-score gnus-summary-default-score)
2024 gnus-score-below-mark gnus-score-over-mark)))
2025 (gnus-tmp-replied (cond (gnus-tmp-process gnus-process-mark)
2026 ((memq gnus-tmp-current gnus-newsgroup-cached)
2028 (gnus-tmp-replied gnus-replied-mark)
2029 ((memq gnus-tmp-current gnus-newsgroup-saved)
2031 (t gnus-unread-mark)))
2032 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2035 ((string-match "(.+)" gnus-tmp-from)
2036 (substring gnus-tmp-from
2037 (1+ (match-beginning 0)) (1- (match-end 0))))
2038 ((string-match "<[^>]+> *$" gnus-tmp-from)
2039 (let ((beg (match-beginning 0)))
2040 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
2041 (substring gnus-tmp-from (1+ (match-beginning 0))
2042 (1- (match-end 0))))
2043 (substring gnus-tmp-from 0 beg))))
2045 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2046 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2047 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2048 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
2049 (buffer-read-only nil))
2050 (when (string= gnus-tmp-name "")
2051 (setq gnus-tmp-name gnus-tmp-from))
2052 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
2053 (gnus-put-text-property
2055 (progn (eval gnus-summary-line-format-spec) (point))
2056 'gnus-number gnus-tmp-number)
2057 (when (gnus-visual-p 'summary-highlight 'highlight)
2059 (run-hooks 'gnus-summary-update-hook)
2062 (defun gnus-summary-update-line (&optional dont-update)
2063 ;; Update summary line after change.
2064 (when (and gnus-summary-default-score
2065 (not gnus-summary-inhibit-highlight))
2066 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
2067 (article (gnus-summary-article-number))
2068 (score (gnus-summary-article-score article)))
2070 (if (and gnus-summary-mark-below
2071 (< (gnus-summary-article-score)
2072 gnus-summary-mark-below))
2073 ;; This article has a low score, so we mark it as read.
2074 (when (memq article gnus-newsgroup-unreads)
2075 (gnus-summary-mark-article-as-read gnus-low-score-mark))
2076 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
2077 ;; This article was previously marked as read on account
2078 ;; of a low score, but now it has risen, so we mark it as
2080 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
2081 (gnus-summary-update-mark
2082 (if (or (null gnus-summary-default-score)
2083 (<= (abs (- score gnus-summary-default-score))
2084 gnus-summary-zcore-fuzz)) ?
2085 (if (< score gnus-summary-default-score)
2086 gnus-score-below-mark gnus-score-over-mark)) 'score))
2087 ;; Do visual highlighting.
2088 (when (gnus-visual-p 'summary-highlight 'highlight)
2089 (run-hooks 'gnus-summary-update-hook)))))
2091 (defvar gnus-tmp-new-adopts nil)
2093 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
2094 ;; Sum up all elements (and sub-elements) in a list.
2096 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
2098 ((and (consp thread) (cdr thread))
2101 'gnus-summary-number-of-articles-in-thread (cdr thread))))
2104 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
2107 (when (and level (zerop level) gnus-tmp-new-adopts)
2110 'gnus-summary-number-of-articles-in-thread
2111 gnus-tmp-new-adopts))))
2113 (if (> number 1) gnus-not-empty-thread-mark
2114 gnus-empty-thread-mark)
2117 (defun gnus-summary-set-local-parameters (group)
2118 "Go through the local params of GROUP and set all variable specs in that list."
2119 (let ((params (gnus-group-find-parameter group))
2122 (setq elem (car params)
2123 params (cdr params))
2124 (and (consp elem) ; Has to be a cons.
2125 (consp (cdr elem)) ; The cdr has to be a list.
2126 (symbolp (car elem)) ; Has to be a symbol in there.
2127 (not (memq (car elem)
2128 '(quit-config to-address to-list to-group)))
2129 (progn ; So we set it.
2130 (make-local-variable (car elem))
2131 (set (car elem) (eval (nth 1 elem))))))))
2133 (defun gnus-summary-read-group (group &optional show-all no-article
2134 kill-buffer no-display)
2135 "Start reading news in newsgroup GROUP.
2136 If SHOW-ALL is non-nil, already read articles are also listed.
2137 If NO-ARTICLE is non-nil, no article is selected initially.
2138 If NO-DISPLAY, don't generate a summary buffer."
2139 (gnus-message 5 "Retrieving newsgroup: %s..." group)
2140 (let* ((new-group (gnus-summary-setup-buffer group))
2141 (quit-config (gnus-group-quit-config group))
2142 (did-select (and new-group (gnus-select-newsgroup group show-all))))
2144 ;; This summary buffer exists already, so we just select it.
2146 (gnus-set-global-variables)
2148 (gnus-kill-or-deaden-summary kill-buffer))
2149 (gnus-configure-windows 'summary 'force)
2150 (gnus-set-mode-line 'summary)
2151 (gnus-summary-position-point)
2154 ;; We couldn't select this group.
2156 (when (and (eq major-mode 'gnus-summary-mode)
2157 (not (equal (current-buffer) kill-buffer)))
2158 (kill-buffer (current-buffer))
2159 (if (not quit-config)
2161 (set-buffer gnus-group-buffer)
2162 (gnus-group-jump-to-group group)
2163 (gnus-group-next-unread-group 1))
2164 (if (not (buffer-name (car quit-config)))
2165 (gnus-configure-windows 'group 'force)
2166 (set-buffer (car quit-config))
2167 (and (eq major-mode 'gnus-summary-mode)
2168 (gnus-set-global-variables))
2169 (gnus-configure-windows (cdr quit-config)))))
2170 (gnus-message 3 "Can't select group")
2172 ;; The user did a `C-g' while prompting for number of articles,
2173 ;; so we exit this group.
2174 ((eq did-select 'quit)
2175 (and (eq major-mode 'gnus-summary-mode)
2176 (not (equal (current-buffer) kill-buffer))
2177 (kill-buffer (current-buffer)))
2179 (gnus-kill-or-deaden-summary kill-buffer))
2180 (if (not quit-config)
2182 (set-buffer gnus-group-buffer)
2183 (gnus-group-jump-to-group group)
2184 (gnus-group-next-unread-group 1)
2185 (gnus-configure-windows 'group 'force))
2186 (if (not (buffer-name (car quit-config)))
2187 (gnus-configure-windows 'group 'force)
2188 (set-buffer (car quit-config))
2189 (and (eq major-mode 'gnus-summary-mode)
2190 (gnus-set-global-variables))
2191 (gnus-configure-windows (cdr quit-config))))
2192 ;; Finally signal the quit.
2194 ;; The group was successfully selected.
2196 (gnus-set-global-variables)
2197 ;; Save the active value in effect when the group was entered.
2198 (setq gnus-newsgroup-active
2200 (gnus-active gnus-newsgroup-name)))
2201 ;; You can change the summary buffer in some way with this hook.
2202 (run-hooks 'gnus-select-group-hook)
2203 ;; Set any local variables in the group parameters.
2204 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2205 (gnus-update-format-specifications
2206 nil 'summary 'summary-mode 'summary-dummy)
2207 ;; Do score processing.
2208 (when gnus-use-scoring
2209 (gnus-possibly-score-headers))
2210 ;; Check whether to fill in the gaps in the threads.
2211 (when gnus-build-sparse-threads
2212 (gnus-build-sparse-threads))
2213 ;; Find the initial limit.
2214 (if gnus-show-threads
2216 (let ((gnus-newsgroup-dormant nil))
2217 (gnus-summary-initial-limit show-all))
2218 (gnus-summary-initial-limit show-all))
2219 (setq gnus-newsgroup-limit
2221 (lambda (header) (mail-header-number header))
2222 gnus-newsgroup-headers)))
2223 ;; Generate the summary buffer.
2225 (gnus-summary-prepare))
2226 (when gnus-use-trees
2227 (gnus-tree-open group)
2228 (setq gnus-summary-highlight-line-function
2229 'gnus-tree-highlight-article))
2230 ;; If the summary buffer is empty, but there are some low-scored
2231 ;; articles or some excluded dormants, we include these in the
2233 (when (and (zerop (buffer-size))
2235 (cond (gnus-newsgroup-dormant
2236 (gnus-summary-limit-include-dormant))
2237 ((and gnus-newsgroup-scored show-all)
2238 (gnus-summary-limit-include-expunged t))))
2239 ;; Function `gnus-apply-kill-file' must be called in this hook.
2240 (run-hooks 'gnus-apply-kill-hook)
2241 (if (and (zerop (buffer-size))
2244 ;; This newsgroup is empty.
2245 (gnus-summary-catchup-and-exit nil t) ;Without confirmations.
2246 (gnus-message 6 "No unread news")
2248 (gnus-kill-or-deaden-summary kill-buffer))
2249 ;; Return nil from this function.
2251 ;; Hide conversation thread subtrees. We cannot do this in
2252 ;; gnus-summary-prepare-hook since kill processing may not
2253 ;; work with hidden articles.
2254 (and gnus-show-threads
2255 gnus-thread-hide-subtree
2256 (gnus-summary-hide-all-threads))
2257 ;; Show first unread article if requested.
2258 (if (and (not no-article)
2260 gnus-newsgroup-unreads
2261 gnus-auto-select-first)
2262 (unless (if (eq gnus-auto-select-first 'best)
2263 (gnus-summary-best-unread-article)
2264 (gnus-summary-first-unread-article))
2265 (gnus-configure-windows 'summary))
2266 ;; Don't select any articles, just move point to the first
2267 ;; article in the group.
2268 (goto-char (point-min))
2269 (gnus-summary-position-point)
2270 (gnus-set-mode-line 'summary)
2271 (gnus-configure-windows 'summary 'force))
2273 (gnus-kill-or-deaden-summary kill-buffer))
2274 (when (get-buffer-window gnus-group-buffer t)
2275 ;; Gotta use windows, because recenter does wierd stuff if
2276 ;; the current buffer ain't the displayed window.
2277 (let ((owin (selected-window)))
2278 (select-window (get-buffer-window gnus-group-buffer t))
2279 (when (gnus-group-goto-group group)
2281 (select-window owin))))
2282 ;; Mark this buffer as "prepared".
2283 (setq gnus-newsgroup-prepared t)
2286 (defun gnus-summary-prepare ()
2287 "Generate the summary buffer."
2288 (let ((buffer-read-only nil))
2290 (setq gnus-newsgroup-data nil
2291 gnus-newsgroup-data-reverse nil)
2292 (run-hooks 'gnus-summary-generate-hook)
2293 ;; Generate the buffer, either with threads or without.
2294 (when gnus-newsgroup-headers
2295 (gnus-summary-prepare-threads
2296 (if gnus-show-threads
2297 (gnus-sort-gathered-threads
2298 (funcall gnus-summary-thread-gathering-function
2300 (gnus-cut-threads (gnus-make-threads)))))
2301 ;; Unthreaded display.
2302 (gnus-sort-articles gnus-newsgroup-headers))))
2303 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
2304 ;; Call hooks for modifying summary buffer.
2305 (goto-char (point-min))
2306 (run-hooks 'gnus-summary-prepare-hook)))
2308 (defsubst gnus-general-simplify-subject (subject)
2309 "Simply subject by the same rules as gnus-gather-threads-by-subject."
2312 ;; Truncate the subject.
2313 ((numberp gnus-summary-gather-subject-limit)
2314 (setq subject (gnus-simplify-subject-re subject))
2315 (if (> (length subject) gnus-summary-gather-subject-limit)
2316 (substring subject 0 gnus-summary-gather-subject-limit)
2318 ;; Fuzzily simplify it.
2319 ((eq 'fuzzy gnus-summary-gather-subject-limit)
2320 (gnus-simplify-subject-fuzzy subject))
2321 ;; Just remove the leading "Re:".
2323 (gnus-simplify-subject-re subject))))
2325 (if (and gnus-summary-gather-exclude-subject
2326 (string-match gnus-summary-gather-exclude-subject subject))
2327 nil ; This article shouldn't be gathered
2330 (defun gnus-summary-simplify-subject-query ()
2331 "Query where the respool algorithm would put this article."
2333 (gnus-set-global-variables)
2334 (gnus-summary-select-article)
2335 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
2337 (defun gnus-gather-threads-by-subject (threads)
2338 "Gather threads by looking at Subject headers."
2339 (if (not gnus-summary-make-false-root)
2341 (let ((hashtb (gnus-make-hashtable 1023))
2344 subject hthread whole-subject)
2346 (setq subject (gnus-general-simplify-subject
2347 (setq whole-subject (mail-header-subject
2350 (if (setq hthread (gnus-gethash subject hashtb))
2352 ;; We enter a dummy root into the thread, if we
2353 ;; haven't done that already.
2354 (unless (stringp (caar hthread))
2355 (setcar hthread (list whole-subject (car hthread))))
2356 ;; We add this new gathered thread to this gathered
2358 (setcdr (car hthread)
2359 (nconc (cdar hthread) (list (car threads))))
2360 ;; Remove it from the list of threads.
2361 (setcdr prev (cdr threads))
2362 (setq threads prev))
2363 ;; Enter this thread into the hash table.
2364 (gnus-sethash subject threads hashtb)))
2366 (setq threads (cdr threads)))
2369 (defun gnus-gather-threads-by-references (threads)
2370 "Gather threads by looking at References headers."
2371 (let ((idhashtb (gnus-make-hashtable 1023))
2372 (thhashtb (gnus-make-hashtable 1023))
2375 ids references id gthread gid entered)
2377 (when (setq references (mail-header-references (caar threads)))
2378 (setq id (mail-header-id (caar threads)))
2379 (setq ids (gnus-split-references references))
2382 (if (not (setq gid (gnus-gethash (car ids) idhashtb)))
2384 (gnus-sethash (car ids) id idhashtb)
2385 (gnus-sethash id threads thhashtb))
2386 (setq gthread (gnus-gethash gid thhashtb))
2388 ;; We enter a dummy root into the thread, if we
2389 ;; haven't done that already.
2390 (unless (stringp (caar gthread))
2391 (setcar gthread (list (mail-header-subject (caar gthread))
2393 ;; We add this new gathered thread to this gathered
2395 (setcdr (car gthread)
2396 (nconc (cdar gthread) (list (car threads)))))
2397 ;; Add it into the thread hash table.
2398 (gnus-sethash id gthread thhashtb)
2400 ;; Remove it from the list of threads.
2401 (setcdr prev (cdr threads))
2402 (setq threads prev))
2403 (setq ids (cdr ids))))
2405 (setq threads (cdr threads)))
2408 (defun gnus-sort-gathered-threads (threads)
2409 "Sort subtreads inside each gathered thread by article number."
2410 (let ((result threads))
2412 (when (stringp (caar threads))
2413 (setcdr (car threads)
2414 (sort (cdar threads) 'gnus-thread-sort-by-number)))
2415 (setq threads (cdr threads)))
2418 (defun gnus-make-threads ()
2419 "Go through the dependency hashtb and find the roots. Return all threads."
2423 (unless (car (symbol-value refs))
2424 ;; These threads do not refer back to any other articles,
2425 ;; so they're roots.
2426 (setq threads (append (cdr (symbol-value refs)) threads))))
2427 gnus-newsgroup-dependencies)
2430 (defun gnus-build-sparse-threads ()
2431 (let ((headers gnus-newsgroup-headers)
2432 (deps gnus-newsgroup-dependencies)
2433 header references generation relations
2434 cthread subject child end pthread relation)
2435 ;; First we create an alist of generations/relations, where
2436 ;; generations is how much we trust the ralation, and the relation
2438 (gnus-message 7 "Making sparse threads...")
2440 (nnheader-set-temp-buffer " *gnus sparse threads*")
2441 (while (setq header (pop headers))
2442 (when (and (setq references (mail-header-references header))
2443 (not (string= references "")))
2445 (setq child (mail-header-id header)
2446 subject (mail-header-subject header))
2448 (while (search-backward ">" nil t)
2449 (setq end (1+ (point)))
2450 (when (search-backward "<" nil t)
2451 (push (list (incf generation)
2452 child (setq child (buffer-substring (point) end))
2455 (push (list (1+ generation) child nil subject) relations)
2457 (kill-buffer (current-buffer)))
2458 ;; Sort over trustworthiness.
2459 (setq relations (sort relations (lambda (r1 r2) (< (car r1) (car r2)))))
2460 (while (setq relation (pop relations))
2461 (when (if (boundp (setq cthread (intern (cadr relation) deps)))
2462 (unless (car (symbol-value cthread))
2463 ;; Make this article the parent of these threads.
2464 (setcar (symbol-value cthread)
2465 (vector gnus-reffed-article-number
2469 (or (caddr relation) "") 0 0 "")))
2470 (set cthread (list (vector gnus-reffed-article-number
2472 "" "" (cadr relation)
2473 (or (caddr relation) "") 0 0 ""))))
2474 (push gnus-reffed-article-number gnus-newsgroup-limit)
2475 (push gnus-reffed-article-number gnus-newsgroup-sparse)
2476 (push (cons gnus-reffed-article-number gnus-sparse-mark)
2477 gnus-newsgroup-reads)
2478 (decf gnus-reffed-article-number)
2479 ;; Make this new thread the child of its parent.
2480 (if (boundp (setq pthread (intern (or (caddr relation) "none") deps)))
2481 (setcdr (symbol-value pthread)
2482 (nconc (cdr (symbol-value pthread))
2483 (list (symbol-value cthread))))
2484 (set pthread (list nil (symbol-value cthread))))))
2485 (gnus-message 7 "Making sparse threads...done")))
2487 (defun gnus-build-old-threads ()
2488 ;; Look at all the articles that refer back to old articles, and
2489 ;; fetch the headers for the articles that aren't there. This will
2490 ;; build complete threads - if the roots haven't been expired by the
2495 (when (not (car (symbol-value refs)))
2496 (setq heads (cdr (symbol-value refs)))
2498 (if (memq (mail-header-number (caar heads))
2499 gnus-newsgroup-dormant)
2500 (setq heads (cdr heads))
2501 (setq id (symbol-name refs))
2502 (while (and (setq id (gnus-build-get-header id))
2503 (not (car (gnus-gethash
2504 id gnus-newsgroup-dependencies)))))
2505 (setq heads nil)))))
2506 gnus-newsgroup-dependencies)))
2508 (defun gnus-build-get-header (id)
2509 ;; Look through the buffer of NOV lines and find the header to
2510 ;; ID. Enter this line into the dependencies hash table, and return
2511 ;; the id of the parent article (if any).
2512 (let ((deps gnus-newsgroup-dependencies)
2516 (set-buffer nntp-server-buffer)
2517 (goto-char (point-min))
2518 (while (and (not found) (search-forward id nil t))
2520 (setq found (looking-at
2521 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
2522 (regexp-quote id))))
2523 (or found (beginning-of-line 2)))
2527 (setq header (gnus-nov-parse-line
2528 (read (current-buffer)) deps))
2529 (gnus-parent-id (mail-header-references header)))))
2531 (let ((number (mail-header-number header)))
2532 (push number gnus-newsgroup-limit)
2533 (push header gnus-newsgroup-headers)
2534 (if (memq number gnus-newsgroup-unselected)
2536 (push number gnus-newsgroup-unreads)
2537 (setq gnus-newsgroup-unselected
2538 (delq number gnus-newsgroup-unselected)))
2539 (push number gnus-newsgroup-ancient)))))))
2541 (defun gnus-summary-update-article-line (article header)
2542 "Update the line for ARTICLE using HEADERS."
2543 (let* ((id (mail-header-id header))
2544 (thread (gnus-id-to-thread id)))
2546 (error "Article in no thread"))
2547 ;; Update the thread.
2548 (setcar thread header)
2549 (gnus-summary-goto-subject article)
2550 (let* ((datal (gnus-data-find-list article))
2552 (length (when (cdr datal)
2553 (- (gnus-data-pos data)
2554 (gnus-data-pos (cadr datal)))))
2555 (buffer-read-only nil)
2556 (level (gnus-summary-thread-level)))
2558 (gnus-summary-insert-line
2559 header level nil (gnus-article-mark article)
2560 (memq article gnus-newsgroup-replied)
2561 (memq article gnus-newsgroup-expirable)
2562 (mail-header-subject header)
2563 nil (cdr (assq article gnus-newsgroup-scored))
2564 (memq article gnus-newsgroup-processable))
2566 (gnus-data-update-list
2567 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
2569 (defun gnus-summary-update-article (article &optional iheader)
2570 "Update ARTICLE in the summary buffer."
2571 (set-buffer gnus-summary-buffer)
2572 (let* ((header (or iheader (gnus-summary-article-header article)))
2573 (id (mail-header-id header))
2574 (data (gnus-data-find article))
2575 (thread (gnus-id-to-thread id))
2576 (references (mail-header-references header))
2581 (not (equal "" references)))
2584 (buffer-read-only nil)
2586 (number (mail-header-number header))
2589 ;; !!! Should this be in or not?
2591 (setcar thread nil))
2593 (delq thread parent))
2594 (if (gnus-summary-insert-subject id header iheader)
2595 ;; Set the (possibly) new article number in the data structure.
2596 (gnus-data-set-number data (gnus-id-to-article id))
2600 (defun gnus-rebuild-thread (id)
2601 "Rebuild the thread containing ID."
2602 (let ((buffer-read-only nil)
2603 current thread data)
2604 (if (not gnus-show-threads)
2605 (setq thread (list (car (gnus-id-to-thread id))))
2606 ;; Get the thread this article is part of.
2607 (setq thread (gnus-remove-thread id)))
2608 (setq current (save-excursion
2609 (and (zerop (forward-line -1))
2610 (gnus-summary-article-number))))
2611 ;; If this is a gathered thread, we have to go some re-gathering.
2612 (when (stringp (car thread))
2613 (let ((subject (car thread))
2615 (setq thread (cdr thread))
2617 (unless (memq (setq thr (gnus-id-to-thread
2619 (mail-header-id (caar thread)))))
2622 (setq thread (cdr thread)))
2623 ;; We now have all (unique) roots.
2624 (if (= (length roots) 1)
2625 ;; All the loose roots are now one solid root.
2626 (setq thread (car roots))
2627 (setq thread (cons subject (gnus-sort-threads roots))))))
2629 ;; We then insert this thread into the summary buffer.
2630 (let (gnus-newsgroup-data gnus-newsgroup-threads)
2631 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
2632 (setq data (nreverse gnus-newsgroup-data))
2633 (setq threads gnus-newsgroup-threads))
2634 ;; We splice the new data into the data structure.
2635 (gnus-data-enter-list current data)
2636 (gnus-data-compute-positions)
2637 (setq gnus-newsgroup-threads (nconc threads gnus-newsgroup-threads)))))
2639 (defun gnus-number-to-header (number)
2640 "Return the header for article NUMBER."
2641 (let ((headers gnus-newsgroup-headers))
2643 (not (= number (mail-header-number (car headers)))))
2648 (defun gnus-parent-headers (headers &optional generation)
2649 "Return the headers of the GENERATIONeth parent of HEADERS."
2651 (setq generation 1))
2652 (let (references parent)
2653 (while (and headers (not (zerop generation)))
2654 (setq references (mail-header-references headers))
2655 (when (and references
2656 (setq parent (gnus-parent-id references))
2657 (setq headers (car (gnus-id-to-thread parent))))
2661 (defun gnus-id-to-thread (id)
2662 "Return the (sub-)thread where ID appears."
2663 (gnus-gethash id gnus-newsgroup-dependencies))
2665 (defun gnus-id-to-article (id)
2666 "Return the article number of ID."
2667 (let ((thread (gnus-id-to-thread id)))
2670 (mail-header-number (car thread)))))
2672 (defun gnus-id-to-header (id)
2673 "Return the article headers of ID."
2674 (car (gnus-id-to-thread id)))
2676 (defun gnus-article-displayed-root-p (article)
2677 "Say whether ARTICLE is a root(ish) article."
2678 (let ((level (gnus-summary-thread-level article))
2679 (refs (mail-header-references (gnus-summary-article-header article)))
2685 ((null (gnus-parent-id refs)) t)
2687 (null (setq particle (gnus-id-to-article
2688 (gnus-parent-id refs))))
2689 (null (gnus-summary-thread-level particle)))))))
2691 (defun gnus-root-id (id)
2692 "Return the id of the root of the thread where ID appears."
2694 (while (and id (setq prev (car (gnus-gethash
2695 id gnus-newsgroup-dependencies))))
2697 id (gnus-parent-id (mail-header-references prev))))
2700 (defun gnus-remove-thread (id &optional dont-remove)
2701 "Remove the thread that has ID in it."
2702 (let ((dep gnus-newsgroup-dependencies)
2703 headers thread last-id)
2704 ;; First go up in this thread until we find the root.
2705 (setq last-id (gnus-root-id id))
2706 (setq headers (list (car (gnus-id-to-thread last-id))
2707 (caadr (gnus-id-to-thread last-id))))
2708 ;; We have now found the real root of this thread. It might have
2709 ;; been gathered into some loose thread, so we have to search
2710 ;; through the threads to find the thread we wanted.
2711 (let ((threads gnus-newsgroup-threads)
2714 (setq sub (car threads))
2715 (if (stringp (car sub))
2716 ;; This is a gathered thread, so we look at the roots
2717 ;; below it to find whether this article is in this
2720 (setq sub (cdr sub))
2722 (when (member (caar sub) headers)
2723 (setq thread (car threads)
2726 (setq sub (cdr sub))))
2727 ;; It's an ordinary thread, so we check it.
2728 (when (eq (car sub) (car headers))
2731 (setq threads (cdr threads)))
2732 ;; If this article is in no thread, then it's a root.
2735 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
2736 (setq thread (gnus-gethash last-id dep)))
2739 thread ; We return this thread.
2741 (if (stringp (car thread))
2743 ;; If we use dummy roots, then we have to remove the
2744 ;; dummy root as well.
2745 (when (eq gnus-summary-make-false-root 'dummy)
2748 (setq thread (cdr thread))
2750 (gnus-remove-thread-1 (car thread))
2751 (setq thread (cdr thread))))
2752 (gnus-remove-thread-1 thread))))))))
2754 (defun gnus-remove-thread-1 (thread)
2755 "Remove the thread THREAD recursively."
2756 (let ((number (mail-header-number (car thread)))
2758 (when (setq pos (text-property-any
2759 (point-min) (point-max) 'gnus-number number))
2762 (gnus-data-remove number))
2763 (setq thread (cdr thread))
2765 (gnus-remove-thread-1 (pop thread)))))
2767 (defun gnus-sort-threads (threads)
2769 (if (not gnus-thread-sort-functions)
2771 (let ((func (if (= 1 (length gnus-thread-sort-functions))
2772 (car gnus-thread-sort-functions)
2774 ,(gnus-make-sort-function
2775 (reverse gnus-thread-sort-functions))))))
2776 (gnus-message 7 "Sorting threads...")
2779 (gnus-message 7 "Sorting threads...done")))))
2781 (defun gnus-sort-articles (articles)
2783 (when gnus-article-sort-functions
2784 (let ((func (if (= 1 (length gnus-article-sort-functions))
2785 (car gnus-article-sort-functions)
2787 ,(gnus-make-sort-function
2788 (reverse gnus-article-sort-functions))))))
2789 (gnus-message 7 "Sorting articles...")
2791 (setq gnus-newsgroup-headers (sort articles func))
2792 (gnus-message 7 "Sorting articles...done")))))
2794 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
2795 (defmacro gnus-thread-header (thread)
2796 ;; Return header of first article in THREAD.
2797 ;; Note that THREAD must never, ever be anything else than a variable -
2798 ;; using some other form will lead to serious barfage.
2799 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
2800 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
2801 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
2804 (defsubst gnus-article-sort-by-number (h1 h2)
2805 "Sort articles by article number."
2806 (< (mail-header-number h1)
2807 (mail-header-number h2)))
2809 (defun gnus-thread-sort-by-number (h1 h2)
2810 "Sort threads by root article number."
2811 (gnus-article-sort-by-number
2812 (gnus-thread-header h1) (gnus-thread-header h2)))
2814 (defsubst gnus-article-sort-by-author (h1 h2)
2815 "Sort articles by root author."
2817 (let ((extract (funcall
2818 gnus-extract-address-components
2819 (mail-header-from h1))))
2820 (or (car extract) (cdr extract)))
2821 (let ((extract (funcall
2822 gnus-extract-address-components
2823 (mail-header-from h2))))
2824 (or (car extract) (cdr extract)))))
2826 (defun gnus-thread-sort-by-author (h1 h2)
2827 "Sort threads by root author."
2828 (gnus-article-sort-by-author
2829 (gnus-thread-header h1) (gnus-thread-header h2)))
2831 (defsubst gnus-article-sort-by-subject (h1 h2)
2832 "Sort articles by root subject."
2834 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
2835 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
2837 (defun gnus-thread-sort-by-subject (h1 h2)
2838 "Sort threads by root subject."
2839 (gnus-article-sort-by-subject
2840 (gnus-thread-header h1) (gnus-thread-header h2)))
2842 (defsubst gnus-article-sort-by-date (h1 h2)
2843 "Sort articles by root article date."
2845 (inline (gnus-sortable-date (mail-header-date h1)))
2846 (inline (gnus-sortable-date (mail-header-date h2)))))
2848 (defun gnus-thread-sort-by-date (h1 h2)
2849 "Sort threads by root article date."
2850 (gnus-article-sort-by-date
2851 (gnus-thread-header h1) (gnus-thread-header h2)))
2853 (defsubst gnus-article-sort-by-score (h1 h2)
2854 "Sort articles by root article score.
2855 Unscored articles will be counted as having a score of zero."
2856 (> (or (cdr (assq (mail-header-number h1)
2857 gnus-newsgroup-scored))
2858 gnus-summary-default-score 0)
2859 (or (cdr (assq (mail-header-number h2)
2860 gnus-newsgroup-scored))
2861 gnus-summary-default-score 0)))
2863 (defun gnus-thread-sort-by-score (h1 h2)
2864 "Sort threads by root article score."
2865 (gnus-article-sort-by-score
2866 (gnus-thread-header h1) (gnus-thread-header h2)))
2868 (defun gnus-thread-sort-by-total-score (h1 h2)
2869 "Sort threads by the sum of all scores in the thread.
2870 Unscored articles will be counted as having a score of zero."
2871 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
2873 (defun gnus-thread-total-score (thread)
2874 ;; This function find the total score of THREAD.
2875 (cond ((null thread)
2878 (if (stringp (car thread))
2879 (apply gnus-thread-score-function 0
2880 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
2881 (gnus-thread-total-score-1 thread)))
2883 (gnus-thread-total-score-1 (list thread)))))
2885 (defun gnus-thread-total-score-1 (root)
2886 ;; This function find the total score of the thread below ROOT.
2887 (setq root (car root))
2888 (apply gnus-thread-score-function
2890 (mapcar 'gnus-thread-total-score
2891 (cdr (gnus-gethash (mail-header-id root)
2892 gnus-newsgroup-dependencies)))
2893 (if (> (mail-header-number root) 0)
2894 (list (or (cdr (assq (mail-header-number root)
2895 gnus-newsgroup-scored))
2896 gnus-summary-default-score 0))))
2897 (list gnus-summary-default-score)
2900 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
2901 (defvar gnus-tmp-prev-subject nil)
2902 (defvar gnus-tmp-false-parent nil)
2903 (defvar gnus-tmp-root-expunged nil)
2904 (defvar gnus-tmp-dummy-line nil)
2906 (defun gnus-summary-prepare-threads (threads)
2907 "Prepare summary buffer from THREADS and indentation LEVEL.
2908 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
2909 or a straight list of headers."
2910 (gnus-message 7 "Generating summary...")
2912 (setq gnus-newsgroup-threads threads)
2915 (let ((gnus-tmp-level 0)
2916 (default-score (or gnus-summary-default-score 0))
2917 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
2918 thread number subject stack state gnus-tmp-gathered beg-match
2919 new-roots gnus-tmp-new-adopts thread-end
2920 gnus-tmp-header gnus-tmp-unread
2921 gnus-tmp-replied gnus-tmp-subject-or-nil
2922 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
2923 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
2924 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
2926 (setq gnus-tmp-prev-subject nil)
2928 (if (vectorp (car threads))
2929 ;; If this is a straight (sic) list of headers, then a
2930 ;; threaded summary display isn't required, so we just create
2931 ;; an unthreaded one.
2932 (gnus-summary-prepare-unthreaded threads)
2934 ;; Do the threaded display.
2936 (while (or threads stack gnus-tmp-new-adopts new-roots)
2938 (if (and (= gnus-tmp-level 0)
2939 (not (setq gnus-tmp-dummy-line nil))
2942 (not gnus-tmp-false-parent)
2943 (or gnus-tmp-new-adopts new-roots))
2944 (if gnus-tmp-new-adopts
2945 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
2946 thread (list (car gnus-tmp-new-adopts))
2947 gnus-tmp-header (caar thread)
2948 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
2950 (setq thread (list (car new-roots))
2951 gnus-tmp-header (caar thread)
2952 new-roots (cdr new-roots))))
2955 ;; If there are some threads, we do them before the
2956 ;; threads on the stack.
2957 (setq thread threads
2958 gnus-tmp-header (caar thread))
2959 ;; There were no current threads, so we pop something off
2961 (setq state (car stack)
2962 gnus-tmp-level (car state)
2965 gnus-tmp-header (caar thread))))
2967 (setq gnus-tmp-false-parent nil)
2968 (setq gnus-tmp-root-expunged nil)
2969 (setq thread-end nil)
2971 (if (stringp gnus-tmp-header)
2972 ;; The header is a dummy root.
2974 ((eq gnus-summary-make-false-root 'adopt)
2975 ;; We let the first article adopt the rest.
2976 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
2978 (setq gnus-tmp-gathered
2980 (lambda (h) (mail-header-number (car h)))
2983 (setq thread (cons (list (caar thread)
2986 (setq gnus-tmp-level -1
2987 gnus-tmp-false-parent t))
2988 ((eq gnus-summary-make-false-root 'empty)
2989 ;; We print adopted articles with empty subject fields.
2990 (setq gnus-tmp-gathered
2992 (lambda (h) (mail-header-number (car h)))
2995 (setq gnus-tmp-level -1))
2996 ((eq gnus-summary-make-false-root 'dummy)
2997 ;; We remember that we probably want to output a dummy
2999 (setq gnus-tmp-dummy-line gnus-tmp-header)
3000 (setq gnus-tmp-prev-subject gnus-tmp-header))
3002 ;; We do not make a root for the gathered
3003 ;; sub-threads at all.
3004 (setq gnus-tmp-level -1)))
3006 (setq number (mail-header-number gnus-tmp-header)
3007 subject (mail-header-subject gnus-tmp-header))
3010 ;; If the thread has changed subject, we might want to make
3011 ;; this subthread into a root.
3012 ((and (null gnus-thread-ignore-subject)
3013 (not (zerop gnus-tmp-level))
3014 gnus-tmp-prev-subject
3016 (gnus-subject-equal gnus-tmp-prev-subject subject))))
3017 (setq new-roots (nconc new-roots (list (car thread)))
3019 gnus-tmp-header nil))
3020 ;; If the article lies outside the current limit,
3021 ;; then we do not display it.
3022 ((and (not (memq number gnus-newsgroup-limit))
3023 (not gnus-tmp-dummy-line))
3024 (setq gnus-tmp-gathered
3026 (lambda (h) (mail-header-number (car h)))
3029 (setq gnus-tmp-new-adopts (if (cdar thread)
3030 (append gnus-tmp-new-adopts
3032 gnus-tmp-new-adopts)
3034 gnus-tmp-header nil)
3035 (when (zerop gnus-tmp-level)
3036 (setq gnus-tmp-root-expunged t)))
3037 ;; Perhaps this article is to be marked as read?
3038 ((and gnus-summary-mark-below
3039 (< (or (cdr (assq number gnus-newsgroup-scored))
3041 gnus-summary-mark-below)
3042 ;; Don't touch sparse articles.
3043 (not (memq number gnus-newsgroup-sparse))
3044 (not (memq number gnus-newsgroup-ancient)))
3045 (setq gnus-newsgroup-unreads
3046 (delq number gnus-newsgroup-unreads))
3047 (if gnus-newsgroup-auto-expire
3048 (push number gnus-newsgroup-expirable)
3049 (push (cons number gnus-low-score-mark)
3050 gnus-newsgroup-reads))))
3052 (when gnus-tmp-header
3053 ;; We may have an old dummy line to output before this
3055 (when gnus-tmp-dummy-line
3056 (gnus-summary-insert-dummy-line
3057 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
3058 (setq gnus-tmp-dummy-line nil))
3060 ;; Compute the mark.
3061 (setq gnus-tmp-unread (gnus-article-mark number))
3063 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
3064 gnus-tmp-header gnus-tmp-level)
3065 gnus-newsgroup-data)
3067 ;; Actually insert the line.
3069 gnus-tmp-subject-or-nil
3071 ((and gnus-thread-ignore-subject
3072 gnus-tmp-prev-subject
3073 (not (inline (gnus-subject-equal
3074 gnus-tmp-prev-subject subject))))
3076 ((zerop gnus-tmp-level)
3077 (if (and (eq gnus-summary-make-false-root 'empty)
3078 (memq number gnus-tmp-gathered)
3079 gnus-tmp-prev-subject
3080 (inline (gnus-subject-equal
3081 gnus-tmp-prev-subject subject)))
3082 gnus-summary-same-subject
3084 (t gnus-summary-same-subject)))
3085 (if (and (eq gnus-summary-make-false-root 'adopt)
3086 (= gnus-tmp-level 1)
3087 (memq number gnus-tmp-gathered))
3088 (setq gnus-tmp-opening-bracket ?\<
3089 gnus-tmp-closing-bracket ?\>)
3090 (setq gnus-tmp-opening-bracket ?\[
3091 gnus-tmp-closing-bracket ?\]))
3093 gnus-tmp-indentation
3094 (aref gnus-thread-indent-array gnus-tmp-level)
3095 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
3096 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
3097 gnus-summary-default-score 0)
3099 (if (or (null gnus-summary-default-score)
3100 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3101 gnus-summary-zcore-fuzz)) ?
3102 (if (< gnus-tmp-score gnus-summary-default-score)
3103 gnus-score-below-mark gnus-score-over-mark))
3105 (cond ((memq number gnus-newsgroup-processable)
3107 ((memq number gnus-newsgroup-cached)
3109 ((memq number gnus-newsgroup-replied)
3111 ((memq number gnus-newsgroup-saved)
3113 (t gnus-unread-mark))
3114 gnus-tmp-from (mail-header-from gnus-tmp-header)
3117 ((string-match "(.+)" gnus-tmp-from)
3118 (substring gnus-tmp-from
3119 (1+ (match-beginning 0)) (1- (match-end 0))))
3120 ((string-match "<[^>]+> *$" gnus-tmp-from)
3121 (setq beg-match (match-beginning 0))
3122 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
3123 (substring gnus-tmp-from (1+ (match-beginning 0))
3124 (1- (match-end 0))))
3125 (substring gnus-tmp-from 0 beg-match)))
3127 (when (string= gnus-tmp-name "")
3128 (setq gnus-tmp-name gnus-tmp-from))
3129 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
3130 (gnus-put-text-property
3132 (progn (eval gnus-summary-line-format-spec) (point))
3133 'gnus-number number)
3136 (run-hooks 'gnus-summary-update-hook)
3139 (setq gnus-tmp-prev-subject subject)))
3141 (when (nth 1 thread)
3142 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
3143 (incf gnus-tmp-level)
3144 (setq threads (if thread-end nil (cdar thread)))
3146 (setq gnus-tmp-level 0)))))
3147 (gnus-message 7 "Generating summary...done"))
3149 (defun gnus-summary-prepare-unthreaded (headers)
3150 "Generate an unthreaded summary buffer based on HEADERS."
3151 (let (header number mark)
3154 ;; We may have to root out some bad articles...
3155 (when (memq (setq number (mail-header-number
3156 (setq header (pop headers))))
3157 gnus-newsgroup-limit)
3158 ;; Mark article as read when it has a low score.
3159 (when (and gnus-summary-mark-below
3160 (< (or (cdr (assq number gnus-newsgroup-scored))
3161 gnus-summary-default-score 0)
3162 gnus-summary-mark-below)
3163 (not (memq number gnus-newsgroup-ancient)))
3164 (setq gnus-newsgroup-unreads
3165 (delq number gnus-newsgroup-unreads))
3166 (if gnus-newsgroup-auto-expire
3167 (push number gnus-newsgroup-expirable)
3168 (push (cons number gnus-low-score-mark)
3169 gnus-newsgroup-reads)))
3171 (setq mark (gnus-article-mark number))
3172 (setq gnus-newsgroup-data
3173 (cons (gnus-data-make number mark (1+ (point)) header 0)
3174 gnus-newsgroup-data))
3175 (gnus-summary-insert-line
3176 header 0 nil mark (memq number gnus-newsgroup-replied)
3177 (memq number gnus-newsgroup-expirable)
3178 (mail-header-subject header) nil
3179 (cdr (assq number gnus-newsgroup-scored))
3180 (memq number gnus-newsgroup-processable))))))
3182 (defun gnus-select-newsgroup (group &optional read-all)
3183 "Select newsgroup GROUP.
3184 If READ-ALL is non-nil, all articles in the group are selected."
3185 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
3186 (info (nth 2 entry))
3187 articles fetched-articles cached)
3189 (or (gnus-check-server
3190 (setq gnus-current-select-method (gnus-find-method-for-group group)))
3191 (error "Couldn't open server"))
3193 (or (and entry (not (eq (car entry) t))) ; Either it's active...
3194 (gnus-activate-group group) ; Or we can activate it...
3195 (progn ; Or we bug out.
3196 (when (equal major-mode 'gnus-summary-mode)
3197 (kill-buffer (current-buffer)))
3198 (error "Couldn't request group %s: %s"
3199 group (gnus-status-message group))))
3201 (unless (gnus-request-group group t)
3202 (when (equal major-mode 'gnus-summary-mode)
3203 (kill-buffer (current-buffer)))
3204 (error "Couldn't request group %s: %s"
3205 group (gnus-status-message group)))
3207 (setq gnus-newsgroup-name group)
3208 (setq gnus-newsgroup-unselected nil)
3209 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
3211 ;; Adjust and set lists of article marks.
3213 (gnus-adjust-marked-articles info))
3215 ;; Kludge to avoid having cached articles nixed out in virtual groups.
3216 (when (gnus-virtual-group-p group)
3217 (setq cached gnus-newsgroup-cached))
3219 (setq gnus-newsgroup-unreads
3220 (gnus-set-difference
3221 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
3222 gnus-newsgroup-dormant))
3224 (setq gnus-newsgroup-processable nil)
3226 (setq articles (gnus-articles-to-read group read-all))
3230 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
3232 ((eq articles 0) nil)
3234 ;; Init the dependencies hash table.
3235 (setq gnus-newsgroup-dependencies
3236 (gnus-make-hashtable (length articles)))
3237 ;; Retrieve the headers and read them in.
3238 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
3239 (setq gnus-newsgroup-headers
3241 (setq gnus-headers-retrieved-by
3242 (gnus-retrieve-headers
3243 articles gnus-newsgroup-name
3244 ;; We might want to fetch old headers, but
3245 ;; not if there is only 1 article.
3246 (and gnus-fetch-old-headers
3248 (not (eq gnus-fetch-old-headers 'some))
3249 (not (numberp gnus-fetch-old-headers)))
3250 (> (length articles) 1))))))
3251 (gnus-get-newsgroup-headers-xover articles)
3252 (gnus-get-newsgroup-headers)))
3253 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
3255 ;; Kludge to avoid having cached articles nixed out in virtual groups.
3257 (setq gnus-newsgroup-cached cached))
3259 ;; Suppress duplicates?
3260 (when gnus-suppress-duplicates
3261 (gnus-dup-suppress-articles))
3263 ;; Set the initial limit.
3264 (setq gnus-newsgroup-limit (copy-sequence articles))
3265 ;; Remove canceled articles from the list of unread articles.
3266 (setq gnus-newsgroup-unreads
3267 (gnus-set-sorted-intersection
3268 gnus-newsgroup-unreads
3269 (setq fetched-articles
3270 (mapcar (lambda (headers) (mail-header-number headers))
3271 gnus-newsgroup-headers))))
3272 ;; Removed marked articles that do not exist.
3273 (gnus-update-missing-marks
3274 (gnus-sorted-complement fetched-articles articles))
3275 ;; We might want to build some more threads first.
3276 (and gnus-fetch-old-headers
3277 (eq gnus-headers-retrieved-by 'nov)
3278 (gnus-build-old-threads))
3279 ;; Check whether auto-expire is to be done in this group.
3280 (setq gnus-newsgroup-auto-expire
3281 (gnus-group-auto-expirable-p group))
3282 ;; Set up the article buffer now, if necessary.
3283 (unless gnus-single-article-buffer
3284 (gnus-article-setup-buffer))
3285 ;; First and last article in this newsgroup.
3286 (when gnus-newsgroup-headers
3287 (setq gnus-newsgroup-begin
3288 (mail-header-number (car gnus-newsgroup-headers))
3291 (gnus-last-element gnus-newsgroup-headers))))
3292 ;; GROUP is successfully selected.
3293 (or gnus-newsgroup-headers t)))))
3295 (defun gnus-articles-to-read (group read-all)
3296 ;; Find out what articles the user wants to read.
3298 ;; Select all articles if `read-all' is non-nil, or if there
3299 ;; are no unread articles.
3301 (and (zerop (length gnus-newsgroup-marked))
3302 (zerop (length gnus-newsgroup-unreads)))
3303 (eq (gnus-group-find-parameter group 'display)
3305 (gnus-uncompress-range (gnus-active group))
3306 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
3307 (copy-sequence gnus-newsgroup-unreads))
3309 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
3310 (scored (length scored-list))
3311 (number (length articles))
3312 (marked (+ (length gnus-newsgroup-marked)
3313 (length gnus-newsgroup-dormant)))
3321 ((and (or (<= scored marked) (= scored number))
3322 (numberp gnus-large-newsgroup)
3323 (> number gnus-large-newsgroup))
3327 "How many articles from %s (default %d): "
3328 gnus-newsgroup-name number))))
3329 (if (string-match "^[ \t]*$" input) number input)))
3330 ((and (> scored marked) (< scored number)
3331 (> (- scored number) 20))
3334 (format "%s %s (%d scored, %d total): "
3335 "How many articles from"
3336 group scored number))))
3337 (if (string-match "^[ \t]*$" input)
3341 (setq select (if (stringp select) (string-to-number select) select))
3342 (if (or (null select) (zerop select))
3344 (if (and (not (zerop scored)) (<= (abs select) scored))
3346 (setq articles (sort scored-list '<))
3347 (setq number (length articles)))
3348 (setq articles (copy-sequence articles)))
3350 (if (< (abs select) number)
3352 ;; Select the N oldest articles.
3353 (setcdr (nthcdr (1- (abs select)) articles) nil)
3354 ;; Select the N most recent articles.
3355 (setq articles (nthcdr (- number select) articles))))
3356 (setq gnus-newsgroup-unselected
3357 (gnus-sorted-intersection
3358 gnus-newsgroup-unreads
3359 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
3362 (defun gnus-killed-articles (killed articles)
3365 (if (inline (gnus-member-of-range (car articles) killed))
3366 (setq out (cons (car articles) out)))
3367 (setq articles (cdr articles)))
3370 (defun gnus-uncompress-marks (marks)
3371 "Uncompress the mark ranges in MARKS."
3372 (let ((uncompressed '(score bookmark))
3375 (if (memq (caar marks) uncompressed)
3376 (push (car marks) out)
3377 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
3378 (setq marks (cdr marks)))
3381 (defun gnus-adjust-marked-articles (info)
3382 "Set all article lists and remove all marks that are no longer legal."
3383 (let* ((marked-lists (gnus-info-marks info))
3384 (active (gnus-active (gnus-info-group info)))
3387 (types gnus-article-mark-lists)
3388 (uncompressed '(score bookmark killed))
3389 marks var articles article mark)
3392 (setq marks (pop marked-lists))
3393 (set (setq var (intern (format "gnus-newsgroup-%s"
3394 (car (rassq (setq mark (car marks))
3396 (if (memq (car marks) uncompressed) (cdr marks)
3397 (gnus-uncompress-range (cdr marks))))
3399 (setq articles (symbol-value var))
3401 ;; All articles have to be subsets of the active articles.
3403 ;; Adjust "simple" lists.
3404 ((memq mark '(tick dormant expirable reply save))
3406 (when (or (< (setq article (pop articles)) min) (> article max))
3407 (set var (delq article (symbol-value var))))))
3409 ((memq mark uncompressed)
3411 (when (or (not (consp (setq article (pop articles))))
3412 (< (car article) min)
3413 (> (car article) max))
3414 (set var (delq article (symbol-value var))))))))))
3416 (defun gnus-update-missing-marks (missing)
3417 "Go through the list of MISSING articles and remove them mark lists."
3419 (let ((types gnus-article-mark-lists)
3421 ;; Go through all types.
3423 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
3424 (when (symbol-value var)
3425 ;; This list has articles. So we delete all missing articles
3429 (set var (delq (pop m) (symbol-value var)))))))))
3431 (defun gnus-update-marks ()
3432 "Enter the various lists of marked articles into the newsgroup info list."
3433 (let ((types gnus-article-mark-lists)
3434 (info (gnus-get-info gnus-newsgroup-name))
3435 (uncompressed '(score bookmark killed))
3436 type list newmarked symbol)
3438 ;; Add all marks lists that are non-nil to the list of marks lists.
3440 (setq type (pop types))
3441 (when (setq list (symbol-value
3443 (intern (format "gnus-newsgroup-%s"
3445 (push (cons (cdr type)
3446 (if (memq (cdr type) uncompressed) list
3447 (gnus-compress-sequence
3448 (set symbol (sort list '<)) t)))
3451 ;; Enter these new marks into the info of the group.
3453 (setcar (nthcdr 3 info) newmarked)
3454 ;; Add the marks lists to the end of the info.
3456 (setcdr (nthcdr 2 info) (list newmarked))))
3458 ;; Cut off the end of the info if there's nothing else there.
3462 (when (nthcdr (decf i) info)
3463 (setcdr (nthcdr i info) nil)))))))
3465 (defun gnus-set-mode-line (where)
3466 "This function sets the mode line of the article or summary buffers.
3467 If WHERE is `summary', the summary mode line format will be used."
3468 ;; Is this mode line one we keep updated?
3469 (when (memq where gnus-updated-mode-lines)
3472 ;; We evaluate this in the summary buffer since these
3473 ;; variables are buffer-local to that buffer.
3474 (set-buffer gnus-summary-buffer)
3475 ;; We bind all these variables that are used in the `eval' form
3477 (let* ((mformat (symbol-value
3479 (format "gnus-%s-mode-line-format-spec" where))))
3480 (gnus-tmp-group-name gnus-newsgroup-name)
3481 (gnus-tmp-article-number (or gnus-current-article 0))
3482 (gnus-tmp-unread gnus-newsgroup-unreads)
3483 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
3484 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
3485 (gnus-tmp-unread-and-unselected
3486 (cond ((and (zerop gnus-tmp-unread-and-unticked)
3487 (zerop gnus-tmp-unselected)) "")
3488 ((zerop gnus-tmp-unselected)
3489 (format "{%d more}" gnus-tmp-unread-and-unticked))
3490 (t (format "{%d(+%d) more}"
3491 gnus-tmp-unread-and-unticked
3492 gnus-tmp-unselected))))
3494 (if (and gnus-current-headers
3495 (vectorp gnus-current-headers))
3496 (gnus-mode-string-quote
3497 (mail-header-subject gnus-current-headers)) ""))
3499 gnus-tmp-header);; passed as argument to any user-format-funcs
3500 (setq mode-string (eval mformat))
3501 (setq max-len (max 4 (if gnus-mode-non-string-length
3503 gnus-mode-non-string-length)
3504 (length mode-string))))
3505 ;; We might have to chop a bit of the string off...
3506 (when (> (length mode-string) max-len)
3508 (concat (gnus-truncate-string mode-string (- max-len 3))
3510 ;; Pad the mode string a bit.
3511 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
3512 ;; Update the mode line.
3513 (setq mode-line-buffer-identification
3514 (gnus-mode-line-buffer-identification
3515 (list mode-string)))
3516 (set-buffer-modified-p t))))
3518 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
3519 "Go through the HEADERS list and add all Xrefs to a hash table.
3520 The resulting hash table is returned, or nil if no Xrefs were found."
3521 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
3522 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
3523 (xref-hashtb (make-vector 63 0))
3524 start group entry number xrefs header)
3526 (setq header (pop headers))
3527 (when (and (setq xrefs (mail-header-xref header))
3528 (not (memq (setq number (mail-header-number header))
3531 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
3532 (setq start (match-end 0))
3533 (setq group (if prefix
3534 (concat prefix (substring xrefs (match-beginning 1)
3536 (substring xrefs (match-beginning 1) (match-end 1))))
3538 (string-to-int (substring xrefs (match-beginning 2)
3540 (if (setq entry (gnus-gethash group xref-hashtb))
3541 (setcdr entry (cons number (cdr entry)))
3542 (gnus-sethash group (cons number nil) xref-hashtb)))))
3543 (and start xref-hashtb)))
3545 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
3546 "Look through all the headers and mark the Xrefs as read."
3547 (let ((virtual (gnus-virtual-group-p from-newsgroup))
3548 name entry info xref-hashtb idlist method nth4)
3550 (set-buffer gnus-group-buffer)
3551 (when (setq xref-hashtb
3552 (gnus-create-xref-hashtb from-newsgroup headers unreads))
3555 (unless (string= from-newsgroup (setq name (symbol-name group)))
3556 (setq idlist (symbol-value group))
3557 ;; Dead groups are not updated.
3559 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
3561 (if (stringp (setq nth4 (gnus-info-method info)))
3562 (setq nth4 (gnus-server-to-method nth4))))
3563 ;; Only do the xrefs if the group has the same
3564 ;; select method as the group we have just read.
3565 (or (gnus-methods-equal-p
3566 nth4 (gnus-find-method-for-group from-newsgroup))
3568 (equal nth4 (setq method (gnus-find-method-for-group
3570 (and (equal (car nth4) (car method))
3571 (equal (nth 1 nth4) (nth 1 method))))
3572 gnus-use-cross-reference
3573 (or (not (eq gnus-use-cross-reference t))
3575 ;; Only do cross-references on subscribed
3576 ;; groups, if that is what is wanted.
3577 (<= (gnus-info-level info) gnus-level-subscribed))
3578 (gnus-group-make-articles-read name idlist))))
3581 (defun gnus-group-make-articles-read (group articles)
3582 "Update the info of GROUP to say that only ARTICLES are unread."
3584 (entry (gnus-gethash group gnus-newsrc-hashtb))
3585 (info (nth 2 entry))
3586 (active (gnus-active group))
3588 ;; First peel off all illegal article numbers.
3590 (let ((ids articles)
3592 (while (setq id (pop ids))
3593 (when (and first (> id (cdr active)))
3594 ;; We'll end up in this situation in one particular
3595 ;; obscure situation. If you re-scan a group and get
3596 ;; a new article that is cross-posted to a different
3597 ;; group that has not been re-scanned, you might get
3598 ;; crossposted article that has a higher number than
3599 ;; Gnus believes possible. So we re-activate this
3600 ;; group as well. This might mean doing the
3601 ;; crossposting thingy will *increase* the number
3602 ;; of articles in some groups. Tsk, tsk.
3603 (setq active (or (gnus-activate-group group) active)))
3604 (when (or (> id (cdr active))
3605 (< id (car active)))
3606 (setq articles (delq id articles))))))
3609 (gnus-info-set-marks ,info ,(gnus-info-marks info))
3610 (gnus-info-set-read ,info ,(gnus-info-read info))
3611 (gnus-group-update-group group t)))
3612 ;; If the read list is nil, we init it.
3614 (null (gnus-info-read info))
3616 (gnus-info-set-read info (cons 1 (1- (car active)))))
3617 ;; Then we add the read articles to the range.
3622 (gnus-info-read info) (setq articles (sort articles '<)))))
3623 ;; Then we have to re-compute how many unread
3624 ;; articles there are in this group.
3628 (setq num (- (1+ (cdr active)) (car active))))
3629 ((not (listp (cdr range)))
3630 (setq num (- (cdr active) (- (1+ (cdr range))
3634 (if (numberp (car range))
3636 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
3637 (setq range (cdr range)))
3638 (setq num (- (cdr active) num))))
3639 ;; Update the number of unread articles.
3641 ;; Update the group buffer.
3642 (gnus-group-update-group group t))))
3644 (defun gnus-methods-equal-p (m1 m2)
3645 (let ((m1 (or m1 gnus-select-method))
3646 (m2 (or m2 gnus-select-method)))
3648 (and (eq (car m1) (car m2))
3649 (or (not (memq 'address (assoc (symbol-name (car m1))
3650 gnus-valid-select-methods)))
3651 (equal (nth 1 m1) (nth 1 m2)))))))
3653 (defsubst gnus-header-value ()
3654 (buffer-substring (match-end 0) (gnus-point-at-eol)))
3656 (defvar gnus-newsgroup-none-id 0)
3658 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
3659 (let ((cur nntp-server-buffer)
3662 (save-excursion (set-buffer gnus-summary-buffer)
3663 gnus-newsgroup-dependencies)))
3664 headers id id-dep ref-dep end ref)
3666 (set-buffer nntp-server-buffer)
3667 (run-hooks 'gnus-parse-headers-hook)
3668 (let ((case-fold-search t)
3669 in-reply-to header p lines)
3670 (goto-char (point-min))
3671 ;; Search to the beginning of the next header. Error messages
3672 ;; do not begin with 2 or 3.
3673 (while (re-search-forward "^[23][0-9]+ " nil t)
3676 ;; This implementation of this function, with nine
3677 ;; search-forwards instead of the one re-search-forward and
3678 ;; a case (which basically was the old function) is actually
3679 ;; about twice as fast, even though it looks messier. You
3680 ;; can't have everything, I guess. Speed and elegance
3681 ;; doesn't always go hand in hand.
3690 (narrow-to-region (point)
3691 (or (and (search-forward "\n.\n" nil t)
3697 (if (search-forward "\nsubject: " nil t)
3698 (gnus-header-value) "(none)"))
3702 (if (search-forward "\nfrom: " nil t)
3703 (gnus-header-value) "(nobody)"))
3707 (if (search-forward "\ndate: " nil t)
3708 (gnus-header-value) ""))
3712 (if (search-forward "\nmessage-id: " nil t)
3713 (setq id (gnus-header-value))
3714 ;; If there was no message-id, we just fake one to make
3715 ;; subsequent routines simpler.
3716 (setq id (concat "none+"
3718 (setq gnus-newsgroup-none-id
3719 (1+ gnus-newsgroup-none-id)))))))
3723 (if (search-forward "\nreferences: " nil t)
3732 (search-backward ">" end t)
3735 (search-backward "<" end t)
3737 ;; Get the references from the in-reply-to header if there
3738 ;; were no references and the in-reply-to header looks
3740 (if (and (search-forward "\nin-reply-to: " nil t)
3741 (setq in-reply-to (gnus-header-value))
3742 (string-match "<[^>]+>" in-reply-to))
3743 (setq ref (substring in-reply-to (match-beginning 0)
3751 (if (search-forward "\nlines: " nil t)
3752 (if (numberp (setq lines (read cur)))
3758 (and (search-forward "\nxref: " nil t)
3759 (gnus-header-value)))))
3760 ;; We do the threading while we read the headers. The
3761 ;; message-id and the last reference are both entered into
3762 ;; the same hash table. Some tippy-toeing around has to be
3763 ;; done in case an article has arrived before the article
3764 ;; which it refers to.
3765 (if (boundp (setq id-dep (intern id dependencies)))
3766 (if (and (car (symbol-value id-dep))
3768 ;; An article with this Message-ID has already
3769 ;; been seen, so we ignore this one, except we add
3770 ;; any additional Xrefs (in case the two articles
3771 ;; came from different servers).
3773 (mail-header-set-xref
3774 (car (symbol-value id-dep))
3775 (concat (or (mail-header-xref
3776 (car (symbol-value id-dep))) "")
3777 (or (mail-header-xref header) "")))
3779 (setcar (symbol-value id-dep) header))
3780 (set id-dep (list header)))
3782 (if (boundp (setq ref-dep (intern ref dependencies)))
3783 (setcdr (symbol-value ref-dep)
3784 (nconc (cdr (symbol-value ref-dep))
3785 (list (symbol-value id-dep))))
3786 (set ref-dep (list nil (symbol-value id-dep))))
3787 (setq headers (cons header headers)))
3788 (goto-char (point-max))
3790 (nreverse headers)))))
3792 ;; The following macros and functions were written by Felix Lee
3793 ;; <flee@cse.psu.edu>.
3795 (defmacro gnus-nov-read-integer ()
3797 (if (= (following-char) ?\t)
3799 (let ((num (condition-case nil (read buffer) (error nil))))
3800 (if (numberp num) num 0)))
3801 (or (eobp) (forward-char 1))))
3803 (defmacro gnus-nov-skip-field ()
3804 '(search-forward "\t" eol 'move))
3806 (defmacro gnus-nov-field ()
3807 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
3809 ;; Goes through the xover lines and returns a list of vectors
3810 (defun gnus-get-newsgroup-headers-xover (sequence &optional
3811 force-new dependencies)
3812 "Parse the news overview data in the server buffer, and return a
3813 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
3814 ;; Get the Xref when the users reads the articles since most/some
3815 ;; NNTP servers do not include Xrefs when using XOVER.
3816 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
3817 (let ((cur nntp-server-buffer)
3818 (dependencies (or dependencies gnus-newsgroup-dependencies))
3819 number headers header)
3821 (set-buffer nntp-server-buffer)
3822 ;; Allow the user to mangle the headers before parsing them.
3823 (run-hooks 'gnus-parse-headers-hook)
3824 (goto-char (point-min))
3825 (while (and sequence (not (eobp)))
3826 (setq number (read cur))
3827 (while (and sequence (< (car sequence) number))
3828 (setq sequence (cdr sequence)))
3830 (eq number (car sequence))
3832 (setq sequence (cdr sequence))
3834 (inline (gnus-nov-parse-line
3835 number dependencies force-new)))
3836 (setq headers (cons header headers)))))
3838 (setq headers (nreverse headers)))
3841 ;; This function has to be called with point after the article number
3842 ;; on the beginning of the line.
3843 (defun gnus-nov-parse-line (number dependencies &optional force-new)
3845 (eol (gnus-point-at-eol))
3846 (buffer (current-buffer))
3847 header ref id id-dep ref-dep)
3849 ;; overview: [num subject from date id refs chars lines misc]
3850 (narrow-to-region (point) eol)
3851 (or (eobp) (forward-char))
3857 (gnus-nov-field) ; subject
3858 (gnus-nov-field) ; from
3859 (gnus-nov-field) ; date
3860 (setq id (or (gnus-nov-field)
3863 (setq none (1+ none)))))) ; id
3866 (let ((beg (point)))
3867 (search-forward "\t" eol)
3868 (if (search-backward ">" beg t)
3872 (search-backward "<" beg t)))
3874 (gnus-nov-field)) ; refs
3875 (gnus-nov-read-integer) ; chars
3876 (gnus-nov-read-integer) ; lines
3877 (if (= (following-char) ?\n)
3879 (gnus-nov-field)) ; misc
3882 (gnus-error 4 "Strange nov line")
3888 ;; We build the thread tree.
3890 (if (boundp (setq id-dep (intern id dependencies)))
3891 (if (and (car (symbol-value id-dep))
3893 ;; An article with this Message-ID has already been seen,
3894 ;; so we ignore this one, except we add any additional
3895 ;; Xrefs (in case the two articles came from different
3898 (mail-header-set-xref
3899 (car (symbol-value id-dep))
3900 (concat (or (mail-header-xref
3901 (car (symbol-value id-dep))) "")
3902 (or (mail-header-xref header) "")))
3904 (setcar (symbol-value id-dep) header))
3905 (set id-dep (list header))))
3907 (if (boundp (setq ref-dep (intern (or ref "none") dependencies)))
3908 (setcdr (symbol-value ref-dep)
3909 (nconc (cdr (symbol-value ref-dep))
3910 (list (symbol-value id-dep))))
3911 (set ref-dep (list nil (symbol-value id-dep)))))
3914 (defun gnus-article-get-xrefs ()
3915 "Fill in the Xref value in `gnus-current-headers', if necessary.
3916 This is meant to be called in `gnus-article-internal-prepare-hook'."
3917 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
3918 gnus-current-headers)))
3919 (or (not gnus-use-cross-reference)
3921 (and (mail-header-xref headers)
3922 (not (string= (mail-header-xref headers) "")))
3923 (let ((case-fold-search t)
3926 (nnheader-narrow-to-headers)
3927 (goto-char (point-min))
3928 (if (or (and (eq (downcase (following-char)) ?x)
3929 (looking-at "Xref:"))
3930 (search-forward "\nXref:" nil t))
3932 (goto-char (1+ (match-end 0)))
3933 (setq xref (buffer-substring (point)
3934 (progn (end-of-line) (point))))
3935 (mail-header-set-xref headers xref))))))))
3937 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
3938 "Find article ID and insert the summary line for that article."
3939 (let ((header (if (and old-header use-old-header)
3940 old-header (gnus-read-header id)))
3941 (number (and (numberp id) id))
3944 ;; Rebuild the thread that this article is part of and go to the
3945 ;; article we have fetched.
3946 (when (and (not gnus-show-threads)
3948 (when (setq pos (text-property-any
3949 (point-min) (point-max) 'gnus-number
3950 (mail-header-number old-header)))
3953 (gnus-data-remove (mail-header-number old-header))))
3955 (mail-header-set-number header (mail-header-number old-header)))
3956 (setq gnus-newsgroup-sparse
3957 (delq (setq number (mail-header-number header))
3958 gnus-newsgroup-sparse))
3959 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
3960 (gnus-rebuild-thread (mail-header-id header))
3961 (gnus-summary-goto-subject number nil t))
3962 (when (and (numberp number)
3964 ;; We have to update the boundaries even if we can't fetch the
3965 ;; article if ID is a number -- so that the next `P' or `N'
3966 ;; command will fetch the previous (or next) article even
3967 ;; if the one we tried to fetch this time has been canceled.
3968 (and (> number gnus-newsgroup-end)
3969 (setq gnus-newsgroup-end number))
3970 (and (< number gnus-newsgroup-begin)
3971 (setq gnus-newsgroup-begin number))
3972 (setq gnus-newsgroup-unselected
3973 (delq number gnus-newsgroup-unselected)))
3974 ;; Report back a success?
3975 (and header (mail-header-number header))))
3977 ;;; Process/prefix in the summary buffer
3979 (defun gnus-summary-work-articles (n)
3980 "Return a list of articles to be worked upon. The prefix argument,
3981 the list of process marked articles, and the current article will be
3982 taken into consideration."
3985 ;; A numerical prefix has been given.
3986 (let ((backward (< n 0))
3987 (n (abs (prefix-numeric-value n)))
3992 (push (setq article (gnus-summary-article-number))
3995 (gnus-summary-find-prev nil article)
3996 (gnus-summary-find-next nil article)))
3998 (nreverse articles)))
3999 ((and (boundp 'transient-mark-mode)
4002 ;; Work on the region between point and mark.
4003 (let ((max (max (point) (mark)))
4006 (goto-char (min (point) (mark)))
4009 (push (setq article (gnus-summary-article-number)) articles)
4010 (gnus-summary-find-next nil article)
4012 (nreverse articles))))
4013 (gnus-newsgroup-processable
4014 ;; There are process-marked articles present.
4015 ;; Save current state.
4016 (gnus-summary-save-process-mark)
4018 (reverse gnus-newsgroup-processable))
4020 ;; Just return the current article.
4021 (list (gnus-summary-article-number)))))
4023 (defun gnus-summary-save-process-mark ()
4024 "Push the current set of process marked articles on the stack."
4026 (push (copy-sequence gnus-newsgroup-processable)
4027 gnus-newsgroup-process-stack))
4029 (defun gnus-summary-kill-process-mark ()
4030 "Push the current set of process marked articles on the stack and unmark."
4032 (gnus-summary-save-process-mark)
4033 (gnus-summary-unmark-all-processable))
4035 (defun gnus-summary-yank-process-mark ()
4036 "Pop the last process mark state off the stack and restore it."
4038 (unless gnus-newsgroup-process-stack
4039 (error "Empty mark stack"))
4040 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
4042 (defun gnus-summary-process-mark-set (set)
4043 "Make SET into the current process marked articles."
4044 (gnus-summary-unmark-all-processable)
4046 (gnus-summary-set-process-mark (pop set))))
4048 ;;; Searching and stuff
4050 (defun gnus-summary-search-group (&optional backward use-level)
4051 "Search for next unread newsgroup.
4052 If optional argument BACKWARD is non-nil, search backward instead."
4054 (set-buffer gnus-group-buffer)
4055 (if (gnus-group-search-forward
4056 backward nil (if use-level (gnus-group-group-level) nil))
4057 (gnus-group-group-name))))
4059 (defun gnus-summary-best-group (&optional exclude-group)
4060 "Find the name of the best unread group.
4061 If EXCLUDE-GROUP, do not go to this group."
4063 (set-buffer gnus-group-buffer)
4065 (gnus-group-best-unread-group exclude-group))))
4067 (defun gnus-summary-find-next (&optional unread article backward)
4068 (if backward (gnus-summary-find-prev)
4069 (let* ((dummy (gnus-summary-article-intangible-p))
4070 (article (or article (gnus-summary-article-number)))
4071 (arts (gnus-data-find-list article))
4073 (when (and (not dummy)
4074 (or (not gnus-summary-check-current)
4076 (not (gnus-data-unread-p (car arts)))))
4077 (setq arts (cdr arts)))
4082 (when (gnus-data-unread-p (car arts))
4083 (setq result (car arts)
4085 (setq arts (cdr arts)))
4088 (goto-char (gnus-data-pos result))
4089 (gnus-data-number result)))))
4091 (defun gnus-summary-find-prev (&optional unread article)
4092 (let* ((eobp (eobp))
4093 (article (or article (gnus-summary-article-number)))
4094 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
4096 (when (and (not eobp)
4097 (or (not gnus-summary-check-current)
4099 (not (gnus-data-unread-p (car arts)))))
4100 (setq arts (cdr arts)))
4105 (and (gnus-data-unread-p (car arts))
4106 (setq result (car arts)
4108 (setq arts (cdr arts)))
4112 (goto-char (gnus-data-pos result))
4113 (gnus-data-number result)))))
4115 (defun gnus-summary-find-subject (subject &optional unread backward article)
4116 (let* ((simp-subject (gnus-simplify-subject-fully subject))
4117 (article (or article (gnus-summary-article-number)))
4118 (articles (gnus-data-list backward))
4119 (arts (gnus-data-find-list article articles))
4121 (when (or (not gnus-summary-check-current)
4123 (not (gnus-data-unread-p (car arts))))
4124 (setq arts (cdr arts)))
4126 (and (or (not unread)
4127 (gnus-data-unread-p (car arts)))
4128 (vectorp (gnus-data-header (car arts)))
4130 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
4131 (setq result (car arts)
4133 (setq arts (cdr arts)))
4135 (goto-char (gnus-data-pos result))
4136 (gnus-data-number result))))
4138 (defun gnus-summary-search-forward (&optional unread subject backward)
4139 "Search forward for an article.
4140 If UNREAD, look for unread articles. If SUBJECT, look for
4141 articles with that subject. If BACKWARD, search backward instead."
4142 (cond (subject (gnus-summary-find-subject subject unread backward))
4143 (backward (gnus-summary-find-prev unread))
4144 (t (gnus-summary-find-next unread))))
4146 (defun gnus-recenter (&optional n)
4147 "Center point in window and redisplay frame.
4148 Also do horizontal recentering."
4150 (when (and gnus-auto-center-summary
4151 (not (eq gnus-auto-center-summary 'vertical)))
4152 (gnus-horizontal-recenter))
4155 (defun gnus-summary-recenter ()
4156 "Center point in the summary window.
4157 If `gnus-auto-center-summary' is nil, or the article buffer isn't
4158 displayed, no centering will be performed."
4159 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
4160 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
4161 (let* ((top (cond ((< (window-height) 4) 0)
4162 ((< (window-height) 7) 1)
4164 (height (1- (window-height)))
4165 (bottom (save-excursion (goto-char (point-max))
4166 (forward-line (- height))
4168 (window (get-buffer-window (current-buffer))))
4169 ;; The user has to want it.
4170 (when gnus-auto-center-summary
4171 (when (get-buffer-window gnus-article-buffer)
4172 ;; Only do recentering when the article buffer is displayed,
4173 ;; Set the window start to either `bottom', which is the biggest
4174 ;; possible valid number, or the second line from the top,
4175 ;; whichever is the least.
4177 window (min bottom (save-excursion
4178 (forward-line (- top)) (point)))))
4179 ;; Do horizontal recentering while we're at it.
4180 (when (and (get-buffer-window (current-buffer) t)
4181 (not (eq gnus-auto-center-summary 'vertical)))
4182 (let ((selected (selected-window)))
4183 (select-window (get-buffer-window (current-buffer) t))
4184 (gnus-summary-position-point)
4185 (gnus-horizontal-recenter)
4186 (select-window selected))))))
4188 (defun gnus-summary-jump-to-group (newsgroup)
4189 "Move point to NEWSGROUP in group mode buffer."
4190 ;; Keep update point of group mode buffer if visible.
4191 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
4192 (save-window-excursion
4193 ;; Take care of tree window mode.
4194 (if (get-buffer-window gnus-group-buffer)
4195 (pop-to-buffer gnus-group-buffer))
4196 (gnus-group-jump-to-group newsgroup))
4198 ;; Take care of tree window mode.
4199 (if (get-buffer-window gnus-group-buffer)
4200 (pop-to-buffer gnus-group-buffer)
4201 (set-buffer gnus-group-buffer))
4202 (gnus-group-jump-to-group newsgroup))))
4204 ;; This function returns a list of article numbers based on the
4205 ;; difference between the ranges of read articles in this group and
4206 ;; the range of active articles.
4207 (defun gnus-list-of-unread-articles (group)
4208 (let* ((read (gnus-info-read (gnus-get-info group)))
4209 (active (gnus-active group))
4212 ;; If none are read, then all are unread.
4214 (setq first (car active))
4215 ;; If the range of read articles is a single range, then the
4216 ;; first unread article is the article after the last read
4217 ;; article. Sounds logical, doesn't it?
4218 (if (not (listp (cdr read)))
4219 (setq first (1+ (cdr read)))
4220 ;; `read' is a list of ranges.
4221 (if (/= (setq nlast (or (and (numberp (car read)) (car read))
4226 (while (< first nlast)
4227 (setq unread (cons first unread))
4228 (setq first (1+ first))))
4229 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
4230 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
4231 (setq read (cdr read)))))
4232 ;; And add the last unread articles.
4233 (while (<= first last)
4234 (setq unread (cons first unread))
4235 (setq first (1+ first)))
4236 ;; Return the list of unread articles.
4239 (defun gnus-list-of-read-articles (group)
4240 "Return a list of unread, unticked and non-dormant articles."
4241 (let* ((info (gnus-get-info group))
4242 (marked (gnus-info-marks info))
4243 (active (gnus-active group)))
4245 (gnus-set-difference
4246 (gnus-sorted-complement
4247 (gnus-uncompress-range active)
4248 (gnus-list-of-unread-articles group))
4250 (gnus-uncompress-range (cdr (assq 'dormant marked)))
4251 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
4253 ;; Various summary commands
4255 (defun gnus-summary-universal-argument (arg)
4256 "Perform any operation on all articles that are process/prefixed."
4258 (gnus-set-global-variables)
4259 (let ((articles (gnus-summary-work-articles arg))
4266 (substitute-command-keys
4267 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
4270 (gnus-error 1 "Undefined key")
4273 (gnus-summary-goto-subject (setq article (pop articles)))
4274 (command-execute func)
4275 (gnus-summary-remove-process-mark article)))))
4276 (gnus-summary-position-point))
4278 (defun gnus-summary-toggle-truncation (&optional arg)
4279 "Toggle truncation of summary lines.
4280 With arg, turn line truncation on iff arg is positive."
4282 (setq truncate-lines
4283 (if (null arg) (not truncate-lines)
4284 (> (prefix-numeric-value arg) 0)))
4287 (defun gnus-summary-reselect-current-group (&optional all rescan)
4288 "Exit and then reselect the current newsgroup.
4289 The prefix argument ALL means to select all articles."
4291 (gnus-set-global-variables)
4292 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
4293 (error "Ephemeral groups can't be reselected"))
4294 (let ((current-subject (gnus-summary-article-number))
4295 (group gnus-newsgroup-name))
4296 (setq gnus-newsgroup-begin nil)
4298 ;; We have to adjust the point of group mode buffer because the
4299 ;; current point was moved to the next unread newsgroup by
4301 (gnus-summary-jump-to-group group)
4304 (gnus-group-get-new-news-this-group 1)))
4305 (gnus-group-read-group all t)
4306 (gnus-summary-goto-subject current-subject nil t)))
4308 (defun gnus-summary-rescan-group (&optional all)
4309 "Exit the newsgroup, ask for new articles, and select the newsgroup."
4311 (gnus-summary-reselect-current-group all t))
4313 (defun gnus-summary-update-info ()
4314 (let ((group gnus-newsgroup-name))
4315 (when gnus-newsgroup-kill-headers
4316 (setq gnus-newsgroup-killed
4317 (gnus-compress-sequence
4319 (gnus-set-sorted-intersection
4320 (gnus-uncompress-range gnus-newsgroup-killed)
4321 (setq gnus-newsgroup-unselected
4322 (sort gnus-newsgroup-unselected '<)))
4323 (setq gnus-newsgroup-unreads
4324 (sort gnus-newsgroup-unreads '<))) t)))
4325 (unless (listp (cdr gnus-newsgroup-killed))
4326 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
4327 (let ((headers gnus-newsgroup-headers))
4328 (run-hooks 'gnus-exit-group-hook)
4329 (unless gnus-save-score
4330 (setq gnus-newsgroup-scored nil))
4331 ;; Set the new ranges of read articles.
4332 (gnus-update-read-articles
4333 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
4334 ;; Set the current article marks.
4336 ;; Do the cross-ref thing.
4337 (when gnus-use-cross-reference
4338 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
4339 ;; Do adaptive scoring, and possibly save score files.
4340 (when gnus-newsgroup-adaptive
4341 (gnus-score-adaptive))
4342 (when gnus-use-scoring
4344 ;; Do not switch windows but change the buffer to work.
4345 (set-buffer gnus-group-buffer)
4346 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
4347 (gnus-group-update-group group)))))
4349 (defun gnus-summary-exit (&optional temporary)
4350 "Exit reading current newsgroup, and then return to group selection mode.
4351 gnus-exit-group-hook is called with no arguments if that value is non-nil."
4353 (gnus-set-global-variables)
4354 (gnus-kill-save-kill-buffer)
4355 (let* ((group gnus-newsgroup-name)
4356 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
4358 (buf (current-buffer)))
4359 (run-hooks 'gnus-summary-prepare-exit-hook)
4360 ;; If we have several article buffers, we kill them at exit.
4361 (unless gnus-single-article-buffer
4362 (gnus-kill-buffer gnus-original-article-buffer)
4363 (setq gnus-article-current nil))
4364 (when gnus-use-cache
4365 (gnus-cache-possibly-remove-articles)
4366 (gnus-cache-save-buffers))
4367 (gnus-async-prefetch-remove-group group)
4368 (when gnus-suppress-duplicates
4369 (gnus-dup-enter-articles))
4370 (when gnus-use-trees
4371 (gnus-tree-close group))
4372 ;; Make all changes in this group permanent.
4374 (gnus-summary-update-info))
4375 (gnus-close-group group)
4376 ;; Make sure where I was, and go to next newsgroup.
4377 (set-buffer gnus-group-buffer)
4379 (gnus-group-jump-to-group group))
4380 (run-hooks 'gnus-summary-exit-hook)
4382 (gnus-group-next-unread-group 1))
4385 ;; If we have several article buffers, we kill them at exit.
4386 (unless gnus-single-article-buffer
4387 (gnus-kill-buffer gnus-article-buffer)
4388 (gnus-kill-buffer gnus-original-article-buffer)
4389 (setq gnus-article-current nil))
4391 (if (not gnus-kill-summary-on-exit)
4392 (gnus-deaden-summary)
4393 ;; We set all buffer-local variables to nil. It is unclear why
4394 ;; this is needed, but if we don't, buffer-local variables are
4395 ;; not garbage-collected, it seems. This would the lead to en
4396 ;; ever-growing Emacs.
4397 (gnus-summary-clear-local-variables)
4398 (when (get-buffer gnus-article-buffer)
4399 (bury-buffer gnus-article-buffer))
4400 ;; We clear the global counterparts of the buffer-local
4401 ;; variables as well, just to be on the safe side.
4402 (gnus-configure-windows 'group 'force)
4403 (gnus-summary-clear-local-variables)
4404 ;; Return to group mode buffer.
4405 (if (eq mode 'gnus-summary-mode)
4406 (gnus-kill-buffer buf)))
4407 (setq gnus-current-select-method gnus-select-method)
4408 (pop-to-buffer gnus-group-buffer)
4409 ;; Clear the current group name.
4410 (if (not quit-config)
4412 (gnus-group-jump-to-group group)
4413 (gnus-group-next-unread-group 1)
4414 (gnus-configure-windows 'group 'force))
4415 (if (not (buffer-name (car quit-config)))
4416 (gnus-configure-windows 'group 'force)
4417 (set-buffer (car quit-config))
4418 (and (eq major-mode 'gnus-summary-mode)
4419 (gnus-set-global-variables))
4420 (gnus-configure-windows (cdr quit-config))))
4422 (setq gnus-newsgroup-name nil)))))
4424 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
4425 (defun gnus-summary-exit-no-update (&optional no-questions)
4426 "Quit reading current newsgroup without updating read article info."
4428 (gnus-set-global-variables)
4429 (let* ((group gnus-newsgroup-name)
4430 (quit-config (gnus-group-quit-config group)))
4431 (when (or no-questions
4433 (gnus-y-or-n-p "Do you really wanna quit reading this group? "))
4434 ;; If we have several article buffers, we kill them at exit.
4435 (unless gnus-single-article-buffer
4436 (gnus-kill-buffer gnus-article-buffer)
4437 (gnus-kill-buffer gnus-original-article-buffer)
4438 (setq gnus-article-current nil))
4439 (if (not gnus-kill-summary-on-exit)
4440 (gnus-deaden-summary)
4441 (gnus-close-group group)
4442 (gnus-summary-clear-local-variables)
4443 (set-buffer gnus-group-buffer)
4444 (gnus-summary-clear-local-variables)
4445 (when (get-buffer gnus-summary-buffer)
4446 (kill-buffer gnus-summary-buffer)))
4447 (unless gnus-single-article-buffer
4448 (setq gnus-article-current nil))
4449 (when gnus-use-trees
4450 (gnus-tree-close group))
4451 (gnus-async-prefetch-remove-group group)
4452 (when (get-buffer gnus-article-buffer)
4453 (bury-buffer gnus-article-buffer))
4454 ;; Return to the group buffer.
4455 (gnus-configure-windows 'group 'force)
4456 ;; Clear the current group name.
4457 (setq gnus-newsgroup-name nil)
4458 (when (equal (gnus-group-group-name) group)
4459 (gnus-group-next-unread-group 1))
4461 (if (not (buffer-name (car quit-config)))
4462 (gnus-configure-windows 'group 'force)
4463 (set-buffer (car quit-config))
4464 (when (eq major-mode 'gnus-summary-mode)
4465 (gnus-set-global-variables))
4466 (gnus-configure-windows (cdr quit-config)))))))
4470 (defvar gnus-dead-summary-mode-map nil)
4472 (if gnus-dead-summary-mode-map
4474 (setq gnus-dead-summary-mode-map (make-keymap))
4475 (suppress-keymap gnus-dead-summary-mode-map)
4476 (substitute-key-definition
4477 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
4478 (let ((keys '("\C-d" "\r" "\177")))
4480 (define-key gnus-dead-summary-mode-map
4481 (pop keys) 'gnus-summary-wake-up-the-dead))))
4483 (defvar gnus-dead-summary-mode nil
4484 "Minor mode for Gnus summary buffers.")
4486 (defun gnus-dead-summary-mode (&optional arg)
4487 "Minor mode for Gnus summary buffers."
4489 (when (eq major-mode 'gnus-summary-mode)
4490 (make-local-variable 'gnus-dead-summary-mode)
4491 (setq gnus-dead-summary-mode
4492 (if (null arg) (not gnus-dead-summary-mode)
4493 (> (prefix-numeric-value arg) 0)))
4494 (when gnus-dead-summary-mode
4495 (unless (assq 'gnus-dead-summary-mode minor-mode-alist)
4496 (push '(gnus-dead-summary-mode " Dead") minor-mode-alist))
4497 (unless (assq 'gnus-dead-summary-mode minor-mode-map-alist)
4498 (push (cons 'gnus-dead-summary-mode gnus-dead-summary-mode-map)
4499 minor-mode-map-alist)))))
4501 (defun gnus-deaden-summary ()
4502 "Make the current summary buffer into a dead summary buffer."
4503 ;; Kill any previous dead summary buffer.
4504 (when (and gnus-dead-summary
4505 (buffer-name gnus-dead-summary))
4507 (set-buffer gnus-dead-summary)
4508 (when gnus-dead-summary-mode
4509 (kill-buffer (current-buffer)))))
4510 ;; Make this the current dead summary.
4511 (setq gnus-dead-summary (current-buffer))
4512 (gnus-dead-summary-mode 1)
4513 (let ((name (buffer-name)))
4514 (when (string-match "Summary" name)
4516 (concat (substring name 0 (match-beginning 0)) "Dead "
4517 (substring name (match-beginning 0))) t))))
4519 (defun gnus-kill-or-deaden-summary (buffer)
4520 "Kill or deaden the summary BUFFER."
4521 (when (and (buffer-name buffer)
4522 (not gnus-single-article-buffer))
4525 (gnus-kill-buffer gnus-article-buffer)
4526 (gnus-kill-buffer gnus-original-article-buffer)))
4527 (cond (gnus-kill-summary-on-exit
4528 (when (and gnus-use-trees
4529 (and (get-buffer buffer)
4530 (buffer-name (get-buffer buffer))))
4532 (set-buffer (get-buffer buffer))
4533 (gnus-tree-close gnus-newsgroup-name)))
4534 (gnus-kill-buffer buffer))
4535 ((and (get-buffer buffer)
4536 (buffer-name (get-buffer buffer)))
4539 (gnus-deaden-summary)))))
4541 (defun gnus-summary-wake-up-the-dead (&rest args)
4542 "Wake up the dead summary buffer."
4544 (gnus-dead-summary-mode -1)
4545 (let ((name (buffer-name)))
4546 (when (string-match "Dead " name)
4548 (concat (substring name 0 (match-beginning 0))
4549 (substring name (match-end 0))) t)))
4550 (gnus-message 3 "This dead summary is now alive again"))
4552 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
4553 (defun gnus-summary-fetch-faq (&optional faq-dir)
4554 "Fetch the FAQ for the current group.
4555 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
4559 (if current-prefix-arg
4561 "Faq dir: " (and (listp gnus-group-faq-directory)
4562 gnus-group-faq-directory)))))
4563 (let (gnus-faq-buffer)
4564 (and (setq gnus-faq-buffer
4565 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
4566 (gnus-configure-windows 'summary-faq))))
4568 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
4569 (defun gnus-summary-describe-group (&optional force)
4570 "Describe the current newsgroup."
4572 (gnus-group-describe-group force gnus-newsgroup-name))
4574 (defun gnus-summary-describe-briefly ()
4575 "Describe summary mode commands briefly."
4578 (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")))
4580 ;; Walking around group mode buffer from summary mode.
4582 (defun gnus-summary-next-group (&optional no-article target-group backward)
4583 "Exit current newsgroup and then select next unread newsgroup.
4584 If prefix argument NO-ARTICLE is non-nil, no article is selected
4585 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
4586 previous group instead."
4588 (gnus-set-global-variables)
4589 (let ((current-group gnus-newsgroup-name)
4590 (current-buffer (current-buffer))
4592 ;; First we semi-exit this group to update Xrefs and all variables.
4593 ;; We can't do a real exit, because the window conf must remain
4594 ;; the same in case the user is prompted for info, and we don't
4595 ;; want the window conf to change before that...
4596 (gnus-summary-exit t)
4597 (while (not entered)
4598 ;; Then we find what group we are supposed to enter.
4599 (set-buffer gnus-group-buffer)
4600 (gnus-group-jump-to-group current-group)
4603 (if (eq gnus-keep-same-level 'best)
4604 (gnus-summary-best-group gnus-newsgroup-name)
4605 (gnus-summary-search-group backward gnus-keep-same-level))))
4606 (if (not target-group)
4607 ;; There are no further groups, so we return to the group
4610 (gnus-message 5 "Returning to the group buffer")
4612 (set-buffer current-buffer)
4613 (gnus-summary-exit))
4614 ;; We try to enter the target group.
4615 (gnus-group-jump-to-group target-group)
4616 (let ((unreads (gnus-group-group-unread)))
4617 (if (and (or (eq t unreads)
4618 (and unreads (not (zerop unreads))))
4619 (gnus-summary-read-group
4620 target-group nil no-article current-buffer))
4622 (setq current-group target-group
4623 target-group nil)))))))
4625 (defun gnus-summary-prev-group (&optional no-article)
4626 "Exit current newsgroup and then select previous unread newsgroup.
4627 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
4629 (gnus-summary-next-group no-article nil t))
4631 ;; Walking around summary lines.
4633 (defun gnus-summary-first-subject (&optional unread)
4634 "Go to the first unread subject.
4635 If UNREAD is non-nil, go to the first unread article.
4636 Returns the article selected or nil if there are no unread articles."
4641 ((null gnus-newsgroup-data)
4642 (gnus-message 3 "No articles in the group")
4644 ;; Pick the first article.
4646 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
4647 (gnus-data-number (car gnus-newsgroup-data)))
4648 ;; No unread articles.
4649 ((null gnus-newsgroup-unreads)
4650 (gnus-message 3 "No more unread articles")
4652 ;; Find the first unread article.
4654 (let ((data gnus-newsgroup-data))
4656 (not (gnus-data-unread-p (car data))))
4657 (setq data (cdr data)))
4660 (goto-char (gnus-data-pos (car data)))
4661 (gnus-data-number (car data)))))))
4662 (gnus-summary-position-point)))
4664 (defun gnus-summary-next-subject (n &optional unread dont-display)
4665 "Go to next N'th summary line.
4666 If N is negative, go to the previous N'th subject line.
4667 If UNREAD is non-nil, only unread articles are selected.
4668 The difference between N and the actual number of steps taken is
4671 (let ((backward (< n 0))
4675 (gnus-summary-find-prev unread)
4676 (gnus-summary-find-next unread)))
4678 (if (/= 0 n) (gnus-message 7 "No more%s articles"
4679 (if unread " unread" "")))
4680 (unless dont-display
4681 (gnus-summary-recenter)
4682 (gnus-summary-position-point))
4685 (defun gnus-summary-next-unread-subject (n)
4686 "Go to next N'th unread summary line."
4688 (gnus-summary-next-subject n t))
4690 (defun gnus-summary-prev-subject (n &optional unread)
4691 "Go to previous N'th summary line.
4692 If optional argument UNREAD is non-nil, only unread article is selected."
4694 (gnus-summary-next-subject (- n) unread))
4696 (defun gnus-summary-prev-unread-subject (n)
4697 "Go to previous N'th unread summary line."
4699 (gnus-summary-next-subject (- n) t))
4701 (defun gnus-summary-goto-subject (article &optional force silent)
4702 "Go the subject line of ARTICLE.
4703 If FORCE, also allow jumping to articles not currently shown."
4705 (data (gnus-data-find article)))
4706 ;; We read in the article if we have to.
4709 (gnus-summary-insert-subject article (and (vectorp force) force) t)
4710 (setq data (gnus-data-find article)))
4715 (gnus-message 3 "Can't find article %d" article))
4717 (goto-char (gnus-data-pos data))
4720 ;; Walking around summary lines with displaying articles.
4722 (defun gnus-summary-expand-window (&optional arg)
4723 "Make the summary buffer take up the entire Emacs frame.
4724 Given a prefix, will force an `article' buffer configuration."
4726 (gnus-set-global-variables)
4728 (gnus-configure-windows 'article 'force)
4729 (gnus-configure-windows 'summary 'force)))
4731 (defun gnus-summary-display-article (article &optional all-header)
4732 "Display ARTICLE in article buffer."
4733 (gnus-set-global-variables)
4737 (if gnus-summary-display-article-function
4738 (funcall gnus-summary-display-article-function article all-header)
4739 (gnus-article-prepare article all-header))
4740 (run-hooks 'gnus-select-article-hook)
4741 (unless (zerop gnus-current-article)
4742 (gnus-summary-goto-subject gnus-current-article))
4743 (gnus-summary-recenter)
4744 (when gnus-use-trees
4745 (gnus-possibly-generate-tree article)
4746 (gnus-highlight-selected-tree article))
4747 ;; Successfully display article.
4748 (gnus-article-set-window-start
4749 (cdr (assq article gnus-newsgroup-bookmarks))))))
4751 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
4752 "Select the current article.
4753 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
4754 non-nil, the article will be re-fetched even if it already present in
4755 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
4757 ;; Make sure we are in the summary buffer to work around bbdb bug.
4758 (unless (eq major-mode 'gnus-summary-mode)
4759 (set-buffer gnus-summary-buffer))
4760 (let ((article (or article (gnus-summary-article-number)))
4761 (all-headers (not (not all-headers))) ;Must be T or NIL.
4762 gnus-summary-display-article-function
4765 (gnus-summary-article-pseudo-p article)
4766 (error "This is a pseudo-article."))
4769 (set-buffer gnus-summary-buffer)
4770 (if (or (and gnus-single-article-buffer
4771 (or (null gnus-current-article)
4772 (null gnus-article-current)
4773 (null (get-buffer gnus-article-buffer))
4774 (not (eq article (cdr gnus-article-current)))
4775 (not (equal (car gnus-article-current)
4776 gnus-newsgroup-name))))
4777 (and (not gnus-single-article-buffer)
4778 (or (null gnus-current-article)
4779 (not (eq gnus-current-article article))))
4781 ;; The requested article is different from the current article.
4783 (gnus-summary-display-article article all-headers)
4785 (if (or all-headers gnus-show-all-headers)
4786 (gnus-article-show-all-headers))
4789 (gnus-article-set-window-start
4790 (cdr (assq article gnus-newsgroup-bookmarks)))))))
4792 (defun gnus-summary-set-current-mark (&optional current-mark)
4793 "Obsolete function."
4796 (defun gnus-summary-next-article (&optional unread subject backward push)
4797 "Select the next article.
4798 If UNREAD, only unread articles are selected.
4799 If SUBJECT, only articles with SUBJECT are selected.
4800 If BACKWARD, the previous article is selected instead of the next."
4802 (gnus-set-global-variables)
4804 ;; Is there such an article?
4805 ((and (gnus-summary-search-forward unread subject backward)
4806 (or (gnus-summary-display-article (gnus-summary-article-number))
4807 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
4808 (gnus-summary-position-point))
4809 ;; If not, we try the first unread, if that is wanted.
4811 gnus-auto-select-same
4812 ;; Make sure that we don't select the current article.
4813 (not (eq (gnus-summary-article-number)
4815 (gnus-summary-first-subject t)
4816 (gnus-summary-article-number))))
4817 (gnus-summary-first-unread-article))
4818 (gnus-summary-position-point)
4819 (gnus-message 6 "Wrapped"))
4820 ;; Try to get next/previous article not displayed in this group.
4821 ((and gnus-auto-extend-newsgroup
4822 (not unread) (not subject))
4823 (gnus-summary-goto-article
4824 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
4826 ;; Go to next/previous group.
4828 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
4829 (gnus-summary-jump-to-group gnus-newsgroup-name))
4830 (let ((cmd last-command-char)
4832 (if (eq gnus-keep-same-level 'best)
4833 (gnus-summary-best-group gnus-newsgroup-name)
4834 (gnus-summary-search-group backward gnus-keep-same-level))))
4835 ;; For some reason, the group window gets selected. We change
4837 (select-window (get-buffer-window (current-buffer)))
4838 ;; Select next unread newsgroup automagically.
4840 ((or (not gnus-auto-select-next)
4842 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
4843 ((or (eq gnus-auto-select-next 'quietly)
4844 (and (eq gnus-auto-select-next 'slightly-quietly)
4846 (and (eq gnus-auto-select-next 'almost-quietly)
4847 (gnus-summary-last-article-p)))
4849 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
4851 (gnus-message 7 "No more%s articles (%s)..."
4852 (if unread " unread" "")
4853 (if group (concat "selecting " group)
4855 (gnus-summary-next-group nil group backward)))
4857 (gnus-summary-walk-group-buffer
4858 gnus-newsgroup-name cmd unread backward)))))))
4860 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward)
4861 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
4862 (?\C-p (gnus-group-prev-unread-group 1))))
4863 (cursor-in-echo-area t)
4864 keve key group ended)
4866 (set-buffer gnus-group-buffer)
4867 (gnus-summary-jump-to-group from-group)
4869 (if (eq gnus-keep-same-level 'best)
4870 (gnus-summary-best-group gnus-newsgroup-name)
4871 (gnus-summary-search-group backward gnus-keep-same-level))))
4874 5 "No more%s articles%s" (if unread " unread" "")
4876 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
4877 (format " (Type %s for %s [%s])"
4878 (single-key-description cmd) group
4879 (car (gnus-gethash group gnus-newsrc-hashtb)))
4880 (format " (Type %s to exit %s)"
4881 (single-key-description cmd)
4882 gnus-newsgroup-name)))
4883 ;; Confirm auto selection.
4884 (setq key (car (setq keve (gnus-read-event-char))))
4887 ((assq key keystrokes)
4888 (let ((obuf (current-buffer)))
4889 (switch-to-buffer gnus-group-buffer)
4891 (gnus-group-jump-to-group group))
4892 (eval (cadr (assq key keystrokes)))
4893 (setq group (gnus-group-group-name))
4894 (switch-to-buffer obuf))
4898 (gnus-ephemeral-group-p gnus-newsgroup-name))
4900 (gnus-summary-next-group nil group backward)))
4902 (push (cdr keve) unread-command-events))))))
4904 (defun gnus-summary-next-unread-article ()
4905 "Select unread article after current one."
4907 (gnus-summary-next-article t (and gnus-auto-select-same
4908 (gnus-summary-article-subject))))
4910 (defun gnus-summary-prev-article (&optional unread subject)
4911 "Select the article after the current one.
4912 If UNREAD is non-nil, only unread articles are selected."
4914 (gnus-summary-next-article unread subject t))
4916 (defun gnus-summary-prev-unread-article ()
4917 "Select unread article before current one."
4919 (gnus-summary-prev-article t (and gnus-auto-select-same
4920 (gnus-summary-article-subject))))
4922 (defun gnus-summary-next-page (&optional lines circular)
4923 "Show next page of the selected article.
4924 If at the end of the current article, select the next article.
4925 LINES says how many lines should be scrolled up.
4927 If CIRCULAR is non-nil, go to the start of the article instead of
4928 selecting the next article when reaching the end of the current
4931 (setq gnus-summary-buffer (current-buffer))
4932 (gnus-set-global-variables)
4933 (let ((article (gnus-summary-article-number))
4935 (gnus-configure-windows 'article)
4936 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
4937 (if (and (eq gnus-summary-goto-unread 'never)
4938 (not (gnus-summary-last-article-p article)))
4939 (gnus-summary-next-article)
4940 (gnus-summary-next-unread-article))
4941 (if (or (null gnus-current-article)
4942 (null gnus-article-current)
4943 (/= article (cdr gnus-article-current))
4944 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
4945 ;; Selected subject is different from current article's.
4946 (gnus-summary-display-article article)
4947 (gnus-eval-in-buffer-window gnus-article-buffer
4948 (setq endp (gnus-article-next-page lines)))
4951 (gnus-summary-beginning-of-article))
4953 (gnus-message 3 "End of message"))
4955 (if (and (eq gnus-summary-goto-unread 'never)
4956 (not (gnus-summary-last-article-p article)))
4957 (gnus-summary-next-article)
4958 (gnus-summary-next-unread-article)))))))
4959 (gnus-summary-recenter)
4960 (gnus-summary-position-point)))
4962 (defun gnus-summary-prev-page (&optional lines)
4963 "Show previous page of selected article.
4964 Argument LINES specifies lines to be scrolled down."
4966 (gnus-set-global-variables)
4967 (let ((article (gnus-summary-article-number)))
4968 (gnus-configure-windows 'article)
4969 (if (or (null gnus-current-article)
4970 (null gnus-article-current)
4971 (/= article (cdr gnus-article-current))
4972 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
4973 ;; Selected subject is different from current article's.
4974 (gnus-summary-display-article article)
4975 (gnus-summary-recenter)
4976 (gnus-eval-in-buffer-window gnus-article-buffer
4977 (gnus-article-prev-page lines))))
4978 (gnus-summary-position-point))
4980 (defun gnus-summary-scroll-up (lines)
4981 "Scroll up (or down) one line current article.
4982 Argument LINES specifies lines to be scrolled up (or down if negative)."
4984 (gnus-set-global-variables)
4985 (gnus-configure-windows 'article)
4986 (gnus-summary-show-thread)
4987 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
4988 (gnus-eval-in-buffer-window gnus-article-buffer
4990 (if (gnus-article-next-page lines)
4991 (gnus-message 3 "End of message")))
4993 (gnus-article-prev-page (- lines))))))
4994 (gnus-summary-recenter)
4995 (gnus-summary-position-point))
4997 (defun gnus-summary-next-same-subject ()
4998 "Select next article which has the same subject as current one."
5000 (gnus-set-global-variables)
5001 (gnus-summary-next-article nil (gnus-summary-article-subject)))
5003 (defun gnus-summary-prev-same-subject ()
5004 "Select previous article which has the same subject as current one."
5006 (gnus-set-global-variables)
5007 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
5009 (defun gnus-summary-next-unread-same-subject ()
5010 "Select next unread article which has the same subject as current one."
5012 (gnus-set-global-variables)
5013 (gnus-summary-next-article t (gnus-summary-article-subject)))
5015 (defun gnus-summary-prev-unread-same-subject ()
5016 "Select previous unread article which has the same subject as current one."
5018 (gnus-set-global-variables)
5019 (gnus-summary-prev-article t (gnus-summary-article-subject)))
5021 (defun gnus-summary-first-unread-article ()
5022 "Select the first unread article.
5023 Return nil if there are no unread articles."
5025 (gnus-set-global-variables)
5027 (when (gnus-summary-first-subject t)
5028 (gnus-summary-show-thread)
5029 (gnus-summary-first-subject t)
5030 (gnus-summary-display-article (gnus-summary-article-number)))
5031 (gnus-summary-position-point)))
5033 (defun gnus-summary-best-unread-article ()
5034 "Select the unread article with the highest score."
5036 (gnus-set-global-variables)
5037 (let ((best -1000000)
5038 (data gnus-newsgroup-data)
5041 (and (gnus-data-unread-p (car data))
5043 (gnus-summary-article-score (gnus-data-number (car data))))
5046 article (gnus-data-number (car data))))
5047 (setq data (cdr data)))
5050 (gnus-summary-goto-article article)
5051 (error "No unread articles"))
5052 (gnus-summary-position-point))))
5054 (defun gnus-summary-last-subject ()
5055 "Go to the last displayed subject line in the group."
5056 (let ((article (gnus-data-number (car (gnus-data-list t)))))
5058 (gnus-summary-goto-subject article))))
5060 (defun gnus-summary-goto-article (article &optional all-headers force)
5061 "Fetch ARTICLE and display it if it exists.
5062 If ALL-HEADERS is non-nil, no header lines are hidden."
5068 (mapcar (lambda (number) (list (int-to-string number)))
5069 gnus-newsgroup-limit)))
5073 (if (gnus-summary-goto-subject article force)
5074 (gnus-summary-display-article article all-headers)
5075 (gnus-message 4 "Couldn't go to article %s" article) nil)
5076 (gnus-summary-position-point)))
5078 (defun gnus-summary-goto-last-article ()
5079 "Go to the previously read article."
5082 (and gnus-last-article
5083 (gnus-summary-goto-article gnus-last-article))
5084 (gnus-summary-position-point)))
5086 (defun gnus-summary-pop-article (number)
5087 "Pop one article off the history and go to the previous.
5088 NUMBER articles will be popped off."
5091 (setq gnus-newsgroup-history
5092 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
5094 (gnus-summary-goto-article (car to))
5095 (error "Article history empty")))
5096 (gnus-summary-position-point))
5098 ;; Summary commands and functions for limiting the summary buffer.
5100 (defun gnus-summary-limit-to-articles (n)
5101 "Limit the summary buffer to the next N articles.
5102 If not given a prefix, use the process marked articles instead."
5104 (gnus-set-global-variables)
5106 (let ((articles (gnus-summary-work-articles n)))
5107 (setq gnus-newsgroup-processable nil)
5108 (gnus-summary-limit articles))
5109 (gnus-summary-position-point)))
5111 (defun gnus-summary-pop-limit (&optional total)
5112 "Restore the previous limit.
5113 If given a prefix, remove all limits."
5115 (gnus-set-global-variables)
5117 (setq gnus-newsgroup-limits
5118 (list (mapcar (lambda (h) (mail-header-number h))
5119 gnus-newsgroup-headers))))
5120 (unless gnus-newsgroup-limits
5121 (error "No limit to pop"))
5123 (gnus-summary-limit nil 'pop)
5124 (gnus-summary-position-point)))
5126 (defun gnus-summary-limit-to-subject (subject &optional header)
5127 "Limit the summary buffer to articles that have subjects that match a regexp."
5128 (interactive "sRegexp: ")
5130 (setq header "subject"))
5131 (when (not (equal "" subject))
5133 (let ((articles (gnus-summary-find-matching
5134 (or header "subject") subject 'all)))
5135 (or articles (error "Found no matches for \"%s\"" subject))
5136 (gnus-summary-limit articles))
5137 (gnus-summary-position-point))))
5139 (defun gnus-summary-limit-to-author (from)
5140 "Limit the summary buffer to articles that have authors that match a regexp."
5141 (interactive "sRegexp: ")
5142 (gnus-summary-limit-to-subject from "from"))
5144 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
5146 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
5148 (defun gnus-summary-limit-to-unread (&optional all)
5149 "Limit the summary buffer to articles that are not marked as read.
5150 If ALL is non-nil, limit strictly to unread articles."
5153 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
5154 (gnus-summary-limit-to-marks
5155 ;; Concat all the marks that say that an article is read and have
5157 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
5158 gnus-killed-mark gnus-kill-file-mark
5159 gnus-low-score-mark gnus-expirable-mark
5160 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
5161 gnus-duplicate-mark)
5164 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
5165 (make-obsolete 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
5167 (defun gnus-summary-limit-to-marks (marks &optional reverse)
5168 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
5169 If REVERSE, limit the summary buffer to articles that are not marked
5170 with MARKS. MARKS can either be a string of marks or a list of marks.
5171 Returns how many articles were removed."
5172 (interactive "sMarks: ")
5173 (gnus-set-global-variables)
5175 (let ((data gnus-newsgroup-data)
5176 (marks (if (listp marks) marks
5177 (append marks nil))) ; Transform to list.
5180 (and (if reverse (not (memq (gnus-data-mark (car data)) marks))
5181 (memq (gnus-data-mark (car data)) marks))
5182 (setq articles (cons (gnus-data-number (car data)) articles)))
5183 (setq data (cdr data)))
5184 (gnus-summary-limit articles))
5185 (gnus-summary-position-point)))
5187 (defun gnus-summary-limit-to-score (&optional score)
5188 "Limit to articles with score at or above SCORE."
5190 (gnus-set-global-variables)
5191 (setq score (if score
5192 (prefix-numeric-value score)
5193 (or gnus-summary-default-score 0)))
5194 (let ((data gnus-newsgroup-data)
5197 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
5199 (push (gnus-data-number (car data)) articles))
5200 (setq data (cdr data)))
5202 (gnus-summary-limit articles)
5203 (gnus-summary-position-point))))
5205 (defun gnus-summary-limit-include-dormant ()
5206 "Display all the hidden articles that are marked as dormant."
5208 (gnus-set-global-variables)
5209 (or gnus-newsgroup-dormant
5210 (error "There are no dormant articles in this group"))
5212 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
5213 (gnus-summary-position-point)))
5215 (defun gnus-summary-limit-exclude-dormant ()
5216 "Hide all dormant articles."
5218 (gnus-set-global-variables)
5220 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
5221 (gnus-summary-position-point)))
5223 (defun gnus-summary-limit-exclude-childless-dormant ()
5224 "Hide all dormant articles that have no children."
5226 (gnus-set-global-variables)
5227 (let ((data (gnus-data-list t))
5228 articles d children)
5229 ;; Find all articles that are either not dormant or have
5231 (while (setq d (pop data))
5232 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
5234 (gnus-article-children (gnus-data-number d)))
5237 (when (memq (car children) articles)
5242 (push (gnus-data-number d) articles)))
5245 (gnus-summary-limit articles)
5246 (gnus-summary-position-point))))
5248 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
5249 "Mark all unread excluded articles as read.
5250 If ALL, mark even excluded ticked and dormants as read."
5252 (let ((articles (gnus-sorted-complement
5254 (mapcar (lambda (h) (mail-header-number h))
5255 gnus-newsgroup-headers)
5257 (sort gnus-newsgroup-limit '<)))
5259 (setq gnus-newsgroup-unreads nil)
5261 (setq gnus-newsgroup-dormant nil
5262 gnus-newsgroup-marked nil
5263 gnus-newsgroup-reads
5265 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
5266 gnus-newsgroup-reads))
5267 (while (setq article (pop articles))
5268 (unless (or (memq article gnus-newsgroup-dormant)
5269 (memq article gnus-newsgroup-marked))
5270 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
5272 (defun gnus-summary-limit (articles &optional pop)
5274 ;; We pop the previous limit off the stack and use that.
5275 (setq articles (car gnus-newsgroup-limits)
5276 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
5277 ;; We use the new limit, so we push the old limit on the stack.
5278 (setq gnus-newsgroup-limits
5279 (cons gnus-newsgroup-limit gnus-newsgroup-limits)))
5281 (setq gnus-newsgroup-limit articles)
5282 (let ((total (length gnus-newsgroup-data))
5283 (data (gnus-data-find-list (gnus-summary-article-number)))
5284 (gnus-summary-mark-below nil) ; Inhibit this.
5286 ;; This will do all the work of generating the new summary buffer
5287 ;; according to the new limit.
5288 (gnus-summary-prepare)
5289 ;; Hide any threads, possibly.
5290 (and gnus-show-threads
5291 gnus-thread-hide-subtree
5292 (gnus-summary-hide-all-threads))
5293 ;; Try to return to the article you were at, or one in the
5296 ;; We try to find some article after the current one.
5298 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
5301 (setq data (cdr data))))
5303 ;; If there is no data, that means that we were after the last
5304 ;; article. The same goes when we can't find any articles
5305 ;; after the current one.
5306 (goto-char (point-max))
5307 (gnus-summary-find-prev))
5308 ;; We return how many articles were removed from the summary
5309 ;; buffer as a result of the new limit.
5310 (- total (length gnus-newsgroup-data))))
5312 (defsubst gnus-invisible-cut-children (threads)
5315 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
5320 (defsubst gnus-cut-thread (thread)
5321 "Go forwards in the thread until we find an article that we want to display."
5322 (when (or (eq gnus-fetch-old-headers 'some)
5323 (eq gnus-build-sparse-threads 'some)
5324 (eq gnus-build-sparse-threads 'more))
5325 ;; Deal with old-fetched headers and sparse threads.
5329 (memq (mail-header-number (car thread)) gnus-newsgroup-sparse)
5330 (memq (mail-header-number (car thread)) gnus-newsgroup-ancient))
5331 (or (<= (length (cdr thread)) 1)
5332 (gnus-invisible-cut-children (cdr thread))))
5333 (setq thread (cadr thread))))
5336 (defun gnus-cut-threads (threads)
5337 "Cut off all uninteresting articles from the beginning of threads."
5338 (when (or (eq gnus-fetch-old-headers 'some)
5339 (eq gnus-build-sparse-threads 'some)
5340 (eq gnus-build-sparse-threads 'more))
5343 (setcar th (gnus-cut-thread (car th)))
5344 (setq th (cdr th)))))
5345 ;; Remove nixed out threads.
5348 (defun gnus-summary-initial-limit (&optional show-if-empty)
5349 "Figure out what the initial limit is supposed to be on group entry.
5350 This entails weeding out unwanted dormants, low-scored articles,
5351 fetch-old-headers verbiage, and so on."
5352 ;; Most groups have nothing to remove.
5353 (if (or gnus-inhibit-limiting
5354 (and (null gnus-newsgroup-dormant)
5355 (not (eq gnus-fetch-old-headers 'some))
5356 (null gnus-summary-expunge-below)
5357 (not (eq gnus-build-sparse-threads 'some))
5358 (not (eq gnus-build-sparse-threads 'more))
5359 (null gnus-thread-expunge-below)
5360 (not gnus-use-nocem)))
5362 (push gnus-newsgroup-limit gnus-newsgroup-limits)
5363 (setq gnus-newsgroup-limit nil)
5366 (unless (car (symbol-value node))
5367 ;; These threads have no parents -- they are roots.
5368 (let ((nodes (cdr (symbol-value node)))
5371 (if (and gnus-thread-expunge-below
5372 (< (gnus-thread-total-score (car nodes))
5373 gnus-thread-expunge-below))
5374 (gnus-expunge-thread (pop nodes))
5375 (setq thread (pop nodes))
5376 (gnus-summary-limit-children thread))))))
5377 gnus-newsgroup-dependencies)
5378 ;; If this limitation resulted in an empty group, we might
5379 ;; pop the previous limit and use it instead.
5380 (when (and (not gnus-newsgroup-limit)
5382 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
5383 gnus-newsgroup-limit))
5385 (defun gnus-summary-limit-children (thread)
5386 "Return 1 if this subthread is visible and 0 if it is not."
5387 ;; First we get the number of visible children to this thread. This
5388 ;; is done by recursing down the thread using this function, so this
5389 ;; will really go down to a leaf article first, before slowly
5390 ;; working its way up towards the root.
5394 (apply '+ (mapcar 'gnus-summary-limit-children
5397 (number (mail-header-number (car thread)))
5400 (not (memq number gnus-newsgroup-marked))
5402 ;; If this article is dormant and has absolutely no visible
5403 ;; children, then this article isn't visible.
5404 (and (memq number gnus-newsgroup-dormant)
5406 ;; If this is "fetch-old-headered" and there is only one
5407 ;; visible child (or less), then we don't want this article.
5408 (and (eq gnus-fetch-old-headers 'some)
5409 (memq number gnus-newsgroup-ancient)
5411 ;; If this is a sparsely inserted article with no children,
5412 ;; we don't want it.
5413 (and (eq gnus-build-sparse-threads 'some)
5414 (memq number gnus-newsgroup-sparse)
5416 ;; If we use expunging, and this article is really
5417 ;; low-scored, then we don't want this article.
5418 (when (and gnus-summary-expunge-below
5420 (or (cdr (assq number gnus-newsgroup-scored))
5421 gnus-summary-default-score))
5422 gnus-summary-expunge-below))
5423 ;; We increase the expunge-tally here, but that has
5424 ;; nothing to do with the limits, really.
5425 (incf gnus-newsgroup-expunged-tally)
5426 ;; We also mark as read here, if that's wanted.
5427 (when (and gnus-summary-mark-below
5428 (< score gnus-summary-mark-below))
5429 (setq gnus-newsgroup-unreads
5430 (delq number gnus-newsgroup-unreads))
5431 (if gnus-newsgroup-auto-expire
5432 (push number gnus-newsgroup-expirable)
5433 (push (cons number gnus-low-score-mark)
5434 gnus-newsgroup-reads)))
5436 ;; Check NoCeM things.
5438 (gnus-nocem-unwanted-article-p
5439 (mail-header-id (car thread))))))
5440 ;; Nope, invisible article.
5442 ;; Ok, this article is to be visible, so we add it to the limit
5444 (setq gnus-newsgroup-limit (cons number gnus-newsgroup-limit))
5447 (defun gnus-expunge-thread (thread)
5448 "Mark all articles in THREAD as read."
5449 (let* ((number (mail-header-number (car thread))))
5450 (incf gnus-newsgroup-expunged-tally)
5451 ;; We also mark as read here, if that's wanted.
5452 (setq gnus-newsgroup-unreads
5453 (delq number gnus-newsgroup-unreads))
5454 (if gnus-newsgroup-auto-expire
5455 (push number gnus-newsgroup-expirable)
5456 (push (cons number gnus-low-score-mark)
5457 gnus-newsgroup-reads)))
5458 ;; Go recursively through all subthreads.
5459 (mapcar 'gnus-expunge-thread (cdr thread)))
5461 ;; Summary article oriented commands
5463 (defun gnus-summary-refer-parent-article (n)
5464 "Refer parent article N times.
5465 If N is negative, go to ancestor -N instead.
5466 The difference between N and the number of articles fetched is returned."
5468 (gnus-set-global-variables)
5471 (when (not (natnump n))
5476 (setq header (gnus-summary-article-header))
5478 ;; If we try to find the parent of the currently
5479 ;; displayed article, then we take a look at the actual
5480 ;; References header, since this is slightly more
5481 ;; reliable than the References field we got from the
5483 (if (and (eq (mail-header-number header)
5484 (cdr gnus-article-current))
5485 (equal gnus-newsgroup-name
5486 (car gnus-article-current)))
5488 (set-buffer gnus-original-article-buffer)
5489 (nnheader-narrow-to-headers)
5491 (message-fetch-field "references")
5493 ;; It's not the current article, so we take a bet on
5494 ;; the value we got from the server.
5495 (mail-header-references header)))
5497 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
5498 (gnus-message 1 "Couldn't find parent"))
5499 (gnus-message 1 "No references in article %d"
5500 (gnus-summary-article-number))
5503 (gnus-summary-position-point)
5506 (defun gnus-summary-refer-references ()
5507 "Fetch all articles mentioned in the References header.
5508 Return how many articles were fetched."
5510 (gnus-set-global-variables)
5511 (let ((ref (mail-header-references (gnus-summary-article-header)))
5512 (current (gnus-summary-article-number))
5514 ;; For each Message-ID in the References header...
5515 (while (string-match "<[^>]*>" ref)
5517 ;; ... fetch that article.
5518 (gnus-summary-refer-article
5519 (prog1 (match-string 0 ref)
5520 (setq ref (substring ref (match-end 0))))))
5521 (gnus-summary-goto-subject current)
5522 (gnus-summary-position-point)
5525 (defun gnus-summary-refer-article (message-id)
5526 "Fetch an article specified by MESSAGE-ID."
5527 (interactive "sMessage-ID: ")
5528 (when (and (stringp message-id)
5529 (not (zerop (length message-id))))
5530 ;; Construct the correct Message-ID if necessary.
5531 ;; Suggested by tale@pawl.rpi.edu.
5532 (unless (string-match "^<" message-id)
5533 (setq message-id (concat "<" message-id)))
5534 (unless (string-match ">$" message-id)
5535 (setq message-id (concat message-id ">")))
5536 (let* ((header (gnus-id-to-header message-id))
5538 (memq (mail-header-number header)
5539 gnus-newsgroup-sparse))))
5542 ;; The article is present in the buffer, to we just go to it.
5543 (gnus-summary-goto-article
5544 (mail-header-number header) nil header)
5546 (gnus-summary-update-article (mail-header-number header))))
5547 ;; We fetch the article
5548 (let ((gnus-override-method
5549 (and (gnus-news-group-p gnus-newsgroup-name)
5550 gnus-refer-article-method))
5552 ;; Start the special refer-article method, if necessary.
5553 (when (and gnus-refer-article-method
5554 (gnus-news-group-p gnus-newsgroup-name))
5555 (gnus-check-server gnus-refer-article-method))
5556 ;; Fetch the header, and display the article.
5557 (if (setq number (gnus-summary-insert-subject message-id))
5558 (gnus-summary-select-article nil nil nil number)
5559 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
5561 (defun gnus-summary-enter-digest-group (&optional force)
5562 "Enter an nndoc group based on the current article.
5563 If FORCE, force a digest interpretation. If not, try
5564 to guess what the document format is."
5566 (gnus-set-global-variables)
5567 (gnus-summary-select-article)
5568 (let ((name (format "%s-%d"
5569 (gnus-group-prefixed-name
5570 gnus-newsgroup-name (list 'nndoc ""))
5571 gnus-current-article))
5572 (ogroup gnus-newsgroup-name)
5573 (case-fold-search t)
5574 (buf (current-buffer))
5577 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
5578 (insert-buffer-substring gnus-original-article-buffer)
5580 (goto-char (point-min))
5581 (or (search-forward "\n\n" nil t) (point)))
5582 (goto-char (point-min))
5583 (delete-matching-lines "^\\(Path\\):\\|^From ")
5586 (if (gnus-group-read-ephemeral-group
5587 name `(nndoc ,name (nndoc-address
5589 (nndoc-article-type ,(if force 'digest 'guess))) t)
5590 ;; Make all postings to this group go to the parent group.
5591 (nconc (gnus-info-params (gnus-get-info name))
5592 (list (cons 'to-group ogroup)))
5593 ;; Couldn't select this doc group.
5594 (switch-to-buffer buf)
5595 (gnus-set-global-variables)
5596 (gnus-configure-windows 'summary)
5597 (gnus-message 3 "Article couldn't be entered?"))
5598 (kill-buffer dig))))
5600 (defun gnus-summary-read-document (n)
5601 "Open a new group based on the current article(s).
5602 Obeys the standard process/prefix convention."
5604 (let ((articles (gnus-summary-work-articles n))
5605 (ogroup gnus-newsgroup-name)
5606 article group egroup groups vgroup)
5607 (while (setq article (pop articles))
5608 (setq group (format "%s-%d" gnus-newsgroup-name gnus-current-article))
5609 (gnus-summary-remove-process-mark article)
5610 (when (gnus-summary-display-article article)
5612 (nnheader-temp-write nil
5613 (insert-buffer-substring gnus-original-article-buffer)
5614 ;; Remove some headers that may lead nndoc to make
5616 (message-narrow-to-head)
5617 (goto-char (point-min))
5618 (delete-matching-lines "^\\(Path\\):\\|^From ")
5621 (gnus-group-read-ephemeral-group
5622 group `(nndoc ,group (nndoc-address ,(current-buffer))
5623 (nndoc-article-type guess))
5626 ;; Make all postings to this group go to the parent group.
5627 (nconc (gnus-info-params (gnus-get-info egroup))
5628 (list (cons 'to-group ogroup)))
5629 (push egroup groups))
5630 ;; Couldn't select this doc group.
5631 (gnus-error 3 "Article couldn't be entered"))))))
5632 ;; Now we have selected all the documents.
5635 (error "None of the articles could be interpreted as documents"))
5636 ((gnus-group-read-ephemeral-group
5637 (setq vgroup (format
5638 "%s-%s" gnus-newsgroup-name
5639 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
5640 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
5642 (cons (current-buffer) 'summary)))
5644 (error "Couldn't select virtual nndoc group")))))
5646 (defun gnus-summary-isearch-article (&optional regexp-p)
5647 "Do incremental search forward on the current article.
5648 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
5650 (gnus-set-global-variables)
5651 (gnus-summary-select-article)
5652 (gnus-configure-windows 'article)
5653 (gnus-eval-in-buffer-window gnus-article-buffer
5654 ;;(goto-char (point-min))
5655 (isearch-forward regexp-p)))
5657 (defun gnus-summary-search-article-forward (regexp &optional backward)
5658 "Search for an article containing REGEXP forward.
5659 If BACKWARD, search backward instead."
5662 (format "Search article %s (regexp%s): "
5663 (if current-prefix-arg "backward" "forward")
5664 (if gnus-last-search-regexp
5665 (concat ", default " gnus-last-search-regexp)
5667 current-prefix-arg))
5668 (gnus-set-global-variables)
5669 (if (string-equal regexp "")
5670 (setq regexp (or gnus-last-search-regexp ""))
5671 (setq gnus-last-search-regexp regexp))
5672 (if (gnus-summary-search-article regexp backward)
5673 (gnus-summary-show-thread)
5674 (error "Search failed: \"%s\"" regexp)))
5676 (defun gnus-summary-search-article-backward (regexp)
5677 "Search for an article containing REGEXP backward."
5680 (format "Search article backward (regexp%s): "
5681 (if gnus-last-search-regexp
5682 (concat ", default " gnus-last-search-regexp)
5684 (gnus-summary-search-article-forward regexp 'backward))
5686 (defun gnus-summary-search-article (regexp &optional backward)
5687 "Search for an article containing REGEXP.
5688 Optional argument BACKWARD means do search for backward.
5689 `gnus-select-article-hook' is not called during the search."
5690 (let ((gnus-select-article-hook nil) ;Disable hook.
5691 (gnus-article-display-hook nil)
5692 (gnus-mark-article-hook nil) ;Inhibit marking as read.
5693 (gnus-use-article-prefetch nil)
5696 're-search-backward 're-search-forward))
5697 (sum (current-buffer))
5699 (gnus-save-hidden-threads
5700 (gnus-summary-select-article)
5701 (set-buffer gnus-article-buffer)
5705 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
5707 (re-search-backward regexp nil t)
5708 (re-search-forward regexp nil t))
5709 ;; We found the regexp.
5714 (get-buffer-window (current-buffer))
5718 ;; We didn't find it, so we go to the next article.
5720 (if (not (if backward (gnus-summary-find-prev)
5721 (gnus-summary-find-next)))
5722 ;; No more articles.
5724 ;; Select the next article and adjust point.
5725 (gnus-summary-select-article)
5726 (set-buffer gnus-article-buffer)
5728 (goto-char (if backward (point-max) (point-min))))))
5729 (gnus-message 7 ""))
5730 ;; Return whether we found the regexp.
5731 (when (eq found 'found)
5732 (gnus-summary-show-thread)
5733 (gnus-summary-goto-subject gnus-current-article)
5734 (gnus-summary-position-point)
5737 (defun gnus-summary-find-matching (header regexp &optional backward unread
5739 "Return a list of all articles that match REGEXP on HEADER.
5740 The search stars on the current article and goes forwards unless
5741 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
5742 If UNREAD is non-nil, only unread articles will
5743 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
5744 in the comparisons."
5745 (let ((data (if (eq backward 'all) gnus-newsgroup-data
5746 (gnus-data-find-list
5747 (gnus-summary-article-number) (gnus-data-list backward))))
5748 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
5749 (case-fold-search (not not-case-fold))
5751 (or (fboundp (intern (concat "mail-header-" header)))
5752 (error "%s is not a valid header" header))
5755 (and (or (not unread) ; We want all articles...
5756 (gnus-data-unread-p d)) ; Or just unreads.
5757 (vectorp (gnus-data-header d)) ; It's not a pseudo.
5758 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
5759 (setq articles (cons (gnus-data-number d) articles))) ; Success!
5760 (setq data (cdr data)))
5761 (nreverse articles)))
5763 (defun gnus-summary-execute-command (header regexp command &optional backward)
5764 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
5765 If HEADER is an empty string (or nil), the match is done on the entire
5766 article. If BACKWARD (the prefix) is non-nil, search backward instead."
5768 (list (let ((completion-ignore-case t))
5771 (mapcar (lambda (string) (list string))
5772 '("Number" "Subject" "From" "Lines" "Date"
5773 "Message-ID" "Xref" "References" "Body"))
5774 nil 'require-match))
5775 (read-string "Regexp: ")
5776 (read-key-sequence "Command: ")
5777 current-prefix-arg))
5778 (when (equal header "Body")
5780 (gnus-set-global-variables)
5781 ;; Hidden thread subtrees must be searched as well.
5782 (gnus-summary-show-all-threads)
5783 ;; We don't want to change current point nor window configuration.
5785 (save-window-excursion
5786 (gnus-message 6 "Executing %s..." (key-description command))
5787 ;; We'd like to execute COMMAND interactively so as to give arguments.
5788 (gnus-execute header regexp
5789 `(call-interactively ',(key-binding command))
5791 (gnus-message 6 "Executing %s...done" (key-description command)))))
5793 (defun gnus-summary-beginning-of-article ()
5794 "Scroll the article back to the beginning."
5796 (gnus-set-global-variables)
5797 (gnus-summary-select-article)
5798 (gnus-configure-windows 'article)
5799 (gnus-eval-in-buffer-window gnus-article-buffer
5801 (goto-char (point-min))
5802 (and gnus-break-pages (gnus-narrow-to-page))))
5804 (defun gnus-summary-end-of-article ()
5805 "Scroll to the end of the article."
5807 (gnus-set-global-variables)
5808 (gnus-summary-select-article)
5809 (gnus-configure-windows 'article)
5810 (gnus-eval-in-buffer-window gnus-article-buffer
5812 (goto-char (point-max))
5814 (and gnus-break-pages (gnus-narrow-to-page))))
5816 (defun gnus-summary-show-article (&optional arg)
5817 "Force re-fetching of the current article.
5818 If ARG (the prefix) is non-nil, show the raw article without any
5819 article massaging functions being run."
5821 (gnus-set-global-variables)
5823 ;; Select the article the normal way.
5824 (gnus-summary-select-article nil 'force)
5825 ;; Bind the article treatment functions to nil.
5826 (let ((gnus-have-all-headers t)
5827 gnus-article-display-hook
5828 gnus-article-prepare-hook
5831 (gnus-summary-select-article nil 'force)))
5832 (gnus-summary-goto-subject gnus-current-article)
5833 ; (gnus-configure-windows 'article)
5834 (gnus-summary-position-point))
5836 (defun gnus-summary-verbose-headers (&optional arg)
5837 "Toggle permanent full header display.
5838 If ARG is a positive number, turn header display on.
5839 If ARG is a negative number, turn header display off."
5841 (gnus-set-global-variables)
5842 (gnus-summary-toggle-header arg)
5843 (setq gnus-show-all-headers
5844 (cond ((or (not (numberp arg))
5846 (not gnus-show-all-headers))
5850 (defun gnus-summary-toggle-header (&optional arg)
5851 "Show the headers if they are hidden, or hide them if they are shown.
5852 If ARG is a positive number, show the entire header.
5853 If ARG is a negative number, hide the unwanted header lines."
5855 (gnus-set-global-variables)
5857 (set-buffer gnus-article-buffer)
5858 (let* ((buffer-read-only nil)
5859 (inhibit-point-motion-hooks t)
5860 (hidden (text-property-any
5861 (goto-char (point-min)) (search-forward "\n\n")
5864 (goto-char (point-min))
5865 (when (search-forward "\n\n" nil t)
5866 (delete-region (point-min) (1- (point))))
5867 (goto-char (point-min))
5869 (set-buffer gnus-original-article-buffer)
5870 (goto-char (point-min))
5871 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
5872 (insert-buffer-substring gnus-original-article-buffer 1 e)
5873 (let ((article-inhibit-hiding t))
5874 (run-hooks 'gnus-article-display-hook))
5875 (if (or (not hidden) (and (numberp arg) (< arg 0)))
5876 (gnus-article-hide-headers)))))
5878 (defun gnus-summary-show-all-headers ()
5879 "Make all header lines visible."
5881 (gnus-set-global-variables)
5882 (gnus-article-show-all-headers))
5884 (defun gnus-summary-toggle-mime (&optional arg)
5885 "Toggle MIME processing.
5886 If ARG is a positive number, turn MIME processing on."
5888 (gnus-set-global-variables)
5889 (setq gnus-show-mime
5890 (if (null arg) (not gnus-show-mime)
5891 (> (prefix-numeric-value arg) 0)))
5892 (gnus-summary-select-article t 'force))
5894 (defun gnus-summary-caesar-message (&optional arg)
5895 "Caesar rotate the current article by 13.
5896 The numerical prefix specifies how manu places to rotate each letter
5899 (gnus-set-global-variables)
5900 (gnus-summary-select-article)
5901 (let ((mail-header-separator ""))
5902 (gnus-eval-in-buffer-window gnus-article-buffer
5905 (let ((start (window-start))
5907 (message-caesar-buffer-body arg)
5908 (set-window-start (get-buffer-window (current-buffer)) start))))))
5910 (defun gnus-summary-stop-page-breaking ()
5911 "Stop page breaking in the current article."
5913 (gnus-set-global-variables)
5914 (gnus-summary-select-article)
5915 (gnus-eval-in-buffer-window gnus-article-buffer
5918 (defun gnus-summary-move-article (&optional n to-newsgroup select-method action)
5919 "Move the current article to a different newsgroup.
5920 If N is a positive number, move the N next articles.
5921 If N is a negative number, move the N previous articles.
5922 If N is nil and any articles have been marked with the process mark,
5923 move those articles instead.
5924 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
5925 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
5926 re-spool using this method.
5928 For this function to work, both the current newsgroup and the
5929 newsgroup that you want to move to have to support the `request-move'
5930 and `request-accept' functions."
5932 (unless action (setq action 'move))
5933 (gnus-set-global-variables)
5934 ;; Check whether the source group supports the required functions.
5935 (cond ((and (eq action 'move)
5936 (not (gnus-check-backend-function
5937 'request-move-article gnus-newsgroup-name)))
5938 (error "The current group does not support article moving"))
5939 ((and (eq action 'crosspost)
5940 (not (gnus-check-backend-function
5941 'request-replace-article gnus-newsgroup-name)))
5942 (error "The current group does not support article editing")))
5943 (let ((articles (gnus-summary-work-articles n))
5944 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
5945 (names '((move "Move" "Moving")
5946 (copy "Copy" "Copying")
5947 (crosspost "Crosspost" "Crossposting")))
5948 (copy-buf (save-excursion
5949 (nnheader-set-temp-buffer " *copy article*")))
5950 art-group to-method new-xref article to-groups)
5951 (unless (assq action names)
5952 (error "Unknown action %s" action))
5953 ;; Read the newsgroup name.
5954 (when (and (not to-newsgroup)
5955 (not select-method))
5957 (gnus-read-move-group-name
5958 (cadr (assq action names))
5959 (symbol-value (intern (format "gnus-current-%s-group" action)))
5961 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
5962 (setq to-method (or select-method
5963 (gnus-group-name-to-method to-newsgroup)))
5964 ;; Check the method we are to move this article to...
5965 (or (gnus-check-backend-function 'request-accept-article (car to-method))
5966 (error "%s does not support article copying" (car to-method)))
5967 (or (gnus-check-server to-method)
5968 (error "Can't open server %s" (car to-method)))
5969 (gnus-message 6 "%s to %s: %s..."
5970 (caddr (assq action names))
5971 (or (car select-method) to-newsgroup) articles)
5973 (setq article (pop articles))
5977 ;; Move the article.
5979 (gnus-request-move-article
5980 article ; Article to move
5981 gnus-newsgroup-name ; From newsgrouo
5982 (nth 1 (gnus-find-method-for-group
5983 gnus-newsgroup-name)) ; Server
5984 (list 'gnus-request-accept-article
5985 to-newsgroup (list 'quote select-method)
5986 (not articles)) ; Accept form
5987 (not articles))) ; Only save nov last time
5988 ;; Copy the article.
5991 (set-buffer copy-buf)
5992 (gnus-request-article-this-buffer article gnus-newsgroup-name)
5993 (gnus-request-accept-article
5994 to-newsgroup select-method (not articles))))
5995 ;; Crosspost the article.
5996 ((eq action 'crosspost)
5997 (let ((xref (mail-header-xref (gnus-summary-article-header article))))
5998 (setq new-xref (concat gnus-newsgroup-name ":" article))
5999 (if (and xref (not (string= xref "")))
6001 (when (string-match "^Xref: " xref)
6002 (setq xref (substring xref (match-end 0))))
6003 (setq new-xref (concat xref " " new-xref)))
6004 (setq new-xref (concat (system-name) " " new-xref)))
6006 (set-buffer copy-buf)
6007 (gnus-request-article-this-buffer article gnus-newsgroup-name)
6008 (nnheader-replace-header "xref" new-xref)
6009 (gnus-request-accept-article
6010 to-newsgroup select-method (not articles)))))))
6012 (gnus-message 1 "Couldn't %s article %s"
6013 (cadr (assq action names)) article)
6016 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
6018 (gnus-group-prefixed-name
6021 (gnus-find-method-for-group to-newsgroup)))
6022 gnus-newsrc-hashtb)))
6023 (info (nth 2 entry))
6024 (to-group (gnus-info-group info)))
6025 ;; Update the group that has been moved to.
6027 (memq action '(move copy)))
6028 (unless (member to-group to-groups)
6029 (push to-group to-groups))
6031 (unless (memq article gnus-newsgroup-unreads)
6033 info (gnus-add-to-range (gnus-info-read info)
6034 (list (cdr art-group)))))
6036 ;; Copy any marks over to the new group.
6037 (let ((marks gnus-article-mark-lists)
6038 (to-article (cdr art-group)))
6040 ;; See whether the article is to be put in the cache.
6041 (when gnus-use-cache
6042 (gnus-cache-possibly-enter-article
6044 (let ((header (copy-sequence
6045 (gnus-summary-article-header article))))
6046 (mail-header-set-number header to-article)
6048 (memq article gnus-newsgroup-marked)
6049 (memq article gnus-newsgroup-dormant)
6050 (memq article gnus-newsgroup-unreads)))
6053 (when (memq article (symbol-value
6054 (intern (format "gnus-newsgroup-%s"
6056 ;; If the other group is the same as this group,
6057 ;; then we have to add the mark to the list.
6058 (when (equal to-group gnus-newsgroup-name)
6059 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
6062 (intern (format "gnus-newsgroup-%s"
6064 ;; Copy mark to other group.
6065 (gnus-add-marked-articles
6066 to-group (cdar marks) (list to-article) info))
6067 (setq marks (cdr marks)))))
6069 ;; Update the Xref header in this article to point to
6070 ;; the new crossposted article we have just created.
6071 (when (eq action 'crosspost)
6073 (set-buffer copy-buf)
6074 (gnus-request-article-this-buffer article gnus-newsgroup-name)
6075 (nnheader-replace-header
6076 "xref" (concat new-xref " " (gnus-group-prefixed-name
6077 (car art-group) to-method)
6078 ":" (cdr art-group)))
6079 (gnus-request-replace-article
6080 article gnus-newsgroup-name (current-buffer)))))
6082 (gnus-summary-goto-subject article)
6083 (when (eq action 'move)
6084 (gnus-summary-mark-article article gnus-canceled-mark)))
6085 (gnus-summary-remove-process-mark article))
6086 ;; Re-activate all groups that have been moved to.
6088 (gnus-activate-group (pop to-groups)))
6090 (gnus-kill-buffer copy-buf)
6091 (gnus-summary-position-point)
6092 (gnus-set-mode-line 'summary)))
6094 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
6095 "Move the current article to a different newsgroup.
6096 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
6097 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
6098 re-spool using this method."
6100 (gnus-summary-move-article n nil select-method 'copy))
6102 (defun gnus-summary-crosspost-article (&optional n)
6103 "Crosspost the current article to some other group."
6105 (gnus-summary-move-article n nil nil 'crosspost))
6107 (defvar gnus-summary-respool-default-method nil
6108 "Default method for respooling an article.
6109 If nil, use to the current newsgroup method.")
6111 (defun gnus-summary-respool-article (&optional n method)
6112 "Respool the current article.
6113 The article will be squeezed through the mail spooling process again,
6114 which means that it will be put in some mail newsgroup or other
6115 depending on `nnmail-split-methods'.
6116 If N is a positive number, respool the N next articles.
6117 If N is a negative number, respool the N previous articles.
6118 If N is nil and any articles have been marked with the process mark,
6119 respool those articles instead.
6121 Respooling can be done both from mail groups and \"real\" newsgroups.
6122 In the former case, the articles in question will be moved from the
6123 current group into whatever groups they are destined to. In the
6124 latter case, they will be copied into the relevant groups."
6126 (list current-prefix-arg
6127 (let* ((methods (gnus-methods-using 'respool))
6129 (symbol-name (or gnus-summary-respool-default-method
6130 (car (gnus-find-method-for-group
6131 gnus-newsgroup-name)))))
6133 (gnus-completing-read
6134 methname "What backend do you want to use when respooling?"
6135 methods nil t nil 'gnus-method-history))
6138 ((zerop (length (setq ms (gnus-servers-using-backend method))))
6139 (list (intern method) ""))
6143 (cdr (completing-read
6145 (mapcar (lambda (m) (cons (cadr m) m)) ms) nil t)))))))
6146 (gnus-set-global-variables)
6148 (error "No method given for respooling"))
6149 (if (assoc (symbol-name
6150 (car (gnus-find-method-for-group gnus-newsgroup-name)))
6151 (gnus-methods-using 'respool))
6152 (gnus-summary-move-article n nil method)
6153 (gnus-summary-copy-article n nil method)))
6155 (defun gnus-summary-import-article (file)
6156 "Import a random file into a mail newsgroup."
6157 (interactive "fImport file: ")
6158 (gnus-set-global-variables)
6159 (let ((group gnus-newsgroup-name)
6160 (now (current-time))
6162 (or (gnus-check-backend-function 'request-accept-article group)
6163 (error "%s does not support article importing" group))
6164 (or (file-readable-p file)
6165 (not (file-regular-p file))
6166 (error "Can't read %s" file))
6168 (set-buffer (get-buffer-create " *import file*"))
6169 (buffer-disable-undo (current-buffer))
6171 (insert-file-contents file)
6172 (goto-char (point-min))
6173 (unless (nnheader-article-p)
6174 ;; This doesn't look like an article, so we fudge some headers.
6175 (setq atts (file-attributes file)
6176 lines (count-lines (point-min) (point-max)))
6177 (insert "From: " (read-string "From: ") "\n"
6178 "Subject: " (read-string "Subject: ") "\n"
6179 "Date: " (timezone-make-date-arpa-standard
6180 (current-time-string (nth 5 atts))
6181 (current-time-zone now)
6182 (current-time-zone now)) "\n"
6183 "Message-ID: " (message-make-message-id) "\n"
6184 "Lines: " (int-to-string lines) "\n"
6185 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
6186 (gnus-request-accept-article group nil t)
6187 (kill-buffer (current-buffer)))))
6189 (defun gnus-summary-article-posted-p ()
6190 "Say whether the current (mail) article is available from `gnus-select-method' as well.
6191 This will be the case if the article has both been mailed and posted."
6193 (let ((id (mail-header-references (gnus-summary-article-header)))
6194 (gnus-override-method
6195 (or gnus-refer-article-method gnus-select-method)))
6196 (if (gnus-request-head id "")
6197 (gnus-message 2 "The current message was found on %s"
6198 gnus-override-method)
6199 (gnus-message 2 "The current message couldn't be found on %s"
6200 gnus-override-method)
6203 (defun gnus-summary-expire-articles (&optional now)
6204 "Expire all articles that are marked as expirable in the current group."
6206 (gnus-set-global-variables)
6207 (when (gnus-check-backend-function
6208 'request-expire-articles gnus-newsgroup-name)
6209 ;; This backend supports expiry.
6210 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
6211 (expirable (if total
6212 (gnus-list-of-read-articles gnus-newsgroup-name)
6213 (setq gnus-newsgroup-expirable
6214 (sort gnus-newsgroup-expirable '<))))
6215 (expiry-wait (if now 'immediate
6216 (gnus-group-find-parameter
6217 gnus-newsgroup-name 'expiry-wait)))
6220 ;; There are expirable articles in this group, so we run them
6221 ;; through the expiry process.
6222 (gnus-message 6 "Expiring articles...")
6223 ;; The list of articles that weren't expired is returned.
6225 (let ((nnmail-expiry-wait-function nil)
6226 (nnmail-expiry-wait expiry-wait))
6227 (setq es (gnus-request-expire-articles
6228 expirable gnus-newsgroup-name)))
6229 (setq es (gnus-request-expire-articles
6230 expirable gnus-newsgroup-name)))
6232 (setq gnus-newsgroup-expirable es))
6233 ;; We go through the old list of expirable, and mark all
6234 ;; really expired articles as nonexistent.
6235 (unless (eq es expirable) ;If nothing was expired, we don't mark.
6236 (let ((gnus-use-cache nil))
6238 (unless (memq (car expirable) es)
6239 (when (gnus-data-find (car expirable))
6240 (gnus-summary-mark-article
6241 (car expirable) gnus-canceled-mark)))
6242 (setq expirable (cdr expirable)))))
6243 (gnus-message 6 "Expiring articles...done")))))
6245 (defun gnus-summary-expire-articles-now ()
6246 "Expunge all expirable articles in the current group.
6247 This means that *all* articles that are marked as expirable will be
6248 deleted forever, right now."
6250 (gnus-set-global-variables)
6251 (or gnus-expert-user
6253 "Are you really, really, really sure you want to delete all these messages? ")
6255 (gnus-summary-expire-articles t))
6257 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
6258 (defun gnus-summary-delete-article (&optional n)
6259 "Delete the N next (mail) articles.
6260 This command actually deletes articles. This is not a marking
6261 command. The article will disappear forever from your life, never to
6263 If N is negative, delete backwards.
6264 If N is nil and articles have been marked with the process mark,
6265 delete these instead."
6267 (gnus-set-global-variables)
6268 (or (gnus-check-backend-function 'request-expire-articles
6269 gnus-newsgroup-name)
6270 (error "The current newsgroup does not support article deletion."))
6271 ;; Compute the list of articles to delete.
6272 (let ((articles (gnus-summary-work-articles n))
6274 (if (and gnus-novice-user
6276 (format "Do you really want to delete %s forever? "
6277 (if (> (length articles) 1)
6278 (format "these %s articles" (length articles))
6281 ;; Delete the articles.
6282 (setq not-deleted (gnus-request-expire-articles
6283 articles gnus-newsgroup-name 'force))
6285 (gnus-summary-remove-process-mark (car articles))
6286 ;; The backend might not have been able to delete the article
6288 (or (memq (car articles) not-deleted)
6289 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
6290 (setq articles (cdr articles))))
6291 (gnus-summary-position-point)
6292 (gnus-set-mode-line 'summary)
6295 (defun gnus-summary-edit-article (&optional force)
6296 "Edit the current article.
6297 This will have permanent effect only in mail groups.
6298 If FORCE is non-nil, allow editing of articles even in read-only
6302 (set-buffer gnus-summary-buffer)
6303 (gnus-set-global-variables)
6304 (when (and (not force)
6305 (gnus-group-read-only-p))
6306 (error "The current newsgroup does not support article editing."))
6307 ;; Select article if needed.
6308 (unless (eq (gnus-summary-article-number)
6309 gnus-current-article)
6310 (gnus-summary-select-article t))
6311 (gnus-article-edit-article
6313 (gnus-summary-edit-article-done
6314 ,(or (mail-header-references gnus-current-headers) "")
6315 ,(gnus-group-read-only-p) ,gnus-summary-buffer)))))
6317 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
6319 (defun gnus-summary-edit-article-done (references read-only buffer)
6320 "Make edits to the current article permanent."
6322 ;; Replace the article.
6323 (if (and (not read-only)
6324 (not (gnus-request-replace-article
6325 (cdr gnus-article-current) (car gnus-article-current)
6327 (error "Couldn't replace article.")
6328 ;; Update the summary buffer.
6329 (if (equal (message-tokenize-header references " ")
6330 (message-tokenize-header
6331 (or (message-fetch-field "references") "") " "))
6332 ;; We only have to update this line.
6335 (message-narrow-to-head)
6336 (let ((header (nnheader-parse-head t)))
6338 (mail-header-set-number header (cdr gnus-article-current))
6339 (gnus-summary-update-article-line
6340 (cdr gnus-article-current) header))))
6343 (gnus-summary-update-article (cdr gnus-article-current)))
6344 ;; Prettify the article buffer again.
6346 (set-buffer gnus-article-buffer)
6347 (run-hooks 'gnus-article-display-hook))
6348 ;; Prettify the summary buffer line.
6349 (when (gnus-visual-p 'summary-highlight 'highlight)
6350 (run-hooks 'gnus-visual-mark-article-hook))))
6352 (defun gnus-summary-edit-wash (key)
6353 "Perform editing command in the article buffer."
6357 (message "%s" (concat (this-command-keys) "- "))
6360 (gnus-summary-edit-article)
6361 (execute-kbd-macro (concat (this-command-keys) key))
6362 (gnus-article-edit-done))
6366 (defun gnus-summary-respool-query ()
6367 "Query where the respool algorithm would put this article."
6369 (gnus-set-global-variables)
6370 (gnus-summary-select-article)
6372 (set-buffer gnus-article-buffer)
6374 (goto-char (point-min))
6375 (search-forward "\n\n")
6376 (narrow-to-region (point-min) (point))
6378 (list 'quote (mapcar 'car (nnmail-article-group 'identity)))))))
6380 ;; Summary marking commands.
6382 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
6383 "Mark articles which has the same subject as read, and then select the next.
6384 If UNMARK is positive, remove any kind of mark.
6385 If UNMARK is negative, tick articles."
6387 (gnus-set-global-variables)
6389 (setq unmark (prefix-numeric-value unmark)))
6391 (gnus-summary-mark-same-subject
6392 (gnus-summary-article-subject) unmark)))
6393 ;; Select next unread article. If auto-select-same mode, should
6394 ;; select the first unread article.
6395 (gnus-summary-next-article t (and gnus-auto-select-same
6396 (gnus-summary-article-subject)))
6397 (gnus-message 7 "%d article%s marked as %s"
6398 count (if (= count 1) " is" "s are")
6399 (if unmark "unread" "read"))))
6401 (defun gnus-summary-kill-same-subject (&optional unmark)
6402 "Mark articles which has the same subject as read.
6403 If UNMARK is positive, remove any kind of mark.
6404 If UNMARK is negative, tick articles."
6406 (gnus-set-global-variables)
6408 (setq unmark (prefix-numeric-value unmark)))
6410 (gnus-summary-mark-same-subject
6411 (gnus-summary-article-subject) unmark)))
6412 ;; If marked as read, go to next unread subject.
6414 ;; Go to next unread subject.
6415 (gnus-summary-next-subject 1 t))
6416 (gnus-message 7 "%d articles are marked as %s"
6417 count (if unmark "unread" "read"))))
6419 (defun gnus-summary-mark-same-subject (subject &optional unmark)
6420 "Mark articles with same SUBJECT as read, and return marked number.
6421 If optional argument UNMARK is positive, remove any kinds of marks.
6422 If optional argument UNMARK is negative, mark articles as unread instead."
6426 ((null unmark) ; Mark as read.
6429 (gnus-summary-mark-article-as-read gnus-killed-mark)
6430 (gnus-summary-show-thread) t)
6431 (gnus-summary-find-subject subject))
6432 (setq count (1+ count))))
6433 ((> unmark 0) ; Tick.
6436 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
6437 (gnus-summary-show-thread) t)
6438 (gnus-summary-find-subject subject))
6439 (setq count (1+ count))))
6440 (t ; Mark as unread.
6443 (gnus-summary-mark-article-as-unread gnus-unread-mark)
6444 (gnus-summary-show-thread) t)
6445 (gnus-summary-find-subject subject))
6446 (setq count (1+ count)))))
6447 (gnus-set-mode-line 'summary)
6448 ;; Return the number of marked articles.
6451 (defun gnus-summary-mark-as-processable (n &optional unmark)
6452 "Set the process mark on the next N articles.
6453 If N is negative, mark backward instead. If UNMARK is non-nil, remove
6454 the process mark instead. The difference between N and the actual
6455 number of articles marked is returned."
6457 (gnus-set-global-variables)
6458 (let ((backward (< n 0))
6463 (gnus-summary-remove-process-mark
6464 (gnus-summary-article-number))
6465 (gnus-summary-set-process-mark (gnus-summary-article-number)))
6466 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
6468 (if (/= 0 n) (gnus-message 7 "No more articles"))
6469 (gnus-summary-recenter)
6470 (gnus-summary-position-point)
6473 (defun gnus-summary-unmark-as-processable (n)
6474 "Remove the process mark from the next N articles.
6475 If N is negative, mark backward instead. The difference between N and
6476 the actual number of articles marked is returned."
6478 (gnus-set-global-variables)
6479 (gnus-summary-mark-as-processable n t))
6481 (defun gnus-summary-unmark-all-processable ()
6482 "Remove the process mark from all articles."
6484 (gnus-set-global-variables)
6486 (while gnus-newsgroup-processable
6487 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
6488 (gnus-summary-position-point))
6490 (defun gnus-summary-mark-as-expirable (n)
6491 "Mark N articles forward as expirable.
6492 If N is negative, mark backward instead. The difference between N and
6493 the actual number of articles marked is returned."
6495 (gnus-set-global-variables)
6496 (gnus-summary-mark-forward n gnus-expirable-mark))
6498 (defun gnus-summary-mark-article-as-replied (article)
6499 "Mark ARTICLE replied and update the summary line."
6500 (setq gnus-newsgroup-replied (cons article gnus-newsgroup-replied))
6501 (let ((buffer-read-only nil))
6502 (when (gnus-summary-goto-subject article)
6503 (gnus-summary-update-secondary-mark article))))
6505 (defun gnus-summary-set-bookmark (article)
6506 "Set a bookmark in current article."
6507 (interactive (list (gnus-summary-article-number)))
6508 (gnus-set-global-variables)
6509 (if (or (not (get-buffer gnus-article-buffer))
6510 (not gnus-current-article)
6511 (not gnus-article-current)
6512 (not (equal gnus-newsgroup-name (car gnus-article-current))))
6513 (error "No current article selected"))
6514 ;; Remove old bookmark, if one exists.
6515 (let ((old (assq article gnus-newsgroup-bookmarks)))
6516 (if old (setq gnus-newsgroup-bookmarks
6517 (delq old gnus-newsgroup-bookmarks))))
6518 ;; Set the new bookmark, which is on the form
6519 ;; (article-number . line-number-in-body).
6520 (setq gnus-newsgroup-bookmarks
6524 (set-buffer gnus-article-buffer)
6528 (goto-char (point-min))
6529 (search-forward "\n\n" nil t)
6532 gnus-newsgroup-bookmarks))
6533 (gnus-message 6 "A bookmark has been added to the current article."))
6535 (defun gnus-summary-remove-bookmark (article)
6536 "Remove the bookmark from the current article."
6537 (interactive (list (gnus-summary-article-number)))
6538 (gnus-set-global-variables)
6539 ;; Remove old bookmark, if one exists.
6540 (let ((old (assq article gnus-newsgroup-bookmarks)))
6543 (setq gnus-newsgroup-bookmarks
6544 (delq old gnus-newsgroup-bookmarks))
6545 (gnus-message 6 "Removed bookmark."))
6546 (gnus-message 6 "No bookmark in current article."))))
6548 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
6549 (defun gnus-summary-mark-as-dormant (n)
6550 "Mark N articles forward as dormant.
6551 If N is negative, mark backward instead. The difference between N and
6552 the actual number of articles marked is returned."
6554 (gnus-set-global-variables)
6555 (gnus-summary-mark-forward n gnus-dormant-mark))
6557 (defun gnus-summary-set-process-mark (article)
6558 "Set the process mark on ARTICLE and update the summary line."
6559 (setq gnus-newsgroup-processable
6561 (delq article gnus-newsgroup-processable)))
6562 (when (gnus-summary-goto-subject article)
6563 (gnus-summary-show-thread)
6564 (gnus-summary-update-secondary-mark article)))
6566 (defun gnus-summary-remove-process-mark (article)
6567 "Remove the process mark from ARTICLE and update the summary line."
6568 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
6569 (when (gnus-summary-goto-subject article)
6570 (gnus-summary-show-thread)
6571 (gnus-summary-update-secondary-mark article)))
6573 (defun gnus-summary-set-saved-mark (article)
6574 "Set the process mark on ARTICLE and update the summary line."
6575 (push article gnus-newsgroup-saved)
6576 (when (gnus-summary-goto-subject article)
6577 (gnus-summary-update-secondary-mark article)))
6579 (defun gnus-summary-mark-forward (n &optional mark no-expire)
6580 "Mark N articles as read forwards.
6581 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
6582 The difference between N and the actual number of articles marked is
6585 (gnus-set-global-variables)
6586 (let ((backward (< n 0))
6587 (gnus-summary-goto-unread
6588 (and gnus-summary-goto-unread
6589 (not (eq gnus-summary-goto-unread 'never))
6590 (not (memq mark (list gnus-unread-mark
6591 gnus-ticked-mark gnus-dormant-mark)))))
6593 (mark (or mark gnus-del-mark)))
6595 (gnus-summary-mark-article nil mark no-expire)
6596 (zerop (gnus-summary-next-subject
6598 (and gnus-summary-goto-unread
6599 (not (eq gnus-summary-goto-unread 'never)))
6602 (if (/= 0 n) (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
6603 (gnus-summary-recenter)
6604 (gnus-summary-position-point)
6605 (gnus-set-mode-line 'summary)
6608 (defun gnus-summary-mark-article-as-read (mark)
6609 "Mark the current article quickly as read with MARK."
6610 (let ((article (gnus-summary-article-number)))
6611 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
6612 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
6613 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
6614 (setq gnus-newsgroup-reads
6615 (cons (cons article mark) gnus-newsgroup-reads))
6616 ;; Possibly remove from cache, if that is used.
6617 (and gnus-use-cache (gnus-cache-enter-remove-article article))
6618 ;; Allow the backend to change the mark.
6619 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
6620 ;; Check for auto-expiry.
6621 (when (and gnus-newsgroup-auto-expire
6622 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
6623 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
6624 (= mark gnus-ancient-mark)
6625 (= mark gnus-read-mark) (= mark gnus-souped-mark)
6626 (= mark gnus-duplicate-mark)))
6627 (setq mark gnus-expirable-mark)
6628 (push article gnus-newsgroup-expirable))
6629 ;; Set the mark in the buffer.
6630 (gnus-summary-update-mark mark 'unread)
6633 (defun gnus-summary-mark-article-as-unread (mark)
6634 "Mark the current article quickly as unread with MARK."
6635 (let ((article (gnus-summary-article-number)))
6637 (gnus-error 1 "Unmarkable article")
6638 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
6639 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
6640 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
6641 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
6642 (cond ((= mark gnus-ticked-mark)
6643 (push article gnus-newsgroup-marked))
6644 ((= mark gnus-dormant-mark)
6645 (push article gnus-newsgroup-dormant))
6647 (push article gnus-newsgroup-unreads)))
6648 (setq gnus-newsgroup-reads
6649 (delq (assq article gnus-newsgroup-reads)
6650 gnus-newsgroup-reads))
6652 ;; See whether the article is to be put in the cache.
6654 (vectorp (gnus-summary-article-header article))
6656 (gnus-cache-possibly-enter-article
6657 gnus-newsgroup-name article
6658 (gnus-summary-article-header article)
6659 (= mark gnus-ticked-mark)
6660 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
6663 (gnus-summary-update-mark mark 'unread))
6666 (defun gnus-summary-mark-article (&optional article mark no-expire)
6667 "Mark ARTICLE with MARK. MARK can be any character.
6668 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
6669 `??' (dormant) and `?E' (expirable).
6670 If MARK is nil, then the default character `?D' is used.
6671 If ARTICLE is nil, then the article on the current line will be
6673 ;; The mark might be a string.
6675 (setq mark (aref mark 0)))
6676 ;; If no mark is given, then we check auto-expiring.
6677 (and (not no-expire)
6678 gnus-newsgroup-auto-expire
6681 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
6682 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
6683 (= mark gnus-read-mark) (= mark gnus-souped-mark)
6684 (= mark gnus-duplicate-mark))))
6685 (setq mark gnus-expirable-mark))
6686 (let* ((mark (or mark gnus-del-mark))
6687 (article (or article (gnus-summary-article-number))))
6688 (or article (error "No article on current line"))
6689 (if (or (= mark gnus-unread-mark)
6690 (= mark gnus-ticked-mark)
6691 (= mark gnus-dormant-mark))
6692 (gnus-mark-article-as-unread article mark)
6693 (gnus-mark-article-as-read article mark))
6695 ;; See whether the article is to be put in the cache.
6697 (not (= mark gnus-canceled-mark))
6698 (vectorp (gnus-summary-article-header article))
6700 (gnus-cache-possibly-enter-article
6701 gnus-newsgroup-name article
6702 (gnus-summary-article-header article)
6703 (= mark gnus-ticked-mark)
6704 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
6706 (if (gnus-summary-goto-subject article nil t)
6707 (let ((buffer-read-only nil))
6708 (gnus-summary-show-thread)
6710 (gnus-summary-update-mark mark 'unread)
6713 (defun gnus-summary-update-secondary-mark (article)
6714 "Update the secondary (read, process, cache) mark."
6715 (gnus-summary-update-mark
6716 (cond ((memq article gnus-newsgroup-processable)
6718 ((memq article gnus-newsgroup-cached)
6720 ((memq article gnus-newsgroup-replied)
6722 ((memq article gnus-newsgroup-saved)
6724 (t gnus-unread-mark))
6726 (when (gnus-visual-p 'summary-highlight 'highlight)
6727 (run-hooks 'gnus-summary-update-hook))
6730 (defun gnus-summary-update-mark (mark type)
6731 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
6732 (buffer-read-only nil))
6733 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
6734 (and (looking-at "\r") (setq forward (1+ forward)))
6736 (<= (+ forward (point)) (point-max)))
6737 ;; Go to the right position on the line.
6738 (goto-char (+ forward (point)))
6739 ;; Replace the old mark with the new mark.
6740 (subst-char-in-region (point) (1+ (point)) (following-char) mark)
6741 ;; Optionally update the marks by some user rule.
6742 (when (eq type 'unread)
6744 (gnus-data-find (gnus-summary-article-number)) mark)
6745 (gnus-summary-update-line (eq mark gnus-unread-mark))))))
6747 (defun gnus-mark-article-as-read (article &optional mark)
6748 "Enter ARTICLE in the pertinent lists and remove it from others."
6749 ;; Make the article expirable.
6750 (let ((mark (or mark gnus-del-mark)))
6751 (if (= mark gnus-expirable-mark)
6752 (setq gnus-newsgroup-expirable (cons article gnus-newsgroup-expirable))
6753 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
6754 ;; Remove from unread and marked lists.
6755 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
6756 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
6757 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
6758 (push (cons article mark) gnus-newsgroup-reads)
6759 ;; Possibly remove from cache, if that is used.
6760 (when gnus-use-cache
6761 (gnus-cache-enter-remove-article article))))
6763 (defun gnus-mark-article-as-unread (article &optional mark)
6764 "Enter ARTICLE in the pertinent lists and remove it from others."
6765 (let ((mark (or mark gnus-ticked-mark)))
6766 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
6767 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
6768 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
6769 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
6771 ;; Unsuppress duplicates?
6772 (when gnus-suppress-duplicates
6773 (gnus-dup-unsuppress-article article))
6775 (cond ((= mark gnus-ticked-mark)
6776 (push article gnus-newsgroup-marked))
6777 ((= mark gnus-dormant-mark)
6778 (push article gnus-newsgroup-dormant))
6780 (push article gnus-newsgroup-unreads)))
6781 (setq gnus-newsgroup-reads
6782 (delq (assq article gnus-newsgroup-reads)
6783 gnus-newsgroup-reads))))
6785 (defalias 'gnus-summary-mark-as-unread-forward
6786 'gnus-summary-tick-article-forward)
6787 (make-obsolete 'gnus-summary-mark-as-unread-forward
6788 'gnus-summary-tick-article-forward)
6789 (defun gnus-summary-tick-article-forward (n)
6790 "Tick N articles forwards.
6791 If N is negative, tick backwards instead.
6792 The difference between N and the number of articles ticked is returned."
6794 (gnus-summary-mark-forward n gnus-ticked-mark))
6796 (defalias 'gnus-summary-mark-as-unread-backward
6797 'gnus-summary-tick-article-backward)
6798 (make-obsolete 'gnus-summary-mark-as-unread-backward
6799 'gnus-summary-tick-article-backward)
6800 (defun gnus-summary-tick-article-backward (n)
6801 "Tick N articles backwards.
6802 The difference between N and the number of articles ticked is returned."
6804 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
6806 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
6807 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
6808 (defun gnus-summary-tick-article (&optional article clear-mark)
6809 "Mark current article as unread.
6810 Optional 1st argument ARTICLE specifies article number to be marked as unread.
6811 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
6813 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
6816 (defun gnus-summary-mark-as-read-forward (n)
6817 "Mark N articles as read forwards.
6818 If N is negative, mark backwards instead.
6819 The difference between N and the actual number of articles marked is
6822 (gnus-summary-mark-forward n gnus-del-mark t))
6824 (defun gnus-summary-mark-as-read-backward (n)
6825 "Mark the N articles as read backwards.
6826 The difference between N and the actual number of articles marked is
6829 (gnus-summary-mark-forward (- n) gnus-del-mark t))
6831 (defun gnus-summary-mark-as-read (&optional article mark)
6832 "Mark current article as read.
6833 ARTICLE specifies the article to be marked as read.
6834 MARK specifies a string to be inserted at the beginning of the line."
6835 (gnus-summary-mark-article article mark))
6837 (defun gnus-summary-clear-mark-forward (n)
6838 "Clear marks from N articles forward.
6839 If N is negative, clear backward instead.
6840 The difference between N and the number of marks cleared is returned."
6842 (gnus-summary-mark-forward n gnus-unread-mark))
6844 (defun gnus-summary-clear-mark-backward (n)
6845 "Clear marks from N articles backward.
6846 The difference between N and the number of marks cleared is returned."
6848 (gnus-summary-mark-forward (- n) gnus-unread-mark))
6850 (defun gnus-summary-mark-unread-as-read ()
6851 "Intended to be used by `gnus-summary-mark-article-hook'."
6852 (when (memq gnus-current-article gnus-newsgroup-unreads)
6853 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
6855 (defun gnus-summary-mark-read-and-unread-as-read ()
6856 "Intended to be used by `gnus-summary-mark-article-hook'."
6857 (let ((mark (gnus-summary-article-mark)))
6858 (when (or (gnus-unread-mark-p mark)
6859 (gnus-read-mark-p mark))
6860 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
6862 (defun gnus-summary-mark-region-as-read (point mark all)
6863 "Mark all unread articles between point and mark as read.
6864 If given a prefix, mark all articles between point and mark as read,
6865 even ticked and dormant ones."
6866 (interactive "r\nP")
6875 (memq (setq article (gnus-summary-article-number))
6876 gnus-newsgroup-unreads))
6877 (gnus-summary-mark-article article gnus-del-mark))
6879 (gnus-summary-find-next))))))
6881 (defun gnus-summary-mark-below (score mark)
6882 "Mark articles with score less than SCORE with MARK."
6883 (interactive "P\ncMark: ")
6884 (gnus-set-global-variables)
6885 (setq score (if score
6886 (prefix-numeric-value score)
6887 (or gnus-summary-default-score 0)))
6889 (set-buffer gnus-summary-buffer)
6890 (goto-char (point-min))
6893 (and (< (gnus-summary-article-score) score)
6894 (gnus-summary-mark-article nil mark))
6895 (gnus-summary-find-next)))))
6897 (defun gnus-summary-kill-below (&optional score)
6898 "Mark articles with score below SCORE as read."
6900 (gnus-set-global-variables)
6901 (gnus-summary-mark-below score gnus-killed-mark))
6903 (defun gnus-summary-clear-above (&optional score)
6904 "Clear all marks from articles with score above SCORE."
6906 (gnus-set-global-variables)
6907 (gnus-summary-mark-above score gnus-unread-mark))
6909 (defun gnus-summary-tick-above (&optional score)
6910 "Tick all articles with score above SCORE."
6912 (gnus-set-global-variables)
6913 (gnus-summary-mark-above score gnus-ticked-mark))
6915 (defun gnus-summary-mark-above (score mark)
6916 "Mark articles with score over SCORE with MARK."
6917 (interactive "P\ncMark: ")
6918 (gnus-set-global-variables)
6919 (setq score (if score
6920 (prefix-numeric-value score)
6921 (or gnus-summary-default-score 0)))
6923 (set-buffer gnus-summary-buffer)
6924 (goto-char (point-min))
6926 (if (> (gnus-summary-article-score) score)
6927 (gnus-summary-mark-article nil mark))
6929 (gnus-summary-find-next)))))
6931 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
6932 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
6933 (defun gnus-summary-limit-include-expunged (&optional no-error)
6934 "Display all the hidden articles that were expunged for low scores."
6936 (gnus-set-global-variables)
6937 (let ((buffer-read-only nil))
6938 (let ((scored gnus-newsgroup-scored)
6941 (or (gnus-summary-goto-subject (caar scored))
6942 (and (setq h (gnus-summary-article-header (caar scored)))
6943 (< (cdar scored) gnus-summary-expunge-below)
6944 (setq headers (cons h headers))))
6945 (setq scored (cdr scored)))
6947 (when (not no-error)
6948 (error "No expunged articles hidden."))
6949 (goto-char (point-min))
6950 (gnus-summary-prepare-unthreaded (nreverse headers))
6951 (goto-char (point-min))
6952 (gnus-summary-position-point)
6955 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
6956 "Mark all articles not marked as unread in this newsgroup as read.
6957 If prefix argument ALL is non-nil, all articles are marked as read.
6958 If QUIETLY is non-nil, no questions will be asked.
6959 If TO-HERE is non-nil, it should be a point in the buffer. All
6960 articles before this point will be marked as read.
6961 The number of articles marked as read is returned."
6963 (gnus-set-global-variables)
6966 (not gnus-interactive-catchup) ;Without confirmation?
6970 "Mark absolutely all articles as read? "
6971 "Mark all unread articles as read? ")))
6973 (not gnus-newsgroup-adaptive)
6974 (not gnus-newsgroup-auto-expire)
6975 (not gnus-suppress-duplicates))
6978 (setq gnus-newsgroup-marked nil
6979 gnus-newsgroup-dormant nil))
6980 (setq gnus-newsgroup-unreads nil))
6981 ;; We actually mark all articles as canceled, which we
6982 ;; have to do when using auto-expiry or adaptive scoring.
6983 (gnus-summary-show-all-threads)
6984 (when (gnus-summary-first-subject (not all))
6986 (if to-here (< (point) to-here) t)
6987 (gnus-summary-mark-article-as-read gnus-catchup-mark)
6988 (gnus-summary-find-next (not all)))))
6990 (setq gnus-newsgroup-unreads nil))
6991 (gnus-set-mode-line 'summary)))
6992 (let ((method (gnus-find-method-for-group gnus-newsgroup-name)))
6993 (when (and (not to-here) (eq 'nnvirtual (car method)))
6994 (nnvirtual-catchup-group
6995 (gnus-group-real-name gnus-newsgroup-name) (nth 1 method) all)))
6996 (gnus-summary-position-point)))
6998 (defun gnus-summary-catchup-to-here (&optional all)
6999 "Mark all unticked articles before the current one as read.
7000 If ALL is non-nil, also mark ticked and dormant articles as read."
7002 (gnus-set-global-variables)
7004 (gnus-save-hidden-threads
7005 (let ((beg (point)))
7006 ;; We check that there are unread articles.
7007 (when (or all (gnus-summary-find-prev))
7008 (gnus-summary-catchup all t beg)))))
7009 (gnus-summary-position-point))
7011 (defun gnus-summary-catchup-all (&optional quietly)
7012 "Mark all articles in this newsgroup as read."
7014 (gnus-set-global-variables)
7015 (gnus-summary-catchup t quietly))
7017 (defun gnus-summary-catchup-and-exit (&optional all quietly)
7018 "Mark all articles not marked as unread in this newsgroup as read, then exit.
7019 If prefix argument ALL is non-nil, all articles are marked as read."
7021 (gnus-set-global-variables)
7022 (gnus-summary-catchup all quietly nil 'fast)
7023 ;; Select next newsgroup or exit.
7024 (if (eq gnus-auto-select-next 'quietly)
7025 (gnus-summary-next-group nil)
7026 (gnus-summary-exit)))
7028 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
7029 "Mark all articles in this newsgroup as read, and then exit."
7031 (gnus-set-global-variables)
7032 (gnus-summary-catchup-and-exit t quietly))
7034 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
7035 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
7036 "Mark all articles in this group as read and select the next group.
7037 If given a prefix, mark all articles, unread as well as ticked, as
7040 (gnus-set-global-variables)
7042 (gnus-summary-catchup all))
7043 (gnus-summary-next-article t nil nil t))
7045 ;; Thread-based commands.
7047 (defun gnus-summary-articles-in-thread (&optional article)
7048 "Return a list of all articles in the current thread.
7049 If ARTICLE is non-nil, return all articles in the thread that starts
7051 (let* ((article (or article (gnus-summary-article-number)))
7052 (data (gnus-data-find-list article))
7053 (top-level (gnus-data-level (car data)))
7055 (cond ((null gnus-thread-operation-ignore-subject)
7056 (gnus-simplify-subject-re
7057 (mail-header-subject (gnus-data-header (car data)))))
7058 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
7059 (gnus-simplify-subject-fuzzy
7060 (mail-header-subject (gnus-data-header (car data)))))
7062 (end-point (save-excursion
7063 (if (gnus-summary-go-to-next-thread)
7064 (point) (point-max))))
7067 (< (gnus-data-pos (car data)) end-point))
7068 (when (or (not top-subject)
7069 (string= top-subject
7070 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
7071 (gnus-simplify-subject-fuzzy
7072 (mail-header-subject
7073 (gnus-data-header (car data))))
7074 (gnus-simplify-subject-re
7075 (mail-header-subject
7076 (gnus-data-header (car data)))))))
7077 (push (gnus-data-number (car data)) articles))
7078 (unless (and (setq data (cdr data))
7079 (> (gnus-data-level (car data)) top-level))
7081 ;; Return the list of articles.
7082 (nreverse articles)))
7084 (defun gnus-summary-rethread-current ()
7085 "Rethread the thread the current article is part of."
7087 (gnus-set-global-variables)
7088 (let* ((gnus-show-threads t)
7089 (article (gnus-summary-article-number))
7090 (id (mail-header-id (gnus-summary-article-header)))
7091 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
7093 (error "No article on the current line"))
7094 (gnus-rebuild-thread id)
7095 (gnus-summary-goto-subject article)))
7097 (defun gnus-summary-reparent-thread ()
7098 "Make current article child of the marked (or previous) article.
7100 Note that the re-threading will only work if `gnus-thread-ignore-subject'
7101 is non-nil or the Subject: of both articles are the same."
7103 (or (not (gnus-group-read-only-p))
7104 (error "The current newsgroup does not support article editing."))
7105 (or (<= (length gnus-newsgroup-processable) 1)
7106 (error "No more than one article may be marked."))
7107 (save-window-excursion
7108 (let ((gnus-article-buffer " *reparent*")
7109 (current-article (gnus-summary-article-number))
7110 ; first grab the marked article, otherwise one line up.
7111 (parent-article (if (not (null gnus-newsgroup-processable))
7112 (car gnus-newsgroup-processable)
7114 (if (eq (forward-line -1) 0)
7115 (gnus-summary-article-number)
7116 (error "Beginning of summary buffer."))))))
7117 (or (not (eq current-article parent-article))
7118 (error "An article may not be self-referential."))
7119 (let ((message-id (mail-header-id
7120 (gnus-summary-article-header parent-article))))
7121 (or (and message-id (not (equal message-id "")))
7122 (error "No message-id in desired parent."))
7123 (gnus-summary-select-article t t nil current-article)
7124 (set-buffer gnus-article-buffer)
7125 (setq buffer-read-only nil)
7126 (let ((buf (format "%s" (buffer-string))))
7129 (goto-char (point-min))
7130 (if (search-forward-regexp "^References: " nil t)
7131 (insert message-id " " )
7132 (insert "References: " message-id "\n"))
7133 (or (gnus-request-replace-article current-article
7134 (car gnus-article-current)
7135 gnus-article-buffer)
7136 (error "Couldn't replace article."))
7137 (set-buffer gnus-summary-buffer)
7138 (gnus-summary-unmark-all-processable)
7139 (gnus-summary-rethread-current)
7140 (gnus-message 3 "Article %d is now the child of article %d."
7141 current-article parent-article)))))
7143 (defun gnus-summary-toggle-threads (&optional arg)
7144 "Toggle showing conversation threads.
7145 If ARG is positive number, turn showing conversation threads on."
7147 (gnus-set-global-variables)
7148 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
7149 (setq gnus-show-threads
7150 (if (null arg) (not gnus-show-threads)
7151 (> (prefix-numeric-value arg) 0)))
7152 (gnus-summary-prepare)
7153 (gnus-summary-goto-subject current)
7154 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
7155 (gnus-summary-position-point)))
7157 (defun gnus-summary-show-all-threads ()
7160 (gnus-set-global-variables)
7162 (let ((buffer-read-only nil))
7163 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
7164 (gnus-summary-position-point))
7166 (defun gnus-summary-show-thread ()
7167 "Show thread subtrees.
7168 Returns nil if no thread was there to be shown."
7170 (gnus-set-global-variables)
7171 (let ((buffer-read-only nil)
7173 ;; first goto end then to beg, to have point at beg after let
7174 (end (progn (end-of-line) (point)))
7175 (beg (progn (beginning-of-line) (point))))
7177 ;; Any hidden lines here?
7178 (search-forward "\r" end t)
7179 (subst-char-in-region beg end ?\^M ?\n t)
7181 (gnus-summary-position-point))))
7183 (defun gnus-summary-hide-all-threads ()
7184 "Hide all thread subtrees."
7186 (gnus-set-global-variables)
7188 (goto-char (point-min))
7189 (gnus-summary-hide-thread)
7190 (while (zerop (gnus-summary-next-thread 1 t))
7191 (gnus-summary-hide-thread)))
7192 (gnus-summary-position-point))
7194 (defun gnus-summary-hide-thread ()
7195 "Hide thread subtrees.
7196 Returns nil if no threads were there to be hidden."
7198 (gnus-set-global-variables)
7199 (let ((buffer-read-only nil)
7201 (article (gnus-summary-article-number)))
7203 ;; Go forward until either the buffer ends or the subthread
7205 (when (and (not (eobp))
7206 (or (zerop (gnus-summary-next-thread 1 t))
7207 (goto-char (point-max))))
7209 (if (and (> (point) start)
7210 (search-backward "\n" start t))
7212 (subst-char-in-region start (point) ?\n ?\^M)
7213 (gnus-summary-goto-subject article))
7216 ;;(gnus-summary-position-point)
7219 (defun gnus-summary-go-to-next-thread (&optional previous)
7220 "Go to the same level (or less) next thread.
7221 If PREVIOUS is non-nil, go to previous thread instead.
7222 Return the article number moved to, or nil if moving was impossible."
7223 (let ((level (gnus-summary-thread-level))
7224 (way (if previous -1 1))
7227 (while (and (not (eobp))
7228 (< level (gnus-summary-thread-level)))
7236 (gnus-summary-article-number)
7239 (defun gnus-summary-go-to-next-thread-old (&optional previous)
7240 "Go to the same level (or less) next thread.
7241 If PREVIOUS is non-nil, go to previous thread instead.
7242 Return the article number moved to, or nil if moving was impossible."
7243 (if (and (eq gnus-summary-make-false-root 'dummy)
7244 (gnus-summary-article-intangible-p))
7245 (let ((beg (point)))
7246 (while (and (zerop (forward-line 1))
7247 (not (gnus-summary-article-intangible-p))
7248 (not (zerop (save-excursion
7249 (gnus-summary-thread-level))))))
7255 (let* ((level (gnus-summary-thread-level))
7256 (article (gnus-summary-article-number))
7257 (data (cdr (gnus-data-find-list article (gnus-data-list previous))))
7260 (if (<= (gnus-data-level (car data)) level)
7261 (setq oart (gnus-data-number (car data))
7263 (setq data (cdr data))))
7265 (gnus-summary-goto-subject oart)))))
7267 (defun gnus-summary-next-thread (n &optional silent)
7268 "Go to the same level next N'th thread.
7269 If N is negative, search backward instead.
7270 Returns the difference between N and the number of skips actually
7273 If SILENT, don't output messages."
7275 (gnus-set-global-variables)
7276 (let ((backward (< n 0))
7280 (gnus-summary-go-to-next-thread backward))
7283 (gnus-summary-position-point))
7284 (when (and (not silent) (/= 0 n))
7285 (gnus-message 7 "No more threads"))
7288 (defun gnus-summary-prev-thread (n)
7289 "Go to the same level previous N'th thread.
7290 Returns the difference between N and the number of skips actually
7293 (gnus-set-global-variables)
7294 (gnus-summary-next-thread (- n)))
7296 (defun gnus-summary-go-down-thread ()
7297 "Go down one level in the current thread."
7298 (let ((children (gnus-summary-article-children)))
7300 (gnus-summary-goto-subject (car children)))))
7302 (defun gnus-summary-go-up-thread ()
7303 "Go up one level in the current thread."
7304 (let ((parent (gnus-summary-article-parent)))
7306 (gnus-summary-goto-subject parent))))
7308 (defun gnus-summary-down-thread (n)
7309 "Go down thread N steps.
7310 If N is negative, go up instead.
7311 Returns the difference between N and how many steps down that were
7314 (gnus-set-global-variables)
7318 (if up (gnus-summary-go-up-thread)
7319 (gnus-summary-go-down-thread)))
7321 (gnus-summary-position-point)
7322 (if (/= 0 n) (gnus-message 7 "Can't go further"))
7325 (defun gnus-summary-up-thread (n)
7326 "Go up 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)
7332 (gnus-summary-down-thread (- n)))
7334 (defun gnus-summary-top-thread ()
7335 "Go to the top of the thread."
7337 (gnus-set-global-variables)
7338 (while (gnus-summary-go-up-thread))
7339 (gnus-summary-article-number))
7341 (defun gnus-summary-kill-thread (&optional unmark)
7342 "Mark articles under current thread as read.
7343 If the prefix argument is positive, remove any kinds of marks.
7344 If the prefix argument is negative, tick articles instead."
7346 (gnus-set-global-variables)
7348 (setq unmark (prefix-numeric-value unmark)))
7349 (let ((articles (gnus-summary-articles-in-thread)))
7351 ;; Expand the thread.
7352 (gnus-summary-show-thread)
7353 ;; Mark all the articles.
7355 (gnus-summary-goto-subject (car articles))
7356 (cond ((null unmark)
7357 (gnus-summary-mark-article-as-read gnus-killed-mark))
7359 (gnus-summary-mark-article-as-unread gnus-unread-mark))
7361 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
7362 (setq articles (cdr articles))))
7363 ;; Hide killed subtrees.
7365 gnus-thread-hide-killed
7366 (gnus-summary-hide-thread))
7367 ;; If marked as read, go to next unread subject.
7369 ;; Go to next unread subject.
7370 (gnus-summary-next-subject 1 t)))
7371 (gnus-set-mode-line 'summary))
7373 ;; Summary sorting commands
7375 (defun gnus-summary-sort-by-number (&optional reverse)
7376 "Sort summary buffer by article number.
7377 Argument REVERSE means reverse order."
7379 (gnus-summary-sort 'number reverse))
7381 (defun gnus-summary-sort-by-author (&optional reverse)
7382 "Sort summary buffer by author name alphabetically.
7383 If case-fold-search is non-nil, case of letters is ignored.
7384 Argument REVERSE means reverse order."
7386 (gnus-summary-sort 'author reverse))
7388 (defun gnus-summary-sort-by-subject (&optional reverse)
7389 "Sort summary buffer by subject alphabetically. `Re:'s are ignored.
7390 If case-fold-search is non-nil, case of letters is ignored.
7391 Argument REVERSE means reverse order."
7393 (gnus-summary-sort 'subject reverse))
7395 (defun gnus-summary-sort-by-date (&optional reverse)
7396 "Sort summary buffer by date.
7397 Argument REVERSE means reverse order."
7399 (gnus-summary-sort 'date reverse))
7401 (defun gnus-summary-sort-by-score (&optional reverse)
7402 "Sort summary buffer by score.
7403 Argument REVERSE means reverse order."
7405 (gnus-summary-sort 'score reverse))
7407 (defun gnus-summary-sort (predicate reverse)
7408 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
7409 (gnus-set-global-variables)
7410 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
7411 (article (intern (format "gnus-article-sort-by-%s" predicate)))
7412 (gnus-thread-sort-functions
7418 (gnus-article-sort-functions
7423 (,article t2 t1)))))
7425 (gnus-summary-prepare-hook nil))
7426 ;; We do the sorting by regenerating the threads.
7427 (gnus-summary-prepare)
7428 ;; Hide subthreads if needed.
7429 (when (and gnus-show-threads gnus-thread-hide-subtree)
7430 (gnus-summary-hide-all-threads))))
7432 ;; Summary saving commands.
7434 (defun gnus-summary-save-article (&optional n not-saved)
7435 "Save the current article using the default saver function.
7436 If N is a positive number, save the N next articles.
7437 If N is a negative number, save the N previous articles.
7438 If N is nil and any articles have been marked with the process mark,
7439 save those articles instead.
7440 The variable `gnus-default-article-saver' specifies the saver function."
7442 (gnus-set-global-variables)
7443 (let* ((articles (gnus-summary-work-articles n))
7444 (save-buffer (save-excursion
7445 (nnheader-set-temp-buffer " *Gnus Save*")))
7446 (num (length articles))
7447 header article file)
7449 (setq header (gnus-summary-article-header
7450 (setq article (pop articles))))
7451 (if (not (vectorp header))
7452 ;; This is a pseudo-article.
7453 (if (assq 'name header)
7454 (gnus-copy-file (cdr (assq 'name header)))
7455 (gnus-message 1 "Article %d is unsaveable" article))
7456 ;; This is a real article.
7457 (save-window-excursion
7458 (gnus-summary-select-article t nil nil article))
7460 (set-buffer save-buffer)
7462 (insert-buffer-substring gnus-original-article-buffer))
7463 (setq file (gnus-article-save save-buffer file num))
7464 (gnus-summary-remove-process-mark article)
7466 (gnus-summary-set-saved-mark article))))
7467 (gnus-kill-buffer save-buffer)
7468 (gnus-summary-position-point)
7471 (defun gnus-summary-pipe-output (&optional arg)
7472 "Pipe the current article to a subprocess.
7473 If N is a positive number, pipe the N next articles.
7474 If N is a negative number, pipe the N previous articles.
7475 If N is nil and any articles have been marked with the process mark,
7476 pipe those articles instead."
7478 (gnus-set-global-variables)
7479 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
7480 (gnus-summary-save-article arg t))
7481 (gnus-configure-windows 'pipe))
7483 (defun gnus-summary-save-article-mail (&optional arg)
7484 "Append the current article to an mail file.
7485 If N is a positive number, save the N next articles.
7486 If N is a negative number, save the N previous articles.
7487 If N is nil and any articles have been marked with the process mark,
7488 save those articles instead."
7490 (gnus-set-global-variables)
7491 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
7492 (gnus-summary-save-article arg)))
7494 (defun gnus-summary-save-article-rmail (&optional arg)
7495 "Append the current article to an rmail file.
7496 If N is a positive number, save the N next articles.
7497 If N is a negative number, save the N previous articles.
7498 If N is nil and any articles have been marked with the process mark,
7499 save those articles instead."
7501 (gnus-set-global-variables)
7502 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
7503 (gnus-summary-save-article arg)))
7505 (defun gnus-summary-save-article-file (&optional arg)
7506 "Append the current article to a file.
7507 If N is a positive number, save the N next articles.
7508 If N is a negative number, save the N previous articles.
7509 If N is nil and any articles have been marked with the process mark,
7510 save those articles instead."
7512 (gnus-set-global-variables)
7513 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
7514 (gnus-summary-save-article arg)))
7516 (defun gnus-summary-save-article-body-file (&optional arg)
7517 "Append the current article body to a file.
7518 If N is a positive number, save the N next articles.
7519 If N is a negative number, save the N previous articles.
7520 If N is nil and any articles have been marked with the process mark,
7521 save those articles instead."
7523 (gnus-set-global-variables)
7524 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
7525 (gnus-summary-save-article arg)))
7527 (defun gnus-get-split-value (methods)
7528 "Return a value based on the split METHODS."
7529 (let (split-name method result match)
7532 (set-buffer gnus-original-article-buffer)
7534 (nnheader-narrow-to-headers)
7536 (goto-char (point-min))
7537 (setq method (pop methods))
7538 (setq match (car method))
7541 ;; Regular expression.
7543 (re-search-forward match nil t)
7545 ((gnus-functionp match)
7549 (setq result (funcall match gnus-newsgroup-name))))
7554 (setq result (eval match)))))
7555 (setq split-name (append (cdr method) split-name))
7556 (cond ((stringp result)
7557 (push result split-name))
7559 (setq split-name (append result split-name)))))))))
7562 (defun gnus-read-move-group-name (prompt default articles prefix)
7563 "Read a group name."
7564 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
7565 (minibuffer-confirm-incomplete nil) ; XEmacs
7573 (car (gnus-find-method-for-group
7575 gnus-valid-select-methods))
7576 (push (list (symbol-name g)) group-map)))
7577 gnus-active-hashtb))
7581 (if (> (length articles) 1)
7582 (format "these %d articles" (length articles))
7587 (gnus-completing-read default prom
7588 group-map nil nil prefix
7589 'gnus-group-history))
7590 ((= 1 (length split-name))
7591 (gnus-completing-read (car split-name) prom group-map
7593 'gnus-group-history))
7595 (gnus-completing-read nil prom
7596 (mapcar (lambda (el) (list el))
7597 (nreverse split-name))
7599 'gnus-group-history)))))
7601 (if (or (string= to-newsgroup "")
7602 (string= to-newsgroup prefix))
7603 (setq to-newsgroup (or default "")))
7604 (or (gnus-active to-newsgroup)
7605 (gnus-activate-group to-newsgroup)
7606 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
7608 (or (and (gnus-request-create-group
7609 to-newsgroup (gnus-group-name-to-method to-newsgroup))
7610 (gnus-activate-group to-newsgroup nil nil
7611 (gnus-group-name-to-method
7613 (error "Couldn't create group %s" to-newsgroup)))
7614 (error "No such group: %s" to-newsgroup)))
7617 ;; Summary extract commands
7619 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
7620 (let ((buffer-read-only nil)
7621 (article (gnus-summary-article-number))
7623 (or (gnus-summary-goto-subject article)
7624 (error (format "No such article: %d" article)))
7625 (gnus-summary-position-point)
7626 ;; If all commands are to be bunched up on one line, we collect
7628 (if gnus-view-pseudos-separately
7630 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
7633 (setq action (cdr (assq 'action (car ps))))
7634 (setq files (list (cdr (assq 'name (car ps)))))
7635 (while (and ps (cdr ps)
7636 (string= (or action "1")
7637 (or (cdr (assq 'action (cadr ps))) "2")))
7638 (setq files (cons (cdr (assq 'name (cadr ps))) files))
7639 (setcdr ps (cddr ps)))
7642 (if (not (string-match "%s" action))
7643 (setq files (cons " " files)))
7644 (setq files (cons " " files))
7645 (and (assq 'execute (car ps))
7646 (setcdr (assq 'execute (car ps))
7647 (funcall (if (string-match "%s" action)
7650 (mapconcat (lambda (f) f) files " ")))))
7651 (setq ps (cdr ps)))))
7652 (if (and gnus-view-pseudos (not not-view))
7654 (and (assq 'execute (car pslist))
7655 (gnus-execute-command (cdr (assq 'execute (car pslist)))
7656 (eq gnus-view-pseudos 'not-confirm)))
7657 (setq pslist (cdr pslist)))
7660 (setq after-article (or (cdr (assq 'article (car pslist)))
7661 (gnus-summary-article-number)))
7662 (gnus-summary-goto-subject after-article)
7665 (insert " " (file-name-nondirectory
7666 (cdr (assq 'name (car pslist))))
7667 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
7669 (forward-line -1) ; back to `b'
7670 (gnus-add-text-properties
7671 b (1- e) (list 'gnus-number gnus-reffed-article-number
7672 gnus-mouse-face-prop gnus-mouse-face))
7674 after-article gnus-reffed-article-number
7675 gnus-unread-mark b (car pslist) 0 (- e b))
7676 (push gnus-reffed-article-number gnus-newsgroup-unreads)
7677 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
7678 (setq pslist (cdr pslist)))))))
7680 (defun gnus-pseudos< (p1 p2)
7681 (let ((c1 (cdr (assq 'action p1)))
7682 (c2 (cdr (assq 'action p2))))
7683 (and c1 c2 (string< c1 c2))))
7685 (defun gnus-request-pseudo-article (props)
7686 (cond ((assq 'execute props)
7687 (gnus-execute-command (cdr (assq 'execute props)))))
7688 (let ((gnus-current-article (gnus-summary-article-number)))
7689 (run-hooks 'gnus-mark-article-hook)))
7691 (defun gnus-execute-command (command &optional automatic)
7693 (gnus-article-setup-buffer)
7694 (set-buffer gnus-article-buffer)
7695 (setq buffer-read-only nil)
7696 (let ((command (if automatic command (read-string "Command: " command)))
7697 ;; Just binding this here doesn't help, because there might
7698 ;; be output from the process after exiting the scope of
7700 ;; (buffer-read-only nil)
7703 (insert "$ " command "\n\n")
7704 (if gnus-view-pseudo-asynchronously
7705 (start-process "gnus-execute" nil shell-file-name
7706 shell-command-switch command)
7707 (call-process shell-file-name nil t nil
7708 shell-command-switch command)))))
7710 ;; Summary kill commands.
7712 (defun gnus-summary-edit-global-kill (article)
7713 "Edit the \"global\" kill file."
7714 (interactive (list (gnus-summary-article-number)))
7715 (gnus-set-global-variables)
7716 (gnus-group-edit-global-kill article))
7718 (defun gnus-summary-edit-local-kill ()
7719 "Edit a local kill file applied to the current newsgroup."
7721 (gnus-set-global-variables)
7722 (setq gnus-current-headers (gnus-summary-article-header))
7723 (gnus-set-global-variables)
7724 (gnus-group-edit-local-kill
7725 (gnus-summary-article-number) gnus-newsgroup-name))
7729 (defun gnus-read-header (id &optional header)
7730 "Read the headers of article ID and enter them into the Gnus system."
7731 (let ((group gnus-newsgroup-name)
7732 (gnus-override-method
7733 (and (gnus-news-group-p gnus-newsgroup-name)
7734 gnus-refer-article-method))
7736 ;; First we check to see whether the header in question is already
7739 ;; This is a Message-ID.
7740 (setq header (or header (gnus-id-to-header id)))
7741 ;; This is an article number.
7742 (setq header (or header (gnus-summary-article-header id))))
7744 (not (memq (mail-header-number header) gnus-newsgroup-sparse)))
7745 ;; We have found the header.
7747 ;; We have to really fetch the header to this article.
7748 (when (setq where (gnus-request-head id group))
7750 (set-buffer nntp-server-buffer)
7751 (goto-char (point-max))
7753 (goto-char (point-min))
7757 ((cdr where) (cdr where))
7758 (header (mail-header-number header))
7759 (t gnus-reffed-article-number))
7761 (insert " Article retrieved.\n"))
7763 ; (memq (mail-header-number header) gnus-newsgroup-sparse))
7764 ; (setcar (gnus-id-to-thread id) nil))
7765 (if (not (setq header (car (gnus-get-newsgroup-headers))))
7766 () ; Malformed head.
7767 (unless (memq (mail-header-number header) gnus-newsgroup-sparse)
7768 (if (and (stringp id)
7769 (not (string= (gnus-group-real-name group)
7771 ;; If we fetched by Message-ID and the article came
7772 ;; from a different group, we fudge some bogus article
7773 ;; numbers for this article.
7774 (mail-header-set-number header gnus-reffed-article-number))
7775 (decf gnus-reffed-article-number)
7776 (gnus-remove-header (mail-header-number header))
7777 (push header gnus-newsgroup-headers)
7778 (setq gnus-current-headers header)
7779 (push (mail-header-number header) gnus-newsgroup-limit))
7782 (defun gnus-remove-header (number)
7783 "Remove header NUMBER from `gnus-newsgroup-headers'."
7784 (if (and gnus-newsgroup-headers
7785 (= number (mail-header-number (car gnus-newsgroup-headers))))
7786 (pop gnus-newsgroup-headers)
7787 (let ((headers gnus-newsgroup-headers))
7788 (while (and (cdr headers)
7789 (not (= number (mail-header-number (cadr headers)))))
7792 (setcdr headers (cddr headers))))))
7795 ;;; summary highlights
7798 (defun gnus-highlight-selected-summary ()
7799 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
7800 ;; Highlight selected article in summary buffer
7801 (when gnus-summary-selected-face
7803 (let* ((beg (progn (beginning-of-line) (point)))
7804 (end (progn (end-of-line) (point)))
7805 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
7806 (from (if (get-text-property beg gnus-mouse-face-prop)
7808 (or (next-single-property-change
7809 beg gnus-mouse-face-prop nil end)
7814 (or (next-single-property-change
7815 from gnus-mouse-face-prop nil end)
7817 ;; If no mouse-face prop on line we will have to = from = end,
7818 ;; so we highlight the entire line instead.
7819 (when (= (+ to 2) from)
7822 (if gnus-newsgroup-selected-overlay
7823 ;; Move old overlay.
7825 gnus-newsgroup-selected-overlay from to (current-buffer))
7826 ;; Create new overlay.
7828 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
7829 'face gnus-summary-selected-face))))))
7831 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
7832 (defun gnus-summary-highlight-line ()
7833 "Highlight current line according to `gnus-summary-highlight'."
7834 (let* ((list gnus-summary-highlight)
7836 (end (progn (end-of-line) (point)))
7837 ;; now find out where the line starts and leave point there.
7838 (beg (progn (beginning-of-line) (point)))
7839 (article (gnus-summary-article-number))
7840 (score (or (cdr (assq (or article gnus-current-article)
7841 gnus-newsgroup-scored))
7842 gnus-summary-default-score 0))
7843 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
7844 (inhibit-read-only t))
7845 ;; Eval the cars of the lists until we find a match.
7846 (let ((default gnus-summary-default-score))
7848 (not (eval (caar list))))
7849 (setq list (cdr list))))
7850 (let ((face (cdar list)))
7851 (unless (eq face (get-text-property beg 'face))
7852 (gnus-put-text-property
7854 (setq face (if (boundp face) (symbol-value face) face)))
7855 (when gnus-summary-highlight-line-function
7856 (funcall gnus-summary-highlight-line-function article face))))
7861 ;;; gnus-sum.el ends here