Mercurial > emacs
annotate lisp/gnus/gnus-sum.el @ 19521:6f6cf9184e93
Require cl at compile time.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Mon, 25 Aug 1997 04:40:29 +0000 |
parents | e6935c08cf0b |
children | abfa7b46c7bd |
rev | line source |
---|---|
17493 | 1 ;;; gnus-sum.el --- summary mode commands for Gnus |
2 ;; Copyright (C) 1996,97 Free Software Foundation, Inc. | |
3 | |
4 ;; Author: Lars Magne Ingebrigtsen <larsi@ifi.uio.no> | |
5 ;; Keywords: news | |
6 | |
7 ;; This file is part of GNU Emacs. | |
8 | |
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) | |
12 ;; any later version. | |
13 | |
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. | |
18 | |
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. | |
23 | |
24 ;;; Commentary: | |
25 | |
26 ;;; Code: | |
27 | |
19521
6f6cf9184e93
Require cl at compile time.
Richard M. Stallman <rms@gnu.org>
parents:
17493
diff
changeset
|
28 (eval-when-compile (require 'cl)) |
6f6cf9184e93
Require cl at compile time.
Richard M. Stallman <rms@gnu.org>
parents:
17493
diff
changeset
|
29 |
17493 | 30 (require 'gnus) |
31 (require 'gnus-group) | |
32 (require 'gnus-spec) | |
33 (require 'gnus-range) | |
34 (require 'gnus-int) | |
35 (require 'gnus-undo) | |
36 | |
37 (defcustom gnus-kill-summary-on-exit t | |
38 "*If non-nil, kill the summary buffer when you exit from it. | |
39 If nil, the summary will become a \"*Dead Summary*\" buffer, and | |
40 it will be killed sometime later." | |
41 :group 'gnus-summary-exit | |
42 :type 'boolean) | |
43 | |
44 (defcustom gnus-fetch-old-headers nil | |
45 "*Non-nil means that Gnus will try to build threads by grabbing old headers. | |
46 If an unread article in the group refers to an older, already read (or | |
47 just marked as read) article, the old article will not normally be | |
48 displayed in the Summary buffer. If this variable is non-nil, Gnus | |
49 will attempt to grab the headers to the old articles, and thereby | |
50 build complete threads. If it has the value `some', only enough | |
51 headers to connect otherwise loose threads will be displayed. | |
52 This variable can also be a number. In that case, no more than that | |
53 number of old headers will be fetched. | |
54 | |
55 The server has to support NOV for any of this to work." | |
56 :group 'gnus-thread | |
57 :type '(choice (const :tag "off" nil) | |
58 (const some) | |
59 number | |
60 (sexp :menu-tag "other" t))) | |
61 | |
62 (defcustom gnus-summary-make-false-root 'adopt | |
63 "*nil means that Gnus won't gather loose threads. | |
64 If the root of a thread has expired or been read in a previous | |
65 session, the information necessary to build a complete thread has been | |
66 lost. Instead of having many small sub-threads from this original thread | |
67 scattered all over the summary buffer, Gnus can gather them. | |
68 | |
69 If non-nil, Gnus will try to gather all loose sub-threads from an | |
70 original thread into one large thread. | |
71 | |
72 If this variable is non-nil, it should be one of `none', `adopt', | |
73 `dummy' or `empty'. | |
74 | |
75 If this variable is `none', Gnus will not make a false root, but just | |
76 present the sub-threads after another. | |
77 If this variable is `dummy', Gnus will create a dummy root that will | |
78 have all the sub-threads as children. | |
79 If this variable is `adopt', Gnus will make one of the \"children\" | |
80 the parent and mark all the step-children as such. | |
81 If this variable is `empty', the \"children\" are printed with empty | |
82 subject fields. (Or rather, they will be printed with a string | |
83 given by the `gnus-summary-same-subject' variable.)" | |
84 :group 'gnus-thread | |
85 :type '(choice (const :tag "off" nil) | |
86 (const none) | |
87 (const dummy) | |
88 (const adopt) | |
89 (const empty))) | |
90 | |
91 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$" | |
92 "*A regexp to match subjects to be excluded from loose thread gathering. | |
93 As loose thread gathering is done on subjects only, that means that | |
94 there can be many false gatherings performed. By rooting out certain | |
95 common subjects, gathering might become saner." | |
96 :group 'gnus-thread | |
97 :type 'regexp) | |
98 | |
99 (defcustom gnus-summary-gather-subject-limit nil | |
100 "*Maximum length of subject comparisons when gathering loose threads. | |
101 Use nil to compare full subjects. Setting this variable to a low | |
102 number will help gather threads that have been corrupted by | |
103 newsreaders chopping off subject lines, but it might also mean that | |
104 unrelated articles that have subject that happen to begin with the | |
105 same few characters will be incorrectly gathered. | |
106 | |
107 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when | |
108 comparing subjects." | |
109 :group 'gnus-thread | |
110 :type '(choice (const :tag "off" nil) | |
111 (const fuzzy) | |
112 (sexp :menu-tag "on" t))) | |
113 | |
114 (defcustom gnus-simplify-ignored-prefixes nil | |
115 "*Regexp, matches for which are removed from subject lines when simplifying fuzzily." | |
116 :group 'gnus-thread | |
117 :type '(choice (const :tag "off" nil) | |
118 regexp)) | |
119 | |
120 (defcustom gnus-build-sparse-threads nil | |
121 "*If non-nil, fill in the gaps in threads. | |
122 If `some', only fill in the gaps that are needed to tie loose threads | |
123 together. If `more', fill in all leaf nodes that Gnus can find. If | |
124 non-nil and non-`some', fill in all gaps that Gnus manages to guess." | |
125 :group 'gnus-thread | |
126 :type '(choice (const :tag "off" nil) | |
127 (const some) | |
128 (const more) | |
129 (sexp :menu-tag "all" t))) | |
130 | |
131 (defcustom gnus-summary-thread-gathering-function | |
132 'gnus-gather-threads-by-subject | |
133 "Function used for gathering loose threads. | |
134 There are two pre-defined functions: `gnus-gather-threads-by-subject', | |
135 which only takes Subjects into consideration; and | |
136 `gnus-gather-threads-by-references', which compared the References | |
137 headers of the articles to find matches." | |
138 :group 'gnus-thread | |
139 :type '(set (function-item gnus-gather-threads-by-subject) | |
140 (function-item gnus-gather-threads-by-references) | |
141 (function :tag "other"))) | |
142 | |
143 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>. | |
144 (defcustom gnus-summary-same-subject "" | |
145 "*String indicating that the current article has the same subject as the previous. | |
146 This variable will only be used if the value of | |
147 `gnus-summary-make-false-root' is `empty'." | |
148 :group 'gnus-summary-format | |
149 :type 'string) | |
150 | |
151 (defcustom gnus-summary-goto-unread t | |
152 "*If t, marking commands will go to the next unread article. | |
153 If `never', commands that usually go to the next unread article, will | |
154 go to the next article, whether it is read or not. | |
155 If nil, only the marking commands will go to the next (un)read article." | |
156 :group 'gnus-summary-marks | |
157 :link '(custom-manual "(gnus)Setting Marks") | |
158 :type '(choice (const :tag "off" nil) | |
159 (const never) | |
160 (sexp :menu-tag "on" t))) | |
161 | |
162 (defcustom gnus-summary-default-score 0 | |
163 "*Default article score level. | |
164 All scores generated by the score files will be added to this score. | |
165 If this variable is nil, scoring will be disabled." | |
166 :group 'gnus-score-default | |
167 :type '(choice (const :tag "disable") | |
168 integer)) | |
169 | |
170 (defcustom gnus-summary-zcore-fuzz 0 | |
171 "*Fuzziness factor for the zcore in the summary buffer. | |
172 Articles with scores closer than this to `gnus-summary-default-score' | |
173 will not be marked." | |
174 :group 'gnus-summary-format | |
175 :type 'integer) | |
176 | |
177 (defcustom gnus-simplify-subject-fuzzy-regexp nil | |
178 "*Strings to be removed when doing fuzzy matches. | |
179 This can either be a regular expression or list of regular expressions | |
180 that will be removed from subject strings if fuzzy subject | |
181 simplification is selected." | |
182 :group 'gnus-thread | |
183 :type '(repeat regexp)) | |
184 | |
185 (defcustom gnus-show-threads t | |
186 "*If non-nil, display threads in summary mode." | |
187 :group 'gnus-thread | |
188 :type 'boolean) | |
189 | |
190 (defcustom gnus-thread-hide-subtree nil | |
191 "*If non-nil, hide all threads initially. | |
192 If threads are hidden, you have to run the command | |
193 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook' | |
194 to expose hidden threads." | |
195 :group 'gnus-thread | |
196 :type 'boolean) | |
197 | |
198 (defcustom gnus-thread-hide-killed t | |
199 "*If non-nil, hide killed threads automatically." | |
200 :group 'gnus-thread | |
201 :type 'boolean) | |
202 | |
203 (defcustom gnus-thread-ignore-subject nil | |
204 "*If non-nil, ignore subjects and do all threading based on the Reference header. | |
205 If nil, which is the default, articles that have different subjects | |
206 from their parents will start separate threads." | |
207 :group 'gnus-thread | |
208 :type 'boolean) | |
209 | |
210 (defcustom gnus-thread-operation-ignore-subject t | |
211 "*If non-nil, subjects will be ignored when doing thread commands. | |
212 This affects commands like `gnus-summary-kill-thread' and | |
213 `gnus-summary-lower-thread'. | |
214 | |
215 If this variable is nil, articles in the same thread with different | |
216 subjects will not be included in the operation in question. If this | |
217 variable is `fuzzy', only articles that have subjects that are fuzzily | |
218 equal will be included." | |
219 :group 'gnus-thread | |
220 :type '(choice (const :tag "off" nil) | |
221 (const fuzzy) | |
222 (sexp :tag "on" t))) | |
223 | |
224 (defcustom gnus-thread-indent-level 4 | |
225 "*Number that says how much each sub-thread should be indented." | |
226 :group 'gnus-thread | |
227 :type 'integer) | |
228 | |
229 (defcustom gnus-auto-extend-newsgroup t | |
230 "*If non-nil, extend newsgroup forward and backward when requested." | |
231 :group 'gnus-summary-choose | |
232 :type 'boolean) | |
233 | |
234 (defcustom gnus-auto-select-first t | |
235 "*If nil, don't select the first unread article when entering a group. | |
236 If this variable is `best', select the highest-scored unread article | |
237 in the group. If neither nil nor `best', select the first unread | |
238 article. | |
239 | |
240 If you want to prevent automatic selection of the first unread article | |
241 in some newsgroups, set the variable to nil in | |
242 `gnus-select-group-hook'." | |
243 :group 'gnus-group-select | |
244 :type '(choice (const :tag "none" nil) | |
245 (const best) | |
246 (sexp :menu-tag "first" t))) | |
247 | |
248 (defcustom gnus-auto-select-next t | |
249 "*If non-nil, offer to go to the next group from the end of the previous. | |
250 If the value is t and the next newsgroup is empty, Gnus will exit | |
251 summary mode and go back to group mode. If the value is neither nil | |
252 nor t, Gnus will select the following unread newsgroup. In | |
253 particular, if the value is the symbol `quietly', the next unread | |
254 newsgroup will be selected without any confirmation, and if it is | |
255 `almost-quietly', the next group will be selected without any | |
256 confirmation if you are located on the last article in the group. | |
257 Finally, if this variable is `slightly-quietly', the `Z n' command | |
258 will go to the next group without confirmation." | |
259 :group 'gnus-summary-maneuvering | |
260 :type '(choice (const :tag "off" nil) | |
261 (const quietly) | |
262 (const almost-quietly) | |
263 (const slightly-quietly) | |
264 (sexp :menu-tag "on" t))) | |
265 | |
266 (defcustom gnus-auto-select-same nil | |
267 "*If non-nil, select the next article with the same subject." | |
268 :group 'gnus-summary-maneuvering | |
269 :type 'boolean) | |
270 | |
271 (defcustom gnus-summary-check-current nil | |
272 "*If non-nil, consider the current article when moving. | |
273 The \"unread\" movement commands will stay on the same line if the | |
274 current article is unread." | |
275 :group 'gnus-summary-maneuvering | |
276 :type 'boolean) | |
277 | |
278 (defcustom gnus-auto-center-summary t | |
279 "*If non-nil, always center the current summary buffer. | |
280 In particular, if `vertical' do only vertical recentering. If non-nil | |
281 and non-`vertical', do both horizontal and vertical recentering." | |
282 :group 'gnus-summary-maneuvering | |
283 :type '(choice (const :tag "none" nil) | |
284 (const vertical) | |
285 (sexp :menu-tag "both" t))) | |
286 | |
287 (defcustom gnus-show-all-headers nil | |
288 "*If non-nil, don't hide any headers." | |
289 :group 'gnus-article-hiding | |
290 :group 'gnus-article-headers | |
291 :type 'boolean) | |
292 | |
293 (defcustom gnus-summary-ignore-duplicates nil | |
294 "*If non-nil, ignore articles with identical Message-ID headers." | |
295 :group 'gnus-summary | |
296 :type 'boolean) | |
297 | |
298 (defcustom gnus-single-article-buffer t | |
299 "*If non-nil, display all articles in the same buffer. | |
300 If nil, each group will get its own article buffer." | |
301 :group 'gnus-article-various | |
302 :type 'boolean) | |
303 | |
304 (defcustom gnus-break-pages t | |
305 "*If non-nil, do page breaking on articles. | |
306 The page delimiter is specified by the `gnus-page-delimiter' | |
307 variable." | |
308 :group 'gnus-article-various | |
309 :type 'boolean) | |
310 | |
311 (defcustom gnus-show-mime nil | |
312 "*If non-nil, do mime processing of articles. | |
313 The articles will simply be fed to the function given by | |
314 `gnus-show-mime-method'." | |
315 :group 'gnus-article-mime | |
316 :type 'boolean) | |
317 | |
318 (defcustom gnus-move-split-methods nil | |
319 "*Variable used to suggest where articles are to be moved to. | |
320 It uses the same syntax as the `gnus-split-methods' variable." | |
321 :group 'gnus-summary-mail | |
322 :type '(repeat (choice (list function) | |
323 (cons regexp (repeat string)) | |
324 sexp))) | |
325 | |
326 (defcustom gnus-unread-mark ? | |
327 "*Mark used for unread articles." | |
328 :group 'gnus-summary-marks | |
329 :type 'character) | |
330 | |
331 (defcustom gnus-ticked-mark ?! | |
332 "*Mark used for ticked articles." | |
333 :group 'gnus-summary-marks | |
334 :type 'character) | |
335 | |
336 (defcustom gnus-dormant-mark ?? | |
337 "*Mark used for dormant articles." | |
338 :group 'gnus-summary-marks | |
339 :type 'character) | |
340 | |
341 (defcustom gnus-del-mark ?r | |
342 "*Mark used for del'd articles." | |
343 :group 'gnus-summary-marks | |
344 :type 'character) | |
345 | |
346 (defcustom gnus-read-mark ?R | |
347 "*Mark used for read articles." | |
348 :group 'gnus-summary-marks | |
349 :type 'character) | |
350 | |
351 (defcustom gnus-expirable-mark ?E | |
352 "*Mark used for expirable articles." | |
353 :group 'gnus-summary-marks | |
354 :type 'character) | |
355 | |
356 (defcustom gnus-killed-mark ?K | |
357 "*Mark used for killed articles." | |
358 :group 'gnus-summary-marks | |
359 :type 'character) | |
360 | |
361 (defcustom gnus-souped-mark ?F | |
362 "*Mark used for killed articles." | |
363 :group 'gnus-summary-marks | |
364 :type 'character) | |
365 | |
366 (defcustom gnus-kill-file-mark ?X | |
367 "*Mark used for articles killed by kill files." | |
368 :group 'gnus-summary-marks | |
369 :type 'character) | |
370 | |
371 (defcustom gnus-low-score-mark ?Y | |
372 "*Mark used for articles with a low score." | |
373 :group 'gnus-summary-marks | |
374 :type 'character) | |
375 | |
376 (defcustom gnus-catchup-mark ?C | |
377 "*Mark used for articles that are caught up." | |
378 :group 'gnus-summary-marks | |
379 :type 'character) | |
380 | |
381 (defcustom gnus-replied-mark ?A | |
382 "*Mark used for articles that have been replied to." | |
383 :group 'gnus-summary-marks | |
384 :type 'character) | |
385 | |
386 (defcustom gnus-cached-mark ?* | |
387 "*Mark used for articles that are in the cache." | |
388 :group 'gnus-summary-marks | |
389 :type 'character) | |
390 | |
391 (defcustom gnus-saved-mark ?S | |
392 "*Mark used for articles that have been saved to." | |
393 :group 'gnus-summary-marks | |
394 :type 'character) | |
395 | |
396 (defcustom gnus-ancient-mark ?O | |
397 "*Mark used for ancient articles." | |
398 :group 'gnus-summary-marks | |
399 :type 'character) | |
400 | |
401 (defcustom gnus-sparse-mark ?Q | |
402 "*Mark used for sparsely reffed articles." | |
403 :group 'gnus-summary-marks | |
404 :type 'character) | |
405 | |
406 (defcustom gnus-canceled-mark ?G | |
407 "*Mark used for canceled articles." | |
408 :group 'gnus-summary-marks | |
409 :type 'character) | |
410 | |
411 (defcustom gnus-duplicate-mark ?M | |
412 "*Mark used for duplicate articles." | |
413 :group 'gnus-summary-marks | |
414 :type 'character) | |
415 | |
416 (defcustom gnus-score-over-mark ?+ | |
417 "*Score mark used for articles with high scores." | |
418 :group 'gnus-summary-marks | |
419 :type 'character) | |
420 | |
421 (defcustom gnus-score-below-mark ?- | |
422 "*Score mark used for articles with low scores." | |
423 :group 'gnus-summary-marks | |
424 :type 'character) | |
425 | |
426 (defcustom gnus-empty-thread-mark ? | |
427 "*There is no thread under the article." | |
428 :group 'gnus-summary-marks | |
429 :type 'character) | |
430 | |
431 (defcustom gnus-not-empty-thread-mark ?= | |
432 "*There is a thread under the article." | |
433 :group 'gnus-summary-marks | |
434 :type 'character) | |
435 | |
436 (defcustom gnus-view-pseudo-asynchronously nil | |
437 "*If non-nil, Gnus will view pseudo-articles asynchronously." | |
438 :group 'gnus-extract-view | |
439 :type 'boolean) | |
440 | |
441 (defcustom gnus-view-pseudos nil | |
442 "*If `automatic', pseudo-articles will be viewed automatically. | |
443 If `not-confirm', pseudos will be viewed automatically, and the user | |
444 will not be asked to confirm the command." | |
445 :group 'gnus-extract-view | |
446 :type '(choice (const :tag "off" nil) | |
447 (const automatic) | |
448 (const not-confirm))) | |
449 | |
450 (defcustom gnus-view-pseudos-separately t | |
451 "*If non-nil, one pseudo-article will be created for each file to be viewed. | |
452 If nil, all files that use the same viewing command will be given as a | |
453 list of parameters to that command." | |
454 :group 'gnus-extract-view | |
455 :type 'boolean) | |
456 | |
457 (defcustom gnus-insert-pseudo-articles t | |
458 "*If non-nil, insert pseudo-articles when decoding articles." | |
459 :group 'gnus-extract-view | |
460 :type 'boolean) | |
461 | |
462 (defcustom gnus-summary-dummy-line-format | |
463 "* %(: :%) %S\n" | |
464 "*The format specification for the dummy roots in the summary buffer. | |
465 It works along the same lines as a normal formatting string, | |
466 with some simple extensions. | |
467 | |
468 %S The subject" | |
469 :group 'gnus-threading | |
470 :type 'string) | |
471 | |
472 (defcustom gnus-summary-mode-line-format "Gnus: %%b [%A] %Z" | |
473 "*The format specification for the summary mode line. | |
474 It works along the same lines as a normal formatting string, | |
475 with some simple extensions: | |
476 | |
477 %G Group name | |
478 %p Unprefixed group name | |
479 %A Current article number | |
480 %V Gnus version | |
481 %U Number of unread articles in the group | |
482 %e Number of unselected articles in the group | |
483 %Z A string with unread/unselected article counts | |
484 %g Shortish group name | |
485 %S Subject of the current article | |
486 %u User-defined spec | |
487 %s Current score file name | |
488 %d Number of dormant articles | |
489 %r Number of articles that have been marked as read in this session | |
490 %E Number of articles expunged by the score files" | |
491 :group 'gnus-summary-format | |
492 :type 'string) | |
493 | |
494 (defcustom gnus-summary-mark-below 0 | |
495 "*Mark all articles with a score below this variable as read. | |
496 This variable is local to each summary buffer and usually set by the | |
497 score file." | |
498 :group 'gnus-score-default | |
499 :type 'integer) | |
500 | |
501 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number) | |
502 "*List of functions used for sorting articles in the summary buffer. | |
503 This variable is only used when not using a threaded display." | |
504 :group 'gnus-summary-sort | |
505 :type '(repeat (choice (function-item gnus-article-sort-by-number) | |
506 (function-item gnus-article-sort-by-author) | |
507 (function-item gnus-article-sort-by-subject) | |
508 (function-item gnus-article-sort-by-date) | |
509 (function-item gnus-article-sort-by-score) | |
510 (function :tag "other")))) | |
511 | |
512 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number) | |
513 "*List of functions used for sorting threads in the summary buffer. | |
514 By default, threads are sorted by article number. | |
515 | |
516 Each function takes two threads and return non-nil if the first thread | |
517 should be sorted before the other. If you use more than one function, | |
518 the primary sort function should be the last. You should probably | |
519 always include `gnus-thread-sort-by-number' in the list of sorting | |
520 functions -- preferably first. | |
521 | |
522 Ready-made functions include `gnus-thread-sort-by-number', | |
523 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject', | |
524 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and | |
525 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function')." | |
526 :group 'gnus-summary-sort | |
527 :type '(repeat (choice (function-item gnus-thread-sort-by-number) | |
528 (function-item gnus-thread-sort-by-author) | |
529 (function-item gnus-thread-sort-by-subject) | |
530 (function-item gnus-thread-sort-by-date) | |
531 (function-item gnus-thread-sort-by-score) | |
532 (function-item gnus-thread-sort-by-total-score) | |
533 (function :tag "other")))) | |
534 | |
535 (defcustom gnus-thread-score-function '+ | |
536 "*Function used for calculating the total score of a thread. | |
537 | |
538 The function is called with the scores of the article and each | |
539 subthread and should then return the score of the thread. | |
540 | |
541 Some functions you can use are `+', `max', or `min'." | |
542 :group 'gnus-summary-sort | |
543 :type 'function) | |
544 | |
545 (defcustom gnus-summary-expunge-below nil | |
546 "All articles that have a score less than this variable will be expunged." | |
547 :group 'gnus-score-default | |
548 :type '(choice (const :tag "off" nil) | |
549 integer)) | |
550 | |
551 (defcustom gnus-thread-expunge-below nil | |
552 "All threads that have a total score less than this variable will be expunged. | |
553 See `gnus-thread-score-function' for en explanation of what a | |
554 \"thread score\" is." | |
555 :group 'gnus-treading | |
556 :group 'gnus-score-default | |
557 :type '(choice (const :tag "off" nil) | |
558 integer)) | |
559 | |
560 (defcustom gnus-summary-mode-hook nil | |
561 "*A hook for Gnus summary mode. | |
562 This hook is run before any variables are set in the summary buffer." | |
563 :group 'gnus-summary-various | |
564 :type 'hook) | |
565 | |
566 (defcustom gnus-summary-menu-hook nil | |
567 "*Hook run after the creation of the summary mode menu." | |
568 :group 'gnus-summary-visual | |
569 :type 'hook) | |
570 | |
571 (defcustom gnus-summary-exit-hook nil | |
572 "*A hook called on exit from the summary buffer. | |
573 It will be called with point in the group buffer." | |
574 :group 'gnus-summary-exit | |
575 :type 'hook) | |
576 | |
577 (defcustom gnus-summary-prepare-hook nil | |
578 "*A hook called after the summary buffer has been generated. | |
579 If you want to modify the summary buffer, you can use this hook." | |
580 :group 'gnus-summary-various | |
581 :type 'hook) | |
582 | |
583 (defcustom gnus-summary-generate-hook nil | |
584 "*A hook run just before generating the summary buffer. | |
585 This hook is commonly used to customize threading variables and the | |
586 like." | |
587 :group 'gnus-summary-various | |
588 :type 'hook) | |
589 | |
590 (defcustom gnus-select-group-hook nil | |
591 "*A hook called when a newsgroup is selected. | |
592 | |
593 If you'd like to simplify subjects like the | |
594 `gnus-summary-next-same-subject' command does, you can use the | |
595 following hook: | |
596 | |
597 (setq gnus-select-group-hook | |
598 (list | |
599 (lambda () | |
600 (mapcar (lambda (header) | |
601 (mail-header-set-subject | |
602 header | |
603 (gnus-simplify-subject | |
604 (mail-header-subject header) 're-only))) | |
605 gnus-newsgroup-headers))))" | |
606 :group 'gnus-group-select | |
607 :type 'hook) | |
608 | |
609 (defcustom gnus-select-article-hook nil | |
610 "*A hook called when an article is selected." | |
611 :group 'gnus-summary-choose | |
612 :type 'hook) | |
613 | |
614 (defcustom gnus-visual-mark-article-hook | |
615 (list 'gnus-highlight-selected-summary) | |
616 "*Hook run after selecting an article in the summary buffer. | |
617 It is meant to be used for highlighting the article in some way. It | |
618 is not run if `gnus-visual' is nil." | |
619 :group 'gnus-summary-visual | |
620 :type 'hook) | |
621 | |
622 (defcustom gnus-parse-headers-hook | |
623 (list 'gnus-decode-rfc1522) | |
624 "*A hook called before parsing the headers." | |
625 :group 'gnus-various | |
626 :type 'hook) | |
627 | |
628 (defcustom gnus-exit-group-hook nil | |
629 "*A hook called when exiting (not quitting) summary mode." | |
630 :group 'gnus-various | |
631 :type 'hook) | |
632 | |
633 (defcustom gnus-summary-update-hook | |
634 (list 'gnus-summary-highlight-line) | |
635 "*A hook called when a summary line is changed. | |
636 The hook will not be called if `gnus-visual' is nil. | |
637 | |
638 The default function `gnus-summary-highlight-line' will | |
639 highlight the line according to the `gnus-summary-highlight' | |
640 variable." | |
641 :group 'gnus-summary-visual | |
642 :type 'hook) | |
643 | |
644 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read) | |
645 "*A hook called when an article is selected for the first time. | |
646 The hook is intended to mark an article as read (or unread) | |
647 automatically when it is selected." | |
648 :group 'gnus-summary-choose | |
649 :type 'hook) | |
650 | |
651 (defcustom gnus-group-no-more-groups-hook nil | |
652 "*A hook run when returning to group mode having no more (unread) groups." | |
653 :group 'gnus-group-select | |
654 :type 'hook) | |
655 | |
656 (defcustom gnus-ps-print-hook nil | |
657 "*A hook run before ps-printing something from Gnus." | |
658 :group 'gnus-summary | |
659 :type 'hook) | |
660 | |
661 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face | |
662 "Face used for highlighting the current article in the summary buffer." | |
663 :group 'gnus-summary-visual | |
664 :type 'face) | |
665 | |
666 (defcustom gnus-summary-highlight | |
667 '(((= mark gnus-canceled-mark) | |
668 . gnus-summary-cancelled-face) | |
669 ((and (> score default) | |
670 (or (= mark gnus-dormant-mark) | |
671 (= mark gnus-ticked-mark))) | |
672 . gnus-summary-high-ticked-face) | |
673 ((and (< score default) | |
674 (or (= mark gnus-dormant-mark) | |
675 (= mark gnus-ticked-mark))) | |
676 . gnus-summary-low-ticked-face) | |
677 ((or (= mark gnus-dormant-mark) | |
678 (= mark gnus-ticked-mark)) | |
679 . gnus-summary-normal-ticked-face) | |
680 ((and (> score default) (= mark gnus-ancient-mark)) | |
681 . gnus-summary-high-ancient-face) | |
682 ((and (< score default) (= mark gnus-ancient-mark)) | |
683 . gnus-summary-low-ancient-face) | |
684 ((= mark gnus-ancient-mark) | |
685 . gnus-summary-normal-ancient-face) | |
686 ((and (> score default) (= mark gnus-unread-mark)) | |
687 . gnus-summary-high-unread-face) | |
688 ((and (< score default) (= mark gnus-unread-mark)) | |
689 . gnus-summary-low-unread-face) | |
690 ((and (= mark gnus-unread-mark)) | |
691 . gnus-summary-normal-unread-face) | |
692 ((> score default) | |
693 . gnus-summary-high-read-face) | |
694 ((< score default) | |
695 . gnus-summary-low-read-face) | |
696 (t | |
697 . gnus-summary-normal-read-face)) | |
698 "Controls the highlighting of summary buffer lines. | |
699 | |
700 A list of (FORM . FACE) pairs. When deciding how a a particular | |
701 summary line should be displayed, each form is evaluated. The content | |
702 of the face field after the first true form is used. You can change | |
703 how those summary lines are displayed, by editing the face field. | |
704 | |
705 You can use the following variables in the FORM field. | |
706 | |
707 score: The articles score | |
708 default: The default article score. | |
709 below: The score below which articles are automatically marked as read. | |
710 mark: The articles mark." | |
711 :group 'gnus-summary-visual | |
712 :type '(repeat (cons (sexp :tag "Form" nil) | |
713 face))) | |
714 | |
715 | |
716 ;;; Internal variables | |
717 | |
718 (defvar gnus-scores-exclude-files nil) | |
719 (defvar gnus-page-broken nil) | |
720 | |
721 (defvar gnus-original-article nil) | |
722 (defvar gnus-article-internal-prepare-hook nil) | |
723 (defvar gnus-newsgroup-process-stack nil) | |
724 | |
725 (defvar gnus-thread-indent-array nil) | |
726 (defvar gnus-thread-indent-array-level gnus-thread-indent-level) | |
727 | |
728 ;; Avoid highlighting in kill files. | |
729 (defvar gnus-summary-inhibit-highlight nil) | |
730 (defvar gnus-newsgroup-selected-overlay nil) | |
731 (defvar gnus-inhibit-limiting nil) | |
732 (defvar gnus-newsgroup-adaptive-score-file nil) | |
733 (defvar gnus-current-score-file nil) | |
734 (defvar gnus-current-move-group nil) | |
735 (defvar gnus-current-copy-group nil) | |
736 (defvar gnus-current-crosspost-group nil) | |
737 | |
738 (defvar gnus-newsgroup-dependencies nil) | |
739 (defvar gnus-newsgroup-adaptive nil) | |
740 (defvar gnus-summary-display-article-function nil) | |
741 (defvar gnus-summary-highlight-line-function nil | |
742 "Function called after highlighting a summary line.") | |
743 | |
744 (defvar gnus-summary-line-format-alist | |
745 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d) | |
746 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s) | |
747 (?s gnus-tmp-subject-or-nil ?s) | |
748 (?n gnus-tmp-name ?s) | |
749 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from))) | |
750 ?s) | |
751 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from)) | |
752 gnus-tmp-from) ?s) | |
753 (?F gnus-tmp-from ?s) | |
754 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s) | |
755 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s) | |
756 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s) | |
757 (?o (gnus-date-iso8601 gnus-tmp-header) ?s) | |
758 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s) | |
759 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s) | |
760 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d) | |
761 (?L gnus-tmp-lines ?d) | |
762 (?I gnus-tmp-indentation ?s) | |
763 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s) | |
764 (?R gnus-tmp-replied ?c) | |
765 (?\[ gnus-tmp-opening-bracket ?c) | |
766 (?\] gnus-tmp-closing-bracket ?c) | |
767 (?\> (make-string gnus-tmp-level ? ) ?s) | |
768 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s) | |
769 (?i gnus-tmp-score ?d) | |
770 (?z gnus-tmp-score-char ?c) | |
771 (?l (bbb-grouplens-score gnus-tmp-header) ?s) | |
772 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d) | |
773 (?U gnus-tmp-unread ?c) | |
774 (?t (gnus-summary-number-of-articles-in-thread | |
775 (and (boundp 'thread) (car thread)) gnus-tmp-level) | |
776 ?d) | |
777 (?e (gnus-summary-number-of-articles-in-thread | |
778 (and (boundp 'thread) (car thread)) gnus-tmp-level t) | |
779 ?c) | |
780 (?u gnus-tmp-user-defined ?s) | |
781 (?P (gnus-pick-line-number) ?d)) | |
782 "An alist of format specifications that can appear in summary lines, | |
783 and what variables they correspond with, along with the type of the | |
784 variable (string, integer, character, etc).") | |
785 | |
786 (defvar gnus-summary-dummy-line-format-alist | |
787 `((?S gnus-tmp-subject ?s) | |
788 (?N gnus-tmp-number ?d) | |
789 (?u gnus-tmp-user-defined ?s))) | |
790 | |
791 (defvar gnus-summary-mode-line-format-alist | |
792 `((?G gnus-tmp-group-name ?s) | |
793 (?g (gnus-short-group-name gnus-tmp-group-name) ?s) | |
794 (?p (gnus-group-real-name gnus-tmp-group-name) ?s) | |
795 (?A gnus-tmp-article-number ?d) | |
796 (?Z gnus-tmp-unread-and-unselected ?s) | |
797 (?V gnus-version ?s) | |
798 (?U gnus-tmp-unread-and-unticked ?d) | |
799 (?S gnus-tmp-subject ?s) | |
800 (?e gnus-tmp-unselected ?d) | |
801 (?u gnus-tmp-user-defined ?s) | |
802 (?d (length gnus-newsgroup-dormant) ?d) | |
803 (?t (length gnus-newsgroup-marked) ?d) | |
804 (?r (length gnus-newsgroup-reads) ?d) | |
805 (?E gnus-newsgroup-expunged-tally ?d) | |
806 (?s (gnus-current-score-file-nondirectory) ?s))) | |
807 | |
808 (defvar gnus-last-search-regexp nil | |
809 "Default regexp for article search command.") | |
810 | |
811 (defvar gnus-last-shell-command nil | |
812 "Default shell command on article.") | |
813 | |
814 (defvar gnus-newsgroup-begin nil) | |
815 (defvar gnus-newsgroup-end nil) | |
816 (defvar gnus-newsgroup-last-rmail nil) | |
817 (defvar gnus-newsgroup-last-mail nil) | |
818 (defvar gnus-newsgroup-last-folder nil) | |
819 (defvar gnus-newsgroup-last-file nil) | |
820 (defvar gnus-newsgroup-auto-expire nil) | |
821 (defvar gnus-newsgroup-active nil) | |
822 | |
823 (defvar gnus-newsgroup-data nil) | |
824 (defvar gnus-newsgroup-data-reverse nil) | |
825 (defvar gnus-newsgroup-limit nil) | |
826 (defvar gnus-newsgroup-limits nil) | |
827 | |
828 (defvar gnus-newsgroup-unreads nil | |
829 "List of unread articles in the current newsgroup.") | |
830 | |
831 (defvar gnus-newsgroup-unselected nil | |
832 "List of unselected unread articles in the current newsgroup.") | |
833 | |
834 (defvar gnus-newsgroup-reads nil | |
835 "Alist of read articles and article marks in the current newsgroup.") | |
836 | |
837 (defvar gnus-newsgroup-expunged-tally nil) | |
838 | |
839 (defvar gnus-newsgroup-marked nil | |
840 "List of ticked articles in the current newsgroup (a subset of unread art).") | |
841 | |
842 (defvar gnus-newsgroup-killed nil | |
843 "List of ranges of articles that have been through the scoring process.") | |
844 | |
845 (defvar gnus-newsgroup-cached nil | |
846 "List of articles that come from the article cache.") | |
847 | |
848 (defvar gnus-newsgroup-saved nil | |
849 "List of articles that have been saved.") | |
850 | |
851 (defvar gnus-newsgroup-kill-headers nil) | |
852 | |
853 (defvar gnus-newsgroup-replied nil | |
854 "List of articles that have been replied to in the current newsgroup.") | |
855 | |
856 (defvar gnus-newsgroup-expirable nil | |
857 "List of articles in the current newsgroup that can be expired.") | |
858 | |
859 (defvar gnus-newsgroup-processable nil | |
860 "List of articles in the current newsgroup that can be processed.") | |
861 | |
862 (defvar gnus-newsgroup-bookmarks nil | |
863 "List of articles in the current newsgroup that have bookmarks.") | |
864 | |
865 (defvar gnus-newsgroup-dormant nil | |
866 "List of dormant articles in the current newsgroup.") | |
867 | |
868 (defvar gnus-newsgroup-scored nil | |
869 "List of scored articles in the current newsgroup.") | |
870 | |
871 (defvar gnus-newsgroup-headers nil | |
872 "List of article headers in the current newsgroup.") | |
873 | |
874 (defvar gnus-newsgroup-threads nil) | |
875 | |
876 (defvar gnus-newsgroup-prepared nil | |
877 "Whether the current group has been prepared properly.") | |
878 | |
879 (defvar gnus-newsgroup-ancient nil | |
880 "List of `gnus-fetch-old-headers' articles in the current newsgroup.") | |
881 | |
882 (defvar gnus-newsgroup-sparse nil) | |
883 | |
884 (defvar gnus-current-article nil) | |
885 (defvar gnus-article-current nil) | |
886 (defvar gnus-current-headers nil) | |
887 (defvar gnus-have-all-headers nil) | |
888 (defvar gnus-last-article nil) | |
889 (defvar gnus-newsgroup-history nil) | |
890 | |
891 (defconst gnus-summary-local-variables | |
892 '(gnus-newsgroup-name | |
893 gnus-newsgroup-begin gnus-newsgroup-end | |
894 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail | |
895 gnus-newsgroup-last-folder gnus-newsgroup-last-file | |
896 gnus-newsgroup-auto-expire gnus-newsgroup-unreads | |
897 gnus-newsgroup-unselected gnus-newsgroup-marked | |
898 gnus-newsgroup-reads gnus-newsgroup-saved | |
899 gnus-newsgroup-replied gnus-newsgroup-expirable | |
900 gnus-newsgroup-processable gnus-newsgroup-killed | |
901 gnus-newsgroup-bookmarks gnus-newsgroup-dormant | |
902 gnus-newsgroup-headers gnus-newsgroup-threads | |
903 gnus-newsgroup-prepared gnus-summary-highlight-line-function | |
904 gnus-current-article gnus-current-headers gnus-have-all-headers | |
905 gnus-last-article gnus-article-internal-prepare-hook | |
906 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay | |
907 gnus-newsgroup-scored gnus-newsgroup-kill-headers | |
908 gnus-thread-expunge-below | |
909 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below | |
910 (gnus-summary-mark-below . global) | |
911 gnus-newsgroup-active gnus-scores-exclude-files | |
912 gnus-newsgroup-history gnus-newsgroup-ancient | |
913 gnus-newsgroup-sparse gnus-newsgroup-process-stack | |
914 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring) | |
915 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1) | |
916 (gnus-newsgroup-expunged-tally . 0) | |
917 gnus-cache-removable-articles gnus-newsgroup-cached | |
918 gnus-newsgroup-data gnus-newsgroup-data-reverse | |
919 gnus-newsgroup-limit gnus-newsgroup-limits) | |
920 "Variables that are buffer-local to the summary buffers.") | |
921 | |
922 ;; Byte-compiler warning. | |
923 (defvar gnus-article-mode-map) | |
924 | |
925 ;; Subject simplification. | |
926 | |
927 (defsubst gnus-simplify-subject-re (subject) | |
928 "Remove \"Re:\" from subject lines." | |
929 (if (string-match "^[Rr][Ee]: *" subject) | |
930 (substring subject (match-end 0)) | |
931 subject)) | |
932 | |
933 (defun gnus-simplify-subject (subject &optional re-only) | |
934 "Remove `Re:' and words in parentheses. | |
935 If RE-ONLY is non-nil, strip leading `Re:'s only." | |
936 (let ((case-fold-search t)) ;Ignore case. | |
937 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'. | |
938 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject) | |
939 (setq subject (substring subject (match-end 0)))) | |
940 ;; Remove uninteresting prefixes. | |
941 (when (and (not re-only) | |
942 gnus-simplify-ignored-prefixes | |
943 (string-match gnus-simplify-ignored-prefixes subject)) | |
944 (setq subject (substring subject (match-end 0)))) | |
945 ;; Remove words in parentheses from end. | |
946 (unless re-only | |
947 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject) | |
948 (setq subject (substring subject 0 (match-beginning 0))))) | |
949 ;; Return subject string. | |
950 subject)) | |
951 | |
952 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify | |
953 ;; all whitespace. | |
954 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext) | |
955 (goto-char (point-min)) | |
956 (while (re-search-forward regexp nil t) | |
957 (replace-match (or newtext "")))) | |
958 | |
959 (defun gnus-simplify-buffer-fuzzy () | |
960 "Simplify string in the buffer fuzzily. | |
961 The string in the accessible portion of the current buffer is simplified. | |
962 It is assumed to be a single-line subject. | |
963 Whitespace is generally cleaned up, and miscellaneous leading/trailing | |
964 matter is removed. Additional things can be deleted by setting | |
965 gnus-simplify-subject-fuzzy-regexp." | |
966 (let ((case-fold-search t) | |
967 (modified-tick)) | |
968 (gnus-simplify-buffer-fuzzy-step "\t" " ") | |
969 | |
970 (while (not (eq modified-tick (buffer-modified-tick))) | |
971 (setq modified-tick (buffer-modified-tick)) | |
972 (cond | |
973 ((listp gnus-simplify-subject-fuzzy-regexp) | |
974 (mapcar 'gnus-simplify-buffer-fuzzy-step | |
975 gnus-simplify-subject-fuzzy-regexp)) | |
976 (gnus-simplify-subject-fuzzy-regexp | |
977 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp))) | |
978 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *") | |
979 (gnus-simplify-buffer-fuzzy-step | |
980 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *") | |
981 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1")) | |
982 | |
983 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$") | |
984 (gnus-simplify-buffer-fuzzy-step " +" " ") | |
985 (gnus-simplify-buffer-fuzzy-step " $") | |
986 (gnus-simplify-buffer-fuzzy-step "^ +"))) | |
987 | |
988 (defun gnus-simplify-subject-fuzzy (subject) | |
989 "Simplify a subject string fuzzily. | |
990 See gnus-simplify-buffer-fuzzy for details." | |
991 (save-excursion | |
992 (gnus-set-work-buffer) | |
993 (let ((case-fold-search t)) | |
994 (insert subject) | |
995 (inline (gnus-simplify-buffer-fuzzy)) | |
996 (buffer-string)))) | |
997 | |
998 (defsubst gnus-simplify-subject-fully (subject) | |
999 "Simplify a subject string according to gnus-summary-gather-subject-limit." | |
1000 (cond | |
1001 ((null gnus-summary-gather-subject-limit) | |
1002 (gnus-simplify-subject-re subject)) | |
1003 ((eq gnus-summary-gather-subject-limit 'fuzzy) | |
1004 (gnus-simplify-subject-fuzzy subject)) | |
1005 ((numberp gnus-summary-gather-subject-limit) | |
1006 (gnus-limit-string (gnus-simplify-subject-re subject) | |
1007 gnus-summary-gather-subject-limit)) | |
1008 (t | |
1009 subject))) | |
1010 | |
1011 (defsubst gnus-subject-equal (s1 s2 &optional simple-first) | |
1012 "Check whether two subjects are equal. If optional argument | |
1013 simple-first is t, first argument is already simplified." | |
1014 (cond | |
1015 ((null simple-first) | |
1016 (equal (gnus-simplify-subject-fully s1) | |
1017 (gnus-simplify-subject-fully s2))) | |
1018 (t | |
1019 (equal s1 | |
1020 (gnus-simplify-subject-fully s2))))) | |
1021 | |
1022 (defun gnus-summary-bubble-group () | |
1023 "Increase the score of the current group. | |
1024 This is a handy function to add to `gnus-summary-exit-hook' to | |
1025 increase the score of each group you read." | |
1026 (gnus-group-add-score gnus-newsgroup-name)) | |
1027 | |
1028 | |
1029 ;;; | |
1030 ;;; Gnus summary mode | |
1031 ;;; | |
1032 | |
1033 (put 'gnus-summary-mode 'mode-class 'special) | |
1034 | |
1035 (when t | |
1036 ;; Non-orthogonal keys | |
1037 | |
1038 (gnus-define-keys gnus-summary-mode-map | |
1039 " " gnus-summary-next-page | |
1040 "\177" gnus-summary-prev-page | |
1041 [delete] gnus-summary-prev-page | |
1042 "\r" gnus-summary-scroll-up | |
1043 "n" gnus-summary-next-unread-article | |
1044 "p" gnus-summary-prev-unread-article | |
1045 "N" gnus-summary-next-article | |
1046 "P" gnus-summary-prev-article | |
1047 "\M-\C-n" gnus-summary-next-same-subject | |
1048 "\M-\C-p" gnus-summary-prev-same-subject | |
1049 "\M-n" gnus-summary-next-unread-subject | |
1050 "\M-p" gnus-summary-prev-unread-subject | |
1051 "." gnus-summary-first-unread-article | |
1052 "," gnus-summary-best-unread-article | |
1053 "\M-s" gnus-summary-search-article-forward | |
1054 "\M-r" gnus-summary-search-article-backward | |
1055 "<" gnus-summary-beginning-of-article | |
1056 ">" gnus-summary-end-of-article | |
1057 "j" gnus-summary-goto-article | |
1058 "^" gnus-summary-refer-parent-article | |
1059 "\M-^" gnus-summary-refer-article | |
1060 "u" gnus-summary-tick-article-forward | |
1061 "!" gnus-summary-tick-article-forward | |
1062 "U" gnus-summary-tick-article-backward | |
1063 "d" gnus-summary-mark-as-read-forward | |
1064 "D" gnus-summary-mark-as-read-backward | |
1065 "E" gnus-summary-mark-as-expirable | |
1066 "\M-u" gnus-summary-clear-mark-forward | |
1067 "\M-U" gnus-summary-clear-mark-backward | |
1068 "k" gnus-summary-kill-same-subject-and-select | |
1069 "\C-k" gnus-summary-kill-same-subject | |
1070 "\M-\C-k" gnus-summary-kill-thread | |
1071 "\M-\C-l" gnus-summary-lower-thread | |
1072 "e" gnus-summary-edit-article | |
1073 "#" gnus-summary-mark-as-processable | |
1074 "\M-#" gnus-summary-unmark-as-processable | |
1075 "\M-\C-t" gnus-summary-toggle-threads | |
1076 "\M-\C-s" gnus-summary-show-thread | |
1077 "\M-\C-h" gnus-summary-hide-thread | |
1078 "\M-\C-f" gnus-summary-next-thread | |
1079 "\M-\C-b" gnus-summary-prev-thread | |
1080 "\M-\C-u" gnus-summary-up-thread | |
1081 "\M-\C-d" gnus-summary-down-thread | |
1082 "&" gnus-summary-execute-command | |
1083 "c" gnus-summary-catchup-and-exit | |
1084 "\C-w" gnus-summary-mark-region-as-read | |
1085 "\C-t" gnus-summary-toggle-truncation | |
1086 "?" gnus-summary-mark-as-dormant | |
1087 "\C-c\M-\C-s" gnus-summary-limit-include-expunged | |
1088 "\C-c\C-s\C-n" gnus-summary-sort-by-number | |
1089 "\C-c\C-s\C-l" gnus-summary-sort-by-lines | |
1090 "\C-c\C-s\C-a" gnus-summary-sort-by-author | |
1091 "\C-c\C-s\C-s" gnus-summary-sort-by-subject | |
1092 "\C-c\C-s\C-d" gnus-summary-sort-by-date | |
1093 "\C-c\C-s\C-i" gnus-summary-sort-by-score | |
1094 "=" gnus-summary-expand-window | |
1095 "\C-x\C-s" gnus-summary-reselect-current-group | |
1096 "\M-g" gnus-summary-rescan-group | |
1097 "w" gnus-summary-stop-page-breaking | |
1098 "\C-c\C-r" gnus-summary-caesar-message | |
1099 "\M-t" gnus-summary-toggle-mime | |
1100 "f" gnus-summary-followup | |
1101 "F" gnus-summary-followup-with-original | |
1102 "C" gnus-summary-cancel-article | |
1103 "r" gnus-summary-reply | |
1104 "R" gnus-summary-reply-with-original | |
1105 "\C-c\C-f" gnus-summary-mail-forward | |
1106 "o" gnus-summary-save-article | |
1107 "\C-o" gnus-summary-save-article-mail | |
1108 "|" gnus-summary-pipe-output | |
1109 "\M-k" gnus-summary-edit-local-kill | |
1110 "\M-K" gnus-summary-edit-global-kill | |
1111 ;; "V" gnus-version | |
1112 "\C-c\C-d" gnus-summary-describe-group | |
1113 "q" gnus-summary-exit | |
1114 "Q" gnus-summary-exit-no-update | |
1115 "\C-c\C-i" gnus-info-find-node | |
1116 gnus-mouse-2 gnus-mouse-pick-article | |
1117 "m" gnus-summary-mail-other-window | |
1118 "a" gnus-summary-post-news | |
1119 "x" gnus-summary-limit-to-unread | |
1120 "s" gnus-summary-isearch-article | |
1121 "t" gnus-article-hide-headers | |
1122 "g" gnus-summary-show-article | |
1123 "l" gnus-summary-goto-last-article | |
1124 "\C-c\C-v\C-v" gnus-uu-decode-uu-view | |
1125 "\C-d" gnus-summary-enter-digest-group | |
1126 "\M-\C-d" gnus-summary-read-document | |
1127 "\C-c\C-b" gnus-bug | |
1128 "*" gnus-cache-enter-article | |
1129 "\M-*" gnus-cache-remove-article | |
1130 "\M-&" gnus-summary-universal-argument | |
1131 "\C-l" gnus-recenter | |
1132 "I" gnus-summary-increase-score | |
1133 "L" gnus-summary-lower-score | |
1134 | |
1135 "V" gnus-summary-score-map | |
1136 "X" gnus-uu-extract-map | |
1137 "S" gnus-summary-send-map) | |
1138 | |
1139 ;; Sort of orthogonal keymap | |
1140 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map) | |
1141 "t" gnus-summary-tick-article-forward | |
1142 "!" gnus-summary-tick-article-forward | |
1143 "d" gnus-summary-mark-as-read-forward | |
1144 "r" gnus-summary-mark-as-read-forward | |
1145 "c" gnus-summary-clear-mark-forward | |
1146 " " gnus-summary-clear-mark-forward | |
1147 "e" gnus-summary-mark-as-expirable | |
1148 "x" gnus-summary-mark-as-expirable | |
1149 "?" gnus-summary-mark-as-dormant | |
1150 "b" gnus-summary-set-bookmark | |
1151 "B" gnus-summary-remove-bookmark | |
1152 "#" gnus-summary-mark-as-processable | |
1153 "\M-#" gnus-summary-unmark-as-processable | |
1154 "S" gnus-summary-limit-include-expunged | |
1155 "C" gnus-summary-catchup | |
1156 "H" gnus-summary-catchup-to-here | |
1157 "\C-c" gnus-summary-catchup-all | |
1158 "k" gnus-summary-kill-same-subject-and-select | |
1159 "K" gnus-summary-kill-same-subject | |
1160 "P" gnus-uu-mark-map) | |
1161 | |
1162 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map) | |
1163 "c" gnus-summary-clear-above | |
1164 "u" gnus-summary-tick-above | |
1165 "m" gnus-summary-mark-above | |
1166 "k" gnus-summary-kill-below) | |
1167 | |
1168 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map) | |
1169 "/" gnus-summary-limit-to-subject | |
1170 "n" gnus-summary-limit-to-articles | |
1171 "w" gnus-summary-pop-limit | |
1172 "s" gnus-summary-limit-to-subject | |
1173 "a" gnus-summary-limit-to-author | |
1174 "u" gnus-summary-limit-to-unread | |
1175 "m" gnus-summary-limit-to-marks | |
1176 "v" gnus-summary-limit-to-score | |
1177 "D" gnus-summary-limit-include-dormant | |
1178 "d" gnus-summary-limit-exclude-dormant | |
1179 "t" gnus-summary-limit-to-age | |
1180 "E" gnus-summary-limit-include-expunged | |
1181 "c" gnus-summary-limit-exclude-childless-dormant | |
1182 "C" gnus-summary-limit-mark-excluded-as-read) | |
1183 | |
1184 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map) | |
1185 "n" gnus-summary-next-unread-article | |
1186 "p" gnus-summary-prev-unread-article | |
1187 "N" gnus-summary-next-article | |
1188 "P" gnus-summary-prev-article | |
1189 "\C-n" gnus-summary-next-same-subject | |
1190 "\C-p" gnus-summary-prev-same-subject | |
1191 "\M-n" gnus-summary-next-unread-subject | |
1192 "\M-p" gnus-summary-prev-unread-subject | |
1193 "f" gnus-summary-first-unread-article | |
1194 "b" gnus-summary-best-unread-article | |
1195 "j" gnus-summary-goto-article | |
1196 "g" gnus-summary-goto-subject | |
1197 "l" gnus-summary-goto-last-article | |
1198 "p" gnus-summary-pop-article) | |
1199 | |
1200 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map) | |
1201 "k" gnus-summary-kill-thread | |
1202 "l" gnus-summary-lower-thread | |
1203 "i" gnus-summary-raise-thread | |
1204 "T" gnus-summary-toggle-threads | |
1205 "t" gnus-summary-rethread-current | |
1206 "^" gnus-summary-reparent-thread | |
1207 "s" gnus-summary-show-thread | |
1208 "S" gnus-summary-show-all-threads | |
1209 "h" gnus-summary-hide-thread | |
1210 "H" gnus-summary-hide-all-threads | |
1211 "n" gnus-summary-next-thread | |
1212 "p" gnus-summary-prev-thread | |
1213 "u" gnus-summary-up-thread | |
1214 "o" gnus-summary-top-thread | |
1215 "d" gnus-summary-down-thread | |
1216 "#" gnus-uu-mark-thread | |
1217 "\M-#" gnus-uu-unmark-thread) | |
1218 | |
1219 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map) | |
1220 "g" gnus-summary-prepare | |
1221 "c" gnus-summary-insert-cached-articles) | |
1222 | |
1223 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map) | |
1224 "c" gnus-summary-catchup-and-exit | |
1225 "C" gnus-summary-catchup-all-and-exit | |
1226 "E" gnus-summary-exit-no-update | |
1227 "Q" gnus-summary-exit | |
1228 "Z" gnus-summary-exit | |
1229 "n" gnus-summary-catchup-and-goto-next-group | |
1230 "R" gnus-summary-reselect-current-group | |
1231 "G" gnus-summary-rescan-group | |
1232 "N" gnus-summary-next-group | |
1233 "s" gnus-summary-save-newsrc | |
1234 "P" gnus-summary-prev-group) | |
1235 | |
1236 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map) | |
1237 " " gnus-summary-next-page | |
1238 "n" gnus-summary-next-page | |
1239 "\177" gnus-summary-prev-page | |
1240 [delete] gnus-summary-prev-page | |
1241 "p" gnus-summary-prev-page | |
1242 "\r" gnus-summary-scroll-up | |
1243 "<" gnus-summary-beginning-of-article | |
1244 ">" gnus-summary-end-of-article | |
1245 "b" gnus-summary-beginning-of-article | |
1246 "e" gnus-summary-end-of-article | |
1247 "^" gnus-summary-refer-parent-article | |
1248 "r" gnus-summary-refer-parent-article | |
1249 "R" gnus-summary-refer-references | |
1250 "g" gnus-summary-show-article | |
1251 "s" gnus-summary-isearch-article | |
1252 "P" gnus-summary-print-article) | |
1253 | |
1254 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map) | |
1255 "b" gnus-article-add-buttons | |
1256 "B" gnus-article-add-buttons-to-head | |
1257 "o" gnus-article-treat-overstrike | |
1258 "e" gnus-article-emphasize | |
1259 "w" gnus-article-fill-cited-article | |
1260 "c" gnus-article-remove-cr | |
1261 "q" gnus-article-de-quoted-unreadable | |
1262 "f" gnus-article-display-x-face | |
1263 "l" gnus-summary-stop-page-breaking | |
1264 "r" gnus-summary-caesar-message | |
1265 "t" gnus-article-hide-headers | |
1266 "v" gnus-summary-verbose-headers | |
1267 "m" gnus-summary-toggle-mime | |
1268 "h" gnus-article-treat-html) | |
1269 | |
1270 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map) | |
1271 "a" gnus-article-hide | |
1272 "h" gnus-article-hide-headers | |
1273 "b" gnus-article-hide-boring-headers | |
1274 "s" gnus-article-hide-signature | |
1275 "c" gnus-article-hide-citation | |
1276 "p" gnus-article-hide-pgp | |
1277 "P" gnus-article-hide-pem | |
1278 "\C-c" gnus-article-hide-citation-maybe) | |
1279 | |
1280 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map) | |
1281 "a" gnus-article-highlight | |
1282 "h" gnus-article-highlight-headers | |
1283 "c" gnus-article-highlight-citation | |
1284 "s" gnus-article-highlight-signature) | |
1285 | |
1286 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map) | |
1287 "z" gnus-article-date-ut | |
1288 "u" gnus-article-date-ut | |
1289 "l" gnus-article-date-local | |
1290 "e" gnus-article-date-lapsed | |
1291 "o" gnus-article-date-original | |
1292 "s" gnus-article-date-user) | |
1293 | |
1294 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map) | |
1295 "t" gnus-article-remove-trailing-blank-lines | |
1296 "l" gnus-article-strip-leading-blank-lines | |
1297 "m" gnus-article-strip-multiple-blank-lines | |
1298 "a" gnus-article-strip-blank-lines | |
1299 "s" gnus-article-strip-leading-space) | |
1300 | |
1301 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map) | |
1302 "v" gnus-version | |
1303 "f" gnus-summary-fetch-faq | |
1304 "d" gnus-summary-describe-group | |
1305 "h" gnus-summary-describe-briefly | |
1306 "i" gnus-info-find-node) | |
1307 | |
1308 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map) | |
1309 "e" gnus-summary-expire-articles | |
1310 "\M-\C-e" gnus-summary-expire-articles-now | |
1311 "\177" gnus-summary-delete-article | |
1312 [delete] gnus-summary-delete-article | |
1313 "m" gnus-summary-move-article | |
1314 "r" gnus-summary-respool-article | |
1315 "w" gnus-summary-edit-article | |
1316 "c" gnus-summary-copy-article | |
1317 "B" gnus-summary-crosspost-article | |
1318 "q" gnus-summary-respool-query | |
1319 "i" gnus-summary-import-article | |
1320 "p" gnus-summary-article-posted-p) | |
1321 | |
1322 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map) | |
1323 "o" gnus-summary-save-article | |
1324 "m" gnus-summary-save-article-mail | |
1325 "F" gnus-summary-write-article-file | |
1326 "r" gnus-summary-save-article-rmail | |
1327 "f" gnus-summary-save-article-file | |
1328 "b" gnus-summary-save-article-body-file | |
1329 "h" gnus-summary-save-article-folder | |
1330 "v" gnus-summary-save-article-vm | |
1331 "p" gnus-summary-pipe-output | |
1332 "s" gnus-soup-add-article)) | |
1333 | |
1334 (defun gnus-summary-make-menu-bar () | |
1335 (gnus-turn-off-edit-menu 'summary) | |
1336 | |
1337 (unless (boundp 'gnus-summary-misc-menu) | |
1338 | |
1339 (easy-menu-define | |
1340 gnus-summary-kill-menu gnus-summary-mode-map "" | |
1341 (cons | |
1342 "Score" | |
1343 (nconc | |
1344 (list | |
1345 ["Enter score..." gnus-summary-score-entry t] | |
1346 ["Customize" gnus-score-customize t]) | |
1347 (gnus-make-score-map 'increase) | |
1348 (gnus-make-score-map 'lower) | |
1349 '(("Mark" | |
1350 ["Kill below" gnus-summary-kill-below t] | |
1351 ["Mark above" gnus-summary-mark-above t] | |
1352 ["Tick above" gnus-summary-tick-above t] | |
1353 ["Clear above" gnus-summary-clear-above t]) | |
1354 ["Current score" gnus-summary-current-score t] | |
1355 ["Set score" gnus-summary-set-score t] | |
1356 ["Switch current score file..." gnus-score-change-score-file t] | |
1357 ["Set mark below..." gnus-score-set-mark-below t] | |
1358 ["Set expunge below..." gnus-score-set-expunge-below t] | |
1359 ["Edit current score file" gnus-score-edit-current-scores t] | |
1360 ["Edit score file" gnus-score-edit-file t] | |
1361 ["Trace score" gnus-score-find-trace t] | |
1362 ["Find words" gnus-score-find-favourite-words t] | |
1363 ["Rescore buffer" gnus-summary-rescore t] | |
1364 ["Increase score..." gnus-summary-increase-score t] | |
1365 ["Lower score..." gnus-summary-lower-score t])))) | |
1366 | |
1367 '(("Default header" | |
1368 ["Ask" (gnus-score-set-default 'gnus-score-default-header nil) | |
1369 :style radio | |
1370 :selected (null gnus-score-default-header)] | |
1371 ["From" (gnus-score-set-default 'gnus-score-default-header 'a) | |
1372 :style radio | |
1373 :selected (eq gnus-score-default-header 'a)] | |
1374 ["Subject" (gnus-score-set-default 'gnus-score-default-header 's) | |
1375 :style radio | |
1376 :selected (eq gnus-score-default-header 's)] | |
1377 ["Article body" | |
1378 (gnus-score-set-default 'gnus-score-default-header 'b) | |
1379 :style radio | |
1380 :selected (eq gnus-score-default-header 'b )] | |
1381 ["All headers" | |
1382 (gnus-score-set-default 'gnus-score-default-header 'h) | |
1383 :style radio | |
1384 :selected (eq gnus-score-default-header 'h )] | |
1385 ["Message-ID" (gnus-score-set-default 'gnus-score-default-header 'i) | |
1386 :style radio | |
1387 :selected (eq gnus-score-default-header 'i )] | |
1388 ["Thread" (gnus-score-set-default 'gnus-score-default-header 't) | |
1389 :style radio | |
1390 :selected (eq gnus-score-default-header 't )] | |
1391 ["Crossposting" | |
1392 (gnus-score-set-default 'gnus-score-default-header 'x) | |
1393 :style radio | |
1394 :selected (eq gnus-score-default-header 'x )] | |
1395 ["Lines" (gnus-score-set-default 'gnus-score-default-header 'l) | |
1396 :style radio | |
1397 :selected (eq gnus-score-default-header 'l )] | |
1398 ["Date" (gnus-score-set-default 'gnus-score-default-header 'd) | |
1399 :style radio | |
1400 :selected (eq gnus-score-default-header 'd )] | |
1401 ["Followups to author" | |
1402 (gnus-score-set-default 'gnus-score-default-header 'f) | |
1403 :style radio | |
1404 :selected (eq gnus-score-default-header 'f )]) | |
1405 ("Default type" | |
1406 ["Ask" (gnus-score-set-default 'gnus-score-default-type nil) | |
1407 :style radio | |
1408 :selected (null gnus-score-default-type)] | |
1409 ;; The `:active' key is commented out in the following, | |
1410 ;; because the GNU Emacs hack to support radio buttons use | |
1411 ;; active to indicate which button is selected. | |
1412 ["Substring" (gnus-score-set-default 'gnus-score-default-type 's) | |
1413 :style radio | |
1414 ;; :active (not (memq gnus-score-default-header '(l d))) | |
1415 :selected (eq gnus-score-default-type 's)] | |
1416 ["Regexp" (gnus-score-set-default 'gnus-score-default-type 'r) | |
1417 :style radio | |
1418 ;; :active (not (memq gnus-score-default-header '(l d))) | |
1419 :selected (eq gnus-score-default-type 'r)] | |
1420 ["Exact" (gnus-score-set-default 'gnus-score-default-type 'e) | |
1421 :style radio | |
1422 ;; :active (not (memq gnus-score-default-header '(l d))) | |
1423 :selected (eq gnus-score-default-type 'e)] | |
1424 ["Fuzzy" (gnus-score-set-default 'gnus-score-default-type 'f) | |
1425 :style radio | |
1426 ;; :active (not (memq gnus-score-default-header '(l d))) | |
1427 :selected (eq gnus-score-default-type 'f)] | |
1428 ["Before date" (gnus-score-set-default 'gnus-score-default-type 'b) | |
1429 :style radio | |
1430 ;; :active (eq (gnus-score-default-header 'd)) | |
1431 :selected (eq gnus-score-default-type 'b)] | |
1432 ["At date" (gnus-score-set-default 'gnus-score-default-type 'n) | |
1433 :style radio | |
1434 ;; :active (eq (gnus-score-default-header 'd)) | |
1435 :selected (eq gnus-score-default-type 'n)] | |
1436 ["After date" (gnus-score-set-default 'gnus-score-default-type 'a) | |
1437 :style radio | |
1438 ;; :active (eq (gnus-score-default-header 'd)) | |
1439 :selected (eq gnus-score-default-type 'a)] | |
1440 ["Less than number" | |
1441 (gnus-score-set-default 'gnus-score-default-type '<) | |
1442 :style radio | |
1443 ;; :active (eq (gnus-score-default-header 'l)) | |
1444 :selected (eq gnus-score-default-type '<)] | |
1445 ["Equal to number" | |
1446 (gnus-score-set-default 'gnus-score-default-type '=) | |
1447 :style radio | |
1448 ;; :active (eq (gnus-score-default-header 'l)) | |
1449 :selected (eq gnus-score-default-type '=)] | |
1450 ["Greater than number" | |
1451 (gnus-score-set-default 'gnus-score-default-type '>) | |
1452 :style radio | |
1453 ;; :active (eq (gnus-score-default-header 'l)) | |
1454 :selected (eq gnus-score-default-type '>)]) | |
1455 ["Default fold" gnus-score-default-fold-toggle | |
1456 :style toggle | |
1457 :selected gnus-score-default-fold] | |
1458 ("Default duration" | |
1459 ["Ask" (gnus-score-set-default 'gnus-score-default-duration nil) | |
1460 :style radio | |
1461 :selected (null gnus-score-default-duration)] | |
1462 ["Permanent" | |
1463 (gnus-score-set-default 'gnus-score-default-duration 'p) | |
1464 :style radio | |
1465 :selected (eq gnus-score-default-duration 'p)] | |
1466 ["Temporary" | |
1467 (gnus-score-set-default 'gnus-score-default-duration 't) | |
1468 :style radio | |
1469 :selected (eq gnus-score-default-duration 't)] | |
1470 ["Immediate" | |
1471 (gnus-score-set-default 'gnus-score-default-duration 'i) | |
1472 :style radio | |
1473 :selected (eq gnus-score-default-duration 'i)])) | |
1474 | |
1475 (easy-menu-define | |
1476 gnus-summary-article-menu gnus-summary-mode-map "" | |
1477 '("Article" | |
1478 ("Hide" | |
1479 ["All" gnus-article-hide t] | |
1480 ["Headers" gnus-article-hide-headers t] | |
1481 ["Signature" gnus-article-hide-signature t] | |
1482 ["Citation" gnus-article-hide-citation t] | |
1483 ["PGP" gnus-article-hide-pgp t] | |
1484 ["Boring headers" gnus-article-hide-boring-headers t]) | |
1485 ("Highlight" | |
1486 ["All" gnus-article-highlight t] | |
1487 ["Headers" gnus-article-highlight-headers t] | |
1488 ["Signature" gnus-article-highlight-signature t] | |
1489 ["Citation" gnus-article-highlight-citation t]) | |
1490 ("Date" | |
1491 ["Local" gnus-article-date-local t] | |
1492 ["UT" gnus-article-date-ut t] | |
1493 ["Original" gnus-article-date-original t] | |
1494 ["Lapsed" gnus-article-date-lapsed t] | |
1495 ["User-defined" gnus-article-date-user t]) | |
1496 ("Washing" | |
1497 ("Remove Blanks" | |
1498 ["Leading" gnus-article-strip-leading-blank-lines t] | |
1499 ["Multiple" gnus-article-strip-multiple-blank-lines t] | |
1500 ["Trailing" gnus-article-remove-trailing-blank-lines t] | |
1501 ["All of the above" gnus-article-strip-blank-lines t] | |
1502 ["Leading space" gnus-article-strip-leading-space t]) | |
1503 ["Overstrike" gnus-article-treat-overstrike t] | |
1504 ["Emphasis" gnus-article-emphasize t] | |
1505 ["Word wrap" gnus-article-fill-cited-article t] | |
1506 ["CR" gnus-article-remove-cr t] | |
1507 ["Show X-Face" gnus-article-display-x-face t] | |
1508 ["Quoted-Printable" gnus-article-de-quoted-unreadable t] | |
1509 ["UnHTMLize" gnus-article-treat-html t] | |
1510 ["Rot 13" gnus-summary-caesar-message t] | |
1511 ["Unix pipe" gnus-summary-pipe-message t] | |
1512 ["Add buttons" gnus-article-add-buttons t] | |
1513 ["Add buttons to head" gnus-article-add-buttons-to-head t] | |
1514 ["Stop page breaking" gnus-summary-stop-page-breaking t] | |
1515 ["Toggle MIME" gnus-summary-toggle-mime t] | |
1516 ["Verbose header" gnus-summary-verbose-headers t] | |
1517 ["Toggle header" gnus-summary-toggle-header t]) | |
1518 ("Output" | |
1519 ["Save in default format" gnus-summary-save-article t] | |
1520 ["Save in file" gnus-summary-save-article-file t] | |
1521 ["Save in Unix mail format" gnus-summary-save-article-mail t] | |
1522 ["Write to file" gnus-summary-write-article-mail t] | |
1523 ["Save in MH folder" gnus-summary-save-article-folder t] | |
1524 ["Save in VM folder" gnus-summary-save-article-vm t] | |
1525 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t] | |
1526 ["Save body in file" gnus-summary-save-article-body-file t] | |
1527 ["Pipe through a filter" gnus-summary-pipe-output t] | |
1528 ["Add to SOUP packet" gnus-soup-add-article t] | |
1529 ["Print" gnus-summary-print-article t]) | |
1530 ("Backend" | |
1531 ["Respool article..." gnus-summary-respool-article t] | |
1532 ["Move article..." gnus-summary-move-article | |
1533 (gnus-check-backend-function | |
1534 'request-move-article gnus-newsgroup-name)] | |
1535 ["Copy article..." gnus-summary-copy-article t] | |
1536 ["Crosspost article..." gnus-summary-crosspost-article | |
1537 (gnus-check-backend-function | |
1538 'request-replace-article gnus-newsgroup-name)] | |
1539 ["Import file..." gnus-summary-import-article t] | |
1540 ["Check if posted" gnus-summary-article-posted-p t] | |
1541 ["Edit article" gnus-summary-edit-article | |
1542 (not (gnus-group-read-only-p))] | |
1543 ["Delete article" gnus-summary-delete-article | |
1544 (gnus-check-backend-function | |
1545 'request-expire-articles gnus-newsgroup-name)] | |
1546 ["Query respool" gnus-summary-respool-query t] | |
1547 ["Delete expirable articles" gnus-summary-expire-articles-now | |
1548 (gnus-check-backend-function | |
1549 'request-expire-articles gnus-newsgroup-name)]) | |
1550 ("Extract" | |
1551 ["Uudecode" gnus-uu-decode-uu t] | |
1552 ["Uudecode and save" gnus-uu-decode-uu-and-save t] | |
1553 ["Unshar" gnus-uu-decode-unshar t] | |
1554 ["Unshar and save" gnus-uu-decode-unshar-and-save t] | |
1555 ["Save" gnus-uu-decode-save t] | |
1556 ["Binhex" gnus-uu-decode-binhex t] | |
1557 ["Postscript" gnus-uu-decode-postscript t]) | |
1558 ("Cache" | |
1559 ["Enter article" gnus-cache-enter-article t] | |
1560 ["Remove article" gnus-cache-remove-article t]) | |
1561 ["Enter digest buffer" gnus-summary-enter-digest-group t] | |
1562 ["Isearch article..." gnus-summary-isearch-article t] | |
1563 ["Beginning of the article" gnus-summary-beginning-of-article t] | |
1564 ["End of the article" gnus-summary-end-of-article t] | |
1565 ["Fetch parent of article" gnus-summary-refer-parent-article t] | |
1566 ["Fetch referenced articles" gnus-summary-refer-references t] | |
1567 ["Fetch article with id..." gnus-summary-refer-article t] | |
1568 ["Redisplay" gnus-summary-show-article t])) | |
1569 | |
1570 (easy-menu-define | |
1571 gnus-summary-thread-menu gnus-summary-mode-map "" | |
1572 '("Threads" | |
1573 ["Toggle threading" gnus-summary-toggle-threads t] | |
1574 ["Hide threads" gnus-summary-hide-all-threads t] | |
1575 ["Show threads" gnus-summary-show-all-threads t] | |
1576 ["Hide thread" gnus-summary-hide-thread t] | |
1577 ["Show thread" gnus-summary-show-thread t] | |
1578 ["Go to next thread" gnus-summary-next-thread t] | |
1579 ["Go to previous thread" gnus-summary-prev-thread t] | |
1580 ["Go down thread" gnus-summary-down-thread t] | |
1581 ["Go up thread" gnus-summary-up-thread t] | |
1582 ["Top of thread" gnus-summary-top-thread t] | |
1583 ["Mark thread as read" gnus-summary-kill-thread t] | |
1584 ["Lower thread score" gnus-summary-lower-thread t] | |
1585 ["Raise thread score" gnus-summary-raise-thread t] | |
1586 ["Rethread current" gnus-summary-rethread-current t] | |
1587 )) | |
1588 | |
1589 (easy-menu-define | |
1590 gnus-summary-post-menu gnus-summary-mode-map "" | |
1591 '("Post" | |
1592 ["Post an article" gnus-summary-post-news t] | |
1593 ["Followup" gnus-summary-followup t] | |
1594 ["Followup and yank" gnus-summary-followup-with-original t] | |
1595 ["Supersede article" gnus-summary-supersede-article t] | |
1596 ["Cancel article" gnus-summary-cancel-article t] | |
1597 ["Reply" gnus-summary-reply t] | |
1598 ["Reply and yank" gnus-summary-reply-with-original t] | |
1599 ["Wide reply" gnus-summary-wide-reply t] | |
1600 ["Wide reply and yank" gnus-summary-wide-reply-with-original t] | |
1601 ["Mail forward" gnus-summary-mail-forward t] | |
1602 ["Post forward" gnus-summary-post-forward t] | |
1603 ["Digest and mail" gnus-uu-digest-mail-forward t] | |
1604 ["Digest and post" gnus-uu-digest-post-forward t] | |
1605 ["Resend message" gnus-summary-resend-message t] | |
1606 ["Send bounced mail" gnus-summary-resend-bounced-mail t] | |
1607 ["Send a mail" gnus-summary-mail-other-window t] | |
1608 ["Uuencode and post" gnus-uu-post-news t] | |
1609 ["Followup via news" gnus-summary-followup-to-mail t] | |
1610 ["Followup via news and yank" | |
1611 gnus-summary-followup-to-mail-with-original t] | |
1612 ;;("Draft" | |
1613 ;;["Send" gnus-summary-send-draft t] | |
1614 ;;["Send bounced" gnus-resend-bounced-mail t]) | |
1615 )) | |
1616 | |
1617 (easy-menu-define | |
1618 gnus-summary-misc-menu gnus-summary-mode-map "" | |
1619 '("Misc" | |
1620 ("Mark Read" | |
1621 ["Mark as read" gnus-summary-mark-as-read-forward t] | |
1622 ["Mark same subject and select" | |
1623 gnus-summary-kill-same-subject-and-select t] | |
1624 ["Mark same subject" gnus-summary-kill-same-subject t] | |
1625 ["Catchup" gnus-summary-catchup t] | |
1626 ["Catchup all" gnus-summary-catchup-all t] | |
1627 ["Catchup to here" gnus-summary-catchup-to-here t] | |
1628 ["Catchup region" gnus-summary-mark-region-as-read t] | |
1629 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t]) | |
1630 ("Mark Various" | |
1631 ["Tick" gnus-summary-tick-article-forward t] | |
1632 ["Mark as dormant" gnus-summary-mark-as-dormant t] | |
1633 ["Remove marks" gnus-summary-clear-mark-forward t] | |
1634 ["Set expirable mark" gnus-summary-mark-as-expirable t] | |
1635 ["Set bookmark" gnus-summary-set-bookmark t] | |
1636 ["Remove bookmark" gnus-summary-remove-bookmark t]) | |
1637 ("Mark Limit" | |
1638 ["Marks..." gnus-summary-limit-to-marks t] | |
1639 ["Subject..." gnus-summary-limit-to-subject t] | |
1640 ["Author..." gnus-summary-limit-to-author t] | |
1641 ["Age..." gnus-summary-limit-to-age t] | |
1642 ["Score" gnus-summary-limit-to-score t] | |
1643 ["Unread" gnus-summary-limit-to-unread t] | |
1644 ["Non-dormant" gnus-summary-limit-exclude-dormant t] | |
1645 ["Articles" gnus-summary-limit-to-articles t] | |
1646 ["Pop limit" gnus-summary-pop-limit t] | |
1647 ["Show dormant" gnus-summary-limit-include-dormant t] | |
1648 ["Hide childless dormant" | |
1649 gnus-summary-limit-exclude-childless-dormant t] | |
1650 ;;["Hide thread" gnus-summary-limit-exclude-thread t] | |
1651 ["Show expunged" gnus-summary-show-all-expunged t]) | |
1652 ("Process Mark" | |
1653 ["Set mark" gnus-summary-mark-as-processable t] | |
1654 ["Remove mark" gnus-summary-unmark-as-processable t] | |
1655 ["Remove all marks" gnus-summary-unmark-all-processable t] | |
1656 ["Mark above" gnus-uu-mark-over t] | |
1657 ["Mark series" gnus-uu-mark-series t] | |
1658 ["Mark region" gnus-uu-mark-region t] | |
1659 ["Mark by regexp..." gnus-uu-mark-by-regexp t] | |
1660 ["Mark all" gnus-uu-mark-all t] | |
1661 ["Mark buffer" gnus-uu-mark-buffer t] | |
1662 ["Mark sparse" gnus-uu-mark-sparse t] | |
1663 ["Mark thread" gnus-uu-mark-thread t] | |
1664 ["Unmark thread" gnus-uu-unmark-thread t] | |
1665 ("Process Mark Sets" | |
1666 ["Kill" gnus-summary-kill-process-mark t] | |
1667 ["Yank" gnus-summary-yank-process-mark | |
1668 gnus-newsgroup-process-stack] | |
1669 ["Save" gnus-summary-save-process-mark t])) | |
1670 ("Scroll article" | |
1671 ["Page forward" gnus-summary-next-page t] | |
1672 ["Page backward" gnus-summary-prev-page t] | |
1673 ["Line forward" gnus-summary-scroll-up t]) | |
1674 ("Move" | |
1675 ["Next unread article" gnus-summary-next-unread-article t] | |
1676 ["Previous unread article" gnus-summary-prev-unread-article t] | |
1677 ["Next article" gnus-summary-next-article t] | |
1678 ["Previous article" gnus-summary-prev-article t] | |
1679 ["Next unread subject" gnus-summary-next-unread-subject t] | |
1680 ["Previous unread subject" gnus-summary-prev-unread-subject t] | |
1681 ["Next article same subject" gnus-summary-next-same-subject t] | |
1682 ["Previous article same subject" gnus-summary-prev-same-subject t] | |
1683 ["First unread article" gnus-summary-first-unread-article t] | |
1684 ["Best unread article" gnus-summary-best-unread-article t] | |
1685 ["Go to subject number..." gnus-summary-goto-subject t] | |
1686 ["Go to article number..." gnus-summary-goto-article t] | |
1687 ["Go to the last article" gnus-summary-goto-last-article t] | |
1688 ["Pop article off history" gnus-summary-pop-article t]) | |
1689 ("Sort" | |
1690 ["Sort by number" gnus-summary-sort-by-number t] | |
1691 ["Sort by author" gnus-summary-sort-by-author t] | |
1692 ["Sort by subject" gnus-summary-sort-by-subject t] | |
1693 ["Sort by date" gnus-summary-sort-by-date t] | |
1694 ["Sort by score" gnus-summary-sort-by-score t] | |
1695 ["Sort by lines" gnus-summary-sort-by-lines t]) | |
1696 ("Help" | |
1697 ["Fetch group FAQ" gnus-summary-fetch-faq t] | |
1698 ["Describe group" gnus-summary-describe-group t] | |
1699 ["Read manual" gnus-info-find-node t]) | |
1700 ("Modes" | |
1701 ["Pick and read" gnus-pick-mode t] | |
1702 ["Binary" gnus-binary-mode t]) | |
1703 ("Regeneration" | |
1704 ["Regenerate" gnus-summary-prepare t] | |
1705 ["Insert cached articles" gnus-summary-insert-cached-articles t] | |
1706 ["Toggle threading" gnus-summary-toggle-threads t]) | |
1707 ["Filter articles..." gnus-summary-execute-command t] | |
1708 ["Run command on subjects..." gnus-summary-universal-argument t] | |
1709 ["Search articles forward..." gnus-summary-search-article-forward t] | |
1710 ["Search articles backward..." gnus-summary-search-article-backward t] | |
1711 ["Toggle line truncation" gnus-summary-toggle-truncation t] | |
1712 ["Expand window" gnus-summary-expand-window t] | |
1713 ["Expire expirable articles" gnus-summary-expire-articles | |
1714 (gnus-check-backend-function | |
1715 'request-expire-articles gnus-newsgroup-name)] | |
1716 ["Edit local kill file" gnus-summary-edit-local-kill t] | |
1717 ["Edit main kill file" gnus-summary-edit-global-kill t] | |
1718 ("Exit" | |
1719 ["Catchup and exit" gnus-summary-catchup-and-exit t] | |
1720 ["Catchup all and exit" gnus-summary-catchup-and-exit t] | |
1721 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t] | |
1722 ["Exit group" gnus-summary-exit t] | |
1723 ["Exit group without updating" gnus-summary-exit-no-update t] | |
1724 ["Exit and goto next group" gnus-summary-next-group t] | |
1725 ["Exit and goto prev group" gnus-summary-prev-group t] | |
1726 ["Reselect group" gnus-summary-reselect-current-group t] | |
1727 ["Rescan group" gnus-summary-rescan-group t] | |
1728 ["Update dribble" gnus-summary-save-newsrc t]))) | |
1729 | |
1730 (run-hooks 'gnus-summary-menu-hook))) | |
1731 | |
1732 (defun gnus-score-set-default (var value) | |
1733 "A version of set that updates the GNU Emacs menu-bar." | |
1734 (set var value) | |
1735 ;; It is the message that forces the active status to be updated. | |
1736 (message "")) | |
1737 | |
1738 (defun gnus-make-score-map (type) | |
1739 "Make a summary score map of type TYPE." | |
1740 (if t | |
1741 nil | |
1742 (let ((headers '(("author" "from" string) | |
1743 ("subject" "subject" string) | |
1744 ("article body" "body" string) | |
1745 ("article head" "head" string) | |
1746 ("xref" "xref" string) | |
1747 ("lines" "lines" number) | |
1748 ("followups to author" "followup" string))) | |
1749 (types '((number ("less than" <) | |
1750 ("greater than" >) | |
1751 ("equal" =)) | |
1752 (string ("substring" s) | |
1753 ("exact string" e) | |
1754 ("fuzzy string" f) | |
1755 ("regexp" r)))) | |
1756 (perms '(("temporary" (current-time-string)) | |
1757 ("permanent" nil) | |
1758 ("immediate" now))) | |
1759 header) | |
1760 (list | |
1761 (apply | |
1762 'nconc | |
1763 (list | |
1764 (if (eq type 'lower) | |
1765 "Lower score" | |
1766 "Increase score")) | |
1767 (let (outh) | |
1768 (while headers | |
1769 (setq header (car headers)) | |
1770 (setq outh | |
1771 (cons | |
1772 (apply | |
1773 'nconc | |
1774 (list (car header)) | |
1775 (let ((ts (cdr (assoc (nth 2 header) types))) | |
1776 outt) | |
1777 (while ts | |
1778 (setq outt | |
1779 (cons | |
1780 (apply | |
1781 'nconc | |
1782 (list (caar ts)) | |
1783 (let ((ps perms) | |
1784 outp) | |
1785 (while ps | |
1786 (setq outp | |
1787 (cons | |
1788 (vector | |
1789 (caar ps) | |
1790 (list | |
1791 'gnus-summary-score-entry | |
1792 (nth 1 header) | |
1793 (if (or (string= (nth 1 header) | |
1794 "head") | |
1795 (string= (nth 1 header) | |
1796 "body")) | |
1797 "" | |
1798 (list 'gnus-summary-header | |
1799 (nth 1 header))) | |
1800 (list 'quote (nth 1 (car ts))) | |
1801 (list 'gnus-score-default nil) | |
1802 (nth 1 (car ps)) | |
1803 t) | |
1804 t) | |
1805 outp)) | |
1806 (setq ps (cdr ps))) | |
1807 (list (nreverse outp)))) | |
1808 outt)) | |
1809 (setq ts (cdr ts))) | |
1810 (list (nreverse outt)))) | |
1811 outh)) | |
1812 (setq headers (cdr headers))) | |
1813 (list (nreverse outh)))))))) | |
1814 | |
1815 | |
1816 | |
1817 (defun gnus-summary-mode (&optional group) | |
1818 "Major mode for reading articles. | |
1819 | |
1820 All normal editing commands are switched off. | |
1821 \\<gnus-summary-mode-map> | |
1822 Each line in this buffer represents one article. To read an | |
1823 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards | |
1824 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]', | |
1825 respectively. | |
1826 | |
1827 You can also post articles and send mail from this buffer. To | |
1828 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author | |
1829 of an article, type `\\[gnus-summary-reply]'. | |
1830 | |
1831 There are approx. one gazillion commands you can execute in this | |
1832 buffer; read the info pages for more information (`\\[gnus-info-find-node]'). | |
1833 | |
1834 The following commands are available: | |
1835 | |
1836 \\{gnus-summary-mode-map}" | |
1837 (interactive) | |
1838 (when (gnus-visual-p 'summary-menu 'menu) | |
1839 (gnus-summary-make-menu-bar)) | |
1840 (kill-all-local-variables) | |
1841 (gnus-summary-make-local-variables) | |
1842 (gnus-make-thread-indent-array) | |
1843 (gnus-simplify-mode-line) | |
1844 (setq major-mode 'gnus-summary-mode) | |
1845 (setq mode-name "Summary") | |
1846 (make-local-variable 'minor-mode-alist) | |
1847 (use-local-map gnus-summary-mode-map) | |
1848 (buffer-disable-undo (current-buffer)) | |
1849 (setq buffer-read-only t) ;Disable modification | |
1850 (setq truncate-lines t) | |
1851 (setq selective-display t) | |
1852 (setq selective-display-ellipses t) ;Display `...' | |
1853 (gnus-summary-set-display-table) | |
1854 (gnus-set-default-directory) | |
1855 (setq gnus-newsgroup-name group) | |
1856 (make-local-variable 'gnus-summary-line-format) | |
1857 (make-local-variable 'gnus-summary-line-format-spec) | |
1858 (make-local-variable 'gnus-summary-mark-positions) | |
1859 (make-local-hook 'post-command-hook) | |
1860 (add-hook 'post-command-hook 'gnus-clear-inboxes-moved nil t) | |
1861 (run-hooks 'gnus-summary-mode-hook) | |
1862 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy) | |
1863 (gnus-update-summary-mark-positions)) | |
1864 | |
1865 (defun gnus-summary-make-local-variables () | |
1866 "Make all the local summary buffer variables." | |
1867 (let ((locals gnus-summary-local-variables) | |
1868 global local) | |
1869 (while (setq local (pop locals)) | |
1870 (if (consp local) | |
1871 (progn | |
1872 (if (eq (cdr local) 'global) | |
1873 ;; Copy the global value of the variable. | |
1874 (setq global (symbol-value (car local))) | |
1875 ;; Use the value from the list. | |
1876 (setq global (eval (cdr local)))) | |
1877 (make-local-variable (car local)) | |
1878 (set (car local) global)) | |
1879 ;; Simple nil-valued local variable. | |
1880 (make-local-variable local) | |
1881 (set local nil))))) | |
1882 | |
1883 (defun gnus-summary-clear-local-variables () | |
1884 (let ((locals gnus-summary-local-variables)) | |
1885 (while locals | |
1886 (if (consp (car locals)) | |
1887 (and (vectorp (caar locals)) | |
1888 (set (caar locals) nil)) | |
1889 (and (vectorp (car locals)) | |
1890 (set (car locals) nil))) | |
1891 (setq locals (cdr locals))))) | |
1892 | |
1893 ;; Summary data functions. | |
1894 | |
1895 (defmacro gnus-data-number (data) | |
1896 `(car ,data)) | |
1897 | |
1898 (defmacro gnus-data-set-number (data number) | |
1899 `(setcar ,data ,number)) | |
1900 | |
1901 (defmacro gnus-data-mark (data) | |
1902 `(nth 1 ,data)) | |
1903 | |
1904 (defmacro gnus-data-set-mark (data mark) | |
1905 `(setcar (nthcdr 1 ,data) ,mark)) | |
1906 | |
1907 (defmacro gnus-data-pos (data) | |
1908 `(nth 2 ,data)) | |
1909 | |
1910 (defmacro gnus-data-set-pos (data pos) | |
1911 `(setcar (nthcdr 2 ,data) ,pos)) | |
1912 | |
1913 (defmacro gnus-data-header (data) | |
1914 `(nth 3 ,data)) | |
1915 | |
1916 (defmacro gnus-data-set-header (data header) | |
1917 `(setf (nth 3 ,data) ,header)) | |
1918 | |
1919 (defmacro gnus-data-level (data) | |
1920 `(nth 4 ,data)) | |
1921 | |
1922 (defmacro gnus-data-unread-p (data) | |
1923 `(= (nth 1 ,data) gnus-unread-mark)) | |
1924 | |
1925 (defmacro gnus-data-read-p (data) | |
1926 `(/= (nth 1 ,data) gnus-unread-mark)) | |
1927 | |
1928 (defmacro gnus-data-pseudo-p (data) | |
1929 `(consp (nth 3 ,data))) | |
1930 | |
1931 (defmacro gnus-data-find (number) | |
1932 `(assq ,number gnus-newsgroup-data)) | |
1933 | |
1934 (defmacro gnus-data-find-list (number &optional data) | |
1935 `(let ((bdata ,(or data 'gnus-newsgroup-data))) | |
1936 (memq (assq ,number bdata) | |
1937 bdata))) | |
1938 | |
1939 (defmacro gnus-data-make (number mark pos header level) | |
1940 `(list ,number ,mark ,pos ,header ,level)) | |
1941 | |
1942 (defun gnus-data-enter (after-article number mark pos header level offset) | |
1943 (let ((data (gnus-data-find-list after-article))) | |
1944 (unless data | |
1945 (error "No such article: %d" after-article)) | |
1946 (setcdr data (cons (gnus-data-make number mark pos header level) | |
1947 (cdr data))) | |
1948 (setq gnus-newsgroup-data-reverse nil) | |
1949 (gnus-data-update-list (cddr data) offset))) | |
1950 | |
1951 (defun gnus-data-enter-list (after-article list &optional offset) | |
1952 (when list | |
1953 (let ((data (and after-article (gnus-data-find-list after-article))) | |
1954 (ilist list)) | |
1955 (or data (not after-article) (error "No such article: %d" after-article)) | |
1956 ;; Find the last element in the list to be spliced into the main | |
1957 ;; list. | |
1958 (while (cdr list) | |
1959 (setq list (cdr list))) | |
1960 (if (not data) | |
1961 (progn | |
1962 (setcdr list gnus-newsgroup-data) | |
1963 (setq gnus-newsgroup-data ilist) | |
1964 (when offset | |
1965 (gnus-data-update-list (cdr list) offset))) | |
1966 (setcdr list (cdr data)) | |
1967 (setcdr data ilist) | |
1968 (when offset | |
1969 (gnus-data-update-list (cdr list) offset))) | |
1970 (setq gnus-newsgroup-data-reverse nil)))) | |
1971 | |
1972 (defun gnus-data-remove (article &optional offset) | |
1973 (let ((data gnus-newsgroup-data)) | |
1974 (if (= (gnus-data-number (car data)) article) | |
1975 (progn | |
1976 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data) | |
1977 gnus-newsgroup-data-reverse nil) | |
1978 (when offset | |
1979 (gnus-data-update-list gnus-newsgroup-data offset))) | |
1980 (while (cdr data) | |
1981 (when (= (gnus-data-number (cadr data)) article) | |
1982 (setcdr data (cddr data)) | |
1983 (when offset | |
1984 (gnus-data-update-list (cdr data) offset)) | |
1985 (setq data nil | |
1986 gnus-newsgroup-data-reverse nil)) | |
1987 (setq data (cdr data)))))) | |
1988 | |
1989 (defmacro gnus-data-list (backward) | |
1990 `(if ,backward | |
1991 (or gnus-newsgroup-data-reverse | |
1992 (setq gnus-newsgroup-data-reverse | |
1993 (reverse gnus-newsgroup-data))) | |
1994 gnus-newsgroup-data)) | |
1995 | |
1996 (defun gnus-data-update-list (data offset) | |
1997 "Add OFFSET to the POS of all data entries in DATA." | |
1998 (while data | |
1999 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data)))) | |
2000 (setq data (cdr data)))) | |
2001 | |
2002 (defun gnus-data-compute-positions () | |
2003 "Compute the positions of all articles." | |
2004 (let ((data gnus-newsgroup-data) | |
2005 pos) | |
2006 (while data | |
2007 (when (setq pos (text-property-any | |
2008 (point-min) (point-max) | |
2009 'gnus-number (gnus-data-number (car data)))) | |
2010 (gnus-data-set-pos (car data) (+ pos 3))) | |
2011 (setq data (cdr data))))) | |
2012 | |
2013 (defun gnus-summary-article-pseudo-p (article) | |
2014 "Say whether this article is a pseudo article or not." | |
2015 (not (vectorp (gnus-data-header (gnus-data-find article))))) | |
2016 | |
2017 (defmacro gnus-summary-article-sparse-p (article) | |
2018 "Say whether this article is a sparse article or not." | |
2019 ` (memq ,article gnus-newsgroup-sparse)) | |
2020 | |
2021 (defmacro gnus-summary-article-ancient-p (article) | |
2022 "Say whether this article is a sparse article or not." | |
2023 `(memq ,article gnus-newsgroup-ancient)) | |
2024 | |
2025 (defun gnus-article-parent-p (number) | |
2026 "Say whether this article is a parent or not." | |
2027 (let ((data (gnus-data-find-list number))) | |
2028 (and (cdr data) ; There has to be an article after... | |
2029 (< (gnus-data-level (car data)) ; And it has to have a higher level. | |
2030 (gnus-data-level (nth 1 data)))))) | |
2031 | |
2032 (defun gnus-article-children (number) | |
2033 "Return a list of all children to NUMBER." | |
2034 (let* ((data (gnus-data-find-list number)) | |
2035 (level (gnus-data-level (car data))) | |
2036 children) | |
2037 (setq data (cdr data)) | |
2038 (while (and data | |
2039 (= (gnus-data-level (car data)) (1+ level))) | |
2040 (push (gnus-data-number (car data)) children) | |
2041 (setq data (cdr data))) | |
2042 children)) | |
2043 | |
2044 (defmacro gnus-summary-skip-intangible () | |
2045 "If the current article is intangible, then jump to a different article." | |
2046 '(let ((to (get-text-property (point) 'gnus-intangible))) | |
2047 (and to (gnus-summary-goto-subject to)))) | |
2048 | |
2049 (defmacro gnus-summary-article-intangible-p () | |
2050 "Say whether this article is intangible or not." | |
2051 '(get-text-property (point) 'gnus-intangible)) | |
2052 | |
2053 (defun gnus-article-read-p (article) | |
2054 "Say whether ARTICLE is read or not." | |
2055 (not (or (memq article gnus-newsgroup-marked) | |
2056 (memq article gnus-newsgroup-unreads) | |
2057 (memq article gnus-newsgroup-unselected) | |
2058 (memq article gnus-newsgroup-dormant)))) | |
2059 | |
2060 ;; Some summary mode macros. | |
2061 | |
2062 (defmacro gnus-summary-article-number () | |
2063 "The article number of the article on the current line. | |
2064 If there isn's an article number here, then we return the current | |
2065 article number." | |
2066 '(progn | |
2067 (gnus-summary-skip-intangible) | |
2068 (or (get-text-property (point) 'gnus-number) | |
2069 (gnus-summary-last-subject)))) | |
2070 | |
2071 (defmacro gnus-summary-article-header (&optional number) | |
2072 `(gnus-data-header (gnus-data-find | |
2073 ,(or number '(gnus-summary-article-number))))) | |
2074 | |
2075 (defmacro gnus-summary-thread-level (&optional number) | |
2076 `(if (and (eq gnus-summary-make-false-root 'dummy) | |
2077 (get-text-property (point) 'gnus-intangible)) | |
2078 0 | |
2079 (gnus-data-level (gnus-data-find | |
2080 ,(or number '(gnus-summary-article-number)))))) | |
2081 | |
2082 (defmacro gnus-summary-article-mark (&optional number) | |
2083 `(gnus-data-mark (gnus-data-find | |
2084 ,(or number '(gnus-summary-article-number))))) | |
2085 | |
2086 (defmacro gnus-summary-article-pos (&optional number) | |
2087 `(gnus-data-pos (gnus-data-find | |
2088 ,(or number '(gnus-summary-article-number))))) | |
2089 | |
2090 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject) | |
2091 (defmacro gnus-summary-article-subject (&optional number) | |
2092 "Return current subject string or nil if nothing." | |
2093 `(let ((headers | |
2094 ,(if number | |
2095 `(gnus-data-header (assq ,number gnus-newsgroup-data)) | |
2096 '(gnus-data-header (assq (gnus-summary-article-number) | |
2097 gnus-newsgroup-data))))) | |
2098 (and headers | |
2099 (vectorp headers) | |
2100 (mail-header-subject headers)))) | |
2101 | |
2102 (defmacro gnus-summary-article-score (&optional number) | |
2103 "Return current article score." | |
2104 `(or (cdr (assq ,(or number '(gnus-summary-article-number)) | |
2105 gnus-newsgroup-scored)) | |
2106 gnus-summary-default-score 0)) | |
2107 | |
2108 (defun gnus-summary-article-children (&optional number) | |
2109 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number)))) | |
2110 (level (gnus-data-level (car data))) | |
2111 l children) | |
2112 (while (and (setq data (cdr data)) | |
2113 (> (setq l (gnus-data-level (car data))) level)) | |
2114 (and (= (1+ level) l) | |
2115 (push (gnus-data-number (car data)) | |
2116 children))) | |
2117 (nreverse children))) | |
2118 | |
2119 (defun gnus-summary-article-parent (&optional number) | |
2120 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number)) | |
2121 (gnus-data-list t))) | |
2122 (level (gnus-data-level (car data)))) | |
2123 (if (zerop level) | |
2124 () ; This is a root. | |
2125 ;; We search until we find an article with a level less than | |
2126 ;; this one. That function has to be the parent. | |
2127 (while (and (setq data (cdr data)) | |
2128 (not (< (gnus-data-level (car data)) level)))) | |
2129 (and data (gnus-data-number (car data)))))) | |
2130 | |
2131 (defun gnus-unread-mark-p (mark) | |
2132 "Say whether MARK is the unread mark." | |
2133 (= mark gnus-unread-mark)) | |
2134 | |
2135 (defun gnus-read-mark-p (mark) | |
2136 "Say whether MARK is one of the marks that mark as read. | |
2137 This is all marks except unread, ticked, dormant, and expirable." | |
2138 (not (or (= mark gnus-unread-mark) | |
2139 (= mark gnus-ticked-mark) | |
2140 (= mark gnus-dormant-mark) | |
2141 (= mark gnus-expirable-mark)))) | |
2142 | |
2143 (defmacro gnus-article-mark (number) | |
2144 `(cond | |
2145 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark) | |
2146 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark) | |
2147 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark) | |
2148 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark) | |
2149 (t (or (cdr (assq ,number gnus-newsgroup-reads)) | |
2150 gnus-ancient-mark)))) | |
2151 | |
2152 ;; Saving hidden threads. | |
2153 | |
2154 (put 'gnus-save-hidden-threads 'lisp-indent-function 0) | |
2155 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body)) | |
2156 | |
2157 (defmacro gnus-save-hidden-threads (&rest forms) | |
2158 "Save hidden threads, eval FORMS, and restore the hidden threads." | |
2159 (let ((config (make-symbol "config"))) | |
2160 `(let ((,config (gnus-hidden-threads-configuration))) | |
2161 (unwind-protect | |
2162 (save-excursion | |
2163 ,@forms) | |
2164 (gnus-restore-hidden-threads-configuration ,config))))) | |
2165 | |
2166 (defun gnus-hidden-threads-configuration () | |
2167 "Return the current hidden threads configuration." | |
2168 (save-excursion | |
2169 (let (config) | |
2170 (goto-char (point-min)) | |
2171 (while (search-forward "\r" nil t) | |
2172 (push (1- (point)) config)) | |
2173 config))) | |
2174 | |
2175 (defun gnus-restore-hidden-threads-configuration (config) | |
2176 "Restore hidden threads configuration from CONFIG." | |
2177 (let (point buffer-read-only) | |
2178 (while (setq point (pop config)) | |
2179 (when (and (< point (point-max)) | |
2180 (goto-char point) | |
2181 (= (following-char) ?\n)) | |
2182 (subst-char-in-region point (1+ point) ?\n ?\r))))) | |
2183 | |
2184 ;; Various summary mode internalish functions. | |
2185 | |
2186 (defun gnus-mouse-pick-article (e) | |
2187 (interactive "e") | |
2188 (mouse-set-point e) | |
2189 (gnus-summary-next-page nil t)) | |
2190 | |
2191 (defun gnus-summary-set-display-table () | |
2192 ;; Change the display table. Odd characters have a tendency to mess | |
2193 ;; up nicely formatted displays - we make all possible glyphs | |
2194 ;; display only a single character. | |
2195 | |
2196 ;; We start from the standard display table, if any. | |
2197 (let ((table (or (copy-sequence standard-display-table) | |
2198 (make-display-table))) | |
2199 (i 32)) | |
2200 ;; Nix out all the control chars... | |
2201 (while (>= (setq i (1- i)) 0) | |
2202 (aset table i [??])) | |
2203 ;; ... but not newline and cr, of course. (cr is necessary for the | |
2204 ;; selective display). | |
2205 (aset table ?\n nil) | |
2206 (aset table ?\r nil) | |
2207 ;; We nix out any glyphs over 126 that are not set already. | |
2208 (let ((i 256)) | |
2209 (while (>= (setq i (1- i)) 127) | |
2210 ;; Only modify if the entry is nil. | |
2211 (unless (aref table i) | |
2212 (aset table i [??])))) | |
2213 (setq buffer-display-table table))) | |
2214 | |
2215 (defun gnus-summary-setup-buffer (group) | |
2216 "Initialize summary buffer." | |
2217 (let ((buffer (concat "*Summary " group "*"))) | |
2218 (if (get-buffer buffer) | |
2219 (progn | |
2220 (set-buffer buffer) | |
2221 (setq gnus-summary-buffer (current-buffer)) | |
2222 (not gnus-newsgroup-prepared)) | |
2223 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu> | |
2224 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer))) | |
2225 (gnus-add-current-to-buffer-list) | |
2226 (gnus-summary-mode group) | |
2227 (when gnus-carpal | |
2228 (gnus-carpal-setup-buffer 'summary)) | |
2229 (unless gnus-single-article-buffer | |
2230 (make-local-variable 'gnus-article-buffer) | |
2231 (make-local-variable 'gnus-article-current) | |
2232 (make-local-variable 'gnus-original-article-buffer)) | |
2233 (setq gnus-newsgroup-name group) | |
2234 t))) | |
2235 | |
2236 (defun gnus-set-global-variables () | |
2237 ;; Set the global equivalents of the summary buffer-local variables | |
2238 ;; to the latest values they had. These reflect the summary buffer | |
2239 ;; that was in action when the last article was fetched. | |
2240 (when (eq major-mode 'gnus-summary-mode) | |
2241 (setq gnus-summary-buffer (current-buffer)) | |
2242 (let ((name gnus-newsgroup-name) | |
2243 (marked gnus-newsgroup-marked) | |
2244 (unread gnus-newsgroup-unreads) | |
2245 (headers gnus-current-headers) | |
2246 (data gnus-newsgroup-data) | |
2247 (summary gnus-summary-buffer) | |
2248 (article-buffer gnus-article-buffer) | |
2249 (original gnus-original-article-buffer) | |
2250 (gac gnus-article-current) | |
2251 (reffed gnus-reffed-article-number) | |
2252 (score-file gnus-current-score-file)) | |
2253 (save-excursion | |
2254 (set-buffer gnus-group-buffer) | |
2255 (setq gnus-newsgroup-name name) | |
2256 (setq gnus-newsgroup-marked marked) | |
2257 (setq gnus-newsgroup-unreads unread) | |
2258 (setq gnus-current-headers headers) | |
2259 (setq gnus-newsgroup-data data) | |
2260 (setq gnus-article-current gac) | |
2261 (setq gnus-summary-buffer summary) | |
2262 (setq gnus-article-buffer article-buffer) | |
2263 (setq gnus-original-article-buffer original) | |
2264 (setq gnus-reffed-article-number reffed) | |
2265 (setq gnus-current-score-file score-file) | |
2266 ;; The article buffer also has local variables. | |
2267 (when (gnus-buffer-live-p gnus-article-buffer) | |
2268 (set-buffer gnus-article-buffer) | |
2269 (setq gnus-summary-buffer summary)))))) | |
2270 | |
2271 (defun gnus-summary-article-unread-p (article) | |
2272 "Say whether ARTICLE is unread or not." | |
2273 (memq article gnus-newsgroup-unreads)) | |
2274 | |
2275 (defun gnus-summary-first-article-p (&optional article) | |
2276 "Return whether ARTICLE is the first article in the buffer." | |
2277 (if (not (setq article (or article (gnus-summary-article-number)))) | |
2278 nil | |
2279 (eq article (caar gnus-newsgroup-data)))) | |
2280 | |
2281 (defun gnus-summary-last-article-p (&optional article) | |
2282 "Return whether ARTICLE is the last article in the buffer." | |
2283 (if (not (setq article (or article (gnus-summary-article-number)))) | |
2284 t ; All non-existent numbers are the last article. :-) | |
2285 (not (cdr (gnus-data-find-list article))))) | |
2286 | |
2287 (defun gnus-make-thread-indent-array () | |
2288 (let ((n 200)) | |
2289 (unless (and gnus-thread-indent-array | |
2290 (= gnus-thread-indent-level gnus-thread-indent-array-level)) | |
2291 (setq gnus-thread-indent-array (make-vector 201 "") | |
2292 gnus-thread-indent-array-level gnus-thread-indent-level) | |
2293 (while (>= n 0) | |
2294 (aset gnus-thread-indent-array n | |
2295 (make-string (* n gnus-thread-indent-level) ? )) | |
2296 (setq n (1- n)))))) | |
2297 | |
2298 (defun gnus-update-summary-mark-positions () | |
2299 "Compute where the summary marks are to go." | |
2300 (save-excursion | |
2301 (when (and gnus-summary-buffer | |
2302 (get-buffer gnus-summary-buffer) | |
2303 (buffer-name (get-buffer gnus-summary-buffer))) | |
2304 (set-buffer gnus-summary-buffer)) | |
2305 (let ((gnus-replied-mark 129) | |
2306 (gnus-score-below-mark 130) | |
2307 (gnus-score-over-mark 130) | |
2308 (spec gnus-summary-line-format-spec) | |
2309 thread gnus-visual pos) | |
2310 (save-excursion | |
2311 (gnus-set-work-buffer) | |
2312 (let ((gnus-summary-line-format-spec spec)) | |
2313 (gnus-summary-insert-line | |
2314 [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1) | |
2315 (goto-char (point-min)) | |
2316 (setq pos (list (cons 'unread (and (search-forward "\200" nil t) | |
2317 (- (point) 2))))) | |
2318 (goto-char (point-min)) | |
2319 (push (cons 'replied (and (search-forward "\201" nil t) | |
2320 (- (point) 2))) | |
2321 pos) | |
2322 (goto-char (point-min)) | |
2323 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2))) | |
2324 pos))) | |
2325 (setq gnus-summary-mark-positions pos)))) | |
2326 | |
2327 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number) | |
2328 "Insert a dummy root in the summary buffer." | |
2329 (beginning-of-line) | |
2330 (gnus-add-text-properties | |
2331 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point)) | |
2332 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number))) | |
2333 | |
2334 (defun gnus-summary-insert-line (gnus-tmp-header | |
2335 gnus-tmp-level gnus-tmp-current | |
2336 gnus-tmp-unread gnus-tmp-replied | |
2337 gnus-tmp-expirable gnus-tmp-subject-or-nil | |
2338 &optional gnus-tmp-dummy gnus-tmp-score | |
2339 gnus-tmp-process) | |
2340 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level)) | |
2341 (gnus-tmp-lines (mail-header-lines gnus-tmp-header)) | |
2342 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0)) | |
2343 (gnus-tmp-score-char | |
2344 (if (or (null gnus-summary-default-score) | |
2345 (<= (abs (- gnus-tmp-score gnus-summary-default-score)) | |
2346 gnus-summary-zcore-fuzz)) | |
2347 ? | |
2348 (if (< gnus-tmp-score gnus-summary-default-score) | |
2349 gnus-score-below-mark gnus-score-over-mark))) | |
2350 (gnus-tmp-replied | |
2351 (cond (gnus-tmp-process gnus-process-mark) | |
2352 ((memq gnus-tmp-current gnus-newsgroup-cached) | |
2353 gnus-cached-mark) | |
2354 (gnus-tmp-replied gnus-replied-mark) | |
2355 ((memq gnus-tmp-current gnus-newsgroup-saved) | |
2356 gnus-saved-mark) | |
2357 (t gnus-unread-mark))) | |
2358 (gnus-tmp-from (mail-header-from gnus-tmp-header)) | |
2359 (gnus-tmp-name | |
2360 (cond | |
2361 ((string-match "<[^>]+> *$" gnus-tmp-from) | |
2362 (let ((beg (match-beginning 0))) | |
2363 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from) | |
2364 (substring gnus-tmp-from (1+ (match-beginning 0)) | |
2365 (1- (match-end 0)))) | |
2366 (substring gnus-tmp-from 0 beg)))) | |
2367 ((string-match "(.+)" gnus-tmp-from) | |
2368 (substring gnus-tmp-from | |
2369 (1+ (match-beginning 0)) (1- (match-end 0)))) | |
2370 (t gnus-tmp-from))) | |
2371 (gnus-tmp-subject (mail-header-subject gnus-tmp-header)) | |
2372 (gnus-tmp-number (mail-header-number gnus-tmp-header)) | |
2373 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[)) | |
2374 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\])) | |
2375 (buffer-read-only nil)) | |
2376 (when (string= gnus-tmp-name "") | |
2377 (setq gnus-tmp-name gnus-tmp-from)) | |
2378 (unless (numberp gnus-tmp-lines) | |
2379 (setq gnus-tmp-lines 0)) | |
2380 (gnus-put-text-property | |
2381 (point) | |
2382 (progn (eval gnus-summary-line-format-spec) (point)) | |
2383 'gnus-number gnus-tmp-number) | |
2384 (when (gnus-visual-p 'summary-highlight 'highlight) | |
2385 (forward-line -1) | |
2386 (run-hooks 'gnus-summary-update-hook) | |
2387 (forward-line 1)))) | |
2388 | |
2389 (defun gnus-summary-update-line (&optional dont-update) | |
2390 ;; Update summary line after change. | |
2391 (when (and gnus-summary-default-score | |
2392 (not gnus-summary-inhibit-highlight)) | |
2393 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion. | |
2394 (article (gnus-summary-article-number)) | |
2395 (score (gnus-summary-article-score article))) | |
2396 (unless dont-update | |
2397 (if (and gnus-summary-mark-below | |
2398 (< (gnus-summary-article-score) | |
2399 gnus-summary-mark-below)) | |
2400 ;; This article has a low score, so we mark it as read. | |
2401 (when (memq article gnus-newsgroup-unreads) | |
2402 (gnus-summary-mark-article-as-read gnus-low-score-mark)) | |
2403 (when (eq (gnus-summary-article-mark) gnus-low-score-mark) | |
2404 ;; This article was previously marked as read on account | |
2405 ;; of a low score, but now it has risen, so we mark it as | |
2406 ;; unread. | |
2407 (gnus-summary-mark-article-as-unread gnus-unread-mark))) | |
2408 (gnus-summary-update-mark | |
2409 (if (or (null gnus-summary-default-score) | |
2410 (<= (abs (- score gnus-summary-default-score)) | |
2411 gnus-summary-zcore-fuzz)) | |
2412 ? | |
2413 (if (< score gnus-summary-default-score) | |
2414 gnus-score-below-mark gnus-score-over-mark)) | |
2415 'score)) | |
2416 ;; Do visual highlighting. | |
2417 (when (gnus-visual-p 'summary-highlight 'highlight) | |
2418 (run-hooks 'gnus-summary-update-hook))))) | |
2419 | |
2420 (defvar gnus-tmp-new-adopts nil) | |
2421 | |
2422 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char) | |
2423 "Return the number of articles in THREAD. | |
2424 This may be 0 in some cases -- if none of the articles in | |
2425 the thread are to be displayed." | |
2426 (let* ((number | |
2427 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>. | |
2428 (cond | |
2429 ((not (listp thread)) | |
2430 1) | |
2431 ((and (consp thread) (cdr thread)) | |
2432 (apply | |
2433 '+ 1 (mapcar | |
2434 'gnus-summary-number-of-articles-in-thread (cdr thread)))) | |
2435 ((null thread) | |
2436 1) | |
2437 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit) | |
2438 1) | |
2439 (t 0)))) | |
2440 (when (and level (zerop level) gnus-tmp-new-adopts) | |
2441 (incf number | |
2442 (apply '+ (mapcar | |
2443 'gnus-summary-number-of-articles-in-thread | |
2444 gnus-tmp-new-adopts)))) | |
2445 (if char | |
2446 (if (> number 1) gnus-not-empty-thread-mark | |
2447 gnus-empty-thread-mark) | |
2448 number))) | |
2449 | |
2450 (defun gnus-summary-set-local-parameters (group) | |
2451 "Go through the local params of GROUP and set all variable specs in that list." | |
2452 (let ((params (gnus-group-find-parameter group)) | |
2453 elem) | |
2454 (while params | |
2455 (setq elem (car params) | |
2456 params (cdr params)) | |
2457 (and (consp elem) ; Has to be a cons. | |
2458 (consp (cdr elem)) ; The cdr has to be a list. | |
2459 (symbolp (car elem)) ; Has to be a symbol in there. | |
2460 (not (memq (car elem) | |
2461 '(quit-config to-address to-list to-group))) | |
2462 (ignore-errors ; So we set it. | |
2463 (make-local-variable (car elem)) | |
2464 (set (car elem) (eval (nth 1 elem)))))))) | |
2465 | |
2466 (defun gnus-summary-read-group (group &optional show-all no-article | |
2467 kill-buffer no-display) | |
2468 "Start reading news in newsgroup GROUP. | |
2469 If SHOW-ALL is non-nil, already read articles are also listed. | |
2470 If NO-ARTICLE is non-nil, no article is selected initially. | |
2471 If NO-DISPLAY, don't generate a summary buffer." | |
2472 (let (result) | |
2473 (while (and group | |
2474 (null (setq result | |
2475 (let ((gnus-auto-select-next nil)) | |
2476 (gnus-summary-read-group-1 | |
2477 group show-all no-article | |
2478 kill-buffer no-display)))) | |
2479 (eq gnus-auto-select-next 'quietly)) | |
2480 (set-buffer gnus-group-buffer) | |
2481 (if (not (equal group (gnus-group-group-name))) | |
2482 (setq group (gnus-group-group-name)) | |
2483 (setq group nil))) | |
2484 result)) | |
2485 | |
2486 (defun gnus-summary-read-group-1 (group show-all no-article | |
2487 kill-buffer no-display) | |
2488 ;; Killed foreign groups can't be entered. | |
2489 (when (and (not (gnus-group-native-p group)) | |
2490 (not (gnus-gethash group gnus-newsrc-hashtb))) | |
2491 (error "Dead non-native groups can't be entered")) | |
2492 (gnus-message 5 "Retrieving newsgroup: %s..." group) | |
2493 (let* ((new-group (gnus-summary-setup-buffer group)) | |
2494 (quit-config (gnus-group-quit-config group)) | |
2495 (did-select (and new-group (gnus-select-newsgroup group show-all)))) | |
2496 (cond | |
2497 ;; This summary buffer exists already, so we just select it. | |
2498 ((not new-group) | |
2499 (gnus-set-global-variables) | |
2500 (when kill-buffer | |
2501 (gnus-kill-or-deaden-summary kill-buffer)) | |
2502 (gnus-configure-windows 'summary 'force) | |
2503 (gnus-set-mode-line 'summary) | |
2504 (gnus-summary-position-point) | |
2505 (message "") | |
2506 t) | |
2507 ;; We couldn't select this group. | |
2508 ((null did-select) | |
2509 (when (and (eq major-mode 'gnus-summary-mode) | |
2510 (not (equal (current-buffer) kill-buffer))) | |
2511 (kill-buffer (current-buffer)) | |
2512 (if (not quit-config) | |
2513 (progn | |
2514 (set-buffer gnus-group-buffer) | |
2515 (gnus-group-jump-to-group group) | |
2516 (gnus-group-next-unread-group 1)) | |
2517 (gnus-handle-ephemeral-exit quit-config))) | |
2518 (gnus-message 3 "Can't select group") | |
2519 nil) | |
2520 ;; The user did a `C-g' while prompting for number of articles, | |
2521 ;; so we exit this group. | |
2522 ((eq did-select 'quit) | |
2523 (and (eq major-mode 'gnus-summary-mode) | |
2524 (not (equal (current-buffer) kill-buffer)) | |
2525 (kill-buffer (current-buffer))) | |
2526 (when kill-buffer | |
2527 (gnus-kill-or-deaden-summary kill-buffer)) | |
2528 (if (not quit-config) | |
2529 (progn | |
2530 (set-buffer gnus-group-buffer) | |
2531 (gnus-group-jump-to-group group) | |
2532 (gnus-group-next-unread-group 1) | |
2533 (gnus-configure-windows 'group 'force)) | |
2534 (gnus-handle-ephemeral-exit quit-config)) | |
2535 ;; Finally signal the quit. | |
2536 (signal 'quit nil)) | |
2537 ;; The group was successfully selected. | |
2538 (t | |
2539 (gnus-set-global-variables) | |
2540 ;; Save the active value in effect when the group was entered. | |
2541 (setq gnus-newsgroup-active | |
2542 (gnus-copy-sequence | |
2543 (gnus-active gnus-newsgroup-name))) | |
2544 ;; You can change the summary buffer in some way with this hook. | |
2545 (run-hooks 'gnus-select-group-hook) | |
2546 ;; Set any local variables in the group parameters. | |
2547 (gnus-summary-set-local-parameters gnus-newsgroup-name) | |
2548 (gnus-update-format-specifications | |
2549 nil 'summary 'summary-mode 'summary-dummy) | |
2550 ;; Do score processing. | |
2551 (when gnus-use-scoring | |
2552 (gnus-possibly-score-headers)) | |
2553 ;; Check whether to fill in the gaps in the threads. | |
2554 (when gnus-build-sparse-threads | |
2555 (gnus-build-sparse-threads)) | |
2556 ;; Find the initial limit. | |
2557 (if gnus-show-threads | |
2558 (if show-all | |
2559 (let ((gnus-newsgroup-dormant nil)) | |
2560 (gnus-summary-initial-limit show-all)) | |
2561 (gnus-summary-initial-limit show-all)) | |
2562 (setq gnus-newsgroup-limit | |
2563 (mapcar | |
2564 (lambda (header) (mail-header-number header)) | |
2565 gnus-newsgroup-headers))) | |
2566 ;; Generate the summary buffer. | |
2567 (unless no-display | |
2568 (gnus-summary-prepare)) | |
2569 (when gnus-use-trees | |
2570 (gnus-tree-open group) | |
2571 (setq gnus-summary-highlight-line-function | |
2572 'gnus-tree-highlight-article)) | |
2573 ;; If the summary buffer is empty, but there are some low-scored | |
2574 ;; articles or some excluded dormants, we include these in the | |
2575 ;; buffer. | |
2576 (when (and (zerop (buffer-size)) | |
2577 (not no-display)) | |
2578 (cond (gnus-newsgroup-dormant | |
2579 (gnus-summary-limit-include-dormant)) | |
2580 ((and gnus-newsgroup-scored show-all) | |
2581 (gnus-summary-limit-include-expunged t)))) | |
2582 ;; Function `gnus-apply-kill-file' must be called in this hook. | |
2583 (run-hooks 'gnus-apply-kill-hook) | |
2584 (if (and (zerop (buffer-size)) | |
2585 (not no-display)) | |
2586 (progn | |
2587 ;; This newsgroup is empty. | |
2588 (gnus-summary-catchup-and-exit nil t) | |
2589 (gnus-message 6 "No unread news") | |
2590 (when kill-buffer | |
2591 (gnus-kill-or-deaden-summary kill-buffer)) | |
2592 ;; Return nil from this function. | |
2593 nil) | |
2594 ;; Hide conversation thread subtrees. We cannot do this in | |
2595 ;; gnus-summary-prepare-hook since kill processing may not | |
2596 ;; work with hidden articles. | |
2597 (and gnus-show-threads | |
2598 gnus-thread-hide-subtree | |
2599 (gnus-summary-hide-all-threads)) | |
2600 ;; Show first unread article if requested. | |
2601 (if (and (not no-article) | |
2602 (not no-display) | |
2603 gnus-newsgroup-unreads | |
2604 gnus-auto-select-first) | |
2605 (unless (if (eq gnus-auto-select-first 'best) | |
2606 (gnus-summary-best-unread-article) | |
2607 (gnus-summary-first-unread-article)) | |
2608 (gnus-configure-windows 'summary)) | |
2609 ;; Don't select any articles, just move point to the first | |
2610 ;; article in the group. | |
2611 (goto-char (point-min)) | |
2612 (gnus-summary-position-point) | |
2613 (gnus-set-mode-line 'summary) | |
2614 (gnus-configure-windows 'summary 'force)) | |
2615 (when kill-buffer | |
2616 (gnus-kill-or-deaden-summary kill-buffer)) | |
2617 (when (get-buffer-window gnus-group-buffer t) | |
2618 ;; Gotta use windows, because recenter does weird stuff if | |
2619 ;; the current buffer ain't the displayed window. | |
2620 (let ((owin (selected-window))) | |
2621 (select-window (get-buffer-window gnus-group-buffer t)) | |
2622 (when (gnus-group-goto-group group) | |
2623 (recenter)) | |
2624 (select-window owin))) | |
2625 ;; Mark this buffer as "prepared". | |
2626 (setq gnus-newsgroup-prepared t) | |
2627 t))))) | |
2628 | |
2629 (defun gnus-summary-prepare () | |
2630 "Generate the summary buffer." | |
2631 (interactive) | |
2632 (let ((buffer-read-only nil)) | |
2633 (erase-buffer) | |
2634 (setq gnus-newsgroup-data nil | |
2635 gnus-newsgroup-data-reverse nil) | |
2636 (run-hooks 'gnus-summary-generate-hook) | |
2637 ;; Generate the buffer, either with threads or without. | |
2638 (when gnus-newsgroup-headers | |
2639 (gnus-summary-prepare-threads | |
2640 (if gnus-show-threads | |
2641 (gnus-sort-gathered-threads | |
2642 (funcall gnus-summary-thread-gathering-function | |
2643 (gnus-sort-threads | |
2644 (gnus-cut-threads (gnus-make-threads))))) | |
2645 ;; Unthreaded display. | |
2646 (gnus-sort-articles gnus-newsgroup-headers)))) | |
2647 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data)) | |
2648 ;; Call hooks for modifying summary buffer. | |
2649 (goto-char (point-min)) | |
2650 (run-hooks 'gnus-summary-prepare-hook))) | |
2651 | |
2652 (defsubst gnus-general-simplify-subject (subject) | |
2653 "Simply subject by the same rules as gnus-gather-threads-by-subject." | |
2654 (setq subject | |
2655 (cond | |
2656 ;; Truncate the subject. | |
2657 ((numberp gnus-summary-gather-subject-limit) | |
2658 (setq subject (gnus-simplify-subject-re subject)) | |
2659 (if (> (length subject) gnus-summary-gather-subject-limit) | |
2660 (substring subject 0 gnus-summary-gather-subject-limit) | |
2661 subject)) | |
2662 ;; Fuzzily simplify it. | |
2663 ((eq 'fuzzy gnus-summary-gather-subject-limit) | |
2664 (gnus-simplify-subject-fuzzy subject)) | |
2665 ;; Just remove the leading "Re:". | |
2666 (t | |
2667 (gnus-simplify-subject-re subject)))) | |
2668 | |
2669 (if (and gnus-summary-gather-exclude-subject | |
2670 (string-match gnus-summary-gather-exclude-subject subject)) | |
2671 nil ; This article shouldn't be gathered | |
2672 subject)) | |
2673 | |
2674 (defun gnus-summary-simplify-subject-query () | |
2675 "Query where the respool algorithm would put this article." | |
2676 (interactive) | |
2677 (gnus-set-global-variables) | |
2678 (gnus-summary-select-article) | |
2679 (message (gnus-general-simplify-subject (gnus-summary-article-subject)))) | |
2680 | |
2681 (defun gnus-gather-threads-by-subject (threads) | |
2682 "Gather threads by looking at Subject headers." | |
2683 (if (not gnus-summary-make-false-root) | |
2684 threads | |
2685 (let ((hashtb (gnus-make-hashtable 1024)) | |
2686 (prev threads) | |
2687 (result threads) | |
2688 subject hthread whole-subject) | |
2689 (while threads | |
2690 (setq subject (gnus-general-simplify-subject | |
2691 (setq whole-subject (mail-header-subject | |
2692 (caar threads))))) | |
2693 (when subject | |
2694 (if (setq hthread (gnus-gethash subject hashtb)) | |
2695 (progn | |
2696 ;; We enter a dummy root into the thread, if we | |
2697 ;; haven't done that already. | |
2698 (unless (stringp (caar hthread)) | |
2699 (setcar hthread (list whole-subject (car hthread)))) | |
2700 ;; We add this new gathered thread to this gathered | |
2701 ;; thread. | |
2702 (setcdr (car hthread) | |
2703 (nconc (cdar hthread) (list (car threads)))) | |
2704 ;; Remove it from the list of threads. | |
2705 (setcdr prev (cdr threads)) | |
2706 (setq threads prev)) | |
2707 ;; Enter this thread into the hash table. | |
2708 (gnus-sethash subject threads hashtb))) | |
2709 (setq prev threads) | |
2710 (setq threads (cdr threads))) | |
2711 result))) | |
2712 | |
2713 (defun gnus-gather-threads-by-references (threads) | |
2714 "Gather threads by looking at References headers." | |
2715 (let ((idhashtb (gnus-make-hashtable 1024)) | |
2716 (thhashtb (gnus-make-hashtable 1024)) | |
2717 (prev threads) | |
2718 (result threads) | |
2719 ids references id gthread gid entered ref) | |
2720 (while threads | |
2721 (when (setq references (mail-header-references (caar threads))) | |
2722 (setq id (mail-header-id (caar threads)) | |
2723 ids (gnus-split-references references) | |
2724 entered nil) | |
2725 (while (setq ref (pop ids)) | |
2726 (setq ids (delete ref ids)) | |
2727 (if (not (setq gid (gnus-gethash ref idhashtb))) | |
2728 (progn | |
2729 (gnus-sethash ref id idhashtb) | |
2730 (gnus-sethash id threads thhashtb)) | |
2731 (setq gthread (gnus-gethash gid thhashtb)) | |
2732 (unless entered | |
2733 ;; We enter a dummy root into the thread, if we | |
2734 ;; haven't done that already. | |
2735 (unless (stringp (caar gthread)) | |
2736 (setcar gthread (list (mail-header-subject (caar gthread)) | |
2737 (car gthread)))) | |
2738 ;; We add this new gathered thread to this gathered | |
2739 ;; thread. | |
2740 (setcdr (car gthread) | |
2741 (nconc (cdar gthread) (list (car threads))))) | |
2742 ;; Add it into the thread hash table. | |
2743 (gnus-sethash id gthread thhashtb) | |
2744 (setq entered t) | |
2745 ;; Remove it from the list of threads. | |
2746 (setcdr prev (cdr threads)) | |
2747 (setq threads prev)))) | |
2748 (setq prev threads) | |
2749 (setq threads (cdr threads))) | |
2750 result)) | |
2751 | |
2752 (defun gnus-sort-gathered-threads (threads) | |
2753 "Sort subtreads inside each gathered thread by article number." | |
2754 (let ((result threads)) | |
2755 (while threads | |
2756 (when (stringp (caar threads)) | |
2757 (setcdr (car threads) | |
2758 (sort (cdar threads) 'gnus-thread-sort-by-number))) | |
2759 (setq threads (cdr threads))) | |
2760 result)) | |
2761 | |
2762 (defun gnus-thread-loop-p (root thread) | |
2763 "Say whether ROOT is in THREAD." | |
2764 (let ((stack (list thread)) | |
2765 (infloop 0) | |
2766 th) | |
2767 (while (setq thread (pop stack)) | |
2768 (setq th (cdr thread)) | |
2769 (while (and th | |
2770 (not (eq (caar th) root))) | |
2771 (pop th)) | |
2772 (if th | |
2773 ;; We have found a loop. | |
2774 (let (ref-dep) | |
2775 (setcdr thread (delq (car th) (cdr thread))) | |
2776 (if (boundp (setq ref-dep (intern "none" | |
2777 gnus-newsgroup-dependencies))) | |
2778 (setcdr (symbol-value ref-dep) | |
2779 (nconc (cdr (symbol-value ref-dep)) | |
2780 (list (car th)))) | |
2781 (set ref-dep (list nil (car th)))) | |
2782 (setq infloop 1 | |
2783 stack nil)) | |
2784 ;; Push all the subthreads onto the stack. | |
2785 (push (cdr thread) stack))) | |
2786 infloop)) | |
2787 | |
2788 (defun gnus-make-threads () | |
2789 "Go through the dependency hashtb and find the roots. Return all threads." | |
2790 (let (threads) | |
2791 (while (catch 'infloop | |
2792 (mapatoms | |
2793 (lambda (refs) | |
2794 ;; Deal with self-referencing References loops. | |
2795 (when (and (car (symbol-value refs)) | |
2796 (not (zerop | |
2797 (apply | |
2798 '+ | |
2799 (mapcar | |
2800 (lambda (thread) | |
2801 (gnus-thread-loop-p | |
2802 (car (symbol-value refs)) thread)) | |
2803 (cdr (symbol-value refs))))))) | |
2804 (setq threads nil) | |
2805 (throw 'infloop t)) | |
2806 (unless (car (symbol-value refs)) | |
2807 ;; These threads do not refer back to any other articles, | |
2808 ;; so they're roots. | |
2809 (setq threads (append (cdr (symbol-value refs)) threads)))) | |
2810 gnus-newsgroup-dependencies))) | |
2811 threads)) | |
2812 | |
2813 (defun gnus-build-sparse-threads () | |
2814 (let ((headers gnus-newsgroup-headers) | |
2815 (deps gnus-newsgroup-dependencies) | |
2816 header references generation relations | |
2817 cthread subject child end pthread relation) | |
2818 ;; First we create an alist of generations/relations, where | |
2819 ;; generations is how much we trust the relation, and the relation | |
2820 ;; is parent/child. | |
2821 (gnus-message 7 "Making sparse threads...") | |
2822 (save-excursion | |
2823 (nnheader-set-temp-buffer " *gnus sparse threads*") | |
2824 (while (setq header (pop headers)) | |
2825 (when (and (setq references (mail-header-references header)) | |
2826 (not (string= references ""))) | |
2827 (insert references) | |
2828 (setq child (mail-header-id header) | |
2829 subject (mail-header-subject header)) | |
2830 (setq generation 0) | |
2831 (while (search-backward ">" nil t) | |
2832 (setq end (1+ (point))) | |
2833 (when (search-backward "<" nil t) | |
2834 (push (list (incf generation) | |
2835 child (setq child (buffer-substring (point) end)) | |
2836 subject) | |
2837 relations))) | |
2838 (push (list (1+ generation) child nil subject) relations) | |
2839 (erase-buffer))) | |
2840 (kill-buffer (current-buffer))) | |
2841 ;; Sort over trustworthiness. | |
2842 (setq relations (sort relations (lambda (r1 r2) (< (car r1) (car r2))))) | |
2843 (while (setq relation (pop relations)) | |
2844 (when (if (boundp (setq cthread (intern (cadr relation) deps))) | |
2845 (unless (car (symbol-value cthread)) | |
2846 ;; Make this article the parent of these threads. | |
2847 (setcar (symbol-value cthread) | |
2848 (vector gnus-reffed-article-number | |
2849 (cadddr relation) | |
2850 "" "" | |
2851 (cadr relation) | |
2852 (or (caddr relation) "") 0 0 ""))) | |
2853 (set cthread (list (vector gnus-reffed-article-number | |
2854 (cadddr relation) | |
2855 "" "" (cadr relation) | |
2856 (or (caddr relation) "") 0 0 "")))) | |
2857 (push gnus-reffed-article-number gnus-newsgroup-limit) | |
2858 (push gnus-reffed-article-number gnus-newsgroup-sparse) | |
2859 (push (cons gnus-reffed-article-number gnus-sparse-mark) | |
2860 gnus-newsgroup-reads) | |
2861 (decf gnus-reffed-article-number) | |
2862 ;; Make this new thread the child of its parent. | |
2863 (if (boundp (setq pthread (intern (or (caddr relation) "none") deps))) | |
2864 (setcdr (symbol-value pthread) | |
2865 (nconc (cdr (symbol-value pthread)) | |
2866 (list (symbol-value cthread)))) | |
2867 (set pthread (list nil (symbol-value cthread)))))) | |
2868 (gnus-message 7 "Making sparse threads...done"))) | |
2869 | |
2870 (defun gnus-build-old-threads () | |
2871 ;; Look at all the articles that refer back to old articles, and | |
2872 ;; fetch the headers for the articles that aren't there. This will | |
2873 ;; build complete threads - if the roots haven't been expired by the | |
2874 ;; server, that is. | |
2875 (let (id heads) | |
2876 (mapatoms | |
2877 (lambda (refs) | |
2878 (when (not (car (symbol-value refs))) | |
2879 (setq heads (cdr (symbol-value refs))) | |
2880 (while heads | |
2881 (if (memq (mail-header-number (caar heads)) | |
2882 gnus-newsgroup-dormant) | |
2883 (setq heads (cdr heads)) | |
2884 (setq id (symbol-name refs)) | |
2885 (while (and (setq id (gnus-build-get-header id)) | |
2886 (not (car (gnus-gethash | |
2887 id gnus-newsgroup-dependencies))))) | |
2888 (setq heads nil))))) | |
2889 gnus-newsgroup-dependencies))) | |
2890 | |
2891 (defun gnus-build-get-header (id) | |
2892 ;; Look through the buffer of NOV lines and find the header to | |
2893 ;; ID. Enter this line into the dependencies hash table, and return | |
2894 ;; the id of the parent article (if any). | |
2895 (let ((deps gnus-newsgroup-dependencies) | |
2896 found header) | |
2897 (prog1 | |
2898 (save-excursion | |
2899 (set-buffer nntp-server-buffer) | |
2900 (let ((case-fold-search nil)) | |
2901 (goto-char (point-min)) | |
2902 (while (and (not found) | |
2903 (search-forward id nil t)) | |
2904 (beginning-of-line) | |
2905 (setq found (looking-at | |
2906 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s" | |
2907 (regexp-quote id)))) | |
2908 (or found (beginning-of-line 2))) | |
2909 (when found | |
2910 (beginning-of-line) | |
2911 (and | |
2912 (setq header (gnus-nov-parse-line | |
2913 (read (current-buffer)) deps)) | |
2914 (gnus-parent-id (mail-header-references header)))))) | |
2915 (when header | |
2916 (let ((number (mail-header-number header))) | |
2917 (push number gnus-newsgroup-limit) | |
2918 (push header gnus-newsgroup-headers) | |
2919 (if (memq number gnus-newsgroup-unselected) | |
2920 (progn | |
2921 (push number gnus-newsgroup-unreads) | |
2922 (setq gnus-newsgroup-unselected | |
2923 (delq number gnus-newsgroup-unselected))) | |
2924 (push number gnus-newsgroup-ancient))))))) | |
2925 | |
2926 (defun gnus-summary-update-article-line (article header) | |
2927 "Update the line for ARTICLE using HEADERS." | |
2928 (let* ((id (mail-header-id header)) | |
2929 (thread (gnus-id-to-thread id))) | |
2930 (unless thread | |
2931 (error "Article in no thread")) | |
2932 ;; Update the thread. | |
2933 (setcar thread header) | |
2934 (gnus-summary-goto-subject article) | |
2935 (let* ((datal (gnus-data-find-list article)) | |
2936 (data (car datal)) | |
2937 (length (when (cdr datal) | |
2938 (- (gnus-data-pos data) | |
2939 (gnus-data-pos (cadr datal))))) | |
2940 (buffer-read-only nil) | |
2941 (level (gnus-summary-thread-level))) | |
2942 (gnus-delete-line) | |
2943 (gnus-summary-insert-line | |
2944 header level nil (gnus-article-mark article) | |
2945 (memq article gnus-newsgroup-replied) | |
2946 (memq article gnus-newsgroup-expirable) | |
2947 ;; Only insert the Subject string when it's different | |
2948 ;; from the previous Subject string. | |
2949 (if (gnus-subject-equal | |
2950 (condition-case () | |
2951 (mail-header-subject | |
2952 (gnus-data-header | |
2953 (cadr | |
2954 (gnus-data-find-list | |
2955 article | |
2956 (gnus-data-list t))))) | |
2957 ;; Error on the side of excessive subjects. | |
2958 (error "")) | |
2959 (mail-header-subject header)) | |
2960 "" | |
2961 (mail-header-subject header)) | |
2962 nil (cdr (assq article gnus-newsgroup-scored)) | |
2963 (memq article gnus-newsgroup-processable)) | |
2964 (when length | |
2965 (gnus-data-update-list | |
2966 (cdr datal) (- length (- (gnus-data-pos data) (point)))))))) | |
2967 | |
2968 (defun gnus-summary-update-article (article &optional iheader) | |
2969 "Update ARTICLE in the summary buffer." | |
2970 (set-buffer gnus-summary-buffer) | |
2971 (let* ((header (or iheader (gnus-summary-article-header article))) | |
2972 (id (mail-header-id header)) | |
2973 (data (gnus-data-find article)) | |
2974 (thread (gnus-id-to-thread id)) | |
2975 (references (mail-header-references header)) | |
2976 (parent | |
2977 (gnus-id-to-thread | |
2978 (or (gnus-parent-id | |
2979 (when (and references | |
2980 (not (equal "" references))) | |
2981 references)) | |
2982 "none"))) | |
2983 (buffer-read-only nil) | |
2984 (old (car thread)) | |
2985 (number (mail-header-number header)) | |
2986 pos) | |
2987 (when thread | |
2988 ;; !!! Should this be in or not? | |
2989 (unless iheader | |
2990 (setcar thread nil)) | |
2991 (when parent | |
2992 (delq thread parent)) | |
2993 (if (gnus-summary-insert-subject id header iheader) | |
2994 ;; Set the (possibly) new article number in the data structure. | |
2995 (gnus-data-set-number data (gnus-id-to-article id)) | |
2996 (setcar thread old) | |
2997 nil)))) | |
2998 | |
2999 (defun gnus-rebuild-thread (id) | |
3000 "Rebuild the thread containing ID." | |
3001 (let ((buffer-read-only nil) | |
3002 old-pos current thread data) | |
3003 (if (not gnus-show-threads) | |
3004 (setq thread (list (car (gnus-id-to-thread id)))) | |
3005 ;; Get the thread this article is part of. | |
3006 (setq thread (gnus-remove-thread id))) | |
3007 (setq old-pos (gnus-point-at-bol)) | |
3008 (setq current (save-excursion | |
3009 (and (zerop (forward-line -1)) | |
3010 (gnus-summary-article-number)))) | |
3011 ;; If this is a gathered thread, we have to go some re-gathering. | |
3012 (when (stringp (car thread)) | |
3013 (let ((subject (car thread)) | |
3014 roots thr) | |
3015 (setq thread (cdr thread)) | |
3016 (while thread | |
3017 (unless (memq (setq thr (gnus-id-to-thread | |
3018 (gnus-root-id | |
3019 (mail-header-id (caar thread))))) | |
3020 roots) | |
3021 (push thr roots)) | |
3022 (setq thread (cdr thread))) | |
3023 ;; We now have all (unique) roots. | |
3024 (if (= (length roots) 1) | |
3025 ;; All the loose roots are now one solid root. | |
3026 (setq thread (car roots)) | |
3027 (setq thread (cons subject (gnus-sort-threads roots)))))) | |
3028 (let (threads) | |
3029 ;; We then insert this thread into the summary buffer. | |
3030 (let (gnus-newsgroup-data gnus-newsgroup-threads) | |
3031 (if gnus-show-threads | |
3032 (gnus-summary-prepare-threads (gnus-cut-threads (list thread))) | |
3033 (gnus-summary-prepare-unthreaded thread)) | |
3034 (setq data (nreverse gnus-newsgroup-data)) | |
3035 (setq threads gnus-newsgroup-threads)) | |
3036 ;; We splice the new data into the data structure. | |
3037 (gnus-data-enter-list current data (- (point) old-pos)) | |
3038 (setq gnus-newsgroup-threads (nconc threads gnus-newsgroup-threads))))) | |
3039 | |
3040 (defun gnus-number-to-header (number) | |
3041 "Return the header for article NUMBER." | |
3042 (let ((headers gnus-newsgroup-headers)) | |
3043 (while (and headers | |
3044 (not (= number (mail-header-number (car headers))))) | |
3045 (pop headers)) | |
3046 (when headers | |
3047 (car headers)))) | |
3048 | |
3049 (defun gnus-parent-headers (headers &optional generation) | |
3050 "Return the headers of the GENERATIONeth parent of HEADERS." | |
3051 (unless generation | |
3052 (setq generation 1)) | |
3053 (let (references parent) | |
3054 (while (and headers (not (zerop generation))) | |
3055 (setq references (mail-header-references headers)) | |
3056 (when (and references | |
3057 (setq parent (gnus-parent-id references)) | |
3058 (setq headers (car (gnus-id-to-thread parent)))) | |
3059 (decf generation))) | |
3060 headers)) | |
3061 | |
3062 (defun gnus-id-to-thread (id) | |
3063 "Return the (sub-)thread where ID appears." | |
3064 (gnus-gethash id gnus-newsgroup-dependencies)) | |
3065 | |
3066 (defun gnus-id-to-article (id) | |
3067 "Return the article number of ID." | |
3068 (let ((thread (gnus-id-to-thread id))) | |
3069 (when (and thread | |
3070 (car thread)) | |
3071 (mail-header-number (car thread))))) | |
3072 | |
3073 (defun gnus-id-to-header (id) | |
3074 "Return the article headers of ID." | |
3075 (car (gnus-id-to-thread id))) | |
3076 | |
3077 (defun gnus-article-displayed-root-p (article) | |
3078 "Say whether ARTICLE is a root(ish) article." | |
3079 (let ((level (gnus-summary-thread-level article)) | |
3080 (refs (mail-header-references (gnus-summary-article-header article))) | |
3081 particle) | |
3082 (cond | |
3083 ((null level) nil) | |
3084 ((zerop level) t) | |
3085 ((null refs) t) | |
3086 ((null (gnus-parent-id refs)) t) | |
3087 ((and (= 1 level) | |
3088 (null (setq particle (gnus-id-to-article | |
3089 (gnus-parent-id refs)))) | |
3090 (null (gnus-summary-thread-level particle))))))) | |
3091 | |
3092 (defun gnus-root-id (id) | |
3093 "Return the id of the root of the thread where ID appears." | |
3094 (let (last-id prev) | |
3095 (while (and id (setq prev (car (gnus-gethash | |
3096 id gnus-newsgroup-dependencies)))) | |
3097 (setq last-id id | |
3098 id (gnus-parent-id (mail-header-references prev)))) | |
3099 last-id)) | |
3100 | |
3101 (defun gnus-remove-thread (id &optional dont-remove) | |
3102 "Remove the thread that has ID in it." | |
3103 (let ((dep gnus-newsgroup-dependencies) | |
3104 headers thread last-id) | |
3105 ;; First go up in this thread until we find the root. | |
3106 (setq last-id (gnus-root-id id)) | |
3107 (setq headers (list (car (gnus-id-to-thread last-id)) | |
3108 (caadr (gnus-id-to-thread last-id)))) | |
3109 ;; We have now found the real root of this thread. It might have | |
3110 ;; been gathered into some loose thread, so we have to search | |
3111 ;; through the threads to find the thread we wanted. | |
3112 (let ((threads gnus-newsgroup-threads) | |
3113 sub) | |
3114 (while threads | |
3115 (setq sub (car threads)) | |
3116 (if (stringp (car sub)) | |
3117 ;; This is a gathered thread, so we look at the roots | |
3118 ;; below it to find whether this article is in this | |
3119 ;; gathered root. | |
3120 (progn | |
3121 (setq sub (cdr sub)) | |
3122 (while sub | |
3123 (when (member (caar sub) headers) | |
3124 (setq thread (car threads) | |
3125 threads nil | |
3126 sub nil)) | |
3127 (setq sub (cdr sub)))) | |
3128 ;; It's an ordinary thread, so we check it. | |
3129 (when (eq (car sub) (car headers)) | |
3130 (setq thread sub | |
3131 threads nil))) | |
3132 (setq threads (cdr threads))) | |
3133 ;; If this article is in no thread, then it's a root. | |
3134 (if thread | |
3135 (unless dont-remove | |
3136 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads))) | |
3137 (setq thread (gnus-gethash last-id dep))) | |
3138 (when thread | |
3139 (prog1 | |
3140 thread ; We return this thread. | |
3141 (unless dont-remove | |
3142 (if (stringp (car thread)) | |
3143 (progn | |
3144 ;; If we use dummy roots, then we have to remove the | |
3145 ;; dummy root as well. | |
3146 (when (eq gnus-summary-make-false-root 'dummy) | |
3147 (gnus-delete-line) | |
3148 (gnus-data-compute-positions)) | |
3149 (setq thread (cdr thread)) | |
3150 (while thread | |
3151 (gnus-remove-thread-1 (car thread)) | |
3152 (setq thread (cdr thread)))) | |
3153 (gnus-remove-thread-1 thread)))))))) | |
3154 | |
3155 (defun gnus-remove-thread-1 (thread) | |
3156 "Remove the thread THREAD recursively." | |
3157 (let ((number (mail-header-number (pop thread))) | |
3158 d) | |
3159 (setq thread (reverse thread)) | |
3160 (while thread | |
3161 (gnus-remove-thread-1 (pop thread))) | |
3162 (when (setq d (gnus-data-find number)) | |
3163 (goto-char (gnus-data-pos d)) | |
3164 (gnus-data-remove | |
3165 number | |
3166 (- (gnus-point-at-bol) | |
3167 (prog1 | |
3168 (1+ (gnus-point-at-eol)) | |
3169 (gnus-delete-line))))))) | |
3170 | |
3171 (defun gnus-sort-threads (threads) | |
3172 "Sort THREADS." | |
3173 (if (not gnus-thread-sort-functions) | |
3174 threads | |
3175 (gnus-message 7 "Sorting threads...") | |
3176 (prog1 | |
3177 (sort threads (gnus-make-sort-function gnus-thread-sort-functions)) | |
3178 (gnus-message 7 "Sorting threads...done")))) | |
3179 | |
3180 (defun gnus-sort-articles (articles) | |
3181 "Sort ARTICLES." | |
3182 (when gnus-article-sort-functions | |
3183 (gnus-message 7 "Sorting articles...") | |
3184 (prog1 | |
3185 (setq gnus-newsgroup-headers | |
3186 (sort articles (gnus-make-sort-function | |
3187 gnus-article-sort-functions))) | |
3188 (gnus-message 7 "Sorting articles...done")))) | |
3189 | |
3190 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>. | |
3191 (defmacro gnus-thread-header (thread) | |
3192 ;; Return header of first article in THREAD. | |
3193 ;; Note that THREAD must never, ever be anything else than a variable - | |
3194 ;; using some other form will lead to serious barfage. | |
3195 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread))) | |
3196 ;; (8% speedup to gnus-summary-prepare, just for fun :-) | |
3197 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ; | |
3198 (vector thread) 2)) | |
3199 | |
3200 (defsubst gnus-article-sort-by-number (h1 h2) | |
3201 "Sort articles by article number." | |
3202 (< (mail-header-number h1) | |
3203 (mail-header-number h2))) | |
3204 | |
3205 (defun gnus-thread-sort-by-number (h1 h2) | |
3206 "Sort threads by root article number." | |
3207 (gnus-article-sort-by-number | |
3208 (gnus-thread-header h1) (gnus-thread-header h2))) | |
3209 | |
3210 (defsubst gnus-article-sort-by-lines (h1 h2) | |
3211 "Sort articles by article Lines header." | |
3212 (< (mail-header-lines h1) | |
3213 (mail-header-lines h2))) | |
3214 | |
3215 (defun gnus-thread-sort-by-lines (h1 h2) | |
3216 "Sort threads by root article Lines header." | |
3217 (gnus-article-sort-by-lines | |
3218 (gnus-thread-header h1) (gnus-thread-header h2))) | |
3219 | |
3220 (defsubst gnus-article-sort-by-author (h1 h2) | |
3221 "Sort articles by root author." | |
3222 (string-lessp | |
3223 (let ((extract (funcall | |
3224 gnus-extract-address-components | |
3225 (mail-header-from h1)))) | |
3226 (or (car extract) (cadr extract) "")) | |
3227 (let ((extract (funcall | |
3228 gnus-extract-address-components | |
3229 (mail-header-from h2)))) | |
3230 (or (car extract) (cadr extract) "")))) | |
3231 | |
3232 (defun gnus-thread-sort-by-author (h1 h2) | |
3233 "Sort threads by root author." | |
3234 (gnus-article-sort-by-author | |
3235 (gnus-thread-header h1) (gnus-thread-header h2))) | |
3236 | |
3237 (defsubst gnus-article-sort-by-subject (h1 h2) | |
3238 "Sort articles by root subject." | |
3239 (string-lessp | |
3240 (downcase (gnus-simplify-subject-re (mail-header-subject h1))) | |
3241 (downcase (gnus-simplify-subject-re (mail-header-subject h2))))) | |
3242 | |
3243 (defun gnus-thread-sort-by-subject (h1 h2) | |
3244 "Sort threads by root subject." | |
3245 (gnus-article-sort-by-subject | |
3246 (gnus-thread-header h1) (gnus-thread-header h2))) | |
3247 | |
3248 (defsubst gnus-article-sort-by-date (h1 h2) | |
3249 "Sort articles by root article date." | |
3250 (gnus-time-less | |
3251 (gnus-date-get-time (mail-header-date h1)) | |
3252 (gnus-date-get-time (mail-header-date h2)))) | |
3253 | |
3254 (defun gnus-thread-sort-by-date (h1 h2) | |
3255 "Sort threads by root article date." | |
3256 (gnus-article-sort-by-date | |
3257 (gnus-thread-header h1) (gnus-thread-header h2))) | |
3258 | |
3259 (defsubst gnus-article-sort-by-score (h1 h2) | |
3260 "Sort articles by root article score. | |
3261 Unscored articles will be counted as having a score of zero." | |
3262 (> (or (cdr (assq (mail-header-number h1) | |
3263 gnus-newsgroup-scored)) | |
3264 gnus-summary-default-score 0) | |
3265 (or (cdr (assq (mail-header-number h2) | |
3266 gnus-newsgroup-scored)) | |
3267 gnus-summary-default-score 0))) | |
3268 | |
3269 (defun gnus-thread-sort-by-score (h1 h2) | |
3270 "Sort threads by root article score." | |
3271 (gnus-article-sort-by-score | |
3272 (gnus-thread-header h1) (gnus-thread-header h2))) | |
3273 | |
3274 (defun gnus-thread-sort-by-total-score (h1 h2) | |
3275 "Sort threads by the sum of all scores in the thread. | |
3276 Unscored articles will be counted as having a score of zero." | |
3277 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2))) | |
3278 | |
3279 (defun gnus-thread-total-score (thread) | |
3280 ;; This function find the total score of THREAD. | |
3281 (cond ((null thread) | |
3282 0) | |
3283 ((consp thread) | |
3284 (if (stringp (car thread)) | |
3285 (apply gnus-thread-score-function 0 | |
3286 (mapcar 'gnus-thread-total-score-1 (cdr thread))) | |
3287 (gnus-thread-total-score-1 thread))) | |
3288 (t | |
3289 (gnus-thread-total-score-1 (list thread))))) | |
3290 | |
3291 (defun gnus-thread-total-score-1 (root) | |
3292 ;; This function find the total score of the thread below ROOT. | |
3293 (setq root (car root)) | |
3294 (apply gnus-thread-score-function | |
3295 (or (append | |
3296 (mapcar 'gnus-thread-total-score | |
3297 (cdr (gnus-gethash (mail-header-id root) | |
3298 gnus-newsgroup-dependencies))) | |
3299 (when (> (mail-header-number root) 0) | |
3300 (list (or (cdr (assq (mail-header-number root) | |
3301 gnus-newsgroup-scored)) | |
3302 gnus-summary-default-score 0)))) | |
3303 (list gnus-summary-default-score) | |
3304 '(0)))) | |
3305 | |
3306 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>. | |
3307 (defvar gnus-tmp-prev-subject nil) | |
3308 (defvar gnus-tmp-false-parent nil) | |
3309 (defvar gnus-tmp-root-expunged nil) | |
3310 (defvar gnus-tmp-dummy-line nil) | |
3311 | |
3312 (defun gnus-summary-prepare-threads (threads) | |
3313 "Prepare summary buffer from THREADS and indentation LEVEL. | |
3314 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])' | |
3315 or a straight list of headers." | |
3316 (gnus-message 7 "Generating summary...") | |
3317 | |
3318 (setq gnus-newsgroup-threads threads) | |
3319 (beginning-of-line) | |
3320 | |
3321 (let ((gnus-tmp-level 0) | |
3322 (default-score (or gnus-summary-default-score 0)) | |
3323 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight)) | |
3324 thread number subject stack state gnus-tmp-gathered beg-match | |
3325 new-roots gnus-tmp-new-adopts thread-end | |
3326 gnus-tmp-header gnus-tmp-unread | |
3327 gnus-tmp-replied gnus-tmp-subject-or-nil | |
3328 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score | |
3329 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name | |
3330 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket) | |
3331 | |
3332 (setq gnus-tmp-prev-subject nil) | |
3333 | |
3334 (if (vectorp (car threads)) | |
3335 ;; If this is a straight (sic) list of headers, then a | |
3336 ;; threaded summary display isn't required, so we just create | |
3337 ;; an unthreaded one. | |
3338 (gnus-summary-prepare-unthreaded threads) | |
3339 | |
3340 ;; Do the threaded display. | |
3341 | |
3342 (while (or threads stack gnus-tmp-new-adopts new-roots) | |
3343 | |
3344 (if (and (= gnus-tmp-level 0) | |
3345 (not (setq gnus-tmp-dummy-line nil)) | |
3346 (or (not stack) | |
3347 (= (caar stack) 0)) | |
3348 (not gnus-tmp-false-parent) | |
3349 (or gnus-tmp-new-adopts new-roots)) | |
3350 (if gnus-tmp-new-adopts | |
3351 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1) | |
3352 thread (list (car gnus-tmp-new-adopts)) | |
3353 gnus-tmp-header (caar thread) | |
3354 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts)) | |
3355 (when new-roots | |
3356 (setq thread (list (car new-roots)) | |
3357 gnus-tmp-header (caar thread) | |
3358 new-roots (cdr new-roots)))) | |
3359 | |
3360 (if threads | |
3361 ;; If there are some threads, we do them before the | |
3362 ;; threads on the stack. | |
3363 (setq thread threads | |
3364 gnus-tmp-header (caar thread)) | |
3365 ;; There were no current threads, so we pop something off | |
3366 ;; the stack. | |
3367 (setq state (car stack) | |
3368 gnus-tmp-level (car state) | |
3369 thread (cdr state) | |
3370 stack (cdr stack) | |
3371 gnus-tmp-header (caar thread)))) | |
3372 | |
3373 (setq gnus-tmp-false-parent nil) | |
3374 (setq gnus-tmp-root-expunged nil) | |
3375 (setq thread-end nil) | |
3376 | |
3377 (if (stringp gnus-tmp-header) | |
3378 ;; The header is a dummy root. | |
3379 (cond | |
3380 ((eq gnus-summary-make-false-root 'adopt) | |
3381 ;; We let the first article adopt the rest. | |
3382 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts | |
3383 (cddar thread))) | |
3384 (setq gnus-tmp-gathered | |
3385 (nconc (mapcar | |
3386 (lambda (h) (mail-header-number (car h))) | |
3387 (cddar thread)) | |
3388 gnus-tmp-gathered)) | |
3389 (setq thread (cons (list (caar thread) | |
3390 (cadar thread)) | |
3391 (cdr thread))) | |
3392 (setq gnus-tmp-level -1 | |
3393 gnus-tmp-false-parent t)) | |
3394 ((eq gnus-summary-make-false-root 'empty) | |
3395 ;; We print adopted articles with empty subject fields. | |
3396 (setq gnus-tmp-gathered | |
3397 (nconc (mapcar | |
3398 (lambda (h) (mail-header-number (car h))) | |
3399 (cddar thread)) | |
3400 gnus-tmp-gathered)) | |
3401 (setq gnus-tmp-level -1)) | |
3402 ((eq gnus-summary-make-false-root 'dummy) | |
3403 ;; We remember that we probably want to output a dummy | |
3404 ;; root. | |
3405 (setq gnus-tmp-dummy-line gnus-tmp-header) | |
3406 (setq gnus-tmp-prev-subject gnus-tmp-header)) | |
3407 (t | |
3408 ;; We do not make a root for the gathered | |
3409 ;; sub-threads at all. | |
3410 (setq gnus-tmp-level -1))) | |
3411 | |
3412 (setq number (mail-header-number gnus-tmp-header) | |
3413 subject (mail-header-subject gnus-tmp-header)) | |
3414 | |
3415 (cond | |
3416 ;; If the thread has changed subject, we might want to make | |
3417 ;; this subthread into a root. | |
3418 ((and (null gnus-thread-ignore-subject) | |
3419 (not (zerop gnus-tmp-level)) | |
3420 gnus-tmp-prev-subject | |
3421 (not (inline | |
3422 (gnus-subject-equal gnus-tmp-prev-subject subject)))) | |
3423 (setq new-roots (nconc new-roots (list (car thread))) | |
3424 thread-end t | |
3425 gnus-tmp-header nil)) | |
3426 ;; If the article lies outside the current limit, | |
3427 ;; then we do not display it. | |
3428 ((not (memq number gnus-newsgroup-limit)) | |
3429 (setq gnus-tmp-gathered | |
3430 (nconc (mapcar | |
3431 (lambda (h) (mail-header-number (car h))) | |
3432 (cdar thread)) | |
3433 gnus-tmp-gathered)) | |
3434 (setq gnus-tmp-new-adopts (if (cdar thread) | |
3435 (append gnus-tmp-new-adopts | |
3436 (cdar thread)) | |
3437 gnus-tmp-new-adopts) | |
3438 thread-end t | |
3439 gnus-tmp-header nil) | |
3440 (when (zerop gnus-tmp-level) | |
3441 (setq gnus-tmp-root-expunged t))) | |
3442 ;; Perhaps this article is to be marked as read? | |
3443 ((and gnus-summary-mark-below | |
3444 (< (or (cdr (assq number gnus-newsgroup-scored)) | |
3445 default-score) | |
3446 gnus-summary-mark-below) | |
3447 ;; Don't touch sparse articles. | |
3448 (not (gnus-summary-article-sparse-p number)) | |
3449 (not (gnus-summary-article-ancient-p number))) | |
3450 (setq gnus-newsgroup-unreads | |
3451 (delq number gnus-newsgroup-unreads)) | |
3452 (if gnus-newsgroup-auto-expire | |
3453 (push number gnus-newsgroup-expirable) | |
3454 (push (cons number gnus-low-score-mark) | |
3455 gnus-newsgroup-reads)))) | |
3456 | |
3457 (when gnus-tmp-header | |
3458 ;; We may have an old dummy line to output before this | |
3459 ;; article. | |
3460 (when gnus-tmp-dummy-line | |
3461 (gnus-summary-insert-dummy-line | |
3462 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header)) | |
3463 (setq gnus-tmp-dummy-line nil)) | |
3464 | |
3465 ;; Compute the mark. | |
3466 (setq gnus-tmp-unread (gnus-article-mark number)) | |
3467 | |
3468 (push (gnus-data-make number gnus-tmp-unread (1+ (point)) | |
3469 gnus-tmp-header gnus-tmp-level) | |
3470 gnus-newsgroup-data) | |
3471 | |
3472 ;; Actually insert the line. | |
3473 (setq | |
3474 gnus-tmp-subject-or-nil | |
3475 (cond | |
3476 ((and gnus-thread-ignore-subject | |
3477 gnus-tmp-prev-subject | |
3478 (not (inline (gnus-subject-equal | |
3479 gnus-tmp-prev-subject subject)))) | |
3480 subject) | |
3481 ((zerop gnus-tmp-level) | |
3482 (if (and (eq gnus-summary-make-false-root 'empty) | |
3483 (memq number gnus-tmp-gathered) | |
3484 gnus-tmp-prev-subject | |
3485 (inline (gnus-subject-equal | |
3486 gnus-tmp-prev-subject subject))) | |
3487 gnus-summary-same-subject | |
3488 subject)) | |
3489 (t gnus-summary-same-subject))) | |
3490 (if (and (eq gnus-summary-make-false-root 'adopt) | |
3491 (= gnus-tmp-level 1) | |
3492 (memq number gnus-tmp-gathered)) | |
3493 (setq gnus-tmp-opening-bracket ?\< | |
3494 gnus-tmp-closing-bracket ?\>) | |
3495 (setq gnus-tmp-opening-bracket ?\[ | |
3496 gnus-tmp-closing-bracket ?\])) | |
3497 (setq | |
3498 gnus-tmp-indentation | |
3499 (aref gnus-thread-indent-array gnus-tmp-level) | |
3500 gnus-tmp-lines (mail-header-lines gnus-tmp-header) | |
3501 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored)) | |
3502 gnus-summary-default-score 0) | |
3503 gnus-tmp-score-char | |
3504 (if (or (null gnus-summary-default-score) | |
3505 (<= (abs (- gnus-tmp-score gnus-summary-default-score)) | |
3506 gnus-summary-zcore-fuzz)) | |
3507 ? | |
3508 (if (< gnus-tmp-score gnus-summary-default-score) | |
3509 gnus-score-below-mark gnus-score-over-mark)) | |
3510 gnus-tmp-replied | |
3511 (cond ((memq number gnus-newsgroup-processable) | |
3512 gnus-process-mark) | |
3513 ((memq number gnus-newsgroup-cached) | |
3514 gnus-cached-mark) | |
3515 ((memq number gnus-newsgroup-replied) | |
3516 gnus-replied-mark) | |
3517 ((memq number gnus-newsgroup-saved) | |
3518 gnus-saved-mark) | |
3519 (t gnus-unread-mark)) | |
3520 gnus-tmp-from (mail-header-from gnus-tmp-header) | |
3521 gnus-tmp-name | |
3522 (cond | |
3523 ((string-match "<[^>]+> *$" gnus-tmp-from) | |
3524 (setq beg-match (match-beginning 0)) | |
3525 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from) | |
3526 (substring gnus-tmp-from (1+ (match-beginning 0)) | |
3527 (1- (match-end 0)))) | |
3528 (substring gnus-tmp-from 0 beg-match))) | |
3529 ((string-match "(.+)" gnus-tmp-from) | |
3530 (substring gnus-tmp-from | |
3531 (1+ (match-beginning 0)) (1- (match-end 0)))) | |
3532 (t gnus-tmp-from))) | |
3533 (when (string= gnus-tmp-name "") | |
3534 (setq gnus-tmp-name gnus-tmp-from)) | |
3535 (unless (numberp gnus-tmp-lines) | |
3536 (setq gnus-tmp-lines 0)) | |
3537 (gnus-put-text-property | |
3538 (point) | |
3539 (progn (eval gnus-summary-line-format-spec) (point)) | |
3540 'gnus-number number) | |
3541 (when gnus-visual-p | |
3542 (forward-line -1) | |
3543 (run-hooks 'gnus-summary-update-hook) | |
3544 (forward-line 1)) | |
3545 | |
3546 (setq gnus-tmp-prev-subject subject))) | |
3547 | |
3548 (when (nth 1 thread) | |
3549 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack)) | |
3550 (incf gnus-tmp-level) | |
3551 (setq threads (if thread-end nil (cdar thread))) | |
3552 (unless threads | |
3553 (setq gnus-tmp-level 0))))) | |
3554 (gnus-message 7 "Generating summary...done")) | |
3555 | |
3556 (defun gnus-summary-prepare-unthreaded (headers) | |
3557 "Generate an unthreaded summary buffer based on HEADERS." | |
3558 (let (header number mark) | |
3559 | |
3560 (beginning-of-line) | |
3561 | |
3562 (while headers | |
3563 ;; We may have to root out some bad articles... | |
3564 (when (memq (setq number (mail-header-number | |
3565 (setq header (pop headers)))) | |
3566 gnus-newsgroup-limit) | |
3567 ;; Mark article as read when it has a low score. | |
3568 (when (and gnus-summary-mark-below | |
3569 (< (or (cdr (assq number gnus-newsgroup-scored)) | |
3570 gnus-summary-default-score 0) | |
3571 gnus-summary-mark-below) | |
3572 (not (gnus-summary-article-ancient-p number))) | |
3573 (setq gnus-newsgroup-unreads | |
3574 (delq number gnus-newsgroup-unreads)) | |
3575 (if gnus-newsgroup-auto-expire | |
3576 (push number gnus-newsgroup-expirable) | |
3577 (push (cons number gnus-low-score-mark) | |
3578 gnus-newsgroup-reads))) | |
3579 | |
3580 (setq mark (gnus-article-mark number)) | |
3581 (push (gnus-data-make number mark (1+ (point)) header 0) | |
3582 gnus-newsgroup-data) | |
3583 (gnus-summary-insert-line | |
3584 header 0 number | |
3585 mark (memq number gnus-newsgroup-replied) | |
3586 (memq number gnus-newsgroup-expirable) | |
3587 (mail-header-subject header) nil | |
3588 (cdr (assq number gnus-newsgroup-scored)) | |
3589 (memq number gnus-newsgroup-processable)))))) | |
3590 | |
3591 (defun gnus-select-newsgroup (group &optional read-all) | |
3592 "Select newsgroup GROUP. | |
3593 If READ-ALL is non-nil, all articles in the group are selected." | |
3594 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb)) | |
3595 ;;!!! Dirty hack; should be removed. | |
3596 (gnus-summary-ignore-duplicates | |
3597 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual) | |
3598 t | |
3599 gnus-summary-ignore-duplicates)) | |
3600 (info (nth 2 entry)) | |
3601 articles fetched-articles cached) | |
3602 | |
3603 (unless (gnus-check-server | |
3604 (setq gnus-current-select-method | |
3605 (gnus-find-method-for-group group))) | |
3606 (error "Couldn't open server")) | |
3607 | |
3608 (or (and entry (not (eq (car entry) t))) ; Either it's active... | |
3609 (gnus-activate-group group) ; Or we can activate it... | |
3610 (progn ; Or we bug out. | |
3611 (when (equal major-mode 'gnus-summary-mode) | |
3612 (kill-buffer (current-buffer))) | |
3613 (error "Couldn't request group %s: %s" | |
3614 group (gnus-status-message group)))) | |
3615 | |
3616 (unless (gnus-request-group group t) | |
3617 (when (equal major-mode 'gnus-summary-mode) | |
3618 (kill-buffer (current-buffer))) | |
3619 (error "Couldn't request group %s: %s" | |
3620 group (gnus-status-message group))) | |
3621 | |
3622 (setq gnus-newsgroup-name group) | |
3623 (setq gnus-newsgroup-unselected nil) | |
3624 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group)) | |
3625 | |
3626 ;; Adjust and set lists of article marks. | |
3627 (when info | |
3628 (gnus-adjust-marked-articles info)) | |
3629 | |
3630 ;; Kludge to avoid having cached articles nixed out in virtual groups. | |
3631 (when (gnus-virtual-group-p group) | |
3632 (setq cached gnus-newsgroup-cached)) | |
3633 | |
3634 (setq gnus-newsgroup-unreads | |
3635 (gnus-set-difference | |
3636 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked) | |
3637 gnus-newsgroup-dormant)) | |
3638 | |
3639 (setq gnus-newsgroup-processable nil) | |
3640 | |
3641 (gnus-update-read-articles group gnus-newsgroup-unreads) | |
3642 (unless (gnus-ephemeral-group-p gnus-newsgroup-name) | |
3643 (gnus-group-update-group group)) | |
3644 | |
3645 (setq articles (gnus-articles-to-read group read-all)) | |
3646 | |
3647 (cond | |
3648 ((null articles) | |
3649 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display") | |
3650 'quit) | |
3651 ((eq articles 0) nil) | |
3652 (t | |
3653 ;; Init the dependencies hash table. | |
3654 (setq gnus-newsgroup-dependencies | |
3655 (gnus-make-hashtable (length articles))) | |
3656 ;; Retrieve the headers and read them in. | |
3657 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name) | |
3658 (setq gnus-newsgroup-headers | |
3659 (if (eq 'nov | |
3660 (setq gnus-headers-retrieved-by | |
3661 (gnus-retrieve-headers | |
3662 articles gnus-newsgroup-name | |
3663 ;; We might want to fetch old headers, but | |
3664 ;; not if there is only 1 article. | |
3665 (and gnus-fetch-old-headers | |
3666 (or (and | |
3667 (not (eq gnus-fetch-old-headers 'some)) | |
3668 (not (numberp gnus-fetch-old-headers))) | |
3669 (> (length articles) 1)))))) | |
3670 (gnus-get-newsgroup-headers-xover | |
3671 articles nil nil gnus-newsgroup-name t) | |
3672 (gnus-get-newsgroup-headers))) | |
3673 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name) | |
3674 | |
3675 ;; Kludge to avoid having cached articles nixed out in virtual groups. | |
3676 (when cached | |
3677 (setq gnus-newsgroup-cached cached)) | |
3678 | |
3679 ;; Suppress duplicates? | |
3680 (when gnus-suppress-duplicates | |
3681 (gnus-dup-suppress-articles)) | |
3682 | |
3683 ;; Set the initial limit. | |
3684 (setq gnus-newsgroup-limit (copy-sequence articles)) | |
3685 ;; Remove canceled articles from the list of unread articles. | |
3686 (setq gnus-newsgroup-unreads | |
3687 (gnus-set-sorted-intersection | |
3688 gnus-newsgroup-unreads | |
3689 (setq fetched-articles | |
3690 (mapcar (lambda (headers) (mail-header-number headers)) | |
3691 gnus-newsgroup-headers)))) | |
3692 ;; Removed marked articles that do not exist. | |
3693 (gnus-update-missing-marks | |
3694 (gnus-sorted-complement fetched-articles articles)) | |
3695 ;; We might want to build some more threads first. | |
3696 (and gnus-fetch-old-headers | |
3697 (eq gnus-headers-retrieved-by 'nov) | |
3698 (gnus-build-old-threads)) | |
3699 ;; Check whether auto-expire is to be done in this group. | |
3700 (setq gnus-newsgroup-auto-expire | |
3701 (gnus-group-auto-expirable-p group)) | |
3702 ;; Set up the article buffer now, if necessary. | |
3703 (unless gnus-single-article-buffer | |
3704 (gnus-article-setup-buffer)) | |
3705 ;; First and last article in this newsgroup. | |
3706 (when gnus-newsgroup-headers | |
3707 (setq gnus-newsgroup-begin | |
3708 (mail-header-number (car gnus-newsgroup-headers)) | |
3709 gnus-newsgroup-end | |
3710 (mail-header-number | |
3711 (gnus-last-element gnus-newsgroup-headers)))) | |
3712 ;; GROUP is successfully selected. | |
3713 (or gnus-newsgroup-headers t))))) | |
3714 | |
3715 (defun gnus-articles-to-read (group &optional read-all) | |
3716 ;; Find out what articles the user wants to read. | |
3717 (let* ((articles | |
3718 ;; Select all articles if `read-all' is non-nil, or if there | |
3719 ;; are no unread articles. | |
3720 (if (or read-all | |
3721 (and (zerop (length gnus-newsgroup-marked)) | |
3722 (zerop (length gnus-newsgroup-unreads))) | |
3723 (eq (gnus-group-find-parameter group 'display) | |
3724 'all)) | |
3725 (gnus-uncompress-range (gnus-active group)) | |
3726 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked | |
3727 (copy-sequence gnus-newsgroup-unreads)) | |
3728 '<))) | |
3729 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles)) | |
3730 (scored (length scored-list)) | |
3731 (number (length articles)) | |
3732 (marked (+ (length gnus-newsgroup-marked) | |
3733 (length gnus-newsgroup-dormant))) | |
3734 (select | |
3735 (cond | |
3736 ((numberp read-all) | |
3737 read-all) | |
3738 (t | |
3739 (condition-case () | |
3740 (cond | |
3741 ((and (or (<= scored marked) (= scored number)) | |
3742 (numberp gnus-large-newsgroup) | |
3743 (> number gnus-large-newsgroup)) | |
3744 (let ((input | |
3745 (read-string | |
3746 (format | |
3747 "How many articles from %s (default %d): " | |
3748 (gnus-limit-string gnus-newsgroup-name 35) | |
3749 number)))) | |
3750 (if (string-match "^[ \t]*$" input) number input))) | |
3751 ((and (> scored marked) (< scored number) | |
3752 (> (- scored number) 20)) | |
3753 (let ((input | |
3754 (read-string | |
3755 (format "%s %s (%d scored, %d total): " | |
3756 "How many articles from" | |
3757 group scored number)))) | |
3758 (if (string-match "^[ \t]*$" input) | |
3759 number input))) | |
3760 (t number)) | |
3761 (quit nil)))))) | |
3762 (setq select (if (stringp select) (string-to-number select) select)) | |
3763 (if (or (null select) (zerop select)) | |
3764 select | |
3765 (if (and (not (zerop scored)) (<= (abs select) scored)) | |
3766 (progn | |
3767 (setq articles (sort scored-list '<)) | |
3768 (setq number (length articles))) | |
3769 (setq articles (copy-sequence articles))) | |
3770 | |
3771 (when (< (abs select) number) | |
3772 (if (< select 0) | |
3773 ;; Select the N oldest articles. | |
3774 (setcdr (nthcdr (1- (abs select)) articles) nil) | |
3775 ;; Select the N most recent articles. | |
3776 (setq articles (nthcdr (- number select) articles)))) | |
3777 (setq gnus-newsgroup-unselected | |
3778 (gnus-sorted-intersection | |
3779 gnus-newsgroup-unreads | |
3780 (gnus-sorted-complement gnus-newsgroup-unreads articles))) | |
3781 articles))) | |
3782 | |
3783 (defun gnus-killed-articles (killed articles) | |
3784 (let (out) | |
3785 (while articles | |
3786 (when (inline (gnus-member-of-range (car articles) killed)) | |
3787 (push (car articles) out)) | |
3788 (setq articles (cdr articles))) | |
3789 out)) | |
3790 | |
3791 (defun gnus-uncompress-marks (marks) | |
3792 "Uncompress the mark ranges in MARKS." | |
3793 (let ((uncompressed '(score bookmark)) | |
3794 out) | |
3795 (while marks | |
3796 (if (memq (caar marks) uncompressed) | |
3797 (push (car marks) out) | |
3798 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out)) | |
3799 (setq marks (cdr marks))) | |
3800 out)) | |
3801 | |
3802 (defun gnus-adjust-marked-articles (info) | |
3803 "Set all article lists and remove all marks that are no longer legal." | |
3804 (let* ((marked-lists (gnus-info-marks info)) | |
3805 (active (gnus-active (gnus-info-group info))) | |
3806 (min (car active)) | |
3807 (max (cdr active)) | |
3808 (types gnus-article-mark-lists) | |
3809 (uncompressed '(score bookmark killed)) | |
3810 marks var articles article mark) | |
3811 | |
3812 (while marked-lists | |
3813 (setq marks (pop marked-lists)) | |
3814 (set (setq var (intern (format "gnus-newsgroup-%s" | |
3815 (car (rassq (setq mark (car marks)) | |
3816 types))))) | |
3817 (if (memq (car marks) uncompressed) (cdr marks) | |
3818 (gnus-uncompress-range (cdr marks)))) | |
3819 | |
3820 (setq articles (symbol-value var)) | |
3821 | |
3822 ;; All articles have to be subsets of the active articles. | |
3823 (cond | |
3824 ;; Adjust "simple" lists. | |
3825 ((memq mark '(tick dormant expire reply save)) | |
3826 (while articles | |
3827 (when (or (< (setq article (pop articles)) min) (> article max)) | |
3828 (set var (delq article (symbol-value var)))))) | |
3829 ;; Adjust assocs. | |
3830 ((memq mark uncompressed) | |
3831 (while articles | |
3832 (when (or (not (consp (setq article (pop articles)))) | |
3833 (< (car article) min) | |
3834 (> (car article) max)) | |
3835 (set var (delq article (symbol-value var)))))))))) | |
3836 | |
3837 (defun gnus-update-missing-marks (missing) | |
3838 "Go through the list of MISSING articles and remove them mark lists." | |
3839 (when missing | |
3840 (let ((types gnus-article-mark-lists) | |
3841 var m) | |
3842 ;; Go through all types. | |
3843 (while types | |
3844 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types))))) | |
3845 (when (symbol-value var) | |
3846 ;; This list has articles. So we delete all missing articles | |
3847 ;; from it. | |
3848 (setq m missing) | |
3849 (while m | |
3850 (set var (delq (pop m) (symbol-value var))))))))) | |
3851 | |
3852 (defun gnus-update-marks () | |
3853 "Enter the various lists of marked articles into the newsgroup info list." | |
3854 (let ((types gnus-article-mark-lists) | |
3855 (info (gnus-get-info gnus-newsgroup-name)) | |
3856 (uncompressed '(score bookmark killed)) | |
3857 type list newmarked symbol) | |
3858 (when info | |
3859 ;; Add all marks lists that are non-nil to the list of marks lists. | |
3860 (while (setq type (pop types)) | |
3861 (when (setq list (symbol-value | |
3862 (setq symbol | |
3863 (intern (format "gnus-newsgroup-%s" | |
3864 (car type)))))) | |
3865 | |
3866 ;; Get rid of the entries of the articles that have the | |
3867 ;; default score. | |
3868 (when (and (eq (cdr type) 'score) | |
3869 gnus-save-score | |
3870 list) | |
3871 (let* ((arts list) | |
3872 (prev (cons nil list)) | |
3873 (all prev)) | |
3874 (while arts | |
3875 (if (or (not (consp (car arts))) | |
3876 (= (cdar arts) gnus-summary-default-score)) | |
3877 (setcdr prev (cdr arts)) | |
3878 (setq prev arts)) | |
3879 (setq arts (cdr arts))) | |
3880 (setq list (cdr all)))) | |
3881 | |
3882 (push (cons (cdr type) | |
3883 (if (memq (cdr type) uncompressed) list | |
3884 (gnus-compress-sequence | |
3885 (set symbol (sort list '<)) t))) | |
3886 newmarked))) | |
3887 | |
3888 ;; Enter these new marks into the info of the group. | |
3889 (if (nthcdr 3 info) | |
3890 (setcar (nthcdr 3 info) newmarked) | |
3891 ;; Add the marks lists to the end of the info. | |
3892 (when newmarked | |
3893 (setcdr (nthcdr 2 info) (list newmarked)))) | |
3894 | |
3895 ;; Cut off the end of the info if there's nothing else there. | |
3896 (let ((i 5)) | |
3897 (while (and (> i 2) | |
3898 (not (nth i info))) | |
3899 (when (nthcdr (decf i) info) | |
3900 (setcdr (nthcdr i info) nil))))))) | |
3901 | |
3902 (defun gnus-set-mode-line (where) | |
3903 "This function sets the mode line of the article or summary buffers. | |
3904 If WHERE is `summary', the summary mode line format will be used." | |
3905 ;; Is this mode line one we keep updated? | |
3906 (when (memq where gnus-updated-mode-lines) | |
3907 (let (mode-string) | |
3908 (save-excursion | |
3909 ;; We evaluate this in the summary buffer since these | |
3910 ;; variables are buffer-local to that buffer. | |
3911 (set-buffer gnus-summary-buffer) | |
3912 ;; We bind all these variables that are used in the `eval' form | |
3913 ;; below. | |
3914 (let* ((mformat (symbol-value | |
3915 (intern | |
3916 (format "gnus-%s-mode-line-format-spec" where)))) | |
3917 (gnus-tmp-group-name gnus-newsgroup-name) | |
3918 (gnus-tmp-article-number (or gnus-current-article 0)) | |
3919 (gnus-tmp-unread gnus-newsgroup-unreads) | |
3920 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads)) | |
3921 (gnus-tmp-unselected (length gnus-newsgroup-unselected)) | |
3922 (gnus-tmp-unread-and-unselected | |
3923 (cond ((and (zerop gnus-tmp-unread-and-unticked) | |
3924 (zerop gnus-tmp-unselected)) | |
3925 "") | |
3926 ((zerop gnus-tmp-unselected) | |
3927 (format "{%d more}" gnus-tmp-unread-and-unticked)) | |
3928 (t (format "{%d(+%d) more}" | |
3929 gnus-tmp-unread-and-unticked | |
3930 gnus-tmp-unselected)))) | |
3931 (gnus-tmp-subject | |
3932 (if (and gnus-current-headers | |
3933 (vectorp gnus-current-headers)) | |
3934 (gnus-mode-string-quote | |
3935 (mail-header-subject gnus-current-headers)) | |
3936 "")) | |
3937 bufname-length max-len | |
3938 gnus-tmp-header);; passed as argument to any user-format-funcs | |
3939 (setq mode-string (eval mformat)) | |
3940 (setq bufname-length (if (string-match "%b" mode-string) | |
3941 (- (length | |
3942 (buffer-name | |
3943 (if (eq where 'summary) | |
3944 nil | |
3945 (get-buffer gnus-article-buffer)))) | |
3946 2) | |
3947 0)) | |
3948 (setq max-len (max 4 (if gnus-mode-non-string-length | |
3949 (- (window-width) | |
3950 gnus-mode-non-string-length | |
3951 bufname-length) | |
3952 (length mode-string)))) | |
3953 ;; We might have to chop a bit of the string off... | |
3954 (when (> (length mode-string) max-len) | |
3955 (setq mode-string | |
3956 (concat (gnus-truncate-string mode-string (- max-len 3)) | |
3957 "..."))) | |
3958 ;; Pad the mode string a bit. | |
3959 (setq mode-string (format (format "%%-%ds" max-len) mode-string)))) | |
3960 ;; Update the mode line. | |
3961 (setq mode-line-buffer-identification | |
3962 (gnus-mode-line-buffer-identification (list mode-string))) | |
3963 (set-buffer-modified-p t)))) | |
3964 | |
3965 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads) | |
3966 "Go through the HEADERS list and add all Xrefs to a hash table. | |
3967 The resulting hash table is returned, or nil if no Xrefs were found." | |
3968 (let* ((virtual (gnus-virtual-group-p from-newsgroup)) | |
3969 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup))) | |
3970 (xref-hashtb (gnus-make-hashtable)) | |
3971 start group entry number xrefs header) | |
3972 (while headers | |
3973 (setq header (pop headers)) | |
3974 (when (and (setq xrefs (mail-header-xref header)) | |
3975 (not (memq (setq number (mail-header-number header)) | |
3976 unreads))) | |
3977 (setq start 0) | |
3978 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start) | |
3979 (setq start (match-end 0)) | |
3980 (setq group (if prefix | |
3981 (concat prefix (substring xrefs (match-beginning 1) | |
3982 (match-end 1))) | |
3983 (substring xrefs (match-beginning 1) (match-end 1)))) | |
3984 (setq number | |
3985 (string-to-int (substring xrefs (match-beginning 2) | |
3986 (match-end 2)))) | |
3987 (if (setq entry (gnus-gethash group xref-hashtb)) | |
3988 (setcdr entry (cons number (cdr entry))) | |
3989 (gnus-sethash group (cons number nil) xref-hashtb))))) | |
3990 (and start xref-hashtb))) | |
3991 | |
3992 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads) | |
3993 "Look through all the headers and mark the Xrefs as read." | |
3994 (let ((virtual (gnus-virtual-group-p from-newsgroup)) | |
3995 name entry info xref-hashtb idlist method nth4) | |
3996 (save-excursion | |
3997 (set-buffer gnus-group-buffer) | |
3998 (when (setq xref-hashtb | |
3999 (gnus-create-xref-hashtb from-newsgroup headers unreads)) | |
4000 (mapatoms | |
4001 (lambda (group) | |
4002 (unless (string= from-newsgroup (setq name (symbol-name group))) | |
4003 (setq idlist (symbol-value group)) | |
4004 ;; Dead groups are not updated. | |
4005 (and (prog1 | |
4006 (setq entry (gnus-gethash name gnus-newsrc-hashtb) | |
4007 info (nth 2 entry)) | |
4008 (when (stringp (setq nth4 (gnus-info-method info))) | |
4009 (setq nth4 (gnus-server-to-method nth4)))) | |
4010 ;; Only do the xrefs if the group has the same | |
4011 ;; select method as the group we have just read. | |
4012 (or (gnus-methods-equal-p | |
4013 nth4 (gnus-find-method-for-group from-newsgroup)) | |
4014 virtual | |
4015 (equal nth4 (setq method (gnus-find-method-for-group | |
4016 from-newsgroup))) | |
4017 (and (equal (car nth4) (car method)) | |
4018 (equal (nth 1 nth4) (nth 1 method)))) | |
4019 gnus-use-cross-reference | |
4020 (or (not (eq gnus-use-cross-reference t)) | |
4021 virtual | |
4022 ;; Only do cross-references on subscribed | |
4023 ;; groups, if that is what is wanted. | |
4024 (<= (gnus-info-level info) gnus-level-subscribed)) | |
4025 (gnus-group-make-articles-read name idlist)))) | |
4026 xref-hashtb))))) | |
4027 | |
4028 (defun gnus-group-make-articles-read (group articles) | |
4029 "Update the info of GROUP to say that ARTICLES are read." | |
4030 (let* ((num 0) | |
4031 (entry (gnus-gethash group gnus-newsrc-hashtb)) | |
4032 (info (nth 2 entry)) | |
4033 (active (gnus-active group)) | |
4034 range) | |
4035 ;; First peel off all illegal article numbers. | |
4036 (when active | |
4037 (let ((ids articles) | |
4038 id first) | |
4039 (while (setq id (pop ids)) | |
4040 (when (and first (> id (cdr active))) | |
4041 ;; We'll end up in this situation in one particular | |
4042 ;; obscure situation. If you re-scan a group and get | |
4043 ;; a new article that is cross-posted to a different | |
4044 ;; group that has not been re-scanned, you might get | |
4045 ;; crossposted article that has a higher number than | |
4046 ;; Gnus believes possible. So we re-activate this | |
4047 ;; group as well. This might mean doing the | |
4048 ;; crossposting thingy will *increase* the number | |
4049 ;; of articles in some groups. Tsk, tsk. | |
4050 (setq active (or (gnus-activate-group group) active))) | |
4051 (when (or (> id (cdr active)) | |
4052 (< id (car active))) | |
4053 (setq articles (delq id articles)))))) | |
4054 (save-excursion | |
4055 (set-buffer gnus-group-buffer) | |
4056 (gnus-undo-register | |
4057 `(progn | |
4058 (gnus-info-set-marks ',info ',(gnus-info-marks info) t) | |
4059 (gnus-info-set-read ',info ',(gnus-info-read info)) | |
4060 (gnus-get-unread-articles-in-group ',info (gnus-active ,group)) | |
4061 (gnus-group-update-group ,group t)))) | |
4062 ;; If the read list is nil, we init it. | |
4063 (and active | |
4064 (null (gnus-info-read info)) | |
4065 (> (car active) 1) | |
4066 (gnus-info-set-read info (cons 1 (1- (car active))))) | |
4067 ;; Then we add the read articles to the range. | |
4068 (gnus-info-set-read | |
4069 info | |
4070 (setq range | |
4071 (gnus-add-to-range | |
4072 (gnus-info-read info) (setq articles (sort articles '<))))) | |
4073 ;; Then we have to re-compute how many unread | |
4074 ;; articles there are in this group. | |
4075 (when active | |
4076 (cond | |
4077 ((not range) | |
4078 (setq num (- (1+ (cdr active)) (car active)))) | |
4079 ((not (listp (cdr range))) | |
4080 (setq num (- (cdr active) (- (1+ (cdr range)) | |
4081 (car range))))) | |
4082 (t | |
4083 (while range | |
4084 (if (numberp (car range)) | |
4085 (setq num (1+ num)) | |
4086 (setq num (+ num (- (1+ (cdar range)) (caar range))))) | |
4087 (setq range (cdr range))) | |
4088 (setq num (- (cdr active) num)))) | |
4089 ;; Update the number of unread articles. | |
4090 (setcar entry num) | |
4091 ;; Update the group buffer. | |
4092 (gnus-group-update-group group t)))) | |
4093 | |
4094 (defun gnus-methods-equal-p (m1 m2) | |
4095 (let ((m1 (or m1 gnus-select-method)) | |
4096 (m2 (or m2 gnus-select-method))) | |
4097 (or (equal m1 m2) | |
4098 (and (eq (car m1) (car m2)) | |
4099 (or (not (memq 'address (assoc (symbol-name (car m1)) | |
4100 gnus-valid-select-methods))) | |
4101 (equal (nth 1 m1) (nth 1 m2))))))) | |
4102 | |
4103 (defvar gnus-newsgroup-none-id 0) | |
4104 | |
4105 (defun gnus-get-newsgroup-headers (&optional dependencies force-new) | |
4106 (let ((cur nntp-server-buffer) | |
4107 (dependencies | |
4108 (or dependencies | |
4109 (save-excursion (set-buffer gnus-summary-buffer) | |
4110 gnus-newsgroup-dependencies))) | |
4111 headers id id-dep ref-dep end ref) | |
4112 (save-excursion | |
4113 (set-buffer nntp-server-buffer) | |
4114 ;; Translate all TAB characters into SPACE characters. | |
4115 (subst-char-in-region (point-min) (point-max) ?\t ? t) | |
4116 (run-hooks 'gnus-parse-headers-hook) | |
4117 (let ((case-fold-search t) | |
4118 in-reply-to header p lines) | |
4119 (goto-char (point-min)) | |
4120 ;; Search to the beginning of the next header. Error messages | |
4121 ;; do not begin with 2 or 3. | |
4122 (while (re-search-forward "^[23][0-9]+ " nil t) | |
4123 (setq id nil | |
4124 ref nil) | |
4125 ;; This implementation of this function, with nine | |
4126 ;; search-forwards instead of the one re-search-forward and | |
4127 ;; a case (which basically was the old function) is actually | |
4128 ;; about twice as fast, even though it looks messier. You | |
4129 ;; can't have everything, I guess. Speed and elegance | |
4130 ;; doesn't always go hand in hand. | |
4131 (setq | |
4132 header | |
4133 (vector | |
4134 ;; Number. | |
4135 (prog1 | |
4136 (read cur) | |
4137 (end-of-line) | |
4138 (setq p (point)) | |
4139 (narrow-to-region (point) | |
4140 (or (and (search-forward "\n.\n" nil t) | |
4141 (- (point) 2)) | |
4142 (point)))) | |
4143 ;; Subject. | |
4144 (progn | |
4145 (goto-char p) | |
4146 (if (search-forward "\nsubject: " nil t) | |
4147 (nnheader-header-value) "(none)")) | |
4148 ;; From. | |
4149 (progn | |
4150 (goto-char p) | |
4151 (if (search-forward "\nfrom: " nil t) | |
4152 (nnheader-header-value) "(nobody)")) | |
4153 ;; Date. | |
4154 (progn | |
4155 (goto-char p) | |
4156 (if (search-forward "\ndate: " nil t) | |
4157 (nnheader-header-value) "")) | |
4158 ;; Message-ID. | |
4159 (progn | |
4160 (goto-char p) | |
4161 (setq id (if (search-forward "\nmessage-id:" nil t) | |
4162 (buffer-substring | |
4163 (1- (or (search-forward "<" nil t) (point))) | |
4164 (or (search-forward ">" nil t) (point))) | |
4165 ;; If there was no message-id, we just fake one | |
4166 ;; to make subsequent routines simpler. | |
4167 (nnheader-generate-fake-message-id)))) | |
4168 ;; References. | |
4169 (progn | |
4170 (goto-char p) | |
4171 (if (search-forward "\nreferences: " nil t) | |
4172 (progn | |
4173 (setq end (point)) | |
4174 (prog1 | |
4175 (nnheader-header-value) | |
4176 (setq ref | |
4177 (buffer-substring | |
4178 (progn | |
4179 (end-of-line) | |
4180 (search-backward ">" end t) | |
4181 (1+ (point))) | |
4182 (progn | |
4183 (search-backward "<" end t) | |
4184 (point)))))) | |
4185 ;; Get the references from the in-reply-to header if there | |
4186 ;; were no references and the in-reply-to header looks | |
4187 ;; promising. | |
4188 (if (and (search-forward "\nin-reply-to: " nil t) | |
4189 (setq in-reply-to (nnheader-header-value)) | |
4190 (string-match "<[^>]+>" in-reply-to)) | |
4191 (setq ref (substring in-reply-to (match-beginning 0) | |
4192 (match-end 0))) | |
4193 (setq ref nil)))) | |
4194 ;; Chars. | |
4195 0 | |
4196 ;; Lines. | |
4197 (progn | |
4198 (goto-char p) | |
4199 (if (search-forward "\nlines: " nil t) | |
4200 (if (numberp (setq lines (read cur))) | |
4201 lines 0) | |
4202 0)) | |
4203 ;; Xref. | |
4204 (progn | |
4205 (goto-char p) | |
4206 (and (search-forward "\nxref: " nil t) | |
4207 (nnheader-header-value))))) | |
4208 (when (equal id ref) | |
4209 (setq ref nil)) | |
4210 ;; We do the threading while we read the headers. The | |
4211 ;; message-id and the last reference are both entered into | |
4212 ;; the same hash table. Some tippy-toeing around has to be | |
4213 ;; done in case an article has arrived before the article | |
4214 ;; which it refers to. | |
4215 (if (boundp (setq id-dep (intern id dependencies))) | |
4216 (if (and (car (symbol-value id-dep)) | |
4217 (not force-new)) | |
4218 ;; An article with this Message-ID has already been seen. | |
4219 (if gnus-summary-ignore-duplicates | |
4220 ;; We ignore this one, except we add | |
4221 ;; any additional Xrefs (in case the two articles | |
4222 ;; came from different servers). | |
4223 (progn | |
4224 (mail-header-set-xref | |
4225 (car (symbol-value id-dep)) | |
4226 (concat (or (mail-header-xref | |
4227 (car (symbol-value id-dep))) | |
4228 "") | |
4229 (or (mail-header-xref header) ""))) | |
4230 (setq header nil)) | |
4231 ;; We rename the Message-ID. | |
4232 (set | |
4233 (setq id-dep (intern (setq id (nnmail-message-id)) | |
4234 dependencies)) | |
4235 (list header)) | |
4236 (mail-header-set-id header id)) | |
4237 (setcar (symbol-value id-dep) header)) | |
4238 (set id-dep (list header))) | |
4239 (when header | |
4240 (if (boundp (setq ref-dep (intern (or ref "none") dependencies))) | |
4241 (setcdr (symbol-value ref-dep) | |
4242 (nconc (cdr (symbol-value ref-dep)) | |
4243 (list (symbol-value id-dep)))) | |
4244 (set ref-dep (list nil (symbol-value id-dep)))) | |
4245 (push header headers)) | |
4246 (goto-char (point-max)) | |
4247 (widen)) | |
4248 (nreverse headers))))) | |
4249 | |
4250 ;; The following macros and functions were written by Felix Lee | |
4251 ;; <flee@cse.psu.edu>. | |
4252 | |
4253 (defmacro gnus-nov-read-integer () | |
4254 '(prog1 | |
4255 (if (= (following-char) ?\t) | |
4256 0 | |
4257 (let ((num (ignore-errors (read buffer)))) | |
4258 (if (numberp num) num 0))) | |
4259 (unless (eobp) | |
4260 (forward-char 1)))) | |
4261 | |
4262 (defmacro gnus-nov-skip-field () | |
4263 '(search-forward "\t" eol 'move)) | |
4264 | |
4265 (defmacro gnus-nov-field () | |
4266 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol))) | |
4267 | |
4268 ;; (defvar gnus-nov-none-counter 0) | |
4269 | |
4270 ;; This function has to be called with point after the article number | |
4271 ;; on the beginning of the line. | |
4272 (defun gnus-nov-parse-line (number dependencies &optional force-new) | |
4273 (let ((eol (gnus-point-at-eol)) | |
4274 (buffer (current-buffer)) | |
4275 header ref id id-dep ref-dep) | |
4276 | |
4277 ;; overview: [num subject from date id refs chars lines misc] | |
4278 (unwind-protect | |
4279 (progn | |
4280 (narrow-to-region (point) eol) | |
4281 (unless (eobp) | |
4282 (forward-char)) | |
4283 | |
4284 (setq header | |
4285 (vector | |
4286 number ; number | |
4287 (gnus-nov-field) ; subject | |
4288 (gnus-nov-field) ; from | |
4289 (gnus-nov-field) ; date | |
4290 (setq id (or (gnus-nov-field) | |
4291 (nnheader-generate-fake-message-id))) ; id | |
4292 (progn | |
4293 (let ((beg (point))) | |
4294 (search-forward "\t" eol) | |
4295 (if (search-backward ">" beg t) | |
4296 (setq ref | |
4297 (buffer-substring | |
4298 (1+ (point)) | |
4299 (search-backward "<" beg t))) | |
4300 (setq ref nil)) | |
4301 (goto-char beg)) | |
4302 (gnus-nov-field)) ; refs | |
4303 (gnus-nov-read-integer) ; chars | |
4304 (gnus-nov-read-integer) ; lines | |
4305 (if (= (following-char) ?\n) | |
4306 nil | |
4307 (gnus-nov-field))))) ; misc | |
4308 | |
4309 (widen)) | |
4310 | |
4311 ;; We build the thread tree. | |
4312 (when (equal id ref) | |
4313 ;; This article refers back to itself. Naughty, naughty. | |
4314 (setq ref nil)) | |
4315 (if (boundp (setq id-dep (intern id dependencies))) | |
4316 (if (and (car (symbol-value id-dep)) | |
4317 (not force-new)) | |
4318 ;; An article with this Message-ID has already been seen. | |
4319 (if gnus-summary-ignore-duplicates | |
4320 ;; We ignore this one, except we add any additional | |
4321 ;; Xrefs (in case the two articles came from different | |
4322 ;; servers. | |
4323 (progn | |
4324 (mail-header-set-xref | |
4325 (car (symbol-value id-dep)) | |
4326 (concat (or (mail-header-xref | |
4327 (car (symbol-value id-dep))) | |
4328 "") | |
4329 (or (mail-header-xref header) ""))) | |
4330 (setq header nil)) | |
4331 ;; We rename the Message-ID. | |
4332 (set | |
4333 (setq id-dep (intern (setq id (nnmail-message-id)) | |
4334 dependencies)) | |
4335 (list header)) | |
4336 (mail-header-set-id header id)) | |
4337 (setcar (symbol-value id-dep) header)) | |
4338 (set id-dep (list header))) | |
4339 (when header | |
4340 (if (boundp (setq ref-dep (intern (or ref "none") dependencies))) | |
4341 (setcdr (symbol-value ref-dep) | |
4342 (nconc (cdr (symbol-value ref-dep)) | |
4343 (list (symbol-value id-dep)))) | |
4344 (set ref-dep (list nil (symbol-value id-dep))))) | |
4345 header)) | |
4346 | |
4347 ;; Goes through the xover lines and returns a list of vectors | |
4348 (defun gnus-get-newsgroup-headers-xover (sequence &optional | |
4349 force-new dependencies | |
4350 group also-fetch-heads) | |
4351 "Parse the news overview data in the server buffer, and return a | |
4352 list of headers that match SEQUENCE (see `nntp-retrieve-headers')." | |
4353 ;; Get the Xref when the users reads the articles since most/some | |
4354 ;; NNTP servers do not include Xrefs when using XOVER. | |
4355 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs)) | |
4356 (let ((cur nntp-server-buffer) | |
4357 (dependencies (or dependencies gnus-newsgroup-dependencies)) | |
4358 number headers header) | |
4359 (save-excursion | |
4360 (set-buffer nntp-server-buffer) | |
4361 ;; Allow the user to mangle the headers before parsing them. | |
4362 (run-hooks 'gnus-parse-headers-hook) | |
4363 (goto-char (point-min)) | |
4364 (while (not (eobp)) | |
4365 (condition-case () | |
4366 (while (and sequence (not (eobp))) | |
4367 (setq number (read cur)) | |
4368 (while (and sequence | |
4369 (< (car sequence) number)) | |
4370 (setq sequence (cdr sequence))) | |
4371 (and sequence | |
4372 (eq number (car sequence)) | |
4373 (progn | |
4374 (setq sequence (cdr sequence)) | |
4375 (setq header (inline | |
4376 (gnus-nov-parse-line | |
4377 number dependencies force-new)))) | |
4378 (push header headers)) | |
4379 (forward-line 1)) | |
4380 (error | |
4381 (gnus-error 4 "Strange nov line (%d)" | |
4382 (count-lines (point-min) (point))))) | |
4383 (forward-line 1)) | |
4384 ;; A common bug in inn is that if you have posted an article and | |
4385 ;; then retrieves the active file, it will answer correctly -- | |
4386 ;; the new article is included. However, a NOV entry for the | |
4387 ;; article may not have been generated yet, so this may fail. | |
4388 ;; We work around this problem by retrieving the last few | |
4389 ;; headers using HEAD. | |
4390 (if (or (not also-fetch-heads) | |
4391 (not sequence)) | |
4392 ;; We (probably) got all the headers. | |
4393 (nreverse headers) | |
4394 (let ((gnus-nov-is-evil t)) | |
4395 (nconc | |
4396 (nreverse headers) | |
4397 (when (gnus-retrieve-headers sequence group) | |
4398 (gnus-get-newsgroup-headers)))))))) | |
4399 | |
4400 (defun gnus-article-get-xrefs () | |
4401 "Fill in the Xref value in `gnus-current-headers', if necessary. | |
4402 This is meant to be called in `gnus-article-internal-prepare-hook'." | |
4403 (let ((headers (save-excursion (set-buffer gnus-summary-buffer) | |
4404 gnus-current-headers))) | |
4405 (or (not gnus-use-cross-reference) | |
4406 (not headers) | |
4407 (and (mail-header-xref headers) | |
4408 (not (string= (mail-header-xref headers) ""))) | |
4409 (let ((case-fold-search t) | |
4410 xref) | |
4411 (save-restriction | |
4412 (nnheader-narrow-to-headers) | |
4413 (goto-char (point-min)) | |
4414 (when (or (and (eq (downcase (following-char)) ?x) | |
4415 (looking-at "Xref:")) | |
4416 (search-forward "\nXref:" nil t)) | |
4417 (goto-char (1+ (match-end 0))) | |
4418 (setq xref (buffer-substring (point) | |
4419 (progn (end-of-line) (point)))) | |
4420 (mail-header-set-xref headers xref))))))) | |
4421 | |
4422 (defun gnus-summary-insert-subject (id &optional old-header use-old-header) | |
4423 "Find article ID and insert the summary line for that article." | |
4424 (let ((header (if (and old-header use-old-header) | |
4425 old-header (gnus-read-header id))) | |
4426 (number (and (numberp id) id)) | |
4427 pos d) | |
4428 (when header | |
4429 ;; Rebuild the thread that this article is part of and go to the | |
4430 ;; article we have fetched. | |
4431 (when (and (not gnus-show-threads) | |
4432 old-header) | |
4433 (when (setq d (gnus-data-find (mail-header-number old-header))) | |
4434 (goto-char (gnus-data-pos d)) | |
4435 (gnus-data-remove | |
4436 number | |
4437 (- (gnus-point-at-bol) | |
4438 (prog1 | |
4439 (1+ (gnus-point-at-eol)) | |
4440 (gnus-delete-line)))))) | |
4441 (when old-header | |
4442 (mail-header-set-number header (mail-header-number old-header))) | |
4443 (setq gnus-newsgroup-sparse | |
4444 (delq (setq number (mail-header-number header)) | |
4445 gnus-newsgroup-sparse)) | |
4446 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient)) | |
4447 (gnus-rebuild-thread (mail-header-id header)) | |
4448 (gnus-summary-goto-subject number nil t)) | |
4449 (when (and (numberp number) | |
4450 (> number 0)) | |
4451 ;; We have to update the boundaries even if we can't fetch the | |
4452 ;; article if ID is a number -- so that the next `P' or `N' | |
4453 ;; command will fetch the previous (or next) article even | |
4454 ;; if the one we tried to fetch this time has been canceled. | |
4455 (when (> number gnus-newsgroup-end) | |
4456 (setq gnus-newsgroup-end number)) | |
4457 (when (< number gnus-newsgroup-begin) | |
4458 (setq gnus-newsgroup-begin number)) | |
4459 (setq gnus-newsgroup-unselected | |
4460 (delq number gnus-newsgroup-unselected))) | |
4461 ;; Report back a success? | |
4462 (and header (mail-header-number header)))) | |
4463 | |
4464 ;;; Process/prefix in the summary buffer | |
4465 | |
4466 (defun gnus-summary-work-articles (n) | |
4467 "Return a list of articles to be worked upon. The prefix argument, | |
4468 the list of process marked articles, and the current article will be | |
4469 taken into consideration." | |
4470 (cond | |
4471 (n | |
4472 ;; A numerical prefix has been given. | |
4473 (setq n (prefix-numeric-value n)) | |
4474 (let ((backward (< n 0)) | |
4475 (n (abs (prefix-numeric-value n))) | |
4476 articles article) | |
4477 (save-excursion | |
4478 (while | |
4479 (and (> n 0) | |
4480 (push (setq article (gnus-summary-article-number)) | |
4481 articles) | |
4482 (if backward | |
4483 (gnus-summary-find-prev nil article) | |
4484 (gnus-summary-find-next nil article))) | |
4485 (decf n))) | |
4486 (nreverse articles))) | |
4487 ((gnus-region-active-p) | |
4488 ;; Work on the region between point and mark. | |
4489 (let ((max (max (point) (mark))) | |
4490 articles article) | |
4491 (save-excursion | |
4492 (goto-char (min (point) (mark))) | |
4493 (while | |
4494 (and | |
4495 (push (setq article (gnus-summary-article-number)) articles) | |
4496 (gnus-summary-find-next nil article) | |
4497 (< (point) max))) | |
4498 (nreverse articles)))) | |
4499 (gnus-newsgroup-processable | |
4500 ;; There are process-marked articles present. | |
4501 ;; Save current state. | |
4502 (gnus-summary-save-process-mark) | |
4503 ;; Return the list. | |
4504 (reverse gnus-newsgroup-processable)) | |
4505 (t | |
4506 ;; Just return the current article. | |
4507 (list (gnus-summary-article-number))))) | |
4508 | |
4509 (defun gnus-summary-save-process-mark () | |
4510 "Push the current set of process marked articles on the stack." | |
4511 (interactive) | |
4512 (push (copy-sequence gnus-newsgroup-processable) | |
4513 gnus-newsgroup-process-stack)) | |
4514 | |
4515 (defun gnus-summary-kill-process-mark () | |
4516 "Push the current set of process marked articles on the stack and unmark." | |
4517 (interactive) | |
4518 (gnus-summary-save-process-mark) | |
4519 (gnus-summary-unmark-all-processable)) | |
4520 | |
4521 (defun gnus-summary-yank-process-mark () | |
4522 "Pop the last process mark state off the stack and restore it." | |
4523 (interactive) | |
4524 (unless gnus-newsgroup-process-stack | |
4525 (error "Empty mark stack")) | |
4526 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack))) | |
4527 | |
4528 (defun gnus-summary-process-mark-set (set) | |
4529 "Make SET into the current process marked articles." | |
4530 (gnus-summary-unmark-all-processable) | |
4531 (while set | |
4532 (gnus-summary-set-process-mark (pop set)))) | |
4533 | |
4534 ;;; Searching and stuff | |
4535 | |
4536 (defun gnus-summary-search-group (&optional backward use-level) | |
4537 "Search for next unread newsgroup. | |
4538 If optional argument BACKWARD is non-nil, search backward instead." | |
4539 (save-excursion | |
4540 (set-buffer gnus-group-buffer) | |
4541 (when (gnus-group-search-forward | |
4542 backward nil (if use-level (gnus-group-group-level) nil)) | |
4543 (gnus-group-group-name)))) | |
4544 | |
4545 (defun gnus-summary-best-group (&optional exclude-group) | |
4546 "Find the name of the best unread group. | |
4547 If EXCLUDE-GROUP, do not go to this group." | |
4548 (save-excursion | |
4549 (set-buffer gnus-group-buffer) | |
4550 (save-excursion | |
4551 (gnus-group-best-unread-group exclude-group)))) | |
4552 | |
4553 (defun gnus-summary-find-next (&optional unread article backward) | |
4554 (if backward (gnus-summary-find-prev) | |
4555 (let* ((dummy (gnus-summary-article-intangible-p)) | |
4556 (article (or article (gnus-summary-article-number))) | |
4557 (arts (gnus-data-find-list article)) | |
4558 result) | |
4559 (when (and (not dummy) | |
4560 (or (not gnus-summary-check-current) | |
4561 (not unread) | |
4562 (not (gnus-data-unread-p (car arts))))) | |
4563 (setq arts (cdr arts))) | |
4564 (when (setq result | |
4565 (if unread | |
4566 (progn | |
4567 (while arts | |
4568 (when (gnus-data-unread-p (car arts)) | |
4569 (setq result (car arts) | |
4570 arts nil)) | |
4571 (setq arts (cdr arts))) | |
4572 result) | |
4573 (car arts))) | |
4574 (goto-char (gnus-data-pos result)) | |
4575 (gnus-data-number result))))) | |
4576 | |
4577 (defun gnus-summary-find-prev (&optional unread article) | |
4578 (let* ((eobp (eobp)) | |
4579 (article (or article (gnus-summary-article-number))) | |
4580 (arts (gnus-data-find-list article (gnus-data-list 'rev))) | |
4581 result) | |
4582 (when (and (not eobp) | |
4583 (or (not gnus-summary-check-current) | |
4584 (not unread) | |
4585 (not (gnus-data-unread-p (car arts))))) | |
4586 (setq arts (cdr arts))) | |
4587 (when (setq result | |
4588 (if unread | |
4589 (progn | |
4590 (while arts | |
4591 (when (gnus-data-unread-p (car arts)) | |
4592 (setq result (car arts) | |
4593 arts nil)) | |
4594 (setq arts (cdr arts))) | |
4595 result) | |
4596 (car arts))) | |
4597 (goto-char (gnus-data-pos result)) | |
4598 (gnus-data-number result)))) | |
4599 | |
4600 (defun gnus-summary-find-subject (subject &optional unread backward article) | |
4601 (let* ((simp-subject (gnus-simplify-subject-fully subject)) | |
4602 (article (or article (gnus-summary-article-number))) | |
4603 (articles (gnus-data-list backward)) | |
4604 (arts (gnus-data-find-list article articles)) | |
4605 result) | |
4606 (when (or (not gnus-summary-check-current) | |
4607 (not unread) | |
4608 (not (gnus-data-unread-p (car arts)))) | |
4609 (setq arts (cdr arts))) | |
4610 (while arts | |
4611 (and (or (not unread) | |
4612 (gnus-data-unread-p (car arts))) | |
4613 (vectorp (gnus-data-header (car arts))) | |
4614 (gnus-subject-equal | |
4615 simp-subject (mail-header-subject (gnus-data-header (car arts))) t) | |
4616 (setq result (car arts) | |
4617 arts nil)) | |
4618 (setq arts (cdr arts))) | |
4619 (and result | |
4620 (goto-char (gnus-data-pos result)) | |
4621 (gnus-data-number result)))) | |
4622 | |
4623 (defun gnus-summary-search-forward (&optional unread subject backward) | |
4624 "Search forward for an article. | |
4625 If UNREAD, look for unread articles. If SUBJECT, look for | |
4626 articles with that subject. If BACKWARD, search backward instead." | |
4627 (cond (subject (gnus-summary-find-subject subject unread backward)) | |
4628 (backward (gnus-summary-find-prev unread)) | |
4629 (t (gnus-summary-find-next unread)))) | |
4630 | |
4631 (defun gnus-recenter (&optional n) | |
4632 "Center point in window and redisplay frame. | |
4633 Also do horizontal recentering." | |
4634 (interactive "P") | |
4635 (when (and gnus-auto-center-summary | |
4636 (not (eq gnus-auto-center-summary 'vertical))) | |
4637 (gnus-horizontal-recenter)) | |
4638 (recenter n)) | |
4639 | |
4640 (defun gnus-summary-recenter () | |
4641 "Center point in the summary window. | |
4642 If `gnus-auto-center-summary' is nil, or the article buffer isn't | |
4643 displayed, no centering will be performed." | |
4644 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle). | |
4645 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu. | |
4646 (let* ((top (cond ((< (window-height) 4) 0) | |
4647 ((< (window-height) 7) 1) | |
4648 (t 2))) | |
4649 (height (1- (window-height))) | |
4650 (bottom (save-excursion (goto-char (point-max)) | |
4651 (forward-line (- height)) | |
4652 (point))) | |
4653 (window (get-buffer-window (current-buffer)))) | |
4654 ;; The user has to want it. | |
4655 (when gnus-auto-center-summary | |
4656 (when (get-buffer-window gnus-article-buffer) | |
4657 ;; Only do recentering when the article buffer is displayed, | |
4658 ;; Set the window start to either `bottom', which is the biggest | |
4659 ;; possible valid number, or the second line from the top, | |
4660 ;; whichever is the least. | |
4661 (set-window-start | |
4662 window (min bottom (save-excursion | |
4663 (forward-line (- top)) (point))))) | |
4664 ;; Do horizontal recentering while we're at it. | |
4665 (when (and (get-buffer-window (current-buffer) t) | |
4666 (not (eq gnus-auto-center-summary 'vertical))) | |
4667 (let ((selected (selected-window))) | |
4668 (select-window (get-buffer-window (current-buffer) t)) | |
4669 (gnus-summary-position-point) | |
4670 (gnus-horizontal-recenter) | |
4671 (select-window selected)))))) | |
4672 | |
4673 (defun gnus-summary-jump-to-group (newsgroup) | |
4674 "Move point to NEWSGROUP in group mode buffer." | |
4675 ;; Keep update point of group mode buffer if visible. | |
4676 (if (eq (current-buffer) (get-buffer gnus-group-buffer)) | |
4677 (save-window-excursion | |
4678 ;; Take care of tree window mode. | |
4679 (when (get-buffer-window gnus-group-buffer) | |
4680 (pop-to-buffer gnus-group-buffer)) | |
4681 (gnus-group-jump-to-group newsgroup)) | |
4682 (save-excursion | |
4683 ;; Take care of tree window mode. | |
4684 (if (get-buffer-window gnus-group-buffer) | |
4685 (pop-to-buffer gnus-group-buffer) | |
4686 (set-buffer gnus-group-buffer)) | |
4687 (gnus-group-jump-to-group newsgroup)))) | |
4688 | |
4689 ;; This function returns a list of article numbers based on the | |
4690 ;; difference between the ranges of read articles in this group and | |
4691 ;; the range of active articles. | |
4692 (defun gnus-list-of-unread-articles (group) | |
4693 (let* ((read (gnus-info-read (gnus-get-info group))) | |
4694 (active (or (gnus-active group) (gnus-activate-group group))) | |
4695 (last (cdr active)) | |
4696 first nlast unread) | |
4697 ;; If none are read, then all are unread. | |
4698 (if (not read) | |
4699 (setq first (car active)) | |
4700 ;; If the range of read articles is a single range, then the | |
4701 ;; first unread article is the article after the last read | |
4702 ;; article. Sounds logical, doesn't it? | |
4703 (if (not (listp (cdr read))) | |
4704 (setq first (1+ (cdr read))) | |
4705 ;; `read' is a list of ranges. | |
4706 (when (/= (setq nlast (or (and (numberp (car read)) (car read)) | |
4707 (caar read))) | |
4708 1) | |
4709 (setq first 1)) | |
4710 (while read | |
4711 (when first | |
4712 (while (< first nlast) | |
4713 (push first unread) | |
4714 (setq first (1+ first)))) | |
4715 (setq first (1+ (if (atom (car read)) (car read) (cdar read)))) | |
4716 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read))) | |
4717 (setq read (cdr read))))) | |
4718 ;; And add the last unread articles. | |
4719 (while (<= first last) | |
4720 (push first unread) | |
4721 (setq first (1+ first))) | |
4722 ;; Return the list of unread articles. | |
4723 (nreverse unread))) | |
4724 | |
4725 (defun gnus-list-of-read-articles (group) | |
4726 "Return a list of unread, unticked and non-dormant articles." | |
4727 (let* ((info (gnus-get-info group)) | |
4728 (marked (gnus-info-marks info)) | |
4729 (active (gnus-active group))) | |
4730 (and info active | |
4731 (gnus-set-difference | |
4732 (gnus-sorted-complement | |
4733 (gnus-uncompress-range active) | |
4734 (gnus-list-of-unread-articles group)) | |
4735 (append | |
4736 (gnus-uncompress-range (cdr (assq 'dormant marked))) | |
4737 (gnus-uncompress-range (cdr (assq 'tick marked)))))))) | |
4738 | |
4739 ;; Various summary commands | |
4740 | |
4741 (defun gnus-summary-universal-argument (arg) | |
4742 "Perform any operation on all articles that are process/prefixed." | |
4743 (interactive "P") | |
4744 (gnus-set-global-variables) | |
4745 (let ((articles (gnus-summary-work-articles arg)) | |
4746 func article) | |
4747 (if (eq | |
4748 (setq | |
4749 func | |
4750 (key-binding | |
4751 (read-key-sequence | |
4752 (substitute-command-keys | |
4753 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]" | |
4754 )))) | |
4755 'undefined) | |
4756 (gnus-error 1 "Undefined key") | |
4757 (save-excursion | |
4758 (while articles | |
4759 (gnus-summary-goto-subject (setq article (pop articles))) | |
4760 (let (gnus-newsgroup-processable) | |
4761 (command-execute func)) | |
4762 (gnus-summary-remove-process-mark article))))) | |
4763 (gnus-summary-position-point)) | |
4764 | |
4765 (defun gnus-summary-toggle-truncation (&optional arg) | |
4766 "Toggle truncation of summary lines. | |
4767 With arg, turn line truncation on iff arg is positive." | |
4768 (interactive "P") | |
4769 (setq truncate-lines | |
4770 (if (null arg) (not truncate-lines) | |
4771 (> (prefix-numeric-value arg) 0))) | |
4772 (redraw-display)) | |
4773 | |
4774 (defun gnus-summary-reselect-current-group (&optional all rescan) | |
4775 "Exit and then reselect the current newsgroup. | |
4776 The prefix argument ALL means to select all articles." | |
4777 (interactive "P") | |
4778 (gnus-set-global-variables) | |
4779 (when (gnus-ephemeral-group-p gnus-newsgroup-name) | |
4780 (error "Ephemeral groups can't be reselected")) | |
4781 (let ((current-subject (gnus-summary-article-number)) | |
4782 (group gnus-newsgroup-name)) | |
4783 (setq gnus-newsgroup-begin nil) | |
4784 (gnus-summary-exit) | |
4785 ;; We have to adjust the point of group mode buffer because | |
4786 ;; point was moved to the next unread newsgroup by exiting. | |
4787 (gnus-summary-jump-to-group group) | |
4788 (when rescan | |
4789 (save-excursion | |
4790 (gnus-group-get-new-news-this-group 1))) | |
4791 (gnus-group-read-group all t) | |
4792 (gnus-summary-goto-subject current-subject nil t))) | |
4793 | |
4794 (defun gnus-summary-rescan-group (&optional all) | |
4795 "Exit the newsgroup, ask for new articles, and select the newsgroup." | |
4796 (interactive "P") | |
4797 (gnus-summary-reselect-current-group all t)) | |
4798 | |
4799 (defun gnus-summary-update-info (&optional non-destructive) | |
4800 (save-excursion | |
4801 (let ((group gnus-newsgroup-name)) | |
4802 (when gnus-newsgroup-kill-headers | |
4803 (setq gnus-newsgroup-killed | |
4804 (gnus-compress-sequence | |
4805 (nconc | |
4806 (gnus-set-sorted-intersection | |
4807 (gnus-uncompress-range gnus-newsgroup-killed) | |
4808 (setq gnus-newsgroup-unselected | |
4809 (sort gnus-newsgroup-unselected '<))) | |
4810 (setq gnus-newsgroup-unreads | |
4811 (sort gnus-newsgroup-unreads '<))) | |
4812 t))) | |
4813 (unless (listp (cdr gnus-newsgroup-killed)) | |
4814 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed))) | |
4815 (let ((headers gnus-newsgroup-headers)) | |
4816 (when (and (not gnus-save-score) | |
4817 (not non-destructive)) | |
4818 (setq gnus-newsgroup-scored nil)) | |
4819 ;; Set the new ranges of read articles. | |
4820 (gnus-update-read-articles | |
4821 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected)) | |
4822 ;; Set the current article marks. | |
4823 (gnus-update-marks) | |
4824 ;; Do the cross-ref thing. | |
4825 (when gnus-use-cross-reference | |
4826 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads)) | |
4827 ;; Do adaptive scoring, and possibly save score files. | |
4828 (when gnus-newsgroup-adaptive | |
4829 (gnus-score-adaptive)) | |
4830 (when gnus-use-scoring | |
4831 (gnus-score-save)) | |
4832 ;; Do not switch windows but change the buffer to work. | |
4833 (set-buffer gnus-group-buffer) | |
4834 (unless (gnus-ephemeral-group-p gnus-newsgroup-name) | |
4835 (gnus-group-update-group group)))))) | |
4836 | |
4837 (defun gnus-summary-save-newsrc (&optional force) | |
4838 "Save the current number of read/marked articles in the dribble buffer. | |
4839 The dribble buffer will then be saved. | |
4840 If FORCE (the prefix), also save the .newsrc file(s)." | |
4841 (interactive "P") | |
4842 (gnus-summary-update-info t) | |
4843 (if force | |
4844 (gnus-save-newsrc-file) | |
4845 (gnus-dribble-save))) | |
4846 | |
4847 (defun gnus-summary-exit (&optional temporary) | |
4848 "Exit reading current newsgroup, and then return to group selection mode. | |
4849 gnus-exit-group-hook is called with no arguments if that value is non-nil." | |
4850 (interactive) | |
4851 (gnus-set-global-variables) | |
4852 (gnus-kill-save-kill-buffer) | |
4853 (let* ((group gnus-newsgroup-name) | |
4854 (quit-config (gnus-group-quit-config gnus-newsgroup-name)) | |
4855 (mode major-mode) | |
4856 (buf (current-buffer))) | |
4857 (run-hooks 'gnus-summary-prepare-exit-hook) | |
4858 ;; If we have several article buffers, we kill them at exit. | |
4859 (unless gnus-single-article-buffer | |
4860 (gnus-kill-buffer gnus-original-article-buffer) | |
4861 (setq gnus-article-current nil)) | |
4862 (when gnus-use-cache | |
4863 (gnus-cache-possibly-remove-articles) | |
4864 (gnus-cache-save-buffers)) | |
4865 (gnus-async-prefetch-remove-group group) | |
4866 (when gnus-suppress-duplicates | |
4867 (gnus-dup-enter-articles)) | |
4868 (when gnus-use-trees | |
4869 (gnus-tree-close group)) | |
4870 ;; Make all changes in this group permanent. | |
4871 (unless quit-config | |
4872 (run-hooks 'gnus-exit-group-hook) | |
4873 (gnus-summary-update-info)) | |
4874 (gnus-close-group group) | |
4875 ;; Make sure where we were, and go to next newsgroup. | |
4876 (set-buffer gnus-group-buffer) | |
4877 (unless quit-config | |
4878 (gnus-group-jump-to-group group)) | |
4879 (run-hooks 'gnus-summary-exit-hook) | |
4880 (unless quit-config | |
4881 (gnus-group-next-unread-group 1)) | |
4882 (if temporary | |
4883 nil ;Nothing to do. | |
4884 ;; If we have several article buffers, we kill them at exit. | |
4885 (unless gnus-single-article-buffer | |
4886 (gnus-kill-buffer gnus-article-buffer) | |
4887 (gnus-kill-buffer gnus-original-article-buffer) | |
4888 (setq gnus-article-current nil)) | |
4889 (set-buffer buf) | |
4890 (if (not gnus-kill-summary-on-exit) | |
4891 (gnus-deaden-summary) | |
4892 ;; We set all buffer-local variables to nil. It is unclear why | |
4893 ;; this is needed, but if we don't, buffer-local variables are | |
4894 ;; not garbage-collected, it seems. This would the lead to en | |
4895 ;; ever-growing Emacs. | |
4896 (gnus-summary-clear-local-variables) | |
4897 (when (get-buffer gnus-article-buffer) | |
4898 (bury-buffer gnus-article-buffer)) | |
4899 ;; We clear the global counterparts of the buffer-local | |
4900 ;; variables as well, just to be on the safe side. | |
4901 (set-buffer gnus-group-buffer) | |
4902 (gnus-summary-clear-local-variables) | |
4903 ;; Return to group mode buffer. | |
4904 (when (eq mode 'gnus-summary-mode) | |
4905 (gnus-kill-buffer buf))) | |
4906 (setq gnus-current-select-method gnus-select-method) | |
4907 (pop-to-buffer gnus-group-buffer) | |
4908 ;; Clear the current group name. | |
4909 (if (not quit-config) | |
4910 (progn | |
4911 (gnus-group-jump-to-group group) | |
4912 (gnus-group-next-unread-group 1) | |
4913 (gnus-configure-windows 'group 'force)) | |
4914 (gnus-handle-ephemeral-exit quit-config)) | |
4915 (unless quit-config | |
4916 (setq gnus-newsgroup-name nil))))) | |
4917 | |
4918 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update) | |
4919 (defun gnus-summary-exit-no-update (&optional no-questions) | |
4920 "Quit reading current newsgroup without updating read article info." | |
4921 (interactive) | |
4922 (gnus-set-global-variables) | |
4923 (let* ((group gnus-newsgroup-name) | |
4924 (quit-config (gnus-group-quit-config group))) | |
4925 (when (or no-questions | |
4926 gnus-expert-user | |
4927 (gnus-y-or-n-p "Discard changes to this group and exit? ")) | |
4928 ;; If we have several article buffers, we kill them at exit. | |
4929 (unless gnus-single-article-buffer | |
4930 (gnus-kill-buffer gnus-article-buffer) | |
4931 (gnus-kill-buffer gnus-original-article-buffer) | |
4932 (setq gnus-article-current nil)) | |
4933 (if (not gnus-kill-summary-on-exit) | |
4934 (gnus-deaden-summary) | |
4935 (gnus-close-group group) | |
4936 (gnus-summary-clear-local-variables) | |
4937 (set-buffer gnus-group-buffer) | |
4938 (gnus-summary-clear-local-variables) | |
4939 (when (get-buffer gnus-summary-buffer) | |
4940 (kill-buffer gnus-summary-buffer))) | |
4941 (unless gnus-single-article-buffer | |
4942 (setq gnus-article-current nil)) | |
4943 (when gnus-use-trees | |
4944 (gnus-tree-close group)) | |
4945 (gnus-async-prefetch-remove-group group) | |
4946 (when (get-buffer gnus-article-buffer) | |
4947 (bury-buffer gnus-article-buffer)) | |
4948 ;; Return to the group buffer. | |
4949 (gnus-configure-windows 'group 'force) | |
4950 ;; Clear the current group name. | |
4951 (setq gnus-newsgroup-name nil) | |
4952 (when (equal (gnus-group-group-name) group) | |
4953 (gnus-group-next-unread-group 1)) | |
4954 (when quit-config | |
4955 (gnus-handle-ephemeral-exit quit-config))))) | |
4956 | |
4957 (defun gnus-handle-ephemeral-exit (quit-config) | |
4958 "Handle movement when leaving an ephemeral group. The state | |
4959 which existed when entering the ephemeral is reset." | |
4960 (if (not (buffer-name (car quit-config))) | |
4961 (gnus-configure-windows 'group 'force) | |
4962 (set-buffer (car quit-config)) | |
4963 (cond ((eq major-mode 'gnus-summary-mode) | |
4964 (gnus-set-global-variables)) | |
4965 ((eq major-mode 'gnus-article-mode) | |
4966 (save-excursion | |
4967 ;; The `gnus-summary-buffer' variable may point | |
4968 ;; to the old summary buffer when using a single | |
4969 ;; article buffer. | |
4970 (unless (gnus-buffer-live-p gnus-summary-buffer) | |
4971 (set-buffer gnus-group-buffer)) | |
4972 (set-buffer gnus-summary-buffer) | |
4973 (gnus-set-global-variables)))) | |
4974 (if (or (eq (cdr quit-config) 'article) | |
4975 (eq (cdr quit-config) 'pick)) | |
4976 (progn | |
4977 ;; The current article may be from the ephemeral group | |
4978 ;; thus it is best that we reload this article | |
4979 (gnus-summary-show-article) | |
4980 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode)) | |
4981 (gnus-configure-windows 'pick 'force) | |
4982 (gnus-configure-windows (cdr quit-config) 'force))) | |
4983 (gnus-configure-windows (cdr quit-config) 'force)) | |
4984 (when (eq major-mode 'gnus-summary-mode) | |
4985 (gnus-summary-next-subject 1 nil t) | |
4986 (gnus-summary-recenter) | |
4987 (gnus-summary-position-point)))) | |
4988 | |
4989 ;;; Dead summaries. | |
4990 | |
4991 (defvar gnus-dead-summary-mode-map nil) | |
4992 | |
4993 (unless gnus-dead-summary-mode-map | |
4994 (setq gnus-dead-summary-mode-map (make-keymap)) | |
4995 (suppress-keymap gnus-dead-summary-mode-map) | |
4996 (substitute-key-definition | |
4997 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map) | |
4998 (let ((keys '("\C-d" "\r" "\177"))) | |
4999 (while keys | |
5000 (define-key gnus-dead-summary-mode-map | |
5001 (pop keys) 'gnus-summary-wake-up-the-dead)))) | |
5002 | |
5003 (defvar gnus-dead-summary-mode nil | |
5004 "Minor mode for Gnus summary buffers.") | |
5005 | |
5006 (defun gnus-dead-summary-mode (&optional arg) | |
5007 "Minor mode for Gnus summary buffers." | |
5008 (interactive "P") | |
5009 (when (eq major-mode 'gnus-summary-mode) | |
5010 (make-local-variable 'gnus-dead-summary-mode) | |
5011 (setq gnus-dead-summary-mode | |
5012 (if (null arg) (not gnus-dead-summary-mode) | |
5013 (> (prefix-numeric-value arg) 0))) | |
5014 (when gnus-dead-summary-mode | |
5015 (unless (assq 'gnus-dead-summary-mode minor-mode-alist) | |
5016 (push '(gnus-dead-summary-mode " Dead") minor-mode-alist)) | |
5017 (unless (assq 'gnus-dead-summary-mode minor-mode-map-alist) | |
5018 (push (cons 'gnus-dead-summary-mode gnus-dead-summary-mode-map) | |
5019 minor-mode-map-alist))))) | |
5020 | |
5021 (defun gnus-deaden-summary () | |
5022 "Make the current summary buffer into a dead summary buffer." | |
5023 ;; Kill any previous dead summary buffer. | |
5024 (when (and gnus-dead-summary | |
5025 (buffer-name gnus-dead-summary)) | |
5026 (save-excursion | |
5027 (set-buffer gnus-dead-summary) | |
5028 (when gnus-dead-summary-mode | |
5029 (kill-buffer (current-buffer))))) | |
5030 ;; Make this the current dead summary. | |
5031 (setq gnus-dead-summary (current-buffer)) | |
5032 (gnus-dead-summary-mode 1) | |
5033 (let ((name (buffer-name))) | |
5034 (when (string-match "Summary" name) | |
5035 (rename-buffer | |
5036 (concat (substring name 0 (match-beginning 0)) "Dead " | |
5037 (substring name (match-beginning 0))) | |
5038 t)))) | |
5039 | |
5040 (defun gnus-kill-or-deaden-summary (buffer) | |
5041 "Kill or deaden the summary BUFFER." | |
5042 (when (and (buffer-name buffer) | |
5043 (not gnus-single-article-buffer)) | |
5044 (save-excursion | |
5045 (set-buffer buffer) | |
5046 (gnus-kill-buffer gnus-article-buffer) | |
5047 (gnus-kill-buffer gnus-original-article-buffer))) | |
5048 (cond (gnus-kill-summary-on-exit | |
5049 (when (and gnus-use-trees | |
5050 (and (get-buffer buffer) | |
5051 (buffer-name (get-buffer buffer)))) | |
5052 (save-excursion | |
5053 (set-buffer (get-buffer buffer)) | |
5054 (gnus-tree-close gnus-newsgroup-name))) | |
5055 (gnus-kill-buffer buffer)) | |
5056 ((and (get-buffer buffer) | |
5057 (buffer-name (get-buffer buffer))) | |
5058 (save-excursion | |
5059 (set-buffer buffer) | |
5060 (gnus-deaden-summary))))) | |
5061 | |
5062 (defun gnus-summary-wake-up-the-dead (&rest args) | |
5063 "Wake up the dead summary buffer." | |
5064 (interactive) | |
5065 (gnus-dead-summary-mode -1) | |
5066 (let ((name (buffer-name))) | |
5067 (when (string-match "Dead " name) | |
5068 (rename-buffer | |
5069 (concat (substring name 0 (match-beginning 0)) | |
5070 (substring name (match-end 0))) | |
5071 t))) | |
5072 (gnus-message 3 "This dead summary is now alive again")) | |
5073 | |
5074 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>. | |
5075 (defun gnus-summary-fetch-faq (&optional faq-dir) | |
5076 "Fetch the FAQ for the current group. | |
5077 If FAQ-DIR (the prefix), prompt for a directory to search for the faq | |
5078 in." | |
5079 (interactive | |
5080 (list | |
5081 (when current-prefix-arg | |
5082 (completing-read | |
5083 "Faq dir: " (and (listp gnus-group-faq-directory) | |
5084 gnus-group-faq-directory))))) | |
5085 (let (gnus-faq-buffer) | |
5086 (when (setq gnus-faq-buffer | |
5087 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir)) | |
5088 (gnus-configure-windows 'summary-faq)))) | |
5089 | |
5090 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>. | |
5091 (defun gnus-summary-describe-group (&optional force) | |
5092 "Describe the current newsgroup." | |
5093 (interactive "P") | |
5094 (gnus-group-describe-group force gnus-newsgroup-name)) | |
5095 | |
5096 (defun gnus-summary-describe-briefly () | |
5097 "Describe summary mode commands briefly." | |
5098 (interactive) | |
5099 (gnus-message 6 | |
5100 (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"))) | |
5101 | |
5102 ;; Walking around group mode buffer from summary mode. | |
5103 | |
5104 (defun gnus-summary-next-group (&optional no-article target-group backward) | |
5105 "Exit current newsgroup and then select next unread newsgroup. | |
5106 If prefix argument NO-ARTICLE is non-nil, no article is selected | |
5107 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to | |
5108 previous group instead." | |
5109 (interactive "P") | |
5110 (gnus-set-global-variables) | |
5111 ;; Stop pre-fetching. | |
5112 (gnus-async-halt-prefetch) | |
5113 (let ((current-group gnus-newsgroup-name) | |
5114 (current-buffer (current-buffer)) | |
5115 entered) | |
5116 ;; First we semi-exit this group to update Xrefs and all variables. | |
5117 ;; We can't do a real exit, because the window conf must remain | |
5118 ;; the same in case the user is prompted for info, and we don't | |
5119 ;; want the window conf to change before that... | |
5120 (gnus-summary-exit t) | |
5121 (while (not entered) | |
5122 ;; Then we find what group we are supposed to enter. | |
5123 (set-buffer gnus-group-buffer) | |
5124 (gnus-group-jump-to-group current-group) | |
5125 (setq target-group | |
5126 (or target-group | |
5127 (if (eq gnus-keep-same-level 'best) | |
5128 (gnus-summary-best-group gnus-newsgroup-name) | |
5129 (gnus-summary-search-group backward gnus-keep-same-level)))) | |
5130 (if (not target-group) | |
5131 ;; There are no further groups, so we return to the group | |
5132 ;; buffer. | |
5133 (progn | |
5134 (gnus-message 5 "Returning to the group buffer") | |
5135 (setq entered t) | |
5136 (when (gnus-buffer-live-p current-buffer) | |
5137 (set-buffer current-buffer) | |
5138 (gnus-summary-exit)) | |
5139 (run-hooks 'gnus-group-no-more-groups-hook)) | |
5140 ;; We try to enter the target group. | |
5141 (gnus-group-jump-to-group target-group) | |
5142 (let ((unreads (gnus-group-group-unread))) | |
5143 (if (and (or (eq t unreads) | |
5144 (and unreads (not (zerop unreads)))) | |
5145 (gnus-summary-read-group | |
5146 target-group nil no-article current-buffer)) | |
5147 (setq entered t) | |
5148 (setq current-group target-group | |
5149 target-group nil))))))) | |
5150 | |
5151 (defun gnus-summary-prev-group (&optional no-article) | |
5152 "Exit current newsgroup and then select previous unread newsgroup. | |
5153 If prefix argument NO-ARTICLE is non-nil, no article is selected initially." | |
5154 (interactive "P") | |
5155 (gnus-summary-next-group no-article nil t)) | |
5156 | |
5157 ;; Walking around summary lines. | |
5158 | |
5159 (defun gnus-summary-first-subject (&optional unread) | |
5160 "Go to the first unread subject. | |
5161 If UNREAD is non-nil, go to the first unread article. | |
5162 Returns the article selected or nil if there are no unread articles." | |
5163 (interactive "P") | |
5164 (prog1 | |
5165 (cond | |
5166 ;; Empty summary. | |
5167 ((null gnus-newsgroup-data) | |
5168 (gnus-message 3 "No articles in the group") | |
5169 nil) | |
5170 ;; Pick the first article. | |
5171 ((not unread) | |
5172 (goto-char (gnus-data-pos (car gnus-newsgroup-data))) | |
5173 (gnus-data-number (car gnus-newsgroup-data))) | |
5174 ;; No unread articles. | |
5175 ((null gnus-newsgroup-unreads) | |
5176 (gnus-message 3 "No more unread articles") | |
5177 nil) | |
5178 ;; Find the first unread article. | |
5179 (t | |
5180 (let ((data gnus-newsgroup-data)) | |
5181 (while (and data | |
5182 (not (gnus-data-unread-p (car data)))) | |
5183 (setq data (cdr data))) | |
5184 (when data | |
5185 (goto-char (gnus-data-pos (car data))) | |
5186 (gnus-data-number (car data)))))) | |
5187 (gnus-summary-position-point))) | |
5188 | |
5189 (defun gnus-summary-next-subject (n &optional unread dont-display) | |
5190 "Go to next N'th summary line. | |
5191 If N is negative, go to the previous N'th subject line. | |
5192 If UNREAD is non-nil, only unread articles are selected. | |
5193 The difference between N and the actual number of steps taken is | |
5194 returned." | |
5195 (interactive "p") | |
5196 (let ((backward (< n 0)) | |
5197 (n (abs n))) | |
5198 (while (and (> n 0) | |
5199 (if backward | |
5200 (gnus-summary-find-prev unread) | |
5201 (gnus-summary-find-next unread))) | |
5202 (setq n (1- n))) | |
5203 (when (/= 0 n) | |
5204 (gnus-message 7 "No more%s articles" | |
5205 (if unread " unread" ""))) | |
5206 (unless dont-display | |
5207 (gnus-summary-recenter) | |
5208 (gnus-summary-position-point)) | |
5209 n)) | |
5210 | |
5211 (defun gnus-summary-next-unread-subject (n) | |
5212 "Go to next N'th unread summary line." | |
5213 (interactive "p") | |
5214 (gnus-summary-next-subject n t)) | |
5215 | |
5216 (defun gnus-summary-prev-subject (n &optional unread) | |
5217 "Go to previous N'th summary line. | |
5218 If optional argument UNREAD is non-nil, only unread article is selected." | |
5219 (interactive "p") | |
5220 (gnus-summary-next-subject (- n) unread)) | |
5221 | |
5222 (defun gnus-summary-prev-unread-subject (n) | |
5223 "Go to previous N'th unread summary line." | |
5224 (interactive "p") | |
5225 (gnus-summary-next-subject (- n) t)) | |
5226 | |
5227 (defun gnus-summary-goto-subject (article &optional force silent) | |
5228 "Go the subject line of ARTICLE. | |
5229 If FORCE, also allow jumping to articles not currently shown." | |
5230 (interactive "nArticle number: ") | |
5231 (let ((b (point)) | |
5232 (data (gnus-data-find article))) | |
5233 ;; We read in the article if we have to. | |
5234 (and (not data) | |
5235 force | |
5236 (gnus-summary-insert-subject article (and (vectorp force) force) t) | |
5237 (setq data (gnus-data-find article))) | |
5238 (goto-char b) | |
5239 (if (not data) | |
5240 (progn | |
5241 (unless silent | |
5242 (gnus-message 3 "Can't find article %d" article)) | |
5243 nil) | |
5244 (goto-char (gnus-data-pos data)) | |
5245 article))) | |
5246 | |
5247 ;; Walking around summary lines with displaying articles. | |
5248 | |
5249 (defun gnus-summary-expand-window (&optional arg) | |
5250 "Make the summary buffer take up the entire Emacs frame. | |
5251 Given a prefix, will force an `article' buffer configuration." | |
5252 (interactive "P") | |
5253 (gnus-set-global-variables) | |
5254 (if arg | |
5255 (gnus-configure-windows 'article 'force) | |
5256 (gnus-configure-windows 'summary 'force))) | |
5257 | |
5258 (defun gnus-summary-display-article (article &optional all-header) | |
5259 "Display ARTICLE in article buffer." | |
5260 (gnus-set-global-variables) | |
5261 (if (null article) | |
5262 nil | |
5263 (prog1 | |
5264 (if gnus-summary-display-article-function | |
5265 (funcall gnus-summary-display-article-function article all-header) | |
5266 (gnus-article-prepare article all-header)) | |
5267 (run-hooks 'gnus-select-article-hook) | |
5268 (when (and gnus-current-article | |
5269 (not (zerop gnus-current-article))) | |
5270 (gnus-summary-goto-subject gnus-current-article)) | |
5271 (gnus-summary-recenter) | |
5272 (when (and gnus-use-trees gnus-show-threads) | |
5273 (gnus-possibly-generate-tree article) | |
5274 (gnus-highlight-selected-tree article)) | |
5275 ;; Successfully display article. | |
5276 (gnus-article-set-window-start | |
5277 (cdr (assq article gnus-newsgroup-bookmarks)))))) | |
5278 | |
5279 (defun gnus-summary-select-article (&optional all-headers force pseudo article) | |
5280 "Select the current article. | |
5281 If ALL-HEADERS is non-nil, show all header fields. If FORCE is | |
5282 non-nil, the article will be re-fetched even if it already present in | |
5283 the article buffer. If PSEUDO is non-nil, pseudo-articles will also | |
5284 be displayed." | |
5285 ;; Make sure we are in the summary buffer to work around bbdb bug. | |
5286 (unless (eq major-mode 'gnus-summary-mode) | |
5287 (set-buffer gnus-summary-buffer)) | |
5288 (let ((article (or article (gnus-summary-article-number))) | |
5289 (all-headers (not (not all-headers))) ;Must be T or NIL. | |
5290 gnus-summary-display-article-function | |
5291 did) | |
5292 (and (not pseudo) | |
5293 (gnus-summary-article-pseudo-p article) | |
5294 (error "This is a pseudo-article.")) | |
5295 (prog1 | |
5296 (save-excursion | |
5297 (set-buffer gnus-summary-buffer) | |
5298 (if (or (and gnus-single-article-buffer | |
5299 (or (null gnus-current-article) | |
5300 (null gnus-article-current) | |
5301 (null (get-buffer gnus-article-buffer)) | |
5302 (not (eq article (cdr gnus-article-current))) | |
5303 (not (equal (car gnus-article-current) | |
5304 gnus-newsgroup-name)))) | |
5305 (and (not gnus-single-article-buffer) | |
5306 (or (null gnus-current-article) | |
5307 (not (eq gnus-current-article article)))) | |
5308 force) | |
5309 ;; The requested article is different from the current article. | |
5310 (prog1 | |
5311 (gnus-summary-display-article article all-headers) | |
5312 (setq did article)) | |
5313 (when (or all-headers gnus-show-all-headers) | |
5314 (gnus-article-show-all-headers)) | |
5315 'old)) | |
5316 (when did | |
5317 (gnus-article-set-window-start | |
5318 (cdr (assq article gnus-newsgroup-bookmarks))))))) | |
5319 | |
5320 (defun gnus-summary-set-current-mark (&optional current-mark) | |
5321 "Obsolete function." | |
5322 nil) | |
5323 | |
5324 (defun gnus-summary-next-article (&optional unread subject backward push) | |
5325 "Select the next article. | |
5326 If UNREAD, only unread articles are selected. | |
5327 If SUBJECT, only articles with SUBJECT are selected. | |
5328 If BACKWARD, the previous article is selected instead of the next." | |
5329 (interactive "P") | |
5330 (gnus-set-global-variables) | |
5331 (cond | |
5332 ;; Is there such an article? | |
5333 ((and (gnus-summary-search-forward unread subject backward) | |
5334 (or (gnus-summary-display-article (gnus-summary-article-number)) | |
5335 (eq (gnus-summary-article-mark) gnus-canceled-mark))) | |
5336 (gnus-summary-position-point)) | |
5337 ;; If not, we try the first unread, if that is wanted. | |
5338 ((and subject | |
5339 gnus-auto-select-same | |
5340 (gnus-summary-first-unread-article)) | |
5341 (gnus-summary-position-point) | |
5342 (gnus-message 6 "Wrapped")) | |
5343 ;; Try to get next/previous article not displayed in this group. | |
5344 ((and gnus-auto-extend-newsgroup | |
5345 (not unread) (not subject)) | |
5346 (gnus-summary-goto-article | |
5347 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end)) | |
5348 nil t)) | |
5349 ;; Go to next/previous group. | |
5350 (t | |
5351 (unless (gnus-ephemeral-group-p gnus-newsgroup-name) | |
5352 (gnus-summary-jump-to-group gnus-newsgroup-name)) | |
5353 (let ((cmd last-command-char) | |
5354 (point | |
5355 (save-excursion | |
5356 (set-buffer gnus-group-buffer) | |
5357 (point))) | |
5358 (group | |
5359 (if (eq gnus-keep-same-level 'best) | |
5360 (gnus-summary-best-group gnus-newsgroup-name) | |
5361 (gnus-summary-search-group backward gnus-keep-same-level)))) | |
5362 ;; For some reason, the group window gets selected. We change | |
5363 ;; it back. | |
5364 (select-window (get-buffer-window (current-buffer))) | |
5365 ;; Select next unread newsgroup automagically. | |
5366 (cond | |
5367 ((or (not gnus-auto-select-next) | |
5368 (not cmd)) | |
5369 (gnus-message 7 "No more%s articles" (if unread " unread" ""))) | |
5370 ((or (eq gnus-auto-select-next 'quietly) | |
5371 (and (eq gnus-auto-select-next 'slightly-quietly) | |
5372 push) | |
5373 (and (eq gnus-auto-select-next 'almost-quietly) | |
5374 (gnus-summary-last-article-p))) | |
5375 ;; Select quietly. | |
5376 (if (gnus-ephemeral-group-p gnus-newsgroup-name) | |
5377 (gnus-summary-exit) | |
5378 (gnus-message 7 "No more%s articles (%s)..." | |
5379 (if unread " unread" "") | |
5380 (if group (concat "selecting " group) | |
5381 "exiting")) | |
5382 (gnus-summary-next-group nil group backward))) | |
5383 (t | |
5384 (when (gnus-key-press-event-p last-input-event) | |
5385 (gnus-summary-walk-group-buffer | |
5386 gnus-newsgroup-name cmd unread backward point)))))))) | |
5387 | |
5388 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start) | |
5389 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1)) | |
5390 (?\C-p (gnus-group-prev-unread-group 1)))) | |
5391 (cursor-in-echo-area t) | |
5392 keve key group ended) | |
5393 (save-excursion | |
5394 (set-buffer gnus-group-buffer) | |
5395 (goto-char start) | |
5396 (setq group | |
5397 (if (eq gnus-keep-same-level 'best) | |
5398 (gnus-summary-best-group gnus-newsgroup-name) | |
5399 (gnus-summary-search-group backward gnus-keep-same-level)))) | |
5400 (while (not ended) | |
5401 (gnus-message | |
5402 5 "No more%s articles%s" (if unread " unread" "") | |
5403 (if (and group | |
5404 (not (gnus-ephemeral-group-p gnus-newsgroup-name))) | |
5405 (format " (Type %s for %s [%s])" | |
5406 (single-key-description cmd) group | |
5407 (car (gnus-gethash group gnus-newsrc-hashtb))) | |
5408 (format " (Type %s to exit %s)" | |
5409 (single-key-description cmd) | |
5410 gnus-newsgroup-name))) | |
5411 ;; Confirm auto selection. | |
5412 (setq key (car (setq keve (gnus-read-event-char)))) | |
5413 (setq ended t) | |
5414 (cond | |
5415 ((assq key keystrokes) | |
5416 (let ((obuf (current-buffer))) | |
5417 (switch-to-buffer gnus-group-buffer) | |
5418 (when group | |
5419 (gnus-group-jump-to-group group)) | |
5420 (eval (cadr (assq key keystrokes))) | |
5421 (setq group (gnus-group-group-name)) | |
5422 (switch-to-buffer obuf)) | |
5423 (setq ended nil)) | |
5424 ((equal key cmd) | |
5425 (if (or (not group) | |
5426 (gnus-ephemeral-group-p gnus-newsgroup-name)) | |
5427 (gnus-summary-exit) | |
5428 (gnus-summary-next-group nil group backward))) | |
5429 (t | |
5430 (push (cdr keve) unread-command-events)))))) | |
5431 | |
5432 (defun gnus-summary-next-unread-article () | |
5433 "Select unread article after current one." | |
5434 (interactive) | |
5435 (gnus-summary-next-article | |
5436 (or (not (eq gnus-summary-goto-unread 'never)) | |
5437 (gnus-summary-last-article-p (gnus-summary-article-number))) | |
5438 (and gnus-auto-select-same | |
5439 (gnus-summary-article-subject)))) | |
5440 | |
5441 (defun gnus-summary-prev-article (&optional unread subject) | |
5442 "Select the article after the current one. | |
5443 If UNREAD is non-nil, only unread articles are selected." | |
5444 (interactive "P") | |
5445 (gnus-summary-next-article unread subject t)) | |
5446 | |
5447 (defun gnus-summary-prev-unread-article () | |
5448 "Select unread article before current one." | |
5449 (interactive) | |
5450 (gnus-summary-prev-article | |
5451 (or (not (eq gnus-summary-goto-unread 'never)) | |
5452 (gnus-summary-first-article-p (gnus-summary-article-number))) | |
5453 (and gnus-auto-select-same | |
5454 (gnus-summary-article-subject)))) | |
5455 | |
5456 (defun gnus-summary-next-page (&optional lines circular) | |
5457 "Show next page of the selected article. | |
5458 If at the end of the current article, select the next article. | |
5459 LINES says how many lines should be scrolled up. | |
5460 | |
5461 If CIRCULAR is non-nil, go to the start of the article instead of | |
5462 selecting the next article when reaching the end of the current | |
5463 article." | |
5464 (interactive "P") | |
5465 (setq gnus-summary-buffer (current-buffer)) | |
5466 (gnus-set-global-variables) | |
5467 (let ((article (gnus-summary-article-number)) | |
5468 (article-window (get-buffer-window gnus-article-buffer t)) | |
5469 endp) | |
5470 (gnus-configure-windows 'article) | |
5471 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark) | |
5472 (if (and (eq gnus-summary-goto-unread 'never) | |
5473 (not (gnus-summary-last-article-p article))) | |
5474 (gnus-summary-next-article) | |
5475 (gnus-summary-next-unread-article)) | |
5476 (if (or (null gnus-current-article) | |
5477 (null gnus-article-current) | |
5478 (/= article (cdr gnus-article-current)) | |
5479 (not (equal (car gnus-article-current) gnus-newsgroup-name))) | |
5480 ;; Selected subject is different from current article's. | |
5481 (gnus-summary-display-article article) | |
5482 (when article-window | |
5483 (gnus-eval-in-buffer-window gnus-article-buffer | |
5484 (setq endp (gnus-article-next-page lines))) | |
5485 (when endp | |
5486 (cond (circular | |
5487 (gnus-summary-beginning-of-article)) | |
5488 (lines | |
5489 (gnus-message 3 "End of message")) | |
5490 ((null lines) | |
5491 (if (and (eq gnus-summary-goto-unread 'never) | |
5492 (not (gnus-summary-last-article-p article))) | |
5493 (gnus-summary-next-article) | |
5494 (gnus-summary-next-unread-article)))))))) | |
5495 (gnus-summary-recenter) | |
5496 (gnus-summary-position-point))) | |
5497 | |
5498 (defun gnus-summary-prev-page (&optional lines move) | |
5499 "Show previous page of selected article. | |
5500 Argument LINES specifies lines to be scrolled down. | |
5501 If MOVE, move to the previous unread article if point is at | |
5502 the beginning of the buffer." | |
5503 (interactive "P") | |
5504 (gnus-set-global-variables) | |
5505 (let ((article (gnus-summary-article-number)) | |
5506 (article-window (get-buffer-window gnus-article-buffer t)) | |
5507 endp) | |
5508 (gnus-configure-windows 'article) | |
5509 (if (or (null gnus-current-article) | |
5510 (null gnus-article-current) | |
5511 (/= article (cdr gnus-article-current)) | |
5512 (not (equal (car gnus-article-current) gnus-newsgroup-name))) | |
5513 ;; Selected subject is different from current article's. | |
5514 (gnus-summary-display-article article) | |
5515 (gnus-summary-recenter) | |
5516 (when article-window | |
5517 (gnus-eval-in-buffer-window gnus-article-buffer | |
5518 (setq endp (gnus-article-prev-page lines))) | |
5519 (when (and move endp) | |
5520 (cond (lines | |
5521 (gnus-message 3 "Beginning of message")) | |
5522 ((null lines) | |
5523 (if (and (eq gnus-summary-goto-unread 'never) | |
5524 (not (gnus-summary-first-article-p article))) | |
5525 (gnus-summary-prev-article) | |
5526 (gnus-summary-prev-unread-article)))))))) | |
5527 (gnus-summary-position-point)) | |
5528 | |
5529 (defun gnus-summary-prev-page-or-article (&optional lines) | |
5530 "Show previous page of selected article. | |
5531 Argument LINES specifies lines to be scrolled down. | |
5532 If at the beginning of the article, go to the next article." | |
5533 (interactive "P") | |
5534 (gnus-summary-prev-page lines t)) | |
5535 | |
5536 (defun gnus-summary-scroll-up (lines) | |
5537 "Scroll up (or down) one line current article. | |
5538 Argument LINES specifies lines to be scrolled up (or down if negative)." | |
5539 (interactive "p") | |
5540 (gnus-set-global-variables) | |
5541 (gnus-configure-windows 'article) | |
5542 (gnus-summary-show-thread) | |
5543 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old) | |
5544 (gnus-eval-in-buffer-window gnus-article-buffer | |
5545 (cond ((> lines 0) | |
5546 (when (gnus-article-next-page lines) | |
5547 (gnus-message 3 "End of message"))) | |
5548 ((< lines 0) | |
5549 (gnus-article-prev-page (- lines)))))) | |
5550 (gnus-summary-recenter) | |
5551 (gnus-summary-position-point)) | |
5552 | |
5553 (defun gnus-summary-next-same-subject () | |
5554 "Select next article which has the same subject as current one." | |
5555 (interactive) | |
5556 (gnus-set-global-variables) | |
5557 (gnus-summary-next-article nil (gnus-summary-article-subject))) | |
5558 | |
5559 (defun gnus-summary-prev-same-subject () | |
5560 "Select previous article which has the same subject as current one." | |
5561 (interactive) | |
5562 (gnus-set-global-variables) | |
5563 (gnus-summary-prev-article nil (gnus-summary-article-subject))) | |
5564 | |
5565 (defun gnus-summary-next-unread-same-subject () | |
5566 "Select next unread article which has the same subject as current one." | |
5567 (interactive) | |
5568 (gnus-set-global-variables) | |
5569 (gnus-summary-next-article t (gnus-summary-article-subject))) | |
5570 | |
5571 (defun gnus-summary-prev-unread-same-subject () | |
5572 "Select previous unread article which has the same subject as current one." | |
5573 (interactive) | |
5574 (gnus-set-global-variables) | |
5575 (gnus-summary-prev-article t (gnus-summary-article-subject))) | |
5576 | |
5577 (defun gnus-summary-first-unread-article () | |
5578 "Select the first unread article. | |
5579 Return nil if there are no unread articles." | |
5580 (interactive) | |
5581 (gnus-set-global-variables) | |
5582 (prog1 | |
5583 (when (gnus-summary-first-subject t) | |
5584 (gnus-summary-show-thread) | |
5585 (gnus-summary-first-subject t) | |
5586 (gnus-summary-display-article (gnus-summary-article-number))) | |
5587 (gnus-summary-position-point))) | |
5588 | |
5589 (defun gnus-summary-first-article () | |
5590 "Select the first article. | |
5591 Return nil if there are no articles." | |
5592 (interactive) | |
5593 (gnus-set-global-variables) | |
5594 (prog1 | |
5595 (when (gnus-summary-first-subject) | |
5596 (gnus-summary-show-thread) | |
5597 (gnus-summary-first-subject) | |
5598 (gnus-summary-display-article (gnus-summary-article-number))) | |
5599 (gnus-summary-position-point))) | |
5600 | |
5601 (defun gnus-summary-best-unread-article () | |
5602 "Select the unread article with the highest score." | |
5603 (interactive) | |
5604 (gnus-set-global-variables) | |
5605 (let ((best -1000000) | |
5606 (data gnus-newsgroup-data) | |
5607 article score) | |
5608 (while data | |
5609 (and (gnus-data-unread-p (car data)) | |
5610 (> (setq score | |
5611 (gnus-summary-article-score (gnus-data-number (car data)))) | |
5612 best) | |
5613 (setq best score | |
5614 article (gnus-data-number (car data)))) | |
5615 (setq data (cdr data))) | |
5616 (prog1 | |
5617 (if article | |
5618 (gnus-summary-goto-article article) | |
5619 (error "No unread articles")) | |
5620 (gnus-summary-position-point)))) | |
5621 | |
5622 (defun gnus-summary-last-subject () | |
5623 "Go to the last displayed subject line in the group." | |
5624 (let ((article (gnus-data-number (car (gnus-data-list t))))) | |
5625 (when article | |
5626 (gnus-summary-goto-subject article)))) | |
5627 | |
5628 (defun gnus-summary-goto-article (article &optional all-headers force) | |
5629 "Fetch ARTICLE and display it if it exists. | |
5630 If ALL-HEADERS is non-nil, no header lines are hidden." | |
5631 (interactive | |
5632 (list | |
5633 (string-to-int | |
5634 (completing-read | |
5635 "Article number: " | |
5636 (mapcar (lambda (number) (list (int-to-string number))) | |
5637 gnus-newsgroup-limit))) | |
5638 current-prefix-arg | |
5639 t)) | |
5640 (prog1 | |
5641 (if (gnus-summary-goto-subject article force) | |
5642 (gnus-summary-display-article article all-headers) | |
5643 (gnus-message 4 "Couldn't go to article %s" article) nil) | |
5644 (gnus-summary-position-point))) | |
5645 | |
5646 (defun gnus-summary-goto-last-article () | |
5647 "Go to the previously read article." | |
5648 (interactive) | |
5649 (prog1 | |
5650 (when gnus-last-article | |
5651 (gnus-summary-goto-article gnus-last-article)) | |
5652 (gnus-summary-position-point))) | |
5653 | |
5654 (defun gnus-summary-pop-article (number) | |
5655 "Pop one article off the history and go to the previous. | |
5656 NUMBER articles will be popped off." | |
5657 (interactive "p") | |
5658 (let (to) | |
5659 (setq gnus-newsgroup-history | |
5660 (cdr (setq to (nthcdr number gnus-newsgroup-history)))) | |
5661 (if to | |
5662 (gnus-summary-goto-article (car to)) | |
5663 (error "Article history empty"))) | |
5664 (gnus-summary-position-point)) | |
5665 | |
5666 ;; Summary commands and functions for limiting the summary buffer. | |
5667 | |
5668 (defun gnus-summary-limit-to-articles (n) | |
5669 "Limit the summary buffer to the next N articles. | |
5670 If not given a prefix, use the process marked articles instead." | |
5671 (interactive "P") | |
5672 (gnus-set-global-variables) | |
5673 (prog1 | |
5674 (let ((articles (gnus-summary-work-articles n))) | |
5675 (setq gnus-newsgroup-processable nil) | |
5676 (gnus-summary-limit articles)) | |
5677 (gnus-summary-position-point))) | |
5678 | |
5679 (defun gnus-summary-pop-limit (&optional total) | |
5680 "Restore the previous limit. | |
5681 If given a prefix, remove all limits." | |
5682 (interactive "P") | |
5683 (gnus-set-global-variables) | |
5684 (when total | |
5685 (setq gnus-newsgroup-limits | |
5686 (list (mapcar (lambda (h) (mail-header-number h)) | |
5687 gnus-newsgroup-headers)))) | |
5688 (unless gnus-newsgroup-limits | |
5689 (error "No limit to pop")) | |
5690 (prog1 | |
5691 (gnus-summary-limit nil 'pop) | |
5692 (gnus-summary-position-point))) | |
5693 | |
5694 (defun gnus-summary-limit-to-subject (subject &optional header) | |
5695 "Limit the summary buffer to articles that have subjects that match a regexp." | |
5696 (interactive "sLimit to subject (regexp): ") | |
5697 (unless header | |
5698 (setq header "subject")) | |
5699 (when (not (equal "" subject)) | |
5700 (prog1 | |
5701 (let ((articles (gnus-summary-find-matching | |
5702 (or header "subject") subject 'all))) | |
5703 (unless articles | |
5704 (error "Found no matches for \"%s\"" subject)) | |
5705 (gnus-summary-limit articles)) | |
5706 (gnus-summary-position-point)))) | |
5707 | |
5708 (defun gnus-summary-limit-to-author (from) | |
5709 "Limit the summary buffer to articles that have authors that match a regexp." | |
5710 (interactive "sLimit to author (regexp): ") | |
5711 (gnus-summary-limit-to-subject from "from")) | |
5712 | |
5713 (defun gnus-summary-limit-to-age (age &optional younger-p) | |
5714 "Limit the summary buffer to articles that are older than (or equal) AGE days. | |
5715 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to | |
5716 articles that are younger than AGE days." | |
5717 (interactive "nTime in days: \nP") | |
5718 (prog1 | |
5719 (let ((data gnus-newsgroup-data) | |
5720 (cutoff (nnmail-days-to-time age)) | |
5721 articles d date is-younger) | |
5722 (while (setq d (pop data)) | |
5723 (when (and (vectorp (gnus-data-header d)) | |
5724 (setq date (mail-header-date (gnus-data-header d)))) | |
5725 (setq is-younger (nnmail-time-less | |
5726 (nnmail-time-since (nnmail-date-to-time date)) | |
5727 cutoff)) | |
5728 (when (if younger-p is-younger (not is-younger)) | |
5729 (push (gnus-data-number d) articles)))) | |
5730 (gnus-summary-limit (nreverse articles))) | |
5731 (gnus-summary-position-point))) | |
5732 | |
5733 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread) | |
5734 (make-obsolete | |
5735 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread) | |
5736 | |
5737 (defun gnus-summary-limit-to-unread (&optional all) | |
5738 "Limit the summary buffer to articles that are not marked as read. | |
5739 If ALL is non-nil, limit strictly to unread articles." | |
5740 (interactive "P") | |
5741 (if all | |
5742 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark)) | |
5743 (gnus-summary-limit-to-marks | |
5744 ;; Concat all the marks that say that an article is read and have | |
5745 ;; those removed. | |
5746 (list gnus-del-mark gnus-read-mark gnus-ancient-mark | |
5747 gnus-killed-mark gnus-kill-file-mark | |
5748 gnus-low-score-mark gnus-expirable-mark | |
5749 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark | |
5750 gnus-duplicate-mark gnus-souped-mark) | |
5751 'reverse))) | |
5752 | |
5753 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks) | |
5754 (make-obsolete 'gnus-summary-delete-marked-with | |
5755 'gnus-summary-limit-exlude-marks) | |
5756 | |
5757 (defun gnus-summary-limit-exclude-marks (marks &optional reverse) | |
5758 "Exclude articles that are marked with MARKS (e.g. \"DK\"). | |
5759 If REVERSE, limit the summary buffer to articles that are marked | |
5760 with MARKS. MARKS can either be a string of marks or a list of marks. | |
5761 Returns how many articles were removed." | |
5762 (interactive "sMarks: ") | |
5763 (gnus-summary-limit-to-marks marks t)) | |
5764 | |
5765 (defun gnus-summary-limit-to-marks (marks &optional reverse) | |
5766 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\"). | |
5767 If REVERSE (the prefix), limit the summary buffer to articles that are | |
5768 not marked with MARKS. MARKS can either be a string of marks or a | |
5769 list of marks. | |
5770 Returns how many articles were removed." | |
5771 (interactive (list (read-string "Marks: ") current-prefix-arg)) | |
5772 (gnus-set-global-variables) | |
5773 (prog1 | |
5774 (let ((data gnus-newsgroup-data) | |
5775 (marks (if (listp marks) marks | |
5776 (append marks nil))) ; Transform to list. | |
5777 articles) | |
5778 (while data | |
5779 (when (if reverse (not (memq (gnus-data-mark (car data)) marks)) | |
5780 (memq (gnus-data-mark (car data)) marks)) | |
5781 (push (gnus-data-number (car data)) articles)) | |
5782 (setq data (cdr data))) | |
5783 (gnus-summary-limit articles)) | |
5784 (gnus-summary-position-point))) | |
5785 | |
5786 (defun gnus-summary-limit-to-score (&optional score) | |
5787 "Limit to articles with score at or above SCORE." | |
5788 (interactive "P") | |
5789 (gnus-set-global-variables) | |
5790 (setq score (if score | |
5791 (prefix-numeric-value score) | |
5792 (or gnus-summary-default-score 0))) | |
5793 (let ((data gnus-newsgroup-data) | |
5794 articles) | |
5795 (while data | |
5796 (when (>= (gnus-summary-article-score (gnus-data-number (car data))) | |
5797 score) | |
5798 (push (gnus-data-number (car data)) articles)) | |
5799 (setq data (cdr data))) | |
5800 (prog1 | |
5801 (gnus-summary-limit articles) | |
5802 (gnus-summary-position-point)))) | |
5803 | |
5804 (defun gnus-summary-limit-include-dormant () | |
5805 "Display all the hidden articles that are marked as dormant." | |
5806 (interactive) | |
5807 (gnus-set-global-variables) | |
5808 (unless gnus-newsgroup-dormant | |
5809 (error "There are no dormant articles in this group")) | |
5810 (prog1 | |
5811 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit)) | |
5812 (gnus-summary-position-point))) | |
5813 | |
5814 (defun gnus-summary-limit-exclude-dormant () | |
5815 "Hide all dormant articles." | |
5816 (interactive) | |
5817 (gnus-set-global-variables) | |
5818 (prog1 | |
5819 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse) | |
5820 (gnus-summary-position-point))) | |
5821 | |
5822 (defun gnus-summary-limit-exclude-childless-dormant () | |
5823 "Hide all dormant articles that have no children." | |
5824 (interactive) | |
5825 (gnus-set-global-variables) | |
5826 (let ((data (gnus-data-list t)) | |
5827 articles d children) | |
5828 ;; Find all articles that are either not dormant or have | |
5829 ;; children. | |
5830 (while (setq d (pop data)) | |
5831 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark)) | |
5832 (and (setq children | |
5833 (gnus-article-children (gnus-data-number d))) | |
5834 (let (found) | |
5835 (while children | |
5836 (when (memq (car children) articles) | |
5837 (setq children nil | |
5838 found t)) | |
5839 (pop children)) | |
5840 found))) | |
5841 (push (gnus-data-number d) articles))) | |
5842 ;; Do the limiting. | |
5843 (prog1 | |
5844 (gnus-summary-limit articles) | |
5845 (gnus-summary-position-point)))) | |
5846 | |
5847 (defun gnus-summary-limit-mark-excluded-as-read (&optional all) | |
5848 "Mark all unread excluded articles as read. | |
5849 If ALL, mark even excluded ticked and dormants as read." | |
5850 (interactive "P") | |
5851 (let ((articles (gnus-sorted-complement | |
5852 (sort | |
5853 (mapcar (lambda (h) (mail-header-number h)) | |
5854 gnus-newsgroup-headers) | |
5855 '<) | |
5856 (sort gnus-newsgroup-limit '<))) | |
5857 article) | |
5858 (setq gnus-newsgroup-unreads nil) | |
5859 (if all | |
5860 (setq gnus-newsgroup-dormant nil | |
5861 gnus-newsgroup-marked nil | |
5862 gnus-newsgroup-reads | |
5863 (nconc | |
5864 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles) | |
5865 gnus-newsgroup-reads)) | |
5866 (while (setq article (pop articles)) | |
5867 (unless (or (memq article gnus-newsgroup-dormant) | |
5868 (memq article gnus-newsgroup-marked)) | |
5869 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads)))))) | |
5870 | |
5871 (defun gnus-summary-limit (articles &optional pop) | |
5872 (if pop | |
5873 ;; We pop the previous limit off the stack and use that. | |
5874 (setq articles (car gnus-newsgroup-limits) | |
5875 gnus-newsgroup-limits (cdr gnus-newsgroup-limits)) | |
5876 ;; We use the new limit, so we push the old limit on the stack. | |
5877 (push gnus-newsgroup-limit gnus-newsgroup-limits)) | |
5878 ;; Set the limit. | |
5879 (setq gnus-newsgroup-limit articles) | |
5880 (let ((total (length gnus-newsgroup-data)) | |
5881 (data (gnus-data-find-list (gnus-summary-article-number))) | |
5882 (gnus-summary-mark-below nil) ; Inhibit this. | |
5883 found) | |
5884 ;; This will do all the work of generating the new summary buffer | |
5885 ;; according to the new limit. | |
5886 (gnus-summary-prepare) | |
5887 ;; Hide any threads, possibly. | |
5888 (and gnus-show-threads | |
5889 gnus-thread-hide-subtree | |
5890 (gnus-summary-hide-all-threads)) | |
5891 ;; Try to return to the article you were at, or one in the | |
5892 ;; neighborhood. | |
5893 (when data | |
5894 ;; We try to find some article after the current one. | |
5895 (while data | |
5896 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t) | |
5897 (setq data nil | |
5898 found t)) | |
5899 (setq data (cdr data)))) | |
5900 (unless found | |
5901 ;; If there is no data, that means that we were after the last | |
5902 ;; article. The same goes when we can't find any articles | |
5903 ;; after the current one. | |
5904 (goto-char (point-max)) | |
5905 (gnus-summary-find-prev)) | |
5906 ;; We return how many articles were removed from the summary | |
5907 ;; buffer as a result of the new limit. | |
5908 (- total (length gnus-newsgroup-data)))) | |
5909 | |
5910 (defsubst gnus-invisible-cut-children (threads) | |
5911 (let ((num 0)) | |
5912 (while threads | |
5913 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit) | |
5914 (incf num)) | |
5915 (pop threads)) | |
5916 (< num 2))) | |
5917 | |
5918 (defsubst gnus-cut-thread (thread) | |
5919 "Go forwards in the thread until we find an article that we want to display." | |
5920 (when (or (eq gnus-fetch-old-headers 'some) | |
5921 (eq gnus-build-sparse-threads 'some) | |
5922 (eq gnus-build-sparse-threads 'more)) | |
5923 ;; Deal with old-fetched headers and sparse threads. | |
5924 (while (and | |
5925 thread | |
5926 (or | |
5927 (gnus-summary-article-sparse-p (mail-header-number (car thread))) | |
5928 (gnus-summary-article-ancient-p | |
5929 (mail-header-number (car thread)))) | |
5930 (progn | |
5931 (if (<= (length (cdr thread)) 1) | |
5932 (setq thread (cadr thread)) | |
5933 (when (gnus-invisible-cut-children (cdr thread)) | |
5934 (let ((th (cdr thread))) | |
5935 (while th | |
5936 (if (memq (mail-header-number (caar th)) | |
5937 gnus-newsgroup-limit) | |
5938 (setq thread (car th) | |
5939 th nil) | |
5940 (setq th (cdr th))))))))) | |
5941 )) | |
5942 thread) | |
5943 | |
5944 (defun gnus-cut-threads (threads) | |
5945 "Cut off all uninteresting articles from the beginning of threads." | |
5946 (when (or (eq gnus-fetch-old-headers 'some) | |
5947 (eq gnus-build-sparse-threads 'some) | |
5948 (eq gnus-build-sparse-threads 'more)) | |
5949 (let ((th threads)) | |
5950 (while th | |
5951 (setcar th (gnus-cut-thread (car th))) | |
5952 (setq th (cdr th))))) | |
5953 ;; Remove nixed out threads. | |
5954 (delq nil threads)) | |
5955 | |
5956 (defun gnus-summary-initial-limit (&optional show-if-empty) | |
5957 "Figure out what the initial limit is supposed to be on group entry. | |
5958 This entails weeding out unwanted dormants, low-scored articles, | |
5959 fetch-old-headers verbiage, and so on." | |
5960 ;; Most groups have nothing to remove. | |
5961 (if (or gnus-inhibit-limiting | |
5962 (and (null gnus-newsgroup-dormant) | |
5963 (not (eq gnus-fetch-old-headers 'some)) | |
5964 (null gnus-summary-expunge-below) | |
5965 (not (eq gnus-build-sparse-threads 'some)) | |
5966 (not (eq gnus-build-sparse-threads 'more)) | |
5967 (null gnus-thread-expunge-below) | |
5968 (not gnus-use-nocem))) | |
5969 () ; Do nothing. | |
5970 (push gnus-newsgroup-limit gnus-newsgroup-limits) | |
5971 (setq gnus-newsgroup-limit nil) | |
5972 (mapatoms | |
5973 (lambda (node) | |
5974 (unless (car (symbol-value node)) | |
5975 ;; These threads have no parents -- they are roots. | |
5976 (let ((nodes (cdr (symbol-value node))) | |
5977 thread) | |
5978 (while nodes | |
5979 (if (and gnus-thread-expunge-below | |
5980 (< (gnus-thread-total-score (car nodes)) | |
5981 gnus-thread-expunge-below)) | |
5982 (gnus-expunge-thread (pop nodes)) | |
5983 (setq thread (pop nodes)) | |
5984 (gnus-summary-limit-children thread)))))) | |
5985 gnus-newsgroup-dependencies) | |
5986 ;; If this limitation resulted in an empty group, we might | |
5987 ;; pop the previous limit and use it instead. | |
5988 (when (and (not gnus-newsgroup-limit) | |
5989 show-if-empty) | |
5990 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits))) | |
5991 gnus-newsgroup-limit)) | |
5992 | |
5993 (defun gnus-summary-limit-children (thread) | |
5994 "Return 1 if this subthread is visible and 0 if it is not." | |
5995 ;; First we get the number of visible children to this thread. This | |
5996 ;; is done by recursing down the thread using this function, so this | |
5997 ;; will really go down to a leaf article first, before slowly | |
5998 ;; working its way up towards the root. | |
5999 (when thread | |
6000 (let ((children | |
6001 (if (cdr thread) | |
6002 (apply '+ (mapcar 'gnus-summary-limit-children | |
6003 (cdr thread))) | |
6004 0)) | |
6005 (number (mail-header-number (car thread))) | |
6006 score) | |
6007 (if (and | |
6008 (not (memq number gnus-newsgroup-marked)) | |
6009 (or | |
6010 ;; If this article is dormant and has absolutely no visible | |
6011 ;; children, then this article isn't visible. | |
6012 (and (memq number gnus-newsgroup-dormant) | |
6013 (zerop children)) | |
6014 ;; If this is "fetch-old-headered" and there is no | |
6015 ;; visible children, then we don't want this article. | |
6016 (and (eq gnus-fetch-old-headers 'some) | |
6017 (gnus-summary-article-ancient-p number) | |
6018 (zerop children)) | |
6019 ;; If this is a sparsely inserted article with no children, | |
6020 ;; we don't want it. | |
6021 (and (eq gnus-build-sparse-threads 'some) | |
6022 (gnus-summary-article-sparse-p number) | |
6023 (zerop children)) | |
6024 ;; If we use expunging, and this article is really | |
6025 ;; low-scored, then we don't want this article. | |
6026 (when (and gnus-summary-expunge-below | |
6027 (< (setq score | |
6028 (or (cdr (assq number gnus-newsgroup-scored)) | |
6029 gnus-summary-default-score)) | |
6030 gnus-summary-expunge-below)) | |
6031 ;; We increase the expunge-tally here, but that has | |
6032 ;; nothing to do with the limits, really. | |
6033 (incf gnus-newsgroup-expunged-tally) | |
6034 ;; We also mark as read here, if that's wanted. | |
6035 (when (and gnus-summary-mark-below | |
6036 (< score gnus-summary-mark-below)) | |
6037 (setq gnus-newsgroup-unreads | |
6038 (delq number gnus-newsgroup-unreads)) | |
6039 (if gnus-newsgroup-auto-expire | |
6040 (push number gnus-newsgroup-expirable) | |
6041 (push (cons number gnus-low-score-mark) | |
6042 gnus-newsgroup-reads))) | |
6043 t) | |
6044 ;; Check NoCeM things. | |
6045 (if (and gnus-use-nocem | |
6046 (gnus-nocem-unwanted-article-p | |
6047 (mail-header-id (car thread)))) | |
6048 (progn | |
6049 (setq gnus-newsgroup-reads | |
6050 (delq number gnus-newsgroup-unreads)) | |
6051 t)))) | |
6052 ;; Nope, invisible article. | |
6053 0 | |
6054 ;; Ok, this article is to be visible, so we add it to the limit | |
6055 ;; and return 1. | |
6056 (push number gnus-newsgroup-limit) | |
6057 1)))) | |
6058 | |
6059 (defun gnus-expunge-thread (thread) | |
6060 "Mark all articles in THREAD as read." | |
6061 (let* ((number (mail-header-number (car thread)))) | |
6062 (incf gnus-newsgroup-expunged-tally) | |
6063 ;; We also mark as read here, if that's wanted. | |
6064 (setq gnus-newsgroup-unreads | |
6065 (delq number gnus-newsgroup-unreads)) | |
6066 (if gnus-newsgroup-auto-expire | |
6067 (push number gnus-newsgroup-expirable) | |
6068 (push (cons number gnus-low-score-mark) | |
6069 gnus-newsgroup-reads))) | |
6070 ;; Go recursively through all subthreads. | |
6071 (mapcar 'gnus-expunge-thread (cdr thread))) | |
6072 | |
6073 ;; Summary article oriented commands | |
6074 | |
6075 (defun gnus-summary-refer-parent-article (n) | |
6076 "Refer parent article N times. | |
6077 If N is negative, go to ancestor -N instead. | |
6078 The difference between N and the number of articles fetched is returned." | |
6079 (interactive "p") | |
6080 (gnus-set-global-variables) | |
6081 (let ((skip 1) | |
6082 error header ref) | |
6083 (when (not (natnump n)) | |
6084 (setq skip (abs n) | |
6085 n 1)) | |
6086 (while (and (> n 0) | |
6087 (not error)) | |
6088 (setq header (gnus-summary-article-header)) | |
6089 (if (and (eq (mail-header-number header) | |
6090 (cdr gnus-article-current)) | |
6091 (equal gnus-newsgroup-name | |
6092 (car gnus-article-current))) | |
6093 ;; If we try to find the parent of the currently | |
6094 ;; displayed article, then we take a look at the actual | |
6095 ;; References header, since this is slightly more | |
6096 ;; reliable than the References field we got from the | |
6097 ;; server. | |
6098 (save-excursion | |
6099 (set-buffer gnus-original-article-buffer) | |
6100 (nnheader-narrow-to-headers) | |
6101 (unless (setq ref (message-fetch-field "references")) | |
6102 (setq ref (message-fetch-field "in-reply-to"))) | |
6103 (widen)) | |
6104 (setq ref | |
6105 ;; It's not the current article, so we take a bet on | |
6106 ;; the value we got from the server. | |
6107 (mail-header-references header))) | |
6108 (if (and ref | |
6109 (not (equal ref ""))) | |
6110 (unless (gnus-summary-refer-article (gnus-parent-id ref skip)) | |
6111 (gnus-message 1 "Couldn't find parent")) | |
6112 (gnus-message 1 "No references in article %d" | |
6113 (gnus-summary-article-number)) | |
6114 (setq error t)) | |
6115 (decf n)) | |
6116 (gnus-summary-position-point) | |
6117 n)) | |
6118 | |
6119 (defun gnus-summary-refer-references () | |
6120 "Fetch all articles mentioned in the References header. | |
6121 Return how many articles were fetched." | |
6122 (interactive) | |
6123 (gnus-set-global-variables) | |
6124 (let ((ref (mail-header-references (gnus-summary-article-header))) | |
6125 (current (gnus-summary-article-number)) | |
6126 (n 0)) | |
6127 (if (or (not ref) | |
6128 (equal ref "")) | |
6129 (error "No References in the current article") | |
6130 ;; For each Message-ID in the References header... | |
6131 (while (string-match "<[^>]*>" ref) | |
6132 (incf n) | |
6133 ;; ... fetch that article. | |
6134 (gnus-summary-refer-article | |
6135 (prog1 (match-string 0 ref) | |
6136 (setq ref (substring ref (match-end 0)))))) | |
6137 (gnus-summary-goto-subject current) | |
6138 (gnus-summary-position-point) | |
6139 n))) | |
6140 | |
6141 (defun gnus-summary-refer-article (message-id &optional arg) | |
6142 "Fetch an article specified by MESSAGE-ID. | |
6143 If ARG (the prefix), fetch the article using `gnus-refer-article-method' | |
6144 or `gnus-select-method', no matter what backend the article comes from." | |
6145 (interactive "sMessage-ID: \nP") | |
6146 (when (and (stringp message-id) | |
6147 (not (zerop (length message-id)))) | |
6148 ;; Construct the correct Message-ID if necessary. | |
6149 ;; Suggested by tale@pawl.rpi.edu. | |
6150 (unless (string-match "^<" message-id) | |
6151 (setq message-id (concat "<" message-id))) | |
6152 (unless (string-match ">$" message-id) | |
6153 (setq message-id (concat message-id ">"))) | |
6154 (let* ((header (gnus-id-to-header message-id)) | |
6155 (sparse (and header | |
6156 (gnus-summary-article-sparse-p | |
6157 (mail-header-number header))))) | |
6158 (if header | |
6159 (prog1 | |
6160 ;; The article is present in the buffer, to we just go to it. | |
6161 (gnus-summary-goto-article | |
6162 (mail-header-number header) nil header) | |
6163 (when sparse | |
6164 (gnus-summary-update-article (mail-header-number header)))) | |
6165 ;; We fetch the article | |
6166 (let ((gnus-override-method | |
6167 (cond ((gnus-news-group-p gnus-newsgroup-name) | |
6168 gnus-refer-article-method) | |
6169 (arg | |
6170 (or gnus-refer-article-method gnus-select-method)) | |
6171 (t nil))) | |
6172 number) | |
6173 ;; Start the special refer-article method, if necessary. | |
6174 (when (and gnus-refer-article-method | |
6175 (gnus-news-group-p gnus-newsgroup-name)) | |
6176 (gnus-check-server gnus-refer-article-method)) | |
6177 ;; Fetch the header, and display the article. | |
6178 (if (setq number (gnus-summary-insert-subject message-id)) | |
6179 (gnus-summary-select-article nil nil nil number) | |
6180 (gnus-message 3 "Couldn't fetch article %s" message-id))))))) | |
6181 | |
6182 (defun gnus-summary-enter-digest-group (&optional force) | |
6183 "Enter an nndoc group based on the current article. | |
6184 If FORCE, force a digest interpretation. If not, try | |
6185 to guess what the document format is." | |
6186 (interactive "P") | |
6187 (gnus-set-global-variables) | |
6188 (let ((conf gnus-current-window-configuration)) | |
6189 (save-excursion | |
6190 (gnus-summary-select-article)) | |
6191 (setq gnus-current-window-configuration conf) | |
6192 (let* ((name (format "%s-%d" | |
6193 (gnus-group-prefixed-name | |
6194 gnus-newsgroup-name (list 'nndoc "")) | |
6195 (save-excursion | |
6196 (set-buffer gnus-summary-buffer) | |
6197 gnus-current-article))) | |
6198 (ogroup gnus-newsgroup-name) | |
6199 (params (append (gnus-info-params (gnus-get-info ogroup)) | |
6200 (list (cons 'to-group ogroup)) | |
6201 (list (cons 'save-article-group ogroup)))) | |
6202 (case-fold-search t) | |
6203 (buf (current-buffer)) | |
6204 dig) | |
6205 (save-excursion | |
6206 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*")) | |
6207 (insert-buffer-substring gnus-original-article-buffer) | |
6208 ;; Remove lines that may lead nndoc to misinterpret the | |
6209 ;; document type. | |
6210 (narrow-to-region | |
6211 (goto-char (point-min)) | |
6212 (or (search-forward "\n\n" nil t) (point))) | |
6213 (goto-char (point-min)) | |
6214 (delete-matching-lines "^\\(Path\\):\\|^From ") | |
6215 (widen)) | |
6216 (unwind-protect | |
6217 (if (gnus-group-read-ephemeral-group | |
6218 name `(nndoc ,name (nndoc-address ,(get-buffer dig)) | |
6219 (nndoc-article-type | |
6220 ,(if force 'digest 'guess))) t) | |
6221 ;; Make all postings to this group go to the parent group. | |
6222 (nconc (gnus-info-params (gnus-get-info name)) | |
6223 params) | |
6224 ;; Couldn't select this doc group. | |
6225 (switch-to-buffer buf) | |
6226 (gnus-set-global-variables) | |
6227 (gnus-configure-windows 'summary) | |
6228 (gnus-message 3 "Article couldn't be entered?")) | |
6229 (kill-buffer dig))))) | |
6230 | |
6231 (defun gnus-summary-read-document (n) | |
6232 "Open a new group based on the current article(s). | |
6233 This will allow you to read digests and other similar | |
6234 documents as newsgroups. | |
6235 Obeys the standard process/prefix convention." | |
6236 (interactive "P") | |
6237 (let* ((articles (gnus-summary-work-articles n)) | |
6238 (ogroup gnus-newsgroup-name) | |
6239 (params (append (gnus-info-params (gnus-get-info ogroup)) | |
6240 (list (cons 'to-group ogroup)))) | |
6241 article group egroup groups vgroup) | |
6242 (while (setq article (pop articles)) | |
6243 (setq group (format "%s-%d" gnus-newsgroup-name article)) | |
6244 (gnus-summary-remove-process-mark article) | |
6245 (when (gnus-summary-display-article article) | |
6246 (save-excursion | |
6247 (nnheader-temp-write nil | |
6248 (insert-buffer-substring gnus-original-article-buffer) | |
6249 ;; Remove some headers that may lead nndoc to make | |
6250 ;; the wrong guess. | |
6251 (message-narrow-to-head) | |
6252 (goto-char (point-min)) | |
6253 (delete-matching-lines "^\\(Path\\):\\|^From ") | |
6254 (widen) | |
6255 (if (setq egroup | |
6256 (gnus-group-read-ephemeral-group | |
6257 group `(nndoc ,group (nndoc-address ,(current-buffer)) | |
6258 (nndoc-article-type guess)) | |
6259 t nil t)) | |
6260 (progn | |
6261 ;; Make all postings to this group go to the parent group. | |
6262 (nconc (gnus-info-params (gnus-get-info egroup)) | |
6263 params) | |
6264 (push egroup groups)) | |
6265 ;; Couldn't select this doc group. | |
6266 (gnus-error 3 "Article couldn't be entered")))))) | |
6267 ;; Now we have selected all the documents. | |
6268 (cond | |
6269 ((not groups) | |
6270 (error "None of the articles could be interpreted as documents")) | |
6271 ((gnus-group-read-ephemeral-group | |
6272 (setq vgroup (format | |
6273 "nnvirtual:%s-%s" gnus-newsgroup-name | |
6274 (format-time-string "%Y%m%dT%H%M%S" (current-time)))) | |
6275 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups)) | |
6276 t | |
6277 (cons (current-buffer) 'summary))) | |
6278 (t | |
6279 (error "Couldn't select virtual nndoc group"))))) | |
6280 | |
6281 (defun gnus-summary-isearch-article (&optional regexp-p) | |
6282 "Do incremental search forward on the current article. | |
6283 If REGEXP-P (the prefix) is non-nil, do regexp isearch." | |
6284 (interactive "P") | |
6285 (gnus-set-global-variables) | |
6286 (gnus-summary-select-article) | |
6287 (gnus-configure-windows 'article) | |
6288 (gnus-eval-in-buffer-window gnus-article-buffer | |
6289 ;;(goto-char (point-min)) | |
6290 (isearch-forward regexp-p))) | |
6291 | |
6292 (defun gnus-summary-search-article-forward (regexp &optional backward) | |
6293 "Search for an article containing REGEXP forward. | |
6294 If BACKWARD, search backward instead." | |
6295 (interactive | |
6296 (list (read-string | |
6297 (format "Search article %s (regexp%s): " | |
6298 (if current-prefix-arg "backward" "forward") | |
6299 (if gnus-last-search-regexp | |
6300 (concat ", default " gnus-last-search-regexp) | |
6301 ""))) | |
6302 current-prefix-arg)) | |
6303 (gnus-set-global-variables) | |
6304 (if (string-equal regexp "") | |
6305 (setq regexp (or gnus-last-search-regexp "")) | |
6306 (setq gnus-last-search-regexp regexp)) | |
6307 (if (gnus-summary-search-article regexp backward) | |
6308 (gnus-summary-show-thread) | |
6309 (error "Search failed: \"%s\"" regexp))) | |
6310 | |
6311 (defun gnus-summary-search-article-backward (regexp) | |
6312 "Search for an article containing REGEXP backward." | |
6313 (interactive | |
6314 (list (read-string | |
6315 (format "Search article backward (regexp%s): " | |
6316 (if gnus-last-search-regexp | |
6317 (concat ", default " gnus-last-search-regexp) | |
6318 ""))))) | |
6319 (gnus-summary-search-article-forward regexp 'backward)) | |
6320 | |
6321 (defun gnus-summary-search-article (regexp &optional backward) | |
6322 "Search for an article containing REGEXP. | |
6323 Optional argument BACKWARD means do search for backward. | |
6324 `gnus-select-article-hook' is not called during the search." | |
6325 (let ((gnus-select-article-hook nil) ;Disable hook. | |
6326 (gnus-article-display-hook nil) | |
6327 (gnus-mark-article-hook nil) ;Inhibit marking as read. | |
6328 (gnus-use-article-prefetch nil) | |
6329 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay. | |
6330 (sum (current-buffer)) | |
6331 (found nil) | |
6332 point) | |
6333 (gnus-save-hidden-threads | |
6334 (gnus-summary-select-article) | |
6335 (set-buffer gnus-article-buffer) | |
6336 (when backward | |
6337 (forward-line -1)) | |
6338 (while (not found) | |
6339 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current)) | |
6340 (if (if backward | |
6341 (re-search-backward regexp nil t) | |
6342 (re-search-forward regexp nil t)) | |
6343 ;; We found the regexp. | |
6344 (progn | |
6345 (setq found 'found) | |
6346 (beginning-of-line) | |
6347 (set-window-start | |
6348 (get-buffer-window (current-buffer)) | |
6349 (point)) | |
6350 (forward-line 1) | |
6351 (set-buffer sum) | |
6352 (setq point (point))) | |
6353 ;; We didn't find it, so we go to the next article. | |
6354 (set-buffer sum) | |
6355 (setq found 'not) | |
6356 (while (eq found 'not) | |
6357 (if (not (if backward (gnus-summary-find-prev) | |
6358 (gnus-summary-find-next))) | |
6359 ;; No more articles. | |
6360 (setq found t) | |
6361 ;; Select the next article and adjust point. | |
6362 (unless (gnus-summary-article-sparse-p | |
6363 (gnus-summary-article-number)) | |
6364 (setq found nil) | |
6365 (gnus-summary-select-article) | |
6366 (set-buffer gnus-article-buffer) | |
6367 (widen) | |
6368 (goto-char (if backward (point-max) (point-min)))))))) | |
6369 (gnus-message 7 "")) | |
6370 ;; Return whether we found the regexp. | |
6371 (when (eq found 'found) | |
6372 (goto-char point) | |
6373 (gnus-summary-show-thread) | |
6374 (gnus-summary-goto-subject gnus-current-article) | |
6375 (gnus-summary-position-point) | |
6376 t))) | |
6377 | |
6378 (defun gnus-summary-find-matching (header regexp &optional backward unread | |
6379 not-case-fold) | |
6380 "Return a list of all articles that match REGEXP on HEADER. | |
6381 The search stars on the current article and goes forwards unless | |
6382 BACKWARD is non-nil. If BACKWARD is `all', do all articles. | |
6383 If UNREAD is non-nil, only unread articles will | |
6384 be taken into consideration. If NOT-CASE-FOLD, case won't be folded | |
6385 in the comparisons." | |
6386 (let ((data (if (eq backward 'all) gnus-newsgroup-data | |
6387 (gnus-data-find-list | |
6388 (gnus-summary-article-number) (gnus-data-list backward)))) | |
6389 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h))) | |
6390 (case-fold-search (not not-case-fold)) | |
6391 articles d) | |
6392 (unless (fboundp (intern (concat "mail-header-" header))) | |
6393 (error "%s is not a valid header" header)) | |
6394 (while data | |
6395 (setq d (car data)) | |
6396 (and (or (not unread) ; We want all articles... | |
6397 (gnus-data-unread-p d)) ; Or just unreads. | |
6398 (vectorp (gnus-data-header d)) ; It's not a pseudo. | |
6399 (string-match regexp (funcall func (gnus-data-header d))) ; Match. | |
6400 (push (gnus-data-number d) articles)) ; Success! | |
6401 (setq data (cdr data))) | |
6402 (nreverse articles))) | |
6403 | |
6404 (defun gnus-summary-execute-command (header regexp command &optional backward) | |
6405 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND. | |
6406 If HEADER is an empty string (or nil), the match is done on the entire | |
6407 article. If BACKWARD (the prefix) is non-nil, search backward instead." | |
6408 (interactive | |
6409 (list (let ((completion-ignore-case t)) | |
6410 (completing-read | |
6411 "Header name: " | |
6412 (mapcar (lambda (string) (list string)) | |
6413 '("Number" "Subject" "From" "Lines" "Date" | |
6414 "Message-ID" "Xref" "References" "Body")) | |
6415 nil 'require-match)) | |
6416 (read-string "Regexp: ") | |
6417 (read-key-sequence "Command: ") | |
6418 current-prefix-arg)) | |
6419 (when (equal header "Body") | |
6420 (setq header "")) | |
6421 (gnus-set-global-variables) | |
6422 ;; Hidden thread subtrees must be searched as well. | |
6423 (gnus-summary-show-all-threads) | |
6424 ;; We don't want to change current point nor window configuration. | |
6425 (save-excursion | |
6426 (save-window-excursion | |
6427 (gnus-message 6 "Executing %s..." (key-description command)) | |
6428 ;; We'd like to execute COMMAND interactively so as to give arguments. | |
6429 (gnus-execute header regexp | |
6430 `(call-interactively ',(key-binding command)) | |
6431 backward) | |
6432 (gnus-message 6 "Executing %s...done" (key-description command))))) | |
6433 | |
6434 (defun gnus-summary-beginning-of-article () | |
6435 "Scroll the article back to the beginning." | |
6436 (interactive) | |
6437 (gnus-set-global-variables) | |
6438 (gnus-summary-select-article) | |
6439 (gnus-configure-windows 'article) | |
6440 (gnus-eval-in-buffer-window gnus-article-buffer | |
6441 (widen) | |
6442 (goto-char (point-min)) | |
6443 (when gnus-page-broken | |
6444 (gnus-narrow-to-page)))) | |
6445 | |
6446 (defun gnus-summary-end-of-article () | |
6447 "Scroll to the end of the article." | |
6448 (interactive) | |
6449 (gnus-set-global-variables) | |
6450 (gnus-summary-select-article) | |
6451 (gnus-configure-windows 'article) | |
6452 (gnus-eval-in-buffer-window gnus-article-buffer | |
6453 (widen) | |
6454 (goto-char (point-max)) | |
6455 (recenter -3) | |
6456 (when gnus-page-broken | |
6457 (gnus-narrow-to-page)))) | |
6458 | |
6459 (defun gnus-summary-print-article (&optional filename) | |
6460 "Generate and print a PostScript image of the article buffer. | |
6461 | |
6462 If the optional argument FILENAME is nil, send the image to the printer. | |
6463 If FILENAME is a string, save the PostScript image in a file with that | |
6464 name. If FILENAME is a number, prompt the user for the name of the file | |
6465 to save in." | |
6466 (interactive (list (ps-print-preprint current-prefix-arg))) | |
6467 (gnus-summary-select-article) | |
6468 (gnus-eval-in-buffer-window gnus-article-buffer | |
6469 (let ((buffer (generate-new-buffer " *print*"))) | |
6470 (unwind-protect | |
6471 (progn | |
6472 (copy-to-buffer buffer (point-min) (point-max)) | |
6473 (set-buffer buffer) | |
6474 (gnus-article-delete-invisible-text) | |
6475 (run-hooks 'gnus-ps-print-hook) | |
6476 (ps-print-buffer-with-faces filename)) | |
6477 (kill-buffer buffer))))) | |
6478 | |
6479 (defun gnus-summary-show-article (&optional arg) | |
6480 "Force re-fetching of the current article. | |
6481 If ARG (the prefix) is non-nil, show the raw article without any | |
6482 article massaging functions being run." | |
6483 (interactive "P") | |
6484 (gnus-set-global-variables) | |
6485 (if (not arg) | |
6486 ;; Select the article the normal way. | |
6487 (gnus-summary-select-article nil 'force) | |
6488 ;; Bind the article treatment functions to nil. | |
6489 (let ((gnus-have-all-headers t) | |
6490 gnus-article-display-hook | |
6491 gnus-article-prepare-hook | |
6492 gnus-break-pages | |
6493 gnus-show-mime | |
6494 gnus-visual) | |
6495 (gnus-summary-select-article nil 'force))) | |
6496 (gnus-summary-goto-subject gnus-current-article) | |
6497 (gnus-summary-position-point)) | |
6498 | |
6499 (defun gnus-summary-verbose-headers (&optional arg) | |
6500 "Toggle permanent full header display. | |
6501 If ARG is a positive number, turn header display on. | |
6502 If ARG is a negative number, turn header display off." | |
6503 (interactive "P") | |
6504 (gnus-set-global-variables) | |
6505 (setq gnus-show-all-headers | |
6506 (cond ((or (not (numberp arg)) | |
6507 (zerop arg)) | |
6508 (not gnus-show-all-headers)) | |
6509 ((natnump arg) | |
6510 t))) | |
6511 (gnus-summary-show-article)) | |
6512 | |
6513 (defun gnus-summary-toggle-header (&optional arg) | |
6514 "Show the headers if they are hidden, or hide them if they are shown. | |
6515 If ARG is a positive number, show the entire header. | |
6516 If ARG is a negative number, hide the unwanted header lines." | |
6517 (interactive "P") | |
6518 (gnus-set-global-variables) | |
6519 (save-excursion | |
6520 (set-buffer gnus-article-buffer) | |
6521 (let* ((buffer-read-only nil) | |
6522 (inhibit-point-motion-hooks t) | |
6523 (hidden (text-property-any | |
6524 (goto-char (point-min)) (search-forward "\n\n") | |
6525 'invisible t)) | |
6526 e) | |
6527 (goto-char (point-min)) | |
6528 (when (search-forward "\n\n" nil t) | |
6529 (delete-region (point-min) (1- (point)))) | |
6530 (goto-char (point-min)) | |
6531 (save-excursion | |
6532 (set-buffer gnus-original-article-buffer) | |
6533 (goto-char (point-min)) | |
6534 (setq e (1- (or (search-forward "\n\n" nil t) (point-max))))) | |
6535 (insert-buffer-substring gnus-original-article-buffer 1 e) | |
6536 (let ((article-inhibit-hiding t)) | |
6537 (run-hooks 'gnus-article-display-hook)) | |
6538 (when (or (not hidden) (and (numberp arg) (< arg 0))) | |
6539 (gnus-article-hide-headers))))) | |
6540 | |
6541 (defun gnus-summary-show-all-headers () | |
6542 "Make all header lines visible." | |
6543 (interactive) | |
6544 (gnus-set-global-variables) | |
6545 (gnus-article-show-all-headers)) | |
6546 | |
6547 (defun gnus-summary-toggle-mime (&optional arg) | |
6548 "Toggle MIME processing. | |
6549 If ARG is a positive number, turn MIME processing on." | |
6550 (interactive "P") | |
6551 (gnus-set-global-variables) | |
6552 (setq gnus-show-mime | |
6553 (if (null arg) (not gnus-show-mime) | |
6554 (> (prefix-numeric-value arg) 0))) | |
6555 (gnus-summary-select-article t 'force)) | |
6556 | |
6557 (defun gnus-summary-caesar-message (&optional arg) | |
6558 "Caesar rotate the current article by 13. | |
6559 The numerical prefix specifies how many places to rotate each letter | |
6560 forward." | |
6561 (interactive "P") | |
6562 (gnus-set-global-variables) | |
6563 (gnus-summary-select-article) | |
6564 (let ((mail-header-separator "")) | |
6565 (gnus-eval-in-buffer-window gnus-article-buffer | |
6566 (save-restriction | |
6567 (widen) | |
6568 (let ((start (window-start)) | |
6569 buffer-read-only) | |
6570 (message-caesar-buffer-body arg) | |
6571 (set-window-start (get-buffer-window (current-buffer)) start)))))) | |
6572 | |
6573 (defun gnus-summary-stop-page-breaking () | |
6574 "Stop page breaking in the current article." | |
6575 (interactive) | |
6576 (gnus-set-global-variables) | |
6577 (gnus-summary-select-article) | |
6578 (gnus-eval-in-buffer-window gnus-article-buffer | |
6579 (widen) | |
6580 (when (gnus-visual-p 'page-marker) | |
6581 (let ((buffer-read-only nil)) | |
6582 (gnus-remove-text-with-property 'gnus-prev) | |
6583 (gnus-remove-text-with-property 'gnus-next))))) | |
6584 | |
6585 (defun gnus-summary-move-article (&optional n to-newsgroup | |
6586 select-method action) | |
6587 "Move the current article to a different newsgroup. | |
6588 If N is a positive number, move the N next articles. | |
6589 If N is a negative number, move the N previous articles. | |
6590 If N is nil and any articles have been marked with the process mark, | |
6591 move those articles instead. | |
6592 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to. | |
6593 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but | |
6594 re-spool using this method. | |
6595 | |
6596 For this function to work, both the current newsgroup and the | |
6597 newsgroup that you want to move to have to support the `request-move' | |
6598 and `request-accept' functions." | |
6599 (interactive "P") | |
6600 (unless action | |
6601 (setq action 'move)) | |
6602 (gnus-set-global-variables) | |
6603 ;; Disable marking as read. | |
6604 (let (gnus-mark-article-hook) | |
6605 (save-window-excursion | |
6606 (gnus-summary-select-article))) | |
6607 ;; Check whether the source group supports the required functions. | |
6608 (cond ((and (eq action 'move) | |
6609 (not (gnus-check-backend-function | |
6610 'request-move-article gnus-newsgroup-name))) | |
6611 (error "The current group does not support article moving")) | |
6612 ((and (eq action 'crosspost) | |
6613 (not (gnus-check-backend-function | |
6614 'request-replace-article gnus-newsgroup-name))) | |
6615 (error "The current group does not support article editing"))) | |
6616 (let ((articles (gnus-summary-work-articles n)) | |
6617 (prefix (gnus-group-real-prefix gnus-newsgroup-name)) | |
6618 (names '((move "Move" "Moving") | |
6619 (copy "Copy" "Copying") | |
6620 (crosspost "Crosspost" "Crossposting"))) | |
6621 (copy-buf (save-excursion | |
6622 (nnheader-set-temp-buffer " *copy article*"))) | |
6623 art-group to-method new-xref article to-groups) | |
6624 (unless (assq action names) | |
6625 (error "Unknown action %s" action)) | |
6626 ;; Read the newsgroup name. | |
6627 (when (and (not to-newsgroup) | |
6628 (not select-method)) | |
6629 (setq to-newsgroup | |
6630 (gnus-read-move-group-name | |
6631 (cadr (assq action names)) | |
6632 (symbol-value (intern (format "gnus-current-%s-group" action))) | |
6633 articles prefix)) | |
6634 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup)) | |
6635 (setq to-method (or select-method | |
6636 (gnus-group-name-to-method to-newsgroup))) | |
6637 ;; Check the method we are to move this article to... | |
6638 (unless (gnus-check-backend-function | |
6639 'request-accept-article (car to-method)) | |
6640 (error "%s does not support article copying" (car to-method))) | |
6641 (unless (gnus-check-server to-method) | |
6642 (error "Can't open server %s" (car to-method))) | |
6643 (gnus-message 6 "%s to %s: %s..." | |
6644 (caddr (assq action names)) | |
6645 (or (car select-method) to-newsgroup) articles) | |
6646 (while articles | |
6647 (setq article (pop articles)) | |
6648 (setq | |
6649 art-group | |
6650 (cond | |
6651 ;; Move the article. | |
6652 ((eq action 'move) | |
6653 (gnus-request-move-article | |
6654 article ; Article to move | |
6655 gnus-newsgroup-name ; From newsgroup | |
6656 (nth 1 (gnus-find-method-for-group | |
6657 gnus-newsgroup-name)) ; Server | |
6658 (list 'gnus-request-accept-article | |
6659 to-newsgroup (list 'quote select-method) | |
6660 (not articles)) ; Accept form | |
6661 (not articles))) ; Only save nov last time | |
6662 ;; Copy the article. | |
6663 ((eq action 'copy) | |
6664 (save-excursion | |
6665 (set-buffer copy-buf) | |
6666 (gnus-request-article-this-buffer article gnus-newsgroup-name) | |
6667 (gnus-request-accept-article | |
6668 to-newsgroup select-method (not articles)))) | |
6669 ;; Crosspost the article. | |
6670 ((eq action 'crosspost) | |
6671 (let ((xref (message-tokenize-header | |
6672 (mail-header-xref (gnus-summary-article-header article)) | |
6673 " "))) | |
6674 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name) | |
6675 ":" article)) | |
6676 (unless xref | |
6677 (setq xref (list (system-name)))) | |
6678 (setq new-xref | |
6679 (concat | |
6680 (mapconcat 'identity | |
6681 (delete "Xref:" (delete new-xref xref)) | |
6682 " ") | |
6683 " " new-xref)) | |
6684 (save-excursion | |
6685 (set-buffer copy-buf) | |
6686 ;; First put the article in the destination group. | |
6687 (gnus-request-article-this-buffer article gnus-newsgroup-name) | |
6688 (when (consp (setq art-group | |
6689 (gnus-request-accept-article | |
6690 to-newsgroup select-method (not articles)))) | |
6691 (setq new-xref (concat new-xref " " (car art-group) | |
6692 ":" (cdr art-group))) | |
6693 ;; Now we have the new Xrefs header, so we insert | |
6694 ;; it and replace the new article. | |
6695 (nnheader-replace-header "Xref" new-xref) | |
6696 (gnus-request-replace-article | |
6697 (cdr art-group) to-newsgroup (current-buffer)) | |
6698 art-group)))))) | |
6699 (cond | |
6700 ((not art-group) | |
6701 (gnus-message 1 "Couldn't %s article %s" | |
6702 (cadr (assq action names)) article)) | |
6703 ((and (eq art-group 'junk) | |
6704 (eq action 'move)) | |
6705 (gnus-summary-mark-article article gnus-canceled-mark) | |
6706 (gnus-message 4 "Deleted article %s" article)) | |
6707 (t | |
6708 (let* ((entry | |
6709 (or | |
6710 (gnus-gethash (car art-group) gnus-newsrc-hashtb) | |
6711 (gnus-gethash | |
6712 (gnus-group-prefixed-name | |
6713 (car art-group) | |
6714 (or select-method | |
6715 (gnus-find-method-for-group to-newsgroup))) | |
6716 gnus-newsrc-hashtb))) | |
6717 (info (nth 2 entry)) | |
6718 (to-group (gnus-info-group info))) | |
6719 ;; Update the group that has been moved to. | |
6720 (when (and info | |
6721 (memq action '(move copy))) | |
6722 (unless (member to-group to-groups) | |
6723 (push to-group to-groups)) | |
6724 | |
6725 (unless (memq article gnus-newsgroup-unreads) | |
6726 (gnus-info-set-read | |
6727 info (gnus-add-to-range (gnus-info-read info) | |
6728 (list (cdr art-group))))) | |
6729 | |
6730 ;; Copy any marks over to the new group. | |
6731 (let ((marks gnus-article-mark-lists) | |
6732 (to-article (cdr art-group))) | |
6733 | |
6734 ;; See whether the article is to be put in the cache. | |
6735 (when gnus-use-cache | |
6736 (gnus-cache-possibly-enter-article | |
6737 to-group to-article | |
6738 (let ((header (copy-sequence | |
6739 (gnus-summary-article-header article)))) | |
6740 (mail-header-set-number header to-article) | |
6741 header) | |
6742 (memq article gnus-newsgroup-marked) | |
6743 (memq article gnus-newsgroup-dormant) | |
6744 (memq article gnus-newsgroup-unreads))) | |
6745 | |
6746 (when (and (equal to-group gnus-newsgroup-name) | |
6747 (not (memq article gnus-newsgroup-unreads))) | |
6748 ;; Mark this article as read in this group. | |
6749 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads) | |
6750 (setcdr (gnus-active to-group) to-article) | |
6751 (setcdr gnus-newsgroup-active to-article)) | |
6752 | |
6753 (while marks | |
6754 (when (memq article (symbol-value | |
6755 (intern (format "gnus-newsgroup-%s" | |
6756 (caar marks))))) | |
6757 ;; If the other group is the same as this group, | |
6758 ;; then we have to add the mark to the list. | |
6759 (when (equal to-group gnus-newsgroup-name) | |
6760 (set (intern (format "gnus-newsgroup-%s" (caar marks))) | |
6761 (cons to-article | |
6762 (symbol-value | |
6763 (intern (format "gnus-newsgroup-%s" | |
6764 (caar marks))))))) | |
6765 ;; Copy the marks to other group. | |
6766 (gnus-add-marked-articles | |
6767 to-group (cdar marks) (list to-article) info)) | |
6768 (setq marks (cdr marks))) | |
6769 | |
6770 (gnus-dribble-enter | |
6771 (concat "(gnus-group-set-info '" | |
6772 (gnus-prin1-to-string (gnus-get-info to-group)) | |
6773 ")")))) | |
6774 | |
6775 ;; Update the Xref header in this article to point to | |
6776 ;; the new crossposted article we have just created. | |
6777 (when (eq action 'crosspost) | |
6778 (save-excursion | |
6779 (set-buffer copy-buf) | |
6780 (gnus-request-article-this-buffer article gnus-newsgroup-name) | |
6781 (nnheader-replace-header "Xref" new-xref) | |
6782 (gnus-request-replace-article | |
6783 article gnus-newsgroup-name (current-buffer))))) | |
6784 | |
6785 (gnus-summary-goto-subject article) | |
6786 (when (eq action 'move) | |
6787 (gnus-summary-mark-article article gnus-canceled-mark)))) | |
6788 (gnus-summary-remove-process-mark article)) | |
6789 ;; Re-activate all groups that have been moved to. | |
6790 (while to-groups | |
6791 (save-excursion | |
6792 (set-buffer gnus-group-buffer) | |
6793 (when (gnus-group-goto-group (car to-groups) t) | |
6794 (gnus-group-get-new-news-this-group 1)) | |
6795 (pop to-groups))) | |
6796 | |
6797 (gnus-kill-buffer copy-buf) | |
6798 (gnus-summary-position-point) | |
6799 (gnus-set-mode-line 'summary))) | |
6800 | |
6801 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method) | |
6802 "Move the current article to a different newsgroup. | |
6803 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to. | |
6804 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but | |
6805 re-spool using this method." | |
6806 (interactive "P") | |
6807 (gnus-summary-move-article n to-newsgroup select-method 'copy)) | |
6808 | |
6809 (defun gnus-summary-crosspost-article (&optional n) | |
6810 "Crosspost the current article to some other group." | |
6811 (interactive "P") | |
6812 (gnus-summary-move-article n nil nil 'crosspost)) | |
6813 | |
6814 (defcustom gnus-summary-respool-default-method nil | |
6815 "Default method for respooling an article. | |
6816 If nil, use to the current newsgroup method." | |
6817 :type 'gnus-select-method-name | |
6818 :group 'gnus-summary-mail) | |
6819 | |
6820 (defun gnus-summary-respool-article (&optional n method) | |
6821 "Respool the current article. | |
6822 The article will be squeezed through the mail spooling process again, | |
6823 which means that it will be put in some mail newsgroup or other | |
6824 depending on `nnmail-split-methods'. | |
6825 If N is a positive number, respool the N next articles. | |
6826 If N is a negative number, respool the N previous articles. | |
6827 If N is nil and any articles have been marked with the process mark, | |
6828 respool those articles instead. | |
6829 | |
6830 Respooling can be done both from mail groups and \"real\" newsgroups. | |
6831 In the former case, the articles in question will be moved from the | |
6832 current group into whatever groups they are destined to. In the | |
6833 latter case, they will be copied into the relevant groups." | |
6834 (interactive | |
6835 (list current-prefix-arg | |
6836 (let* ((methods (gnus-methods-using 'respool)) | |
6837 (methname | |
6838 (symbol-name (or gnus-summary-respool-default-method | |
6839 (car (gnus-find-method-for-group | |
6840 gnus-newsgroup-name))))) | |
6841 (method | |
6842 (gnus-completing-read | |
6843 methname "What backend do you want to use when respooling?" | |
6844 methods nil t nil 'gnus-mail-method-history)) | |
6845 ms) | |
6846 (cond | |
6847 ((zerop (length (setq ms (gnus-servers-using-backend | |
6848 (intern method))))) | |
6849 (list (intern method) "")) | |
6850 ((= 1 (length ms)) | |
6851 (car ms)) | |
6852 (t | |
6853 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms))) | |
6854 (cdr (assoc (completing-read "Server name: " ms-alist nil t) | |
6855 ms-alist)))))))) | |
6856 (gnus-set-global-variables) | |
6857 (unless method | |
6858 (error "No method given for respooling")) | |
6859 (if (assoc (symbol-name | |
6860 (car (gnus-find-method-for-group gnus-newsgroup-name))) | |
6861 (gnus-methods-using 'respool)) | |
6862 (gnus-summary-move-article n nil method) | |
6863 (gnus-summary-copy-article n nil method))) | |
6864 | |
6865 (defun gnus-summary-import-article (file) | |
6866 "Import a random file into a mail newsgroup." | |
6867 (interactive "fImport file: ") | |
6868 (gnus-set-global-variables) | |
6869 (let ((group gnus-newsgroup-name) | |
6870 (now (current-time)) | |
6871 atts lines) | |
6872 (unless (gnus-check-backend-function 'request-accept-article group) | |
6873 (error "%s does not support article importing" group)) | |
6874 (or (file-readable-p file) | |
6875 (not (file-regular-p file)) | |
6876 (error "Can't read %s" file)) | |
6877 (save-excursion | |
6878 (set-buffer (get-buffer-create " *import file*")) | |
6879 (buffer-disable-undo (current-buffer)) | |
6880 (erase-buffer) | |
6881 (insert-file-contents file) | |
6882 (goto-char (point-min)) | |
6883 (unless (nnheader-article-p) | |
6884 ;; This doesn't look like an article, so we fudge some headers. | |
6885 (setq atts (file-attributes file) | |
6886 lines (count-lines (point-min) (point-max))) | |
6887 (insert "From: " (read-string "From: ") "\n" | |
6888 "Subject: " (read-string "Subject: ") "\n" | |
6889 "Date: " (timezone-make-date-arpa-standard | |
6890 (current-time-string (nth 5 atts)) | |
6891 (current-time-zone now) | |
6892 (current-time-zone now)) | |
6893 "\n" | |
6894 "Message-ID: " (message-make-message-id) "\n" | |
6895 "Lines: " (int-to-string lines) "\n" | |
6896 "Chars: " (int-to-string (nth 7 atts)) "\n\n")) | |
6897 (gnus-request-accept-article group nil t) | |
6898 (kill-buffer (current-buffer))))) | |
6899 | |
6900 (defun gnus-summary-article-posted-p () | |
6901 "Say whether the current (mail) article is available from `gnus-select-method' as well. | |
6902 This will be the case if the article has both been mailed and posted." | |
6903 (interactive) | |
6904 (let ((id (mail-header-references (gnus-summary-article-header))) | |
6905 (gnus-override-method | |
6906 (or gnus-refer-article-method gnus-select-method))) | |
6907 (if (gnus-request-head id "") | |
6908 (gnus-message 2 "The current message was found on %s" | |
6909 gnus-override-method) | |
6910 (gnus-message 2 "The current message couldn't be found on %s" | |
6911 gnus-override-method) | |
6912 nil))) | |
6913 | |
6914 (defun gnus-summary-expire-articles (&optional now) | |
6915 "Expire all articles that are marked as expirable in the current group." | |
6916 (interactive) | |
6917 (gnus-set-global-variables) | |
6918 (when (gnus-check-backend-function | |
6919 'request-expire-articles gnus-newsgroup-name) | |
6920 ;; This backend supports expiry. | |
6921 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name)) | |
6922 (expirable (if total | |
6923 (progn | |
6924 ;; We need to update the info for | |
6925 ;; this group for `gnus-list-of-read-articles' | |
6926 ;; to give us the right answer. | |
6927 (run-hooks 'gnus-exit-group-hook) | |
6928 (gnus-summary-update-info) | |
6929 (gnus-list-of-read-articles gnus-newsgroup-name)) | |
6930 (setq gnus-newsgroup-expirable | |
6931 (sort gnus-newsgroup-expirable '<)))) | |
6932 (expiry-wait (if now 'immediate | |
6933 (gnus-group-find-parameter | |
6934 gnus-newsgroup-name 'expiry-wait))) | |
6935 es) | |
6936 (when expirable | |
6937 ;; There are expirable articles in this group, so we run them | |
6938 ;; through the expiry process. | |
6939 (gnus-message 6 "Expiring articles...") | |
6940 ;; The list of articles that weren't expired is returned. | |
6941 (if expiry-wait | |
6942 (let ((nnmail-expiry-wait-function nil) | |
6943 (nnmail-expiry-wait expiry-wait)) | |
6944 (setq es (gnus-request-expire-articles | |
6945 expirable gnus-newsgroup-name))) | |
6946 (setq es (gnus-request-expire-articles | |
6947 expirable gnus-newsgroup-name))) | |
6948 (unless total | |
6949 (setq gnus-newsgroup-expirable es)) | |
6950 ;; We go through the old list of expirable, and mark all | |
6951 ;; really expired articles as nonexistent. | |
6952 (unless (eq es expirable) ;If nothing was expired, we don't mark. | |
6953 (let ((gnus-use-cache nil)) | |
6954 (while expirable | |
6955 (unless (memq (car expirable) es) | |
6956 (when (gnus-data-find (car expirable)) | |
6957 (gnus-summary-mark-article | |
6958 (car expirable) gnus-canceled-mark))) | |
6959 (setq expirable (cdr expirable))))) | |
6960 (gnus-message 6 "Expiring articles...done"))))) | |
6961 | |
6962 (defun gnus-summary-expire-articles-now () | |
6963 "Expunge all expirable articles in the current group. | |
6964 This means that *all* articles that are marked as expirable will be | |
6965 deleted forever, right now." | |
6966 (interactive) | |
6967 (gnus-set-global-variables) | |
6968 (or gnus-expert-user | |
6969 (gnus-yes-or-no-p | |
6970 "Are you really, really, really sure you want to delete all these messages? ") | |
6971 (error "Phew!")) | |
6972 (gnus-summary-expire-articles t)) | |
6973 | |
6974 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. | |
6975 (defun gnus-summary-delete-article (&optional n) | |
6976 "Delete the N next (mail) articles. | |
6977 This command actually deletes articles. This is not a marking | |
6978 command. The article will disappear forever from your life, never to | |
6979 return. | |
6980 If N is negative, delete backwards. | |
6981 If N is nil and articles have been marked with the process mark, | |
6982 delete these instead." | |
6983 (interactive "P") | |
6984 (gnus-set-global-variables) | |
6985 (unless (gnus-check-backend-function 'request-expire-articles | |
6986 gnus-newsgroup-name) | |
6987 (error "The current newsgroup does not support article deletion.")) | |
6988 ;; Compute the list of articles to delete. | |
6989 (let ((articles (gnus-summary-work-articles n)) | |
6990 not-deleted) | |
6991 (if (and gnus-novice-user | |
6992 (not (gnus-yes-or-no-p | |
6993 (format "Do you really want to delete %s forever? " | |
6994 (if (> (length articles) 1) | |
6995 (format "these %s articles" (length articles)) | |
6996 "this article"))))) | |
6997 () | |
6998 ;; Delete the articles. | |
6999 (setq not-deleted (gnus-request-expire-articles | |
7000 articles gnus-newsgroup-name 'force)) | |
7001 (while articles | |
7002 (gnus-summary-remove-process-mark (car articles)) | |
7003 ;; The backend might not have been able to delete the article | |
7004 ;; after all. | |
7005 (unless (memq (car articles) not-deleted) | |
7006 (gnus-summary-mark-article (car articles) gnus-canceled-mark)) | |
7007 (setq articles (cdr articles))) | |
7008 (when not-deleted | |
7009 (gnus-message 4 "Couldn't delete articles %s" not-deleted))) | |
7010 (gnus-summary-position-point) | |
7011 (gnus-set-mode-line 'summary) | |
7012 not-deleted)) | |
7013 | |
7014 (defun gnus-summary-edit-article (&optional force) | |
7015 "Edit the current article. | |
7016 This will have permanent effect only in mail groups. | |
7017 If FORCE is non-nil, allow editing of articles even in read-only | |
7018 groups." | |
7019 (interactive "P") | |
7020 (save-excursion | |
7021 (set-buffer gnus-summary-buffer) | |
7022 (gnus-set-global-variables) | |
7023 (when (and (not force) | |
7024 (gnus-group-read-only-p)) | |
7025 (error "The current newsgroup does not support article editing.")) | |
7026 ;; Select article if needed. | |
7027 (unless (eq (gnus-summary-article-number) | |
7028 gnus-current-article) | |
7029 (gnus-summary-select-article t)) | |
7030 (gnus-article-edit-article | |
7031 `(lambda () | |
7032 (gnus-summary-edit-article-done | |
7033 ,(or (mail-header-references gnus-current-headers) "") | |
7034 ,(gnus-group-read-only-p) ,gnus-summary-buffer))))) | |
7035 | |
7036 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit) | |
7037 | |
7038 (defun gnus-summary-edit-article-done (&optional references read-only buffer) | |
7039 "Make edits to the current article permanent." | |
7040 (interactive) | |
7041 ;; Replace the article. | |
7042 (if (and (not read-only) | |
7043 (not (gnus-request-replace-article | |
7044 (cdr gnus-article-current) (car gnus-article-current) | |
7045 (current-buffer)))) | |
7046 (error "Couldn't replace article.") | |
7047 ;; Update the summary buffer. | |
7048 (if (and references | |
7049 (equal (message-tokenize-header references " ") | |
7050 (message-tokenize-header | |
7051 (or (message-fetch-field "references") "") " "))) | |
7052 ;; We only have to update this line. | |
7053 (save-excursion | |
7054 (save-restriction | |
7055 (message-narrow-to-head) | |
7056 (let ((head (buffer-string)) | |
7057 header) | |
7058 (nnheader-temp-write nil | |
7059 (insert (format "211 %d Article retrieved.\n" | |
7060 (cdr gnus-article-current))) | |
7061 (insert head) | |
7062 (insert ".\n") | |
7063 (let ((nntp-server-buffer (current-buffer))) | |
7064 (setq header (car (gnus-get-newsgroup-headers | |
7065 (save-excursion | |
7066 (set-buffer gnus-summary-buffer) | |
7067 gnus-newsgroup-dependencies) | |
7068 t)))) | |
7069 (save-excursion | |
7070 (set-buffer gnus-summary-buffer) | |
7071 (gnus-data-set-header | |
7072 (gnus-data-find (cdr gnus-article-current)) | |
7073 header) | |
7074 (gnus-summary-update-article-line | |
7075 (cdr gnus-article-current) header)))))) | |
7076 ;; Update threads. | |
7077 (set-buffer (or buffer gnus-summary-buffer)) | |
7078 (gnus-summary-update-article (cdr gnus-article-current))) | |
7079 ;; Prettify the article buffer again. | |
7080 (save-excursion | |
7081 (set-buffer gnus-article-buffer) | |
7082 (run-hooks 'gnus-article-display-hook) | |
7083 (set-buffer gnus-original-article-buffer) | |
7084 (gnus-request-article | |
7085 (cdr gnus-article-current) (car gnus-article-current) (current-buffer))) | |
7086 ;; Prettify the summary buffer line. | |
7087 (when (gnus-visual-p 'summary-highlight 'highlight) | |
7088 (run-hooks 'gnus-visual-mark-article-hook)))) | |
7089 | |
7090 (defun gnus-summary-edit-wash (key) | |
7091 "Perform editing command in the article buffer." | |
7092 (interactive | |
7093 (list | |
7094 (progn | |
7095 (message "%s" (concat (this-command-keys) "- ")) | |
7096 (read-char)))) | |
7097 (message "") | |
7098 (gnus-summary-edit-article) | |
7099 (execute-kbd-macro (concat (this-command-keys) key)) | |
7100 (gnus-article-edit-done)) | |
7101 | |
7102 ;;; Respooling | |
7103 | |
7104 (defun gnus-summary-respool-query (&optional silent) | |
7105 "Query where the respool algorithm would put this article." | |
7106 (interactive) | |
7107 (gnus-set-global-variables) | |
7108 (let (gnus-mark-article-hook) | |
7109 (gnus-summary-select-article) | |
7110 (save-excursion | |
7111 (set-buffer gnus-original-article-buffer) | |
7112 (save-restriction | |
7113 (message-narrow-to-head) | |
7114 (let ((groups (nnmail-article-group 'identity))) | |
7115 (unless silent | |
7116 (if groups | |
7117 (message "This message would go to %s" | |
7118 (mapconcat 'car groups ", ")) | |
7119 (message "This message would go to no groups")) | |
7120 groups)))))) | |
7121 | |
7122 ;; Summary marking commands. | |
7123 | |
7124 (defun gnus-summary-kill-same-subject-and-select (&optional unmark) | |
7125 "Mark articles which has the same subject as read, and then select the next. | |
7126 If UNMARK is positive, remove any kind of mark. | |
7127 If UNMARK is negative, tick articles." | |
7128 (interactive "P") | |
7129 (gnus-set-global-variables) | |
7130 (when unmark | |
7131 (setq unmark (prefix-numeric-value unmark))) | |
7132 (let ((count | |
7133 (gnus-summary-mark-same-subject | |
7134 (gnus-summary-article-subject) unmark))) | |
7135 ;; Select next unread article. If auto-select-same mode, should | |
7136 ;; select the first unread article. | |
7137 (gnus-summary-next-article t (and gnus-auto-select-same | |
7138 (gnus-summary-article-subject))) | |
7139 (gnus-message 7 "%d article%s marked as %s" | |
7140 count (if (= count 1) " is" "s are") | |
7141 (if unmark "unread" "read")))) | |
7142 | |
7143 (defun gnus-summary-kill-same-subject (&optional unmark) | |
7144 "Mark articles which has the same subject as read. | |
7145 If UNMARK is positive, remove any kind of mark. | |
7146 If UNMARK is negative, tick articles." | |
7147 (interactive "P") | |
7148 (gnus-set-global-variables) | |
7149 (when unmark | |
7150 (setq unmark (prefix-numeric-value unmark))) | |
7151 (let ((count | |
7152 (gnus-summary-mark-same-subject | |
7153 (gnus-summary-article-subject) unmark))) | |
7154 ;; If marked as read, go to next unread subject. | |
7155 (when (null unmark) | |
7156 ;; Go to next unread subject. | |
7157 (gnus-summary-next-subject 1 t)) | |
7158 (gnus-message 7 "%d articles are marked as %s" | |
7159 count (if unmark "unread" "read")))) | |
7160 | |
7161 (defun gnus-summary-mark-same-subject (subject &optional unmark) | |
7162 "Mark articles with same SUBJECT as read, and return marked number. | |
7163 If optional argument UNMARK is positive, remove any kinds of marks. | |
7164 If optional argument UNMARK is negative, mark articles as unread instead." | |
7165 (let ((count 1)) | |
7166 (save-excursion | |
7167 (cond | |
7168 ((null unmark) ; Mark as read. | |
7169 (while (and | |
7170 (progn | |
7171 (gnus-summary-mark-article-as-read gnus-killed-mark) | |
7172 (gnus-summary-show-thread) t) | |
7173 (gnus-summary-find-subject subject)) | |
7174 (setq count (1+ count)))) | |
7175 ((> unmark 0) ; Tick. | |
7176 (while (and | |
7177 (progn | |
7178 (gnus-summary-mark-article-as-unread gnus-ticked-mark) | |
7179 (gnus-summary-show-thread) t) | |
7180 (gnus-summary-find-subject subject)) | |
7181 (setq count (1+ count)))) | |
7182 (t ; Mark as unread. | |
7183 (while (and | |
7184 (progn | |
7185 (gnus-summary-mark-article-as-unread gnus-unread-mark) | |
7186 (gnus-summary-show-thread) t) | |
7187 (gnus-summary-find-subject subject)) | |
7188 (setq count (1+ count))))) | |
7189 (gnus-set-mode-line 'summary) | |
7190 ;; Return the number of marked articles. | |
7191 count))) | |
7192 | |
7193 (defun gnus-summary-mark-as-processable (n &optional unmark) | |
7194 "Set the process mark on the next N articles. | |
7195 If N is negative, mark backward instead. If UNMARK is non-nil, remove | |
7196 the process mark instead. The difference between N and the actual | |
7197 number of articles marked is returned." | |
7198 (interactive "p") | |
7199 (gnus-set-global-variables) | |
7200 (let ((backward (< n 0)) | |
7201 (n (abs n))) | |
7202 (while (and | |
7203 (> n 0) | |
7204 (if unmark | |
7205 (gnus-summary-remove-process-mark | |
7206 (gnus-summary-article-number)) | |
7207 (gnus-summary-set-process-mark (gnus-summary-article-number))) | |
7208 (zerop (gnus-summary-next-subject (if backward -1 1) nil t))) | |
7209 (setq n (1- n))) | |
7210 (when (/= 0 n) | |
7211 (gnus-message 7 "No more articles")) | |
7212 (gnus-summary-recenter) | |
7213 (gnus-summary-position-point) | |
7214 n)) | |
7215 | |
7216 (defun gnus-summary-unmark-as-processable (n) | |
7217 "Remove the process mark from the next N articles. | |
7218 If N is negative, mark backward instead. The difference between N and | |
7219 the actual number of articles marked is returned." | |
7220 (interactive "p") | |
7221 (gnus-set-global-variables) | |
7222 (gnus-summary-mark-as-processable n t)) | |
7223 | |
7224 (defun gnus-summary-unmark-all-processable () | |
7225 "Remove the process mark from all articles." | |
7226 (interactive) | |
7227 (gnus-set-global-variables) | |
7228 (save-excursion | |
7229 (while gnus-newsgroup-processable | |
7230 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable)))) | |
7231 (gnus-summary-position-point)) | |
7232 | |
7233 (defun gnus-summary-mark-as-expirable (n) | |
7234 "Mark N articles forward as expirable. | |
7235 If N is negative, mark backward instead. The difference between N and | |
7236 the actual number of articles marked is returned." | |
7237 (interactive "p") | |
7238 (gnus-set-global-variables) | |
7239 (gnus-summary-mark-forward n gnus-expirable-mark)) | |
7240 | |
7241 (defun gnus-summary-mark-article-as-replied (article) | |
7242 "Mark ARTICLE replied and update the summary line." | |
7243 (push article gnus-newsgroup-replied) | |
7244 (let ((buffer-read-only nil)) | |
7245 (when (gnus-summary-goto-subject article) | |
7246 (gnus-summary-update-secondary-mark article)))) | |
7247 | |
7248 (defun gnus-summary-set-bookmark (article) | |
7249 "Set a bookmark in current article." | |
7250 (interactive (list (gnus-summary-article-number))) | |
7251 (gnus-set-global-variables) | |
7252 (when (or (not (get-buffer gnus-article-buffer)) | |
7253 (not gnus-current-article) | |
7254 (not gnus-article-current) | |
7255 (not (equal gnus-newsgroup-name (car gnus-article-current)))) | |
7256 (error "No current article selected")) | |
7257 ;; Remove old bookmark, if one exists. | |
7258 (let ((old (assq article gnus-newsgroup-bookmarks))) | |
7259 (when old | |
7260 (setq gnus-newsgroup-bookmarks | |
7261 (delq old gnus-newsgroup-bookmarks)))) | |
7262 ;; Set the new bookmark, which is on the form | |
7263 ;; (article-number . line-number-in-body). | |
7264 (push | |
7265 (cons article | |
7266 (save-excursion | |
7267 (set-buffer gnus-article-buffer) | |
7268 (count-lines | |
7269 (min (point) | |
7270 (save-excursion | |
7271 (goto-char (point-min)) | |
7272 (search-forward "\n\n" nil t) | |
7273 (point))) | |
7274 (point)))) | |
7275 gnus-newsgroup-bookmarks) | |
7276 (gnus-message 6 "A bookmark has been added to the current article.")) | |
7277 | |
7278 (defun gnus-summary-remove-bookmark (article) | |
7279 "Remove the bookmark from the current article." | |
7280 (interactive (list (gnus-summary-article-number))) | |
7281 (gnus-set-global-variables) | |
7282 ;; Remove old bookmark, if one exists. | |
7283 (let ((old (assq article gnus-newsgroup-bookmarks))) | |
7284 (if old | |
7285 (progn | |
7286 (setq gnus-newsgroup-bookmarks | |
7287 (delq old gnus-newsgroup-bookmarks)) | |
7288 (gnus-message 6 "Removed bookmark.")) | |
7289 (gnus-message 6 "No bookmark in current article.")))) | |
7290 | |
7291 ;; Suggested by Daniel Quinlan <quinlan@best.com>. | |
7292 (defun gnus-summary-mark-as-dormant (n) | |
7293 "Mark N articles forward as dormant. | |
7294 If N is negative, mark backward instead. The difference between N and | |
7295 the actual number of articles marked is returned." | |
7296 (interactive "p") | |
7297 (gnus-set-global-variables) | |
7298 (gnus-summary-mark-forward n gnus-dormant-mark)) | |
7299 | |
7300 (defun gnus-summary-set-process-mark (article) | |
7301 "Set the process mark on ARTICLE and update the summary line." | |
7302 (setq gnus-newsgroup-processable | |
7303 (cons article | |
7304 (delq article gnus-newsgroup-processable))) | |
7305 (when (gnus-summary-goto-subject article) | |
7306 (gnus-summary-show-thread) | |
7307 (gnus-summary-update-secondary-mark article))) | |
7308 | |
7309 (defun gnus-summary-remove-process-mark (article) | |
7310 "Remove the process mark from ARTICLE and update the summary line." | |
7311 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable)) | |
7312 (when (gnus-summary-goto-subject article) | |
7313 (gnus-summary-show-thread) | |
7314 (gnus-summary-update-secondary-mark article))) | |
7315 | |
7316 (defun gnus-summary-set-saved-mark (article) | |
7317 "Set the process mark on ARTICLE and update the summary line." | |
7318 (push article gnus-newsgroup-saved) | |
7319 (when (gnus-summary-goto-subject article) | |
7320 (gnus-summary-update-secondary-mark article))) | |
7321 | |
7322 (defun gnus-summary-mark-forward (n &optional mark no-expire) | |
7323 "Mark N articles as read forwards. | |
7324 If N is negative, mark backwards instead. Mark with MARK, ?r by default. | |
7325 The difference between N and the actual number of articles marked is | |
7326 returned." | |
7327 (interactive "p") | |
7328 (gnus-set-global-variables) | |
7329 (let ((backward (< n 0)) | |
7330 (gnus-summary-goto-unread | |
7331 (and gnus-summary-goto-unread | |
7332 (not (eq gnus-summary-goto-unread 'never)) | |
7333 (not (memq mark (list gnus-unread-mark | |
7334 gnus-ticked-mark gnus-dormant-mark))))) | |
7335 (n (abs n)) | |
7336 (mark (or mark gnus-del-mark))) | |
7337 (while (and (> n 0) | |
7338 (gnus-summary-mark-article nil mark no-expire) | |
7339 (zerop (gnus-summary-next-subject | |
7340 (if backward -1 1) | |
7341 (and gnus-summary-goto-unread | |
7342 (not (eq gnus-summary-goto-unread 'never))) | |
7343 t))) | |
7344 (setq n (1- n))) | |
7345 (when (/= 0 n) | |
7346 (gnus-message 7 "No more %sarticles" (if mark "" "unread "))) | |
7347 (gnus-summary-recenter) | |
7348 (gnus-summary-position-point) | |
7349 (gnus-set-mode-line 'summary) | |
7350 n)) | |
7351 | |
7352 (defun gnus-summary-mark-article-as-read (mark) | |
7353 "Mark the current article quickly as read with MARK." | |
7354 (let ((article (gnus-summary-article-number))) | |
7355 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads)) | |
7356 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)) | |
7357 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)) | |
7358 (push (cons article mark) gnus-newsgroup-reads) | |
7359 ;; Possibly remove from cache, if that is used. | |
7360 (when gnus-use-cache | |
7361 (gnus-cache-enter-remove-article article)) | |
7362 ;; Allow the backend to change the mark. | |
7363 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark)) | |
7364 ;; Check for auto-expiry. | |
7365 (when (and gnus-newsgroup-auto-expire | |
7366 (or (= mark gnus-killed-mark) (= mark gnus-del-mark) | |
7367 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark) | |
7368 (= mark gnus-ancient-mark) | |
7369 (= mark gnus-read-mark) (= mark gnus-souped-mark) | |
7370 (= mark gnus-duplicate-mark))) | |
7371 (setq mark gnus-expirable-mark) | |
7372 (push article gnus-newsgroup-expirable)) | |
7373 ;; Set the mark in the buffer. | |
7374 (gnus-summary-update-mark mark 'unread) | |
7375 t)) | |
7376 | |
7377 (defun gnus-summary-mark-article-as-unread (mark) | |
7378 "Mark the current article quickly as unread with MARK." | |
7379 (let ((article (gnus-summary-article-number))) | |
7380 (if (< article 0) | |
7381 (gnus-error 1 "Unmarkable article") | |
7382 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)) | |
7383 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)) | |
7384 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)) | |
7385 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads)) | |
7386 (cond ((= mark gnus-ticked-mark) | |
7387 (push article gnus-newsgroup-marked)) | |
7388 ((= mark gnus-dormant-mark) | |
7389 (push article gnus-newsgroup-dormant)) | |
7390 (t | |
7391 (push article gnus-newsgroup-unreads))) | |
7392 (setq gnus-newsgroup-reads | |
7393 (delq (assq article gnus-newsgroup-reads) | |
7394 gnus-newsgroup-reads)) | |
7395 | |
7396 ;; See whether the article is to be put in the cache. | |
7397 (and gnus-use-cache | |
7398 (vectorp (gnus-summary-article-header article)) | |
7399 (save-excursion | |
7400 (gnus-cache-possibly-enter-article | |
7401 gnus-newsgroup-name article | |
7402 (gnus-summary-article-header article) | |
7403 (= mark gnus-ticked-mark) | |
7404 (= mark gnus-dormant-mark) (= mark gnus-unread-mark)))) | |
7405 | |
7406 ;; Fix the mark. | |
7407 (gnus-summary-update-mark mark 'unread)) | |
7408 t)) | |
7409 | |
7410 (defun gnus-summary-mark-article (&optional article mark no-expire) | |
7411 "Mark ARTICLE with MARK. MARK can be any character. | |
7412 Four MARK strings are reserved: `? ' (unread), `?!' (ticked), | |
7413 `??' (dormant) and `?E' (expirable). | |
7414 If MARK is nil, then the default character `?D' is used. | |
7415 If ARTICLE is nil, then the article on the current line will be | |
7416 marked." | |
7417 ;; The mark might be a string. | |
7418 (when (stringp mark) | |
7419 (setq mark (aref mark 0))) | |
7420 ;; If no mark is given, then we check auto-expiring. | |
7421 (and (not no-expire) | |
7422 gnus-newsgroup-auto-expire | |
7423 (or (not mark) | |
7424 (and (gnus-characterp mark) | |
7425 (or (= mark gnus-killed-mark) (= mark gnus-del-mark) | |
7426 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark) | |
7427 (= mark gnus-read-mark) (= mark gnus-souped-mark) | |
7428 (= mark gnus-duplicate-mark)))) | |
7429 (setq mark gnus-expirable-mark)) | |
7430 (let* ((mark (or mark gnus-del-mark)) | |
7431 (article (or article (gnus-summary-article-number)))) | |
7432 (unless article | |
7433 (error "No article on current line")) | |
7434 (if (or (= mark gnus-unread-mark) | |
7435 (= mark gnus-ticked-mark) | |
7436 (= mark gnus-dormant-mark)) | |
7437 (gnus-mark-article-as-unread article mark) | |
7438 (gnus-mark-article-as-read article mark)) | |
7439 | |
7440 ;; See whether the article is to be put in the cache. | |
7441 (and gnus-use-cache | |
7442 (not (= mark gnus-canceled-mark)) | |
7443 (vectorp (gnus-summary-article-header article)) | |
7444 (save-excursion | |
7445 (gnus-cache-possibly-enter-article | |
7446 gnus-newsgroup-name article | |
7447 (gnus-summary-article-header article) | |
7448 (= mark gnus-ticked-mark) | |
7449 (= mark gnus-dormant-mark) (= mark gnus-unread-mark)))) | |
7450 | |
7451 (when (gnus-summary-goto-subject article nil t) | |
7452 (let ((buffer-read-only nil)) | |
7453 (gnus-summary-show-thread) | |
7454 ;; Fix the mark. | |
7455 (gnus-summary-update-mark mark 'unread) | |
7456 t)))) | |
7457 | |
7458 (defun gnus-summary-update-secondary-mark (article) | |
7459 "Update the secondary (read, process, cache) mark." | |
7460 (gnus-summary-update-mark | |
7461 (cond ((memq article gnus-newsgroup-processable) | |
7462 gnus-process-mark) | |
7463 ((memq article gnus-newsgroup-cached) | |
7464 gnus-cached-mark) | |
7465 ((memq article gnus-newsgroup-replied) | |
7466 gnus-replied-mark) | |
7467 ((memq article gnus-newsgroup-saved) | |
7468 gnus-saved-mark) | |
7469 (t gnus-unread-mark)) | |
7470 'replied) | |
7471 (when (gnus-visual-p 'summary-highlight 'highlight) | |
7472 (run-hooks 'gnus-summary-update-hook)) | |
7473 t) | |
7474 | |
7475 (defun gnus-summary-update-mark (mark type) | |
7476 (let ((forward (cdr (assq type gnus-summary-mark-positions))) | |
7477 (buffer-read-only nil)) | |
7478 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit) | |
7479 (when (looking-at "\r") | |
7480 (incf forward)) | |
7481 (when (and forward | |
7482 (<= (+ forward (point)) (point-max))) | |
7483 ;; Go to the right position on the line. | |
7484 (goto-char (+ forward (point))) | |
7485 ;; Replace the old mark with the new mark. | |
7486 (subst-char-in-region (point) (1+ (point)) (following-char) mark) | |
7487 ;; Optionally update the marks by some user rule. | |
7488 (when (eq type 'unread) | |
7489 (gnus-data-set-mark | |
7490 (gnus-data-find (gnus-summary-article-number)) mark) | |
7491 (gnus-summary-update-line (eq mark gnus-unread-mark)))))) | |
7492 | |
7493 (defun gnus-mark-article-as-read (article &optional mark) | |
7494 "Enter ARTICLE in the pertinent lists and remove it from others." | |
7495 ;; Make the article expirable. | |
7496 (let ((mark (or mark gnus-del-mark))) | |
7497 (if (= mark gnus-expirable-mark) | |
7498 (push article gnus-newsgroup-expirable) | |
7499 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))) | |
7500 ;; Remove from unread and marked lists. | |
7501 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads)) | |
7502 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)) | |
7503 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)) | |
7504 (push (cons article mark) gnus-newsgroup-reads) | |
7505 ;; Possibly remove from cache, if that is used. | |
7506 (when gnus-use-cache | |
7507 (gnus-cache-enter-remove-article article)))) | |
7508 | |
7509 (defun gnus-mark-article-as-unread (article &optional mark) | |
7510 "Enter ARTICLE in the pertinent lists and remove it from others." | |
7511 (let ((mark (or mark gnus-ticked-mark))) | |
7512 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked) | |
7513 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant) | |
7514 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable) | |
7515 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads)) | |
7516 | |
7517 ;; Unsuppress duplicates? | |
7518 (when gnus-suppress-duplicates | |
7519 (gnus-dup-unsuppress-article article)) | |
7520 | |
7521 (cond ((= mark gnus-ticked-mark) | |
7522 (push article gnus-newsgroup-marked)) | |
7523 ((= mark gnus-dormant-mark) | |
7524 (push article gnus-newsgroup-dormant)) | |
7525 (t | |
7526 (push article gnus-newsgroup-unreads))) | |
7527 (setq gnus-newsgroup-reads | |
7528 (delq (assq article gnus-newsgroup-reads) | |
7529 gnus-newsgroup-reads)))) | |
7530 | |
7531 (defalias 'gnus-summary-mark-as-unread-forward | |
7532 'gnus-summary-tick-article-forward) | |
7533 (make-obsolete 'gnus-summary-mark-as-unread-forward | |
7534 'gnus-summary-tick-article-forward) | |
7535 (defun gnus-summary-tick-article-forward (n) | |
7536 "Tick N articles forwards. | |
7537 If N is negative, tick backwards instead. | |
7538 The difference between N and the number of articles ticked is returned." | |
7539 (interactive "p") | |
7540 (gnus-summary-mark-forward n gnus-ticked-mark)) | |
7541 | |
7542 (defalias 'gnus-summary-mark-as-unread-backward | |
7543 'gnus-summary-tick-article-backward) | |
7544 (make-obsolete 'gnus-summary-mark-as-unread-backward | |
7545 'gnus-summary-tick-article-backward) | |
7546 (defun gnus-summary-tick-article-backward (n) | |
7547 "Tick N articles backwards. | |
7548 The difference between N and the number of articles ticked is returned." | |
7549 (interactive "p") | |
7550 (gnus-summary-mark-forward (- n) gnus-ticked-mark)) | |
7551 | |
7552 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article) | |
7553 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article) | |
7554 (defun gnus-summary-tick-article (&optional article clear-mark) | |
7555 "Mark current article as unread. | |
7556 Optional 1st argument ARTICLE specifies article number to be marked as unread. | |
7557 Optional 2nd argument CLEAR-MARK remove any kinds of mark." | |
7558 (interactive) | |
7559 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark | |
7560 gnus-ticked-mark))) | |
7561 | |
7562 (defun gnus-summary-mark-as-read-forward (n) | |
7563 "Mark N articles as read forwards. | |
7564 If N is negative, mark backwards instead. | |
7565 The difference between N and the actual number of articles marked is | |
7566 returned." | |
7567 (interactive "p") | |
7568 (gnus-summary-mark-forward n gnus-del-mark t)) | |
7569 | |
7570 (defun gnus-summary-mark-as-read-backward (n) | |
7571 "Mark the N articles as read backwards. | |
7572 The difference between N and the actual number of articles marked is | |
7573 returned." | |
7574 (interactive "p") | |
7575 (gnus-summary-mark-forward (- n) gnus-del-mark t)) | |
7576 | |
7577 (defun gnus-summary-mark-as-read (&optional article mark) | |
7578 "Mark current article as read. | |
7579 ARTICLE specifies the article to be marked as read. | |
7580 MARK specifies a string to be inserted at the beginning of the line." | |
7581 (gnus-summary-mark-article article mark)) | |
7582 | |
7583 (defun gnus-summary-clear-mark-forward (n) | |
7584 "Clear marks from N articles forward. | |
7585 If N is negative, clear backward instead. | |
7586 The difference between N and the number of marks cleared is returned." | |
7587 (interactive "p") | |
7588 (gnus-summary-mark-forward n gnus-unread-mark)) | |
7589 | |
7590 (defun gnus-summary-clear-mark-backward (n) | |
7591 "Clear marks from N articles backward. | |
7592 The difference between N and the number of marks cleared is returned." | |
7593 (interactive "p") | |
7594 (gnus-summary-mark-forward (- n) gnus-unread-mark)) | |
7595 | |
7596 (defun gnus-summary-mark-unread-as-read () | |
7597 "Intended to be used by `gnus-summary-mark-article-hook'." | |
7598 (when (memq gnus-current-article gnus-newsgroup-unreads) | |
7599 (gnus-summary-mark-article gnus-current-article gnus-read-mark))) | |
7600 | |
7601 (defun gnus-summary-mark-read-and-unread-as-read () | |
7602 "Intended to be used by `gnus-summary-mark-article-hook'." | |
7603 (let ((mark (gnus-summary-article-mark))) | |
7604 (when (or (gnus-unread-mark-p mark) | |
7605 (gnus-read-mark-p mark)) | |
7606 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))) | |
7607 | |
7608 (defun gnus-summary-mark-region-as-read (point mark all) | |
7609 "Mark all unread articles between point and mark as read. | |
7610 If given a prefix, mark all articles between point and mark as read, | |
7611 even ticked and dormant ones." | |
7612 (interactive "r\nP") | |
7613 (save-excursion | |
7614 (let (article) | |
7615 (goto-char point) | |
7616 (beginning-of-line) | |
7617 (while (and | |
7618 (< (point) mark) | |
7619 (progn | |
7620 (when (or all | |
7621 (memq (setq article (gnus-summary-article-number)) | |
7622 gnus-newsgroup-unreads)) | |
7623 (gnus-summary-mark-article article gnus-del-mark)) | |
7624 t) | |
7625 (gnus-summary-find-next)))))) | |
7626 | |
7627 (defun gnus-summary-mark-below (score mark) | |
7628 "Mark articles with score less than SCORE with MARK." | |
7629 (interactive "P\ncMark: ") | |
7630 (gnus-set-global-variables) | |
7631 (setq score (if score | |
7632 (prefix-numeric-value score) | |
7633 (or gnus-summary-default-score 0))) | |
7634 (save-excursion | |
7635 (set-buffer gnus-summary-buffer) | |
7636 (goto-char (point-min)) | |
7637 (while | |
7638 (progn | |
7639 (and (< (gnus-summary-article-score) score) | |
7640 (gnus-summary-mark-article nil mark)) | |
7641 (gnus-summary-find-next))))) | |
7642 | |
7643 (defun gnus-summary-kill-below (&optional score) | |
7644 "Mark articles with score below SCORE as read." | |
7645 (interactive "P") | |
7646 (gnus-set-global-variables) | |
7647 (gnus-summary-mark-below score gnus-killed-mark)) | |
7648 | |
7649 (defun gnus-summary-clear-above (&optional score) | |
7650 "Clear all marks from articles with score above SCORE." | |
7651 (interactive "P") | |
7652 (gnus-set-global-variables) | |
7653 (gnus-summary-mark-above score gnus-unread-mark)) | |
7654 | |
7655 (defun gnus-summary-tick-above (&optional score) | |
7656 "Tick all articles with score above SCORE." | |
7657 (interactive "P") | |
7658 (gnus-set-global-variables) | |
7659 (gnus-summary-mark-above score gnus-ticked-mark)) | |
7660 | |
7661 (defun gnus-summary-mark-above (score mark) | |
7662 "Mark articles with score over SCORE with MARK." | |
7663 (interactive "P\ncMark: ") | |
7664 (gnus-set-global-variables) | |
7665 (setq score (if score | |
7666 (prefix-numeric-value score) | |
7667 (or gnus-summary-default-score 0))) | |
7668 (save-excursion | |
7669 (set-buffer gnus-summary-buffer) | |
7670 (goto-char (point-min)) | |
7671 (while (and (progn | |
7672 (when (> (gnus-summary-article-score) score) | |
7673 (gnus-summary-mark-article nil mark)) | |
7674 t) | |
7675 (gnus-summary-find-next))))) | |
7676 | |
7677 ;; Suggested by Daniel Quinlan <quinlan@best.com>. | |
7678 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged) | |
7679 (defun gnus-summary-limit-include-expunged (&optional no-error) | |
7680 "Display all the hidden articles that were expunged for low scores." | |
7681 (interactive) | |
7682 (gnus-set-global-variables) | |
7683 (let ((buffer-read-only nil)) | |
7684 (let ((scored gnus-newsgroup-scored) | |
7685 headers h) | |
7686 (while scored | |
7687 (unless (gnus-summary-goto-subject (caar scored)) | |
7688 (and (setq h (gnus-summary-article-header (caar scored))) | |
7689 (< (cdar scored) gnus-summary-expunge-below) | |
7690 (push h headers))) | |
7691 (setq scored (cdr scored))) | |
7692 (if (not headers) | |
7693 (when (not no-error) | |
7694 (error "No expunged articles hidden.")) | |
7695 (goto-char (point-min)) | |
7696 (gnus-summary-prepare-unthreaded (nreverse headers)) | |
7697 (goto-char (point-min)) | |
7698 (gnus-summary-position-point) | |
7699 t)))) | |
7700 | |
7701 (defun gnus-summary-catchup (&optional all quietly to-here not-mark) | |
7702 "Mark all unread articles in this newsgroup as read. | |
7703 If prefix argument ALL is non-nil, ticked and dormant articles will | |
7704 also be marked as read. | |
7705 If QUIETLY is non-nil, no questions will be asked. | |
7706 If TO-HERE is non-nil, it should be a point in the buffer. All | |
7707 articles before this point will be marked as read. | |
7708 Note that this function will only catch up the unread article | |
7709 in the current summary buffer limitation. | |
7710 The number of articles marked as read is returned." | |
7711 (interactive "P") | |
7712 (gnus-set-global-variables) | |
7713 (prog1 | |
7714 (save-excursion | |
7715 (when (or quietly | |
7716 (not gnus-interactive-catchup) ;Without confirmation? | |
7717 gnus-expert-user | |
7718 (gnus-y-or-n-p | |
7719 (if all | |
7720 "Mark absolutely all articles as read? " | |
7721 "Mark all unread articles as read? "))) | |
7722 (if (and not-mark | |
7723 (not gnus-newsgroup-adaptive) | |
7724 (not gnus-newsgroup-auto-expire) | |
7725 (not gnus-suppress-duplicates)) | |
7726 (progn | |
7727 (when all | |
7728 (setq gnus-newsgroup-marked nil | |
7729 gnus-newsgroup-dormant nil)) | |
7730 (setq gnus-newsgroup-unreads nil)) | |
7731 ;; We actually mark all articles as canceled, which we | |
7732 ;; have to do when using auto-expiry or adaptive scoring. | |
7733 (gnus-summary-show-all-threads) | |
7734 (when (gnus-summary-first-subject (not all)) | |
7735 (while (and | |
7736 (if to-here (< (point) to-here) t) | |
7737 (gnus-summary-mark-article-as-read gnus-catchup-mark) | |
7738 (gnus-summary-find-next (not all))))) | |
7739 (gnus-set-mode-line 'summary)) | |
7740 t)) | |
7741 (gnus-summary-position-point))) | |
7742 | |
7743 (defun gnus-summary-catchup-to-here (&optional all) | |
7744 "Mark all unticked articles before the current one as read. | |
7745 If ALL is non-nil, also mark ticked and dormant articles as read." | |
7746 (interactive "P") | |
7747 (gnus-set-global-variables) | |
7748 (save-excursion | |
7749 (gnus-save-hidden-threads | |
7750 (let ((beg (point))) | |
7751 ;; We check that there are unread articles. | |
7752 (when (or all (gnus-summary-find-prev)) | |
7753 (gnus-summary-catchup all t beg))))) | |
7754 (gnus-summary-position-point)) | |
7755 | |
7756 (defun gnus-summary-catchup-all (&optional quietly) | |
7757 "Mark all articles in this newsgroup as read." | |
7758 (interactive "P") | |
7759 (gnus-set-global-variables) | |
7760 (gnus-summary-catchup t quietly)) | |
7761 | |
7762 (defun gnus-summary-catchup-and-exit (&optional all quietly) | |
7763 "Mark all articles not marked as unread in this newsgroup as read, then exit. | |
7764 If prefix argument ALL is non-nil, all articles are marked as read." | |
7765 (interactive "P") | |
7766 (gnus-set-global-variables) | |
7767 (when (gnus-summary-catchup all quietly nil 'fast) | |
7768 ;; Select next newsgroup or exit. | |
7769 (if (eq gnus-auto-select-next 'quietly) | |
7770 (gnus-summary-next-group nil) | |
7771 (gnus-summary-exit)))) | |
7772 | |
7773 (defun gnus-summary-catchup-all-and-exit (&optional quietly) | |
7774 "Mark all articles in this newsgroup as read, and then exit." | |
7775 (interactive "P") | |
7776 (gnus-set-global-variables) | |
7777 (gnus-summary-catchup-and-exit t quietly)) | |
7778 | |
7779 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>. | |
7780 (defun gnus-summary-catchup-and-goto-next-group (&optional all) | |
7781 "Mark all articles in this group as read and select the next group. | |
7782 If given a prefix, mark all articles, unread as well as ticked, as | |
7783 read." | |
7784 (interactive "P") | |
7785 (gnus-set-global-variables) | |
7786 (save-excursion | |
7787 (gnus-summary-catchup all)) | |
7788 (gnus-summary-next-article t nil nil t)) | |
7789 | |
7790 ;; Thread-based commands. | |
7791 | |
7792 (defun gnus-summary-articles-in-thread (&optional article) | |
7793 "Return a list of all articles in the current thread. | |
7794 If ARTICLE is non-nil, return all articles in the thread that starts | |
7795 with that article." | |
7796 (let* ((article (or article (gnus-summary-article-number))) | |
7797 (data (gnus-data-find-list article)) | |
7798 (top-level (gnus-data-level (car data))) | |
7799 (top-subject | |
7800 (cond ((null gnus-thread-operation-ignore-subject) | |
7801 (gnus-simplify-subject-re | |
7802 (mail-header-subject (gnus-data-header (car data))))) | |
7803 ((eq gnus-thread-operation-ignore-subject 'fuzzy) | |
7804 (gnus-simplify-subject-fuzzy | |
7805 (mail-header-subject (gnus-data-header (car data))))) | |
7806 (t nil))) | |
7807 (end-point (save-excursion | |
7808 (if (gnus-summary-go-to-next-thread) | |
7809 (point) (point-max)))) | |
7810 articles) | |
7811 (while (and data | |
7812 (< (gnus-data-pos (car data)) end-point)) | |
7813 (when (or (not top-subject) | |
7814 (string= top-subject | |
7815 (if (eq gnus-thread-operation-ignore-subject 'fuzzy) | |
7816 (gnus-simplify-subject-fuzzy | |
7817 (mail-header-subject | |
7818 (gnus-data-header (car data)))) | |
7819 (gnus-simplify-subject-re | |
7820 (mail-header-subject | |
7821 (gnus-data-header (car data))))))) | |
7822 (push (gnus-data-number (car data)) articles)) | |
7823 (unless (and (setq data (cdr data)) | |
7824 (> (gnus-data-level (car data)) top-level)) | |
7825 (setq data nil))) | |
7826 ;; Return the list of articles. | |
7827 (nreverse articles))) | |
7828 | |
7829 (defun gnus-summary-rethread-current () | |
7830 "Rethread the thread the current article is part of." | |
7831 (interactive) | |
7832 (gnus-set-global-variables) | |
7833 (let* ((gnus-show-threads t) | |
7834 (article (gnus-summary-article-number)) | |
7835 (id (mail-header-id (gnus-summary-article-header))) | |
7836 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id))))) | |
7837 (unless id | |
7838 (error "No article on the current line")) | |
7839 (gnus-rebuild-thread id) | |
7840 (gnus-summary-goto-subject article))) | |
7841 | |
7842 (defun gnus-summary-reparent-thread () | |
7843 "Make the current article child of the marked (or previous) article. | |
7844 | |
7845 Note that the re-threading will only work if `gnus-thread-ignore-subject' | |
7846 is non-nil or the Subject: of both articles are the same." | |
7847 (interactive) | |
7848 (unless (not (gnus-group-read-only-p)) | |
7849 (error "The current newsgroup does not support article editing.")) | |
7850 (unless (<= (length gnus-newsgroup-processable) 1) | |
7851 (error "No more than one article may be marked.")) | |
7852 (save-window-excursion | |
7853 (let ((gnus-article-buffer " *reparent*") | |
7854 (current-article (gnus-summary-article-number)) | |
7855 ;; First grab the marked article, otherwise one line up. | |
7856 (parent-article (if (not (null gnus-newsgroup-processable)) | |
7857 (car gnus-newsgroup-processable) | |
7858 (save-excursion | |
7859 (if (eq (forward-line -1) 0) | |
7860 (gnus-summary-article-number) | |
7861 (error "Beginning of summary buffer.")))))) | |
7862 (unless (not (eq current-article parent-article)) | |
7863 (error "An article may not be self-referential.")) | |
7864 (let ((message-id (mail-header-id | |
7865 (gnus-summary-article-header parent-article)))) | |
7866 (unless (and message-id (not (equal message-id ""))) | |
7867 (error "No message-id in desired parent.")) | |
7868 (gnus-summary-select-article t t nil current-article) | |
7869 (set-buffer gnus-original-article-buffer) | |
7870 (let ((buf (format "%s" (buffer-string)))) | |
7871 (nnheader-temp-write nil | |
7872 (insert buf) | |
7873 (goto-char (point-min)) | |
7874 (if (search-forward-regexp "^References: " nil t) | |
7875 (insert message-id " " ) | |
7876 (insert "References: " message-id "\n")) | |
7877 (unless (gnus-request-replace-article | |
7878 current-article (car gnus-article-current) | |
7879 (current-buffer)) | |
7880 (error "Couldn't replace article.")))) | |
7881 (set-buffer gnus-summary-buffer) | |
7882 (gnus-summary-unmark-all-processable) | |
7883 (gnus-summary-rethread-current) | |
7884 (gnus-message 3 "Article %d is now the child of article %d." | |
7885 current-article parent-article))))) | |
7886 | |
7887 (defun gnus-summary-toggle-threads (&optional arg) | |
7888 "Toggle showing conversation threads. | |
7889 If ARG is positive number, turn showing conversation threads on." | |
7890 (interactive "P") | |
7891 (gnus-set-global-variables) | |
7892 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end))) | |
7893 (setq gnus-show-threads | |
7894 (if (null arg) (not gnus-show-threads) | |
7895 (> (prefix-numeric-value arg) 0))) | |
7896 (gnus-summary-prepare) | |
7897 (gnus-summary-goto-subject current) | |
7898 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off")) | |
7899 (gnus-summary-position-point))) | |
7900 | |
7901 (defun gnus-summary-show-all-threads () | |
7902 "Show all threads." | |
7903 (interactive) | |
7904 (gnus-set-global-variables) | |
7905 (save-excursion | |
7906 (let ((buffer-read-only nil)) | |
7907 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t))) | |
7908 (gnus-summary-position-point)) | |
7909 | |
7910 (defun gnus-summary-show-thread () | |
7911 "Show thread subtrees. | |
7912 Returns nil if no thread was there to be shown." | |
7913 (interactive) | |
7914 (gnus-set-global-variables) | |
7915 (let ((buffer-read-only nil) | |
7916 (orig (point)) | |
7917 ;; first goto end then to beg, to have point at beg after let | |
7918 (end (progn (end-of-line) (point))) | |
7919 (beg (progn (beginning-of-line) (point)))) | |
7920 (prog1 | |
7921 ;; Any hidden lines here? | |
7922 (search-forward "\r" end t) | |
7923 (subst-char-in-region beg end ?\^M ?\n t) | |
7924 (goto-char orig) | |
7925 (gnus-summary-position-point)))) | |
7926 | |
7927 (defun gnus-summary-hide-all-threads () | |
7928 "Hide all thread subtrees." | |
7929 (interactive) | |
7930 (gnus-set-global-variables) | |
7931 (save-excursion | |
7932 (goto-char (point-min)) | |
7933 (gnus-summary-hide-thread) | |
7934 (while (zerop (gnus-summary-next-thread 1 t)) | |
7935 (gnus-summary-hide-thread))) | |
7936 (gnus-summary-position-point)) | |
7937 | |
7938 (defun gnus-summary-hide-thread () | |
7939 "Hide thread subtrees. | |
7940 Returns nil if no threads were there to be hidden." | |
7941 (interactive) | |
7942 (gnus-set-global-variables) | |
7943 (let ((buffer-read-only nil) | |
7944 (start (point)) | |
7945 (article (gnus-summary-article-number))) | |
7946 (goto-char start) | |
7947 ;; Go forward until either the buffer ends or the subthread | |
7948 ;; ends. | |
7949 (when (and (not (eobp)) | |
7950 (or (zerop (gnus-summary-next-thread 1 t)) | |
7951 (goto-char (point-max)))) | |
7952 (prog1 | |
7953 (if (and (> (point) start) | |
7954 (search-backward "\n" start t)) | |
7955 (progn | |
7956 (subst-char-in-region start (point) ?\n ?\^M) | |
7957 (gnus-summary-goto-subject article)) | |
7958 (goto-char start) | |
7959 nil) | |
7960 ;;(gnus-summary-position-point) | |
7961 )))) | |
7962 | |
7963 (defun gnus-summary-go-to-next-thread (&optional previous) | |
7964 "Go to the same level (or less) next thread. | |
7965 If PREVIOUS is non-nil, go to previous thread instead. | |
7966 Return the article number moved to, or nil if moving was impossible." | |
7967 (let ((level (gnus-summary-thread-level)) | |
7968 (way (if previous -1 1)) | |
7969 (beg (point))) | |
7970 (forward-line way) | |
7971 (while (and (not (eobp)) | |
7972 (< level (gnus-summary-thread-level))) | |
7973 (forward-line way)) | |
7974 (if (eobp) | |
7975 (progn | |
7976 (goto-char beg) | |
7977 nil) | |
7978 (setq beg (point)) | |
7979 (prog1 | |
7980 (gnus-summary-article-number) | |
7981 (goto-char beg))))) | |
7982 | |
7983 (defun gnus-summary-next-thread (n &optional silent) | |
7984 "Go to the same level next N'th thread. | |
7985 If N is negative, search backward instead. | |
7986 Returns the difference between N and the number of skips actually | |
7987 done. | |
7988 | |
7989 If SILENT, don't output messages." | |
7990 (interactive "p") | |
7991 (gnus-set-global-variables) | |
7992 (let ((backward (< n 0)) | |
7993 (n (abs n))) | |
7994 (while (and (> n 0) | |
7995 (gnus-summary-go-to-next-thread backward)) | |
7996 (decf n)) | |
7997 (unless silent | |
7998 (gnus-summary-position-point)) | |
7999 (when (and (not silent) (/= 0 n)) | |
8000 (gnus-message 7 "No more threads")) | |
8001 n)) | |
8002 | |
8003 (defun gnus-summary-prev-thread (n) | |
8004 "Go to the same level previous N'th thread. | |
8005 Returns the difference between N and the number of skips actually | |
8006 done." | |
8007 (interactive "p") | |
8008 (gnus-set-global-variables) | |
8009 (gnus-summary-next-thread (- n))) | |
8010 | |
8011 (defun gnus-summary-go-down-thread () | |
8012 "Go down one level in the current thread." | |
8013 (let ((children (gnus-summary-article-children))) | |
8014 (when children | |
8015 (gnus-summary-goto-subject (car children))))) | |
8016 | |
8017 (defun gnus-summary-go-up-thread () | |
8018 "Go up one level in the current thread." | |
8019 (let ((parent (gnus-summary-article-parent))) | |
8020 (when parent | |
8021 (gnus-summary-goto-subject parent)))) | |
8022 | |
8023 (defun gnus-summary-down-thread (n) | |
8024 "Go down thread N steps. | |
8025 If N is negative, go up instead. | |
8026 Returns the difference between N and how many steps down that were | |
8027 taken." | |
8028 (interactive "p") | |
8029 (gnus-set-global-variables) | |
8030 (let ((up (< n 0)) | |
8031 (n (abs n))) | |
8032 (while (and (> n 0) | |
8033 (if up (gnus-summary-go-up-thread) | |
8034 (gnus-summary-go-down-thread))) | |
8035 (setq n (1- n))) | |
8036 (gnus-summary-position-point) | |
8037 (when (/= 0 n) | |
8038 (gnus-message 7 "Can't go further")) | |
8039 n)) | |
8040 | |
8041 (defun gnus-summary-up-thread (n) | |
8042 "Go up thread N steps. | |
8043 If N is negative, go up instead. | |
8044 Returns the difference between N and how many steps down that were | |
8045 taken." | |
8046 (interactive "p") | |
8047 (gnus-set-global-variables) | |
8048 (gnus-summary-down-thread (- n))) | |
8049 | |
8050 (defun gnus-summary-top-thread () | |
8051 "Go to the top of the thread." | |
8052 (interactive) | |
8053 (gnus-set-global-variables) | |
8054 (while (gnus-summary-go-up-thread)) | |
8055 (gnus-summary-article-number)) | |
8056 | |
8057 (defun gnus-summary-kill-thread (&optional unmark) | |
8058 "Mark articles under current thread as read. | |
8059 If the prefix argument is positive, remove any kinds of marks. | |
8060 If the prefix argument is negative, tick articles instead." | |
8061 (interactive "P") | |
8062 (gnus-set-global-variables) | |
8063 (when unmark | |
8064 (setq unmark (prefix-numeric-value unmark))) | |
8065 (let ((articles (gnus-summary-articles-in-thread))) | |
8066 (save-excursion | |
8067 ;; Expand the thread. | |
8068 (gnus-summary-show-thread) | |
8069 ;; Mark all the articles. | |
8070 (while articles | |
8071 (gnus-summary-goto-subject (car articles)) | |
8072 (cond ((null unmark) | |
8073 (gnus-summary-mark-article-as-read gnus-killed-mark)) | |
8074 ((> unmark 0) | |
8075 (gnus-summary-mark-article-as-unread gnus-unread-mark)) | |
8076 (t | |
8077 (gnus-summary-mark-article-as-unread gnus-ticked-mark))) | |
8078 (setq articles (cdr articles)))) | |
8079 ;; Hide killed subtrees. | |
8080 (and (null unmark) | |
8081 gnus-thread-hide-killed | |
8082 (gnus-summary-hide-thread)) | |
8083 ;; If marked as read, go to next unread subject. | |
8084 (when (null unmark) | |
8085 ;; Go to next unread subject. | |
8086 (gnus-summary-next-subject 1 t))) | |
8087 (gnus-set-mode-line 'summary)) | |
8088 | |
8089 ;; Summary sorting commands | |
8090 | |
8091 (defun gnus-summary-sort-by-number (&optional reverse) | |
8092 "Sort the summary buffer by article number. | |
8093 Argument REVERSE means reverse order." | |
8094 (interactive "P") | |
8095 (gnus-summary-sort 'number reverse)) | |
8096 | |
8097 (defun gnus-summary-sort-by-author (&optional reverse) | |
8098 "Sort the summary buffer by author name alphabetically. | |
8099 If case-fold-search is non-nil, case of letters is ignored. | |
8100 Argument REVERSE means reverse order." | |
8101 (interactive "P") | |
8102 (gnus-summary-sort 'author reverse)) | |
8103 | |
8104 (defun gnus-summary-sort-by-subject (&optional reverse) | |
8105 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored. | |
8106 If case-fold-search is non-nil, case of letters is ignored. | |
8107 Argument REVERSE means reverse order." | |
8108 (interactive "P") | |
8109 (gnus-summary-sort 'subject reverse)) | |
8110 | |
8111 (defun gnus-summary-sort-by-date (&optional reverse) | |
8112 "Sort the summary buffer by date. | |
8113 Argument REVERSE means reverse order." | |
8114 (interactive "P") | |
8115 (gnus-summary-sort 'date reverse)) | |
8116 | |
8117 (defun gnus-summary-sort-by-score (&optional reverse) | |
8118 "Sort the summary buffer by score. | |
8119 Argument REVERSE means reverse order." | |
8120 (interactive "P") | |
8121 (gnus-summary-sort 'score reverse)) | |
8122 | |
8123 (defun gnus-summary-sort-by-lines (&optional reverse) | |
8124 "Sort the summary buffer by article length. | |
8125 Argument REVERSE means reverse order." | |
8126 (interactive "P") | |
8127 (gnus-summary-sort 'lines reverse)) | |
8128 | |
8129 (defun gnus-summary-sort (predicate reverse) | |
8130 "Sort summary buffer by PREDICATE. REVERSE means reverse order." | |
8131 (gnus-set-global-variables) | |
8132 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate))) | |
8133 (article (intern (format "gnus-article-sort-by-%s" predicate))) | |
8134 (gnus-thread-sort-functions | |
8135 (list | |
8136 (if (not reverse) | |
8137 thread | |
8138 `(lambda (t1 t2) | |
8139 (,thread t2 t1))))) | |
8140 (gnus-article-sort-functions | |
8141 (list | |
8142 (if (not reverse) | |
8143 article | |
8144 `(lambda (t1 t2) | |
8145 (,article t2 t1))))) | |
8146 (buffer-read-only) | |
8147 (gnus-summary-prepare-hook nil)) | |
8148 ;; We do the sorting by regenerating the threads. | |
8149 (gnus-summary-prepare) | |
8150 ;; Hide subthreads if needed. | |
8151 (when (and gnus-show-threads gnus-thread-hide-subtree) | |
8152 (gnus-summary-hide-all-threads)))) | |
8153 | |
8154 ;; Summary saving commands. | |
8155 | |
8156 (defun gnus-summary-save-article (&optional n not-saved) | |
8157 "Save the current article using the default saver function. | |
8158 If N is a positive number, save the N next articles. | |
8159 If N is a negative number, save the N previous articles. | |
8160 If N is nil and any articles have been marked with the process mark, | |
8161 save those articles instead. | |
8162 The variable `gnus-default-article-saver' specifies the saver function." | |
8163 (interactive "P") | |
8164 (gnus-set-global-variables) | |
8165 (let* ((articles (gnus-summary-work-articles n)) | |
8166 (save-buffer (save-excursion | |
8167 (nnheader-set-temp-buffer " *Gnus Save*"))) | |
8168 (num (length articles)) | |
8169 header article file) | |
8170 (while articles | |
8171 (setq header (gnus-summary-article-header | |
8172 (setq article (pop articles)))) | |
8173 (if (not (vectorp header)) | |
8174 ;; This is a pseudo-article. | |
8175 (if (assq 'name header) | |
8176 (gnus-copy-file (cdr (assq 'name header))) | |
8177 (gnus-message 1 "Article %d is unsaveable" article)) | |
8178 ;; This is a real article. | |
8179 (save-window-excursion | |
8180 (gnus-summary-select-article t nil nil article)) | |
8181 (save-excursion | |
8182 (set-buffer save-buffer) | |
8183 (erase-buffer) | |
8184 (insert-buffer-substring gnus-original-article-buffer)) | |
8185 (setq file (gnus-article-save save-buffer file num)) | |
8186 (gnus-summary-remove-process-mark article) | |
8187 (unless not-saved | |
8188 (gnus-summary-set-saved-mark article)))) | |
8189 (gnus-kill-buffer save-buffer) | |
8190 (gnus-summary-position-point) | |
8191 (gnus-set-mode-line 'summary) | |
8192 n)) | |
8193 | |
8194 (defun gnus-summary-pipe-output (&optional arg) | |
8195 "Pipe the current article to a subprocess. | |
8196 If N is a positive number, pipe the N next articles. | |
8197 If N is a negative number, pipe the N previous articles. | |
8198 If N is nil and any articles have been marked with the process mark, | |
8199 pipe those articles instead." | |
8200 (interactive "P") | |
8201 (gnus-set-global-variables) | |
8202 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe)) | |
8203 (gnus-summary-save-article arg t)) | |
8204 (gnus-configure-windows 'pipe)) | |
8205 | |
8206 (defun gnus-summary-save-article-mail (&optional arg) | |
8207 "Append the current article to an mail file. | |
8208 If N is a positive number, save the N next articles. | |
8209 If N is a negative number, save the N previous articles. | |
8210 If N is nil and any articles have been marked with the process mark, | |
8211 save those articles instead." | |
8212 (interactive "P") | |
8213 (gnus-set-global-variables) | |
8214 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail)) | |
8215 (gnus-summary-save-article arg))) | |
8216 | |
8217 (defun gnus-summary-save-article-rmail (&optional arg) | |
8218 "Append the current article to an rmail file. | |
8219 If N is a positive number, save the N next articles. | |
8220 If N is a negative number, save the N previous articles. | |
8221 If N is nil and any articles have been marked with the process mark, | |
8222 save those articles instead." | |
8223 (interactive "P") | |
8224 (gnus-set-global-variables) | |
8225 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail)) | |
8226 (gnus-summary-save-article arg))) | |
8227 | |
8228 (defun gnus-summary-save-article-file (&optional arg) | |
8229 "Append the current article to a file. | |
8230 If N is a positive number, save the N next articles. | |
8231 If N is a negative number, save the N previous articles. | |
8232 If N is nil and any articles have been marked with the process mark, | |
8233 save those articles instead." | |
8234 (interactive "P") | |
8235 (gnus-set-global-variables) | |
8236 (let ((gnus-default-article-saver 'gnus-summary-save-in-file)) | |
8237 (gnus-summary-save-article arg))) | |
8238 | |
8239 (defun gnus-summary-write-article-file (&optional arg) | |
8240 "Write the current article to a file, deleting the previous file. | |
8241 If N is a positive number, save the N next articles. | |
8242 If N is a negative number, save the N previous articles. | |
8243 If N is nil and any articles have been marked with the process mark, | |
8244 save those articles instead." | |
8245 (interactive "P") | |
8246 (gnus-set-global-variables) | |
8247 (let ((gnus-default-article-saver 'gnus-summary-write-to-file)) | |
8248 (gnus-summary-save-article arg))) | |
8249 | |
8250 (defun gnus-summary-save-article-body-file (&optional arg) | |
8251 "Append the current article body to a file. | |
8252 If N is a positive number, save the N next articles. | |
8253 If N is a negative number, save the N previous articles. | |
8254 If N is nil and any articles have been marked with the process mark, | |
8255 save those articles instead." | |
8256 (interactive "P") | |
8257 (gnus-set-global-variables) | |
8258 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file)) | |
8259 (gnus-summary-save-article arg))) | |
8260 | |
8261 (defun gnus-summary-pipe-message (program) | |
8262 "Pipe the current article through PROGRAM." | |
8263 (interactive "sProgram: ") | |
8264 (gnus-set-global-variables) | |
8265 (gnus-summary-select-article) | |
8266 (let ((mail-header-separator "") | |
8267 (art-buf (get-buffer gnus-article-buffer))) | |
8268 (gnus-eval-in-buffer-window gnus-article-buffer | |
8269 (save-restriction | |
8270 (widen) | |
8271 (let ((start (window-start)) | |
8272 buffer-read-only) | |
8273 (message-pipe-buffer-body program) | |
8274 (set-window-start (get-buffer-window (current-buffer)) start)))))) | |
8275 | |
8276 (defun gnus-get-split-value (methods) | |
8277 "Return a value based on the split METHODS." | |
8278 (let (split-name method result match) | |
8279 (when methods | |
8280 (save-excursion | |
8281 (set-buffer gnus-original-article-buffer) | |
8282 (save-restriction | |
8283 (nnheader-narrow-to-headers) | |
8284 (while methods | |
8285 (goto-char (point-min)) | |
8286 (setq method (pop methods)) | |
8287 (setq match (car method)) | |
8288 (when (cond | |
8289 ((stringp match) | |
8290 ;; Regular expression. | |
8291 (ignore-errors | |
8292 (re-search-forward match nil t))) | |
8293 ((gnus-functionp match) | |
8294 ;; Function. | |
8295 (save-restriction | |
8296 (widen) | |
8297 (setq result (funcall match gnus-newsgroup-name)))) | |
8298 ((consp match) | |
8299 ;; Form. | |
8300 (save-restriction | |
8301 (widen) | |
8302 (setq result (eval match))))) | |
8303 (setq split-name (append (cdr method) split-name)) | |
8304 (cond ((stringp result) | |
8305 (push (expand-file-name | |
8306 result gnus-article-save-directory) | |
8307 split-name)) | |
8308 ((consp result) | |
8309 (setq split-name (append result split-name))))))))) | |
8310 split-name)) | |
8311 | |
8312 (defun gnus-valid-move-group-p (group) | |
8313 (and (boundp group) | |
8314 (symbol-name group) | |
8315 (memq 'respool | |
8316 (assoc (symbol-name | |
8317 (car (gnus-find-method-for-group | |
8318 (symbol-name group)))) | |
8319 gnus-valid-select-methods)))) | |
8320 | |
8321 (defun gnus-read-move-group-name (prompt default articles prefix) | |
8322 "Read a group name." | |
8323 (let* ((split-name (gnus-get-split-value gnus-move-split-methods)) | |
8324 (minibuffer-confirm-incomplete nil) ; XEmacs | |
8325 (prom | |
8326 (format "%s %s to:" | |
8327 prompt | |
8328 (if (> (length articles) 1) | |
8329 (format "these %d articles" (length articles)) | |
8330 "this article"))) | |
8331 (to-newsgroup | |
8332 (cond | |
8333 ((null split-name) | |
8334 (gnus-completing-read default prom | |
8335 gnus-active-hashtb | |
8336 'gnus-valid-move-group-p | |
8337 nil prefix | |
8338 'gnus-group-history)) | |
8339 ((= 1 (length split-name)) | |
8340 (gnus-completing-read (car split-name) prom | |
8341 gnus-active-hashtb | |
8342 'gnus-valid-move-group-p | |
8343 nil nil | |
8344 'gnus-group-history)) | |
8345 (t | |
8346 (gnus-completing-read nil prom | |
8347 (mapcar (lambda (el) (list el)) | |
8348 (nreverse split-name)) | |
8349 nil nil nil | |
8350 'gnus-group-history))))) | |
8351 (when to-newsgroup | |
8352 (if (or (string= to-newsgroup "") | |
8353 (string= to-newsgroup prefix)) | |
8354 (setq to-newsgroup default)) | |
8355 (unless to-newsgroup | |
8356 (error "No group name entered")) | |
8357 (or (gnus-active to-newsgroup) | |
8358 (gnus-activate-group to-newsgroup) | |
8359 (if (gnus-y-or-n-p (format "No such group: %s. Create it? " | |
8360 to-newsgroup)) | |
8361 (or (and (gnus-request-create-group | |
8362 to-newsgroup (gnus-group-name-to-method to-newsgroup)) | |
8363 (gnus-activate-group to-newsgroup nil nil | |
8364 (gnus-group-name-to-method | |
8365 to-newsgroup))) | |
8366 (error "Couldn't create group %s" to-newsgroup))) | |
8367 (error "No such group: %s" to-newsgroup))) | |
8368 to-newsgroup)) | |
8369 | |
8370 ;; Summary extract commands | |
8371 | |
8372 (defun gnus-summary-insert-pseudos (pslist &optional not-view) | |
8373 (let ((buffer-read-only nil) | |
8374 (article (gnus-summary-article-number)) | |
8375 after-article b e) | |
8376 (unless (gnus-summary-goto-subject article) | |
8377 (error "No such article: %d" article)) | |
8378 (gnus-summary-position-point) | |
8379 ;; If all commands are to be bunched up on one line, we collect | |
8380 ;; them here. | |
8381 (unless gnus-view-pseudos-separately | |
8382 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<))) | |
8383 files action) | |
8384 (while ps | |
8385 (setq action (cdr (assq 'action (car ps)))) | |
8386 (setq files (list (cdr (assq 'name (car ps))))) | |
8387 (while (and ps (cdr ps) | |
8388 (string= (or action "1") | |
8389 (or (cdr (assq 'action (cadr ps))) "2"))) | |
8390 (push (cdr (assq 'name (cadr ps))) files) | |
8391 (setcdr ps (cddr ps))) | |
8392 (when files | |
8393 (when (not (string-match "%s" action)) | |
8394 (push " " files)) | |
8395 (push " " files) | |
8396 (when (assq 'execute (car ps)) | |
8397 (setcdr (assq 'execute (car ps)) | |
8398 (funcall (if (string-match "%s" action) | |
8399 'format 'concat) | |
8400 action | |
8401 (mapconcat | |
8402 (lambda (f) | |
8403 (if (equal f " ") | |
8404 f | |
8405 (gnus-quote-arg-for-sh-or-csh f))) | |
8406 files " "))))) | |
8407 (setq ps (cdr ps))))) | |
8408 (if (and gnus-view-pseudos (not not-view)) | |
8409 (while pslist | |
8410 (when (assq 'execute (car pslist)) | |
8411 (gnus-execute-command (cdr (assq 'execute (car pslist))) | |
8412 (eq gnus-view-pseudos 'not-confirm))) | |
8413 (setq pslist (cdr pslist))) | |
8414 (save-excursion | |
8415 (while pslist | |
8416 (setq after-article (or (cdr (assq 'article (car pslist))) | |
8417 (gnus-summary-article-number))) | |
8418 (gnus-summary-goto-subject after-article) | |
8419 (forward-line 1) | |
8420 (setq b (point)) | |
8421 (insert " " (file-name-nondirectory | |
8422 (cdr (assq 'name (car pslist)))) | |
8423 ": " (or (cdr (assq 'execute (car pslist))) "") "\n") | |
8424 (setq e (point)) | |
8425 (forward-line -1) ; back to `b' | |
8426 (gnus-add-text-properties | |
8427 b (1- e) (list 'gnus-number gnus-reffed-article-number | |
8428 gnus-mouse-face-prop gnus-mouse-face)) | |
8429 (gnus-data-enter | |
8430 after-article gnus-reffed-article-number | |
8431 gnus-unread-mark b (car pslist) 0 (- e b)) | |
8432 (push gnus-reffed-article-number gnus-newsgroup-unreads) | |
8433 (setq gnus-reffed-article-number (1- gnus-reffed-article-number)) | |
8434 (setq pslist (cdr pslist))))))) | |
8435 | |
8436 (defun gnus-pseudos< (p1 p2) | |
8437 (let ((c1 (cdr (assq 'action p1))) | |
8438 (c2 (cdr (assq 'action p2)))) | |
8439 (and c1 c2 (string< c1 c2)))) | |
8440 | |
8441 (defun gnus-request-pseudo-article (props) | |
8442 (cond ((assq 'execute props) | |
8443 (gnus-execute-command (cdr (assq 'execute props))))) | |
8444 (let ((gnus-current-article (gnus-summary-article-number))) | |
8445 (run-hooks 'gnus-mark-article-hook))) | |
8446 | |
8447 (defun gnus-execute-command (command &optional automatic) | |
8448 (save-excursion | |
8449 (gnus-article-setup-buffer) | |
8450 (set-buffer gnus-article-buffer) | |
8451 (setq buffer-read-only nil) | |
8452 (let ((command (if automatic command (read-string "Command: " command)))) | |
8453 (erase-buffer) | |
8454 (insert "$ " command "\n\n") | |
8455 (if gnus-view-pseudo-asynchronously | |
8456 (start-process "gnus-execute" (current-buffer) shell-file-name | |
8457 shell-command-switch command) | |
8458 (call-process shell-file-name nil t nil | |
8459 shell-command-switch command))))) | |
8460 | |
8461 ;; Summary kill commands. | |
8462 | |
8463 (defun gnus-summary-edit-global-kill (article) | |
8464 "Edit the \"global\" kill file." | |
8465 (interactive (list (gnus-summary-article-number))) | |
8466 (gnus-set-global-variables) | |
8467 (gnus-group-edit-global-kill article)) | |
8468 | |
8469 (defun gnus-summary-edit-local-kill () | |
8470 "Edit a local kill file applied to the current newsgroup." | |
8471 (interactive) | |
8472 (gnus-set-global-variables) | |
8473 (setq gnus-current-headers (gnus-summary-article-header)) | |
8474 (gnus-set-global-variables) | |
8475 (gnus-group-edit-local-kill | |
8476 (gnus-summary-article-number) gnus-newsgroup-name)) | |
8477 | |
8478 ;;; Header reading. | |
8479 | |
8480 (defun gnus-read-header (id &optional header) | |
8481 "Read the headers of article ID and enter them into the Gnus system." | |
8482 (let ((group gnus-newsgroup-name) | |
8483 (gnus-override-method | |
8484 (and (gnus-news-group-p gnus-newsgroup-name) | |
8485 gnus-refer-article-method)) | |
8486 where) | |
8487 ;; First we check to see whether the header in question is already | |
8488 ;; fetched. | |
8489 (if (stringp id) | |
8490 ;; This is a Message-ID. | |
8491 (setq header (or header (gnus-id-to-header id))) | |
8492 ;; This is an article number. | |
8493 (setq header (or header (gnus-summary-article-header id)))) | |
8494 (if (and header | |
8495 (not (gnus-summary-article-sparse-p (mail-header-number header)))) | |
8496 ;; We have found the header. | |
8497 header | |
8498 ;; We have to really fetch the header to this article. | |
8499 (save-excursion | |
8500 (set-buffer nntp-server-buffer) | |
8501 (when (setq where (gnus-request-head id group)) | |
8502 (nnheader-fold-continuation-lines) | |
8503 (goto-char (point-max)) | |
8504 (insert ".\n") | |
8505 (goto-char (point-min)) | |
8506 (insert "211 ") | |
8507 (princ (cond | |
8508 ((numberp id) id) | |
8509 ((cdr where) (cdr where)) | |
8510 (header (mail-header-number header)) | |
8511 (t gnus-reffed-article-number)) | |
8512 (current-buffer)) | |
8513 (insert " Article retrieved.\n")) | |
8514 (if (or (not where) | |
8515 (not (setq header (car (gnus-get-newsgroup-headers nil t))))) | |
8516 () ; Malformed head. | |
8517 (unless (gnus-summary-article-sparse-p (mail-header-number header)) | |
8518 (when (and (stringp id) | |
8519 (not (string= (gnus-group-real-name group) | |
8520 (car where)))) | |
8521 ;; If we fetched by Message-ID and the article came | |
8522 ;; from a different group, we fudge some bogus article | |
8523 ;; numbers for this article. | |
8524 (mail-header-set-number header gnus-reffed-article-number)) | |
8525 (save-excursion | |
8526 (set-buffer gnus-summary-buffer) | |
8527 (decf gnus-reffed-article-number) | |
8528 (gnus-remove-header (mail-header-number header)) | |
8529 (push header gnus-newsgroup-headers) | |
8530 (setq gnus-current-headers header) | |
8531 (push (mail-header-number header) gnus-newsgroup-limit))) | |
8532 header))))) | |
8533 | |
8534 (defun gnus-remove-header (number) | |
8535 "Remove header NUMBER from `gnus-newsgroup-headers'." | |
8536 (if (and gnus-newsgroup-headers | |
8537 (= number (mail-header-number (car gnus-newsgroup-headers)))) | |
8538 (pop gnus-newsgroup-headers) | |
8539 (let ((headers gnus-newsgroup-headers)) | |
8540 (while (and (cdr headers) | |
8541 (not (= number (mail-header-number (cadr headers))))) | |
8542 (pop headers)) | |
8543 (when (cdr headers) | |
8544 (setcdr headers (cddr headers)))))) | |
8545 | |
8546 ;;; | |
8547 ;;; summary highlights | |
8548 ;;; | |
8549 | |
8550 (defun gnus-highlight-selected-summary () | |
8551 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>. | |
8552 ;; Highlight selected article in summary buffer | |
8553 (when gnus-summary-selected-face | |
8554 (save-excursion | |
8555 (let* ((beg (progn (beginning-of-line) (point))) | |
8556 (end (progn (end-of-line) (point))) | |
8557 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>. | |
8558 (from (if (get-text-property beg gnus-mouse-face-prop) | |
8559 beg | |
8560 (or (next-single-property-change | |
8561 beg gnus-mouse-face-prop nil end) | |
8562 beg))) | |
8563 (to | |
8564 (if (= from end) | |
8565 (- from 2) | |
8566 (or (next-single-property-change | |
8567 from gnus-mouse-face-prop nil end) | |
8568 end)))) | |
8569 ;; If no mouse-face prop on line we will have to = from = end, | |
8570 ;; so we highlight the entire line instead. | |
8571 (when (= (+ to 2) from) | |
8572 (setq from beg) | |
8573 (setq to end)) | |
8574 (if gnus-newsgroup-selected-overlay | |
8575 ;; Move old overlay. | |
8576 (gnus-move-overlay | |
8577 gnus-newsgroup-selected-overlay from to (current-buffer)) | |
8578 ;; Create new overlay. | |
8579 (gnus-overlay-put | |
8580 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to)) | |
8581 'face gnus-summary-selected-face)))))) | |
8582 | |
8583 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>. | |
8584 (defun gnus-summary-highlight-line () | |
8585 "Highlight current line according to `gnus-summary-highlight'." | |
8586 (let* ((list gnus-summary-highlight) | |
8587 (p (point)) | |
8588 (end (progn (end-of-line) (point))) | |
8589 ;; now find out where the line starts and leave point there. | |
8590 (beg (progn (beginning-of-line) (point))) | |
8591 (article (gnus-summary-article-number)) | |
8592 (score (or (cdr (assq (or article gnus-current-article) | |
8593 gnus-newsgroup-scored)) | |
8594 gnus-summary-default-score 0)) | |
8595 (mark (or (gnus-summary-article-mark) gnus-unread-mark)) | |
8596 (inhibit-read-only t)) | |
8597 ;; Eval the cars of the lists until we find a match. | |
8598 (let ((default gnus-summary-default-score)) | |
8599 (while (and list | |
8600 (not (eval (caar list)))) | |
8601 (setq list (cdr list)))) | |
8602 (let ((face (cdar list))) | |
8603 (unless (eq face (get-text-property beg 'face)) | |
8604 (gnus-put-text-property | |
8605 beg end 'face | |
8606 (setq face (if (boundp face) (symbol-value face) face))) | |
8607 (when gnus-summary-highlight-line-function | |
8608 (funcall gnus-summary-highlight-line-function article face)))) | |
8609 (goto-char p))) | |
8610 | |
8611 (defun gnus-update-read-articles (group unread) | |
8612 "Update the list of read articles in GROUP." | |
8613 (let* ((active (or gnus-newsgroup-active (gnus-active group))) | |
8614 (entry (gnus-gethash group gnus-newsrc-hashtb)) | |
8615 (info (nth 2 entry)) | |
8616 (prev 1) | |
8617 (unread (sort (copy-sequence unread) '<)) | |
8618 read) | |
8619 (if (or (not info) (not active)) | |
8620 ;; There is no info on this group if it was, in fact, | |
8621 ;; killed. Gnus stores no information on killed groups, so | |
8622 ;; there's nothing to be done. | |
8623 ;; One could store the information somewhere temporarily, | |
8624 ;; perhaps... Hmmm... | |
8625 () | |
8626 ;; Remove any negative articles numbers. | |
8627 (while (and unread (< (car unread) 0)) | |
8628 (setq unread (cdr unread))) | |
8629 ;; Remove any expired article numbers | |
8630 (while (and unread (< (car unread) (car active))) | |
8631 (setq unread (cdr unread))) | |
8632 ;; Compute the ranges of read articles by looking at the list of | |
8633 ;; unread articles. | |
8634 (while unread | |
8635 (when (/= (car unread) prev) | |
8636 (push (if (= prev (1- (car unread))) prev | |
8637 (cons prev (1- (car unread)))) | |
8638 read)) | |
8639 (setq prev (1+ (car unread))) | |
8640 (setq unread (cdr unread))) | |
8641 (when (<= prev (cdr active)) | |
8642 (push (cons prev (cdr active)) read)) | |
8643 (save-excursion | |
8644 (set-buffer gnus-group-buffer) | |
8645 (gnus-undo-register | |
8646 `(progn | |
8647 (gnus-info-set-marks ',info ',(gnus-info-marks info) t) | |
8648 (gnus-info-set-read ',info ',(gnus-info-read info)) | |
8649 (gnus-get-unread-articles-in-group ',info (gnus-active ,group)) | |
8650 (gnus-group-update-group ,group t)))) | |
8651 ;; Enter this list into the group info. | |
8652 (gnus-info-set-read | |
8653 info (if (> (length read) 1) (nreverse read) read)) | |
8654 ;; Set the number of unread articles in gnus-newsrc-hashtb. | |
8655 (gnus-get-unread-articles-in-group info (gnus-active group)) | |
8656 t))) | |
8657 | |
8658 (defun gnus-offer-save-summaries () | |
8659 "Offer to save all active summary buffers." | |
8660 (save-excursion | |
8661 (let ((buflist (buffer-list)) | |
8662 buffers bufname) | |
8663 ;; Go through all buffers and find all summaries. | |
8664 (while buflist | |
8665 (and (setq bufname (buffer-name (car buflist))) | |
8666 (string-match "Summary" bufname) | |
8667 (save-excursion | |
8668 (set-buffer bufname) | |
8669 ;; We check that this is, indeed, a summary buffer. | |
8670 (and (eq major-mode 'gnus-summary-mode) | |
8671 ;; Also make sure this isn't bogus. | |
8672 gnus-newsgroup-prepared | |
8673 ;; Also make sure that this isn't a dead summary buffer. | |
8674 (not gnus-dead-summary-mode))) | |
8675 (push bufname buffers)) | |
8676 (setq buflist (cdr buflist))) | |
8677 ;; Go through all these summary buffers and offer to save them. | |
8678 (when buffers | |
8679 (map-y-or-n-p | |
8680 "Update summary buffer %s? " | |
8681 (lambda (buf) (switch-to-buffer buf) (gnus-summary-exit)) | |
8682 buffers))))) | |
8683 | |
8684 (provide 'gnus-sum) | |
8685 | |
8686 (run-hooks 'gnus-sum-load-hook) | |
8687 | |
8688 ;;; gnus-sum.el ends here |