Commit | Line | Data |
---|---|---|
eec82323 | 1 | ;;; gnus-sum.el --- summary mode commands for Gnus |
676a7cc9 | 2 | ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001 |
16409b0b | 3 | ;; Free Software Foundation, Inc. |
eec82323 | 4 | |
6748645f | 5 | ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org> |
eec82323 LMI |
6 | ;; Keywords: news |
7 | ||
8 | ;; This file is part of GNU Emacs. | |
9 | ||
10 | ;; GNU Emacs is free software; you can redistribute it and/or modify | |
11 | ;; it under the terms of the GNU General Public License as published by | |
12 | ;; the Free Software Foundation; either version 2, or (at your option) | |
13 | ;; any later version. | |
14 | ||
15 | ;; GNU Emacs is distributed in the hope that it will be useful, | |
16 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 | ;; GNU General Public License for more details. | |
19 | ||
20 | ;; You should have received a copy of the GNU General Public License | |
21 | ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
22 | ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
23 | ;; Boston, MA 02111-1307, USA. | |
24 | ||
25 | ;;; Commentary: | |
26 | ||
27 | ;;; Code: | |
28 | ||
5ab7173c RS |
29 | (eval-when-compile (require 'cl)) |
30 | ||
eec82323 LMI |
31 | (require 'gnus) |
32 | (require 'gnus-group) | |
33 | (require 'gnus-spec) | |
34 | (require 'gnus-range) | |
35 | (require 'gnus-int) | |
36 | (require 'gnus-undo) | |
6748645f | 37 | (require 'gnus-util) |
16409b0b | 38 | (require 'mm-decode) |
08c9a385 DL |
39 | ;; Recursive :-(. |
40 | ;; (require 'gnus-art) | |
41 | (require 'nnoo) | |
6748645f | 42 | (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t) |
d4dfaa19 | 43 | (autoload 'gnus-cache-write-active "gnus-cache") |
08c9a385 | 44 | (autoload 'mm-uu-dissect "mm-uu") |
eec82323 LMI |
45 | |
46 | (defcustom gnus-kill-summary-on-exit t | |
47 | "*If non-nil, kill the summary buffer when you exit from it. | |
48 | If nil, the summary will become a \"*Dead Summary*\" buffer, and | |
49 | it will be killed sometime later." | |
50 | :group 'gnus-summary-exit | |
51 | :type 'boolean) | |
52 | ||
53 | (defcustom gnus-fetch-old-headers nil | |
54 | "*Non-nil means that Gnus will try to build threads by grabbing old headers. | |
55 | If an unread article in the group refers to an older, already read (or | |
56 | just marked as read) article, the old article will not normally be | |
57 | displayed in the Summary buffer. If this variable is non-nil, Gnus | |
58 | will attempt to grab the headers to the old articles, and thereby | |
6748645f LMI |
59 | build complete threads. If it has the value `some', only enough |
60 | headers to connect otherwise loose threads will be displayed. This | |
61 | variable can also be a number. In that case, no more than that number | |
62 | of old headers will be fetched. If it has the value `invisible', all | |
63 | old headers will be fetched, but none will be displayed. | |
eec82323 LMI |
64 | |
65 | The server has to support NOV for any of this to work." | |
66 | :group 'gnus-thread | |
67 | :type '(choice (const :tag "off" nil) | |
68 | (const some) | |
69 | number | |
70 | (sexp :menu-tag "other" t))) | |
71 | ||
6748645f LMI |
72 | (defcustom gnus-refer-thread-limit 200 |
73 | "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread]. | |
74 | If t, fetch all the available old headers." | |
75 | :group 'gnus-thread | |
76 | :type '(choice number | |
77 | (sexp :menu-tag "other" t))) | |
78 | ||
eec82323 LMI |
79 | (defcustom gnus-summary-make-false-root 'adopt |
80 | "*nil means that Gnus won't gather loose threads. | |
81 | If the root of a thread has expired or been read in a previous | |
82 | session, the information necessary to build a complete thread has been | |
83 | lost. Instead of having many small sub-threads from this original thread | |
84 | scattered all over the summary buffer, Gnus can gather them. | |
85 | ||
86 | If non-nil, Gnus will try to gather all loose sub-threads from an | |
87 | original thread into one large thread. | |
88 | ||
89 | If this variable is non-nil, it should be one of `none', `adopt', | |
90 | `dummy' or `empty'. | |
91 | ||
92 | If this variable is `none', Gnus will not make a false root, but just | |
93 | present the sub-threads after another. | |
94 | If this variable is `dummy', Gnus will create a dummy root that will | |
95 | have all the sub-threads as children. | |
96 | If this variable is `adopt', Gnus will make one of the \"children\" | |
97 | the parent and mark all the step-children as such. | |
98 | If this variable is `empty', the \"children\" are printed with empty | |
99 | subject fields. (Or rather, they will be printed with a string | |
100 | given by the `gnus-summary-same-subject' variable.)" | |
101 | :group 'gnus-thread | |
102 | :type '(choice (const :tag "off" nil) | |
103 | (const none) | |
104 | (const dummy) | |
105 | (const adopt) | |
106 | (const empty))) | |
107 | ||
108 | (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$" | |
109 | "*A regexp to match subjects to be excluded from loose thread gathering. | |
110 | As loose thread gathering is done on subjects only, that means that | |
111 | there can be many false gatherings performed. By rooting out certain | |
112 | common subjects, gathering might become saner." | |
113 | :group 'gnus-thread | |
114 | :type 'regexp) | |
115 | ||
116 | (defcustom gnus-summary-gather-subject-limit nil | |
117 | "*Maximum length of subject comparisons when gathering loose threads. | |
118 | Use nil to compare full subjects. Setting this variable to a low | |
119 | number will help gather threads that have been corrupted by | |
120 | newsreaders chopping off subject lines, but it might also mean that | |
121 | unrelated articles that have subject that happen to begin with the | |
122 | same few characters will be incorrectly gathered. | |
123 | ||
124 | If this variable is `fuzzy', Gnus will use a fuzzy algorithm when | |
125 | comparing subjects." | |
126 | :group 'gnus-thread | |
127 | :type '(choice (const :tag "off" nil) | |
128 | (const fuzzy) | |
129 | (sexp :menu-tag "on" t))) | |
130 | ||
6748645f LMI |
131 | (defcustom gnus-simplify-subject-functions nil |
132 | "List of functions taking a string argument that simplify subjects. | |
133 | The functions are applied recursively. | |
134 | ||
135 | Useful functions to put in this list include: `gnus-simplify-subject-re', | |
136 | `gnus-simplify-subject-fuzzy' and `gnus-simplify-whitespace'." | |
137 | :group 'gnus-thread | |
138 | :type '(repeat function)) | |
139 | ||
eec82323 LMI |
140 | (defcustom gnus-simplify-ignored-prefixes nil |
141 | "*Regexp, matches for which are removed from subject lines when simplifying fuzzily." | |
142 | :group 'gnus-thread | |
143 | :type '(choice (const :tag "off" nil) | |
144 | regexp)) | |
145 | ||
146 | (defcustom gnus-build-sparse-threads nil | |
147 | "*If non-nil, fill in the gaps in threads. | |
148 | If `some', only fill in the gaps that are needed to tie loose threads | |
149 | together. If `more', fill in all leaf nodes that Gnus can find. If | |
150 | non-nil and non-`some', fill in all gaps that Gnus manages to guess." | |
151 | :group 'gnus-thread | |
152 | :type '(choice (const :tag "off" nil) | |
153 | (const some) | |
154 | (const more) | |
155 | (sexp :menu-tag "all" t))) | |
156 | ||
157 | (defcustom gnus-summary-thread-gathering-function | |
158 | 'gnus-gather-threads-by-subject | |
6748645f | 159 | "*Function used for gathering loose threads. |
eec82323 LMI |
160 | There are two pre-defined functions: `gnus-gather-threads-by-subject', |
161 | which only takes Subjects into consideration; and | |
162 | `gnus-gather-threads-by-references', which compared the References | |
163 | headers of the articles to find matches." | |
164 | :group 'gnus-thread | |
22115a9e RS |
165 | :type '(radio (function-item gnus-gather-threads-by-subject) |
166 | (function-item gnus-gather-threads-by-references) | |
167 | (function :tag "other"))) | |
eec82323 | 168 | |
eec82323 LMI |
169 | (defcustom gnus-summary-same-subject "" |
170 | "*String indicating that the current article has the same subject as the previous. | |
171 | This variable will only be used if the value of | |
172 | `gnus-summary-make-false-root' is `empty'." | |
173 | :group 'gnus-summary-format | |
174 | :type 'string) | |
175 | ||
176 | (defcustom gnus-summary-goto-unread t | |
16409b0b GM |
177 | "*If t, many commands will go to the next unread article. |
178 | This applies to marking commands as well as other commands that | |
179 | \"naturally\" select the next article, like, for instance, `SPC' at | |
180 | the end of an article. | |
181 | ||
182 | If nil, the marking commands do NOT go to the next unread article | |
183 | (they go to the next article instead). If `never', commands that | |
184 | usually go to the next unread article, will go to the next article, | |
185 | whether it is read or not." | |
eec82323 LMI |
186 | :group 'gnus-summary-marks |
187 | :link '(custom-manual "(gnus)Setting Marks") | |
188 | :type '(choice (const :tag "off" nil) | |
189 | (const never) | |
190 | (sexp :menu-tag "on" t))) | |
191 | ||
192 | (defcustom gnus-summary-default-score 0 | |
193 | "*Default article score level. | |
194 | All scores generated by the score files will be added to this score. | |
195 | If this variable is nil, scoring will be disabled." | |
196 | :group 'gnus-score-default | |
197 | :type '(choice (const :tag "disable") | |
198 | integer)) | |
199 | ||
200 | (defcustom gnus-summary-zcore-fuzz 0 | |
201 | "*Fuzziness factor for the zcore in the summary buffer. | |
202 | Articles with scores closer than this to `gnus-summary-default-score' | |
203 | will not be marked." | |
204 | :group 'gnus-summary-format | |
205 | :type 'integer) | |
206 | ||
207 | (defcustom gnus-simplify-subject-fuzzy-regexp nil | |
208 | "*Strings to be removed when doing fuzzy matches. | |
209 | This can either be a regular expression or list of regular expressions | |
210 | that will be removed from subject strings if fuzzy subject | |
211 | simplification is selected." | |
212 | :group 'gnus-thread | |
213 | :type '(repeat regexp)) | |
214 | ||
215 | (defcustom gnus-show-threads t | |
216 | "*If non-nil, display threads in summary mode." | |
217 | :group 'gnus-thread | |
218 | :type 'boolean) | |
219 | ||
220 | (defcustom gnus-thread-hide-subtree nil | |
221 | "*If non-nil, hide all threads initially. | |
222 | If threads are hidden, you have to run the command | |
223 | `gnus-summary-show-thread' by hand or use `gnus-select-article-hook' | |
224 | to expose hidden threads." | |
225 | :group 'gnus-thread | |
226 | :type 'boolean) | |
227 | ||
228 | (defcustom gnus-thread-hide-killed t | |
229 | "*If non-nil, hide killed threads automatically." | |
230 | :group 'gnus-thread | |
231 | :type 'boolean) | |
232 | ||
6748645f LMI |
233 | (defcustom gnus-thread-ignore-subject t |
234 | "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header. | |
235 | If nil, articles that have different subjects from their parents will | |
236 | start separate threads." | |
eec82323 LMI |
237 | :group 'gnus-thread |
238 | :type 'boolean) | |
239 | ||
240 | (defcustom gnus-thread-operation-ignore-subject t | |
241 | "*If non-nil, subjects will be ignored when doing thread commands. | |
242 | This affects commands like `gnus-summary-kill-thread' and | |
243 | `gnus-summary-lower-thread'. | |
244 | ||
245 | If this variable is nil, articles in the same thread with different | |
246 | subjects will not be included in the operation in question. If this | |
247 | variable is `fuzzy', only articles that have subjects that are fuzzily | |
248 | equal will be included." | |
249 | :group 'gnus-thread | |
250 | :type '(choice (const :tag "off" nil) | |
251 | (const fuzzy) | |
252 | (sexp :tag "on" t))) | |
253 | ||
254 | (defcustom gnus-thread-indent-level 4 | |
255 | "*Number that says how much each sub-thread should be indented." | |
256 | :group 'gnus-thread | |
257 | :type 'integer) | |
258 | ||
259 | (defcustom gnus-auto-extend-newsgroup t | |
260 | "*If non-nil, extend newsgroup forward and backward when requested." | |
261 | :group 'gnus-summary-choose | |
262 | :type 'boolean) | |
263 | ||
264 | (defcustom gnus-auto-select-first t | |
265 | "*If nil, don't select the first unread article when entering a group. | |
266 | If this variable is `best', select the highest-scored unread article | |
16409b0b GM |
267 | in the group. If t, select the first unread article. |
268 | ||
269 | This variable can also be a function to place point on a likely | |
270 | subject line. Useful values include `gnus-summary-first-unread-subject', | |
271 | `gnus-summary-first-unread-article' and | |
272 | `gnus-summary-best-unread-article'. | |
eec82323 LMI |
273 | |
274 | If you want to prevent automatic selection of the first unread article | |
275 | in some newsgroups, set the variable to nil in | |
276 | `gnus-select-group-hook'." | |
277 | :group 'gnus-group-select | |
278 | :type '(choice (const :tag "none" nil) | |
279 | (const best) | |
16409b0b GM |
280 | (sexp :menu-tag "first" t) |
281 | (function-item gnus-summary-first-unread-subject) | |
282 | (function-item gnus-summary-first-unread-article) | |
283 | (function-item gnus-summary-best-unread-article))) | |
eec82323 LMI |
284 | |
285 | (defcustom gnus-auto-select-next t | |
286 | "*If non-nil, offer to go to the next group from the end of the previous. | |
287 | If the value is t and the next newsgroup is empty, Gnus will exit | |
288 | summary mode and go back to group mode. If the value is neither nil | |
289 | nor t, Gnus will select the following unread newsgroup. In | |
290 | particular, if the value is the symbol `quietly', the next unread | |
291 | newsgroup will be selected without any confirmation, and if it is | |
292 | `almost-quietly', the next group will be selected without any | |
293 | confirmation if you are located on the last article in the group. | |
294 | Finally, if this variable is `slightly-quietly', the `Z n' command | |
295 | will go to the next group without confirmation." | |
296 | :group 'gnus-summary-maneuvering | |
297 | :type '(choice (const :tag "off" nil) | |
298 | (const quietly) | |
299 | (const almost-quietly) | |
300 | (const slightly-quietly) | |
301 | (sexp :menu-tag "on" t))) | |
302 | ||
303 | (defcustom gnus-auto-select-same nil | |
6748645f LMI |
304 | "*If non-nil, select the next article with the same subject. |
305 | If there are no more articles with the same subject, go to | |
306 | the first unread article." | |
eec82323 LMI |
307 | :group 'gnus-summary-maneuvering |
308 | :type 'boolean) | |
309 | ||
310 | (defcustom gnus-summary-check-current nil | |
311 | "*If non-nil, consider the current article when moving. | |
312 | The \"unread\" movement commands will stay on the same line if the | |
313 | current article is unread." | |
314 | :group 'gnus-summary-maneuvering | |
315 | :type 'boolean) | |
316 | ||
317 | (defcustom gnus-auto-center-summary t | |
318 | "*If non-nil, always center the current summary buffer. | |
319 | In particular, if `vertical' do only vertical recentering. If non-nil | |
320 | and non-`vertical', do both horizontal and vertical recentering." | |
321 | :group 'gnus-summary-maneuvering | |
322 | :type '(choice (const :tag "none" nil) | |
323 | (const vertical) | |
16409b0b | 324 | (integer :tag "height") |
eec82323 LMI |
325 | (sexp :menu-tag "both" t))) |
326 | ||
327 | (defcustom gnus-show-all-headers nil | |
328 | "*If non-nil, don't hide any headers." | |
329 | :group 'gnus-article-hiding | |
330 | :group 'gnus-article-headers | |
331 | :type 'boolean) | |
332 | ||
333 | (defcustom gnus-summary-ignore-duplicates nil | |
334 | "*If non-nil, ignore articles with identical Message-ID headers." | |
335 | :group 'gnus-summary | |
336 | :type 'boolean) | |
6748645f | 337 | |
eec82323 LMI |
338 | (defcustom gnus-single-article-buffer t |
339 | "*If non-nil, display all articles in the same buffer. | |
340 | If nil, each group will get its own article buffer." | |
341 | :group 'gnus-article-various | |
342 | :type 'boolean) | |
343 | ||
344 | (defcustom gnus-break-pages t | |
345 | "*If non-nil, do page breaking on articles. | |
346 | The page delimiter is specified by the `gnus-page-delimiter' | |
347 | variable." | |
348 | :group 'gnus-article-various | |
349 | :type 'boolean) | |
350 | ||
eec82323 LMI |
351 | (defcustom gnus-move-split-methods nil |
352 | "*Variable used to suggest where articles are to be moved to. | |
353 | It uses the same syntax as the `gnus-split-methods' variable." | |
354 | :group 'gnus-summary-mail | |
6748645f LMI |
355 | :type '(repeat (choice (list :value (fun) function) |
356 | (cons :value ("" "") regexp (repeat string)) | |
357 | (sexp :value nil)))) | |
eec82323 | 358 | |
16409b0b | 359 | (defcustom gnus-unread-mark ? ;Whitespace |
eec82323 LMI |
360 | "*Mark used for unread articles." |
361 | :group 'gnus-summary-marks | |
362 | :type 'character) | |
363 | ||
364 | (defcustom gnus-ticked-mark ?! | |
365 | "*Mark used for ticked articles." | |
366 | :group 'gnus-summary-marks | |
367 | :type 'character) | |
368 | ||
369 | (defcustom gnus-dormant-mark ?? | |
370 | "*Mark used for dormant articles." | |
371 | :group 'gnus-summary-marks | |
372 | :type 'character) | |
373 | ||
374 | (defcustom gnus-del-mark ?r | |
375 | "*Mark used for del'd articles." | |
376 | :group 'gnus-summary-marks | |
377 | :type 'character) | |
378 | ||
379 | (defcustom gnus-read-mark ?R | |
380 | "*Mark used for read articles." | |
381 | :group 'gnus-summary-marks | |
382 | :type 'character) | |
383 | ||
384 | (defcustom gnus-expirable-mark ?E | |
385 | "*Mark used for expirable articles." | |
386 | :group 'gnus-summary-marks | |
387 | :type 'character) | |
388 | ||
389 | (defcustom gnus-killed-mark ?K | |
390 | "*Mark used for killed articles." | |
391 | :group 'gnus-summary-marks | |
392 | :type 'character) | |
393 | ||
394 | (defcustom gnus-souped-mark ?F | |
395 | "*Mark used for killed articles." | |
396 | :group 'gnus-summary-marks | |
397 | :type 'character) | |
398 | ||
399 | (defcustom gnus-kill-file-mark ?X | |
400 | "*Mark used for articles killed by kill files." | |
401 | :group 'gnus-summary-marks | |
402 | :type 'character) | |
403 | ||
404 | (defcustom gnus-low-score-mark ?Y | |
405 | "*Mark used for articles with a low score." | |
406 | :group 'gnus-summary-marks | |
407 | :type 'character) | |
408 | ||
409 | (defcustom gnus-catchup-mark ?C | |
410 | "*Mark used for articles that are caught up." | |
411 | :group 'gnus-summary-marks | |
412 | :type 'character) | |
413 | ||
414 | (defcustom gnus-replied-mark ?A | |
415 | "*Mark used for articles that have been replied to." | |
416 | :group 'gnus-summary-marks | |
417 | :type 'character) | |
418 | ||
419 | (defcustom gnus-cached-mark ?* | |
420 | "*Mark used for articles that are in the cache." | |
421 | :group 'gnus-summary-marks | |
422 | :type 'character) | |
423 | ||
424 | (defcustom gnus-saved-mark ?S | |
425 | "*Mark used for articles that have been saved to." | |
426 | :group 'gnus-summary-marks | |
427 | :type 'character) | |
428 | ||
429 | (defcustom gnus-ancient-mark ?O | |
430 | "*Mark used for ancient articles." | |
431 | :group 'gnus-summary-marks | |
432 | :type 'character) | |
433 | ||
434 | (defcustom gnus-sparse-mark ?Q | |
435 | "*Mark used for sparsely reffed articles." | |
436 | :group 'gnus-summary-marks | |
437 | :type 'character) | |
438 | ||
439 | (defcustom gnus-canceled-mark ?G | |
440 | "*Mark used for canceled articles." | |
441 | :group 'gnus-summary-marks | |
442 | :type 'character) | |
443 | ||
444 | (defcustom gnus-duplicate-mark ?M | |
445 | "*Mark used for duplicate articles." | |
446 | :group 'gnus-summary-marks | |
447 | :type 'character) | |
448 | ||
6748645f LMI |
449 | (defcustom gnus-undownloaded-mark ?@ |
450 | "*Mark used for articles that weren't downloaded." | |
451 | :group 'gnus-summary-marks | |
452 | :type 'character) | |
453 | ||
454 | (defcustom gnus-downloadable-mark ?% | |
455 | "*Mark used for articles that are to be downloaded." | |
456 | :group 'gnus-summary-marks | |
457 | :type 'character) | |
458 | ||
459 | (defcustom gnus-unsendable-mark ?= | |
460 | "*Mark used for articles that won't be sent." | |
461 | :group 'gnus-summary-marks | |
462 | :type 'character) | |
463 | ||
eec82323 LMI |
464 | (defcustom gnus-score-over-mark ?+ |
465 | "*Score mark used for articles with high scores." | |
466 | :group 'gnus-summary-marks | |
467 | :type 'character) | |
468 | ||
469 | (defcustom gnus-score-below-mark ?- | |
470 | "*Score mark used for articles with low scores." | |
471 | :group 'gnus-summary-marks | |
472 | :type 'character) | |
473 | ||
16409b0b | 474 | (defcustom gnus-empty-thread-mark ? ;Whitespace |
eec82323 LMI |
475 | "*There is no thread under the article." |
476 | :group 'gnus-summary-marks | |
477 | :type 'character) | |
478 | ||
479 | (defcustom gnus-not-empty-thread-mark ?= | |
480 | "*There is a thread under the article." | |
481 | :group 'gnus-summary-marks | |
482 | :type 'character) | |
483 | ||
484 | (defcustom gnus-view-pseudo-asynchronously nil | |
485 | "*If non-nil, Gnus will view pseudo-articles asynchronously." | |
486 | :group 'gnus-extract-view | |
487 | :type 'boolean) | |
488 | ||
16409b0b GM |
489 | (defcustom gnus-auto-expirable-marks |
490 | (list gnus-killed-mark gnus-del-mark gnus-catchup-mark | |
491 | gnus-low-score-mark gnus-ancient-mark gnus-read-mark | |
492 | gnus-souped-mark gnus-duplicate-mark) | |
493 | "*The list of marks converted into expiration if a group is auto-expirable." | |
58e39d05 | 494 | :version "21.1" |
16409b0b GM |
495 | :group 'gnus-summary |
496 | :type '(repeat character)) | |
497 | ||
498 | (defcustom gnus-inhibit-user-auto-expire t | |
499 | "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on." | |
58e39d05 | 500 | :version "21.1" |
16409b0b GM |
501 | :group 'gnus-summary |
502 | :type 'boolean) | |
503 | ||
eec82323 LMI |
504 | (defcustom gnus-view-pseudos nil |
505 | "*If `automatic', pseudo-articles will be viewed automatically. | |
506 | If `not-confirm', pseudos will be viewed automatically, and the user | |
507 | will not be asked to confirm the command." | |
508 | :group 'gnus-extract-view | |
509 | :type '(choice (const :tag "off" nil) | |
510 | (const automatic) | |
511 | (const not-confirm))) | |
512 | ||
513 | (defcustom gnus-view-pseudos-separately t | |
514 | "*If non-nil, one pseudo-article will be created for each file to be viewed. | |
515 | If nil, all files that use the same viewing command will be given as a | |
516 | list of parameters to that command." | |
517 | :group 'gnus-extract-view | |
518 | :type 'boolean) | |
519 | ||
520 | (defcustom gnus-insert-pseudo-articles t | |
521 | "*If non-nil, insert pseudo-articles when decoding articles." | |
522 | :group 'gnus-extract-view | |
523 | :type 'boolean) | |
524 | ||
525 | (defcustom gnus-summary-dummy-line-format | |
6748645f | 526 | " %(: :%) %S\n" |
eec82323 LMI |
527 | "*The format specification for the dummy roots in the summary buffer. |
528 | It works along the same lines as a normal formatting string, | |
529 | with some simple extensions. | |
530 | ||
531 | %S The subject" | |
532 | :group 'gnus-threading | |
533 | :type 'string) | |
534 | ||
16409b0b | 535 | (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z" |
eec82323 LMI |
536 | "*The format specification for the summary mode line. |
537 | It works along the same lines as a normal formatting string, | |
538 | with some simple extensions: | |
539 | ||
540 | %G Group name | |
541 | %p Unprefixed group name | |
542 | %A Current article number | |
6748645f | 543 | %z Current article score |
eec82323 LMI |
544 | %V Gnus version |
545 | %U Number of unread articles in the group | |
546 | %e Number of unselected articles in the group | |
547 | %Z A string with unread/unselected article counts | |
548 | %g Shortish group name | |
549 | %S Subject of the current article | |
550 | %u User-defined spec | |
551 | %s Current score file name | |
552 | %d Number of dormant articles | |
553 | %r Number of articles that have been marked as read in this session | |
554 | %E Number of articles expunged by the score files" | |
555 | :group 'gnus-summary-format | |
556 | :type 'string) | |
557 | ||
16409b0b GM |
558 | (defcustom gnus-list-identifiers nil |
559 | "Regexp that matches list identifiers to be removed from subject. | |
560 | This can also be a list of regexps." | |
58e39d05 | 561 | :version "21.1" |
16409b0b GM |
562 | :group 'gnus-summary-format |
563 | :group 'gnus-article-hiding | |
564 | :type '(choice (const :tag "none" nil) | |
565 | (regexp :value ".*") | |
566 | (repeat :value (".*") regexp))) | |
567 | ||
eec82323 LMI |
568 | (defcustom gnus-summary-mark-below 0 |
569 | "*Mark all articles with a score below this variable as read. | |
570 | This variable is local to each summary buffer and usually set by the | |
571 | score file." | |
572 | :group 'gnus-score-default | |
573 | :type 'integer) | |
574 | ||
575 | (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number) | |
576 | "*List of functions used for sorting articles in the summary buffer. | |
577 | This variable is only used when not using a threaded display." | |
578 | :group 'gnus-summary-sort | |
579 | :type '(repeat (choice (function-item gnus-article-sort-by-number) | |
580 | (function-item gnus-article-sort-by-author) | |
581 | (function-item gnus-article-sort-by-subject) | |
582 | (function-item gnus-article-sort-by-date) | |
583 | (function-item gnus-article-sort-by-score) | |
584 | (function :tag "other")))) | |
585 | ||
586 | (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number) | |
587 | "*List of functions used for sorting threads in the summary buffer. | |
588 | By default, threads are sorted by article number. | |
589 | ||
590 | Each function takes two threads and return non-nil if the first thread | |
591 | should be sorted before the other. If you use more than one function, | |
592 | the primary sort function should be the last. You should probably | |
593 | always include `gnus-thread-sort-by-number' in the list of sorting | |
594 | functions -- preferably first. | |
595 | ||
596 | Ready-made functions include `gnus-thread-sort-by-number', | |
597 | `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject', | |
598 | `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and | |
599 | `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function')." | |
600 | :group 'gnus-summary-sort | |
601 | :type '(repeat (choice (function-item gnus-thread-sort-by-number) | |
602 | (function-item gnus-thread-sort-by-author) | |
603 | (function-item gnus-thread-sort-by-subject) | |
604 | (function-item gnus-thread-sort-by-date) | |
605 | (function-item gnus-thread-sort-by-score) | |
606 | (function-item gnus-thread-sort-by-total-score) | |
607 | (function :tag "other")))) | |
608 | ||
609 | (defcustom gnus-thread-score-function '+ | |
610 | "*Function used for calculating the total score of a thread. | |
611 | ||
612 | The function is called with the scores of the article and each | |
613 | subthread and should then return the score of the thread. | |
614 | ||
615 | Some functions you can use are `+', `max', or `min'." | |
616 | :group 'gnus-summary-sort | |
617 | :type 'function) | |
618 | ||
619 | (defcustom gnus-summary-expunge-below nil | |
6748645f LMI |
620 | "All articles that have a score less than this variable will be expunged. |
621 | This variable is local to the summary buffers." | |
eec82323 LMI |
622 | :group 'gnus-score-default |
623 | :type '(choice (const :tag "off" nil) | |
624 | integer)) | |
625 | ||
626 | (defcustom gnus-thread-expunge-below nil | |
627 | "All threads that have a total score less than this variable will be expunged. | |
628 | See `gnus-thread-score-function' for en explanation of what a | |
6748645f LMI |
629 | \"thread score\" is. |
630 | ||
631 | This variable is local to the summary buffers." | |
16409b0b | 632 | :group 'gnus-threading |
eec82323 LMI |
633 | :group 'gnus-score-default |
634 | :type '(choice (const :tag "off" nil) | |
635 | integer)) | |
636 | ||
637 | (defcustom gnus-summary-mode-hook nil | |
638 | "*A hook for Gnus summary mode. | |
639 | This hook is run before any variables are set in the summary buffer." | |
60bd5589 | 640 | :options '(turn-on-gnus-mailing-list-mode) |
eec82323 LMI |
641 | :group 'gnus-summary-various |
642 | :type 'hook) | |
643 | ||
644 | (defcustom gnus-summary-menu-hook nil | |
645 | "*Hook run after the creation of the summary mode menu." | |
646 | :group 'gnus-summary-visual | |
647 | :type 'hook) | |
648 | ||
649 | (defcustom gnus-summary-exit-hook nil | |
650 | "*A hook called on exit from the summary buffer. | |
651 | It will be called with point in the group buffer." | |
652 | :group 'gnus-summary-exit | |
653 | :type 'hook) | |
654 | ||
655 | (defcustom gnus-summary-prepare-hook nil | |
656 | "*A hook called after the summary buffer has been generated. | |
657 | If you want to modify the summary buffer, you can use this hook." | |
658 | :group 'gnus-summary-various | |
659 | :type 'hook) | |
660 | ||
6748645f LMI |
661 | (defcustom gnus-summary-prepared-hook nil |
662 | "*A hook called as the last thing after the summary buffer has been generated." | |
663 | :group 'gnus-summary-various | |
664 | :type 'hook) | |
665 | ||
eec82323 LMI |
666 | (defcustom gnus-summary-generate-hook nil |
667 | "*A hook run just before generating the summary buffer. | |
668 | This hook is commonly used to customize threading variables and the | |
669 | like." | |
670 | :group 'gnus-summary-various | |
671 | :type 'hook) | |
672 | ||
673 | (defcustom gnus-select-group-hook nil | |
674 | "*A hook called when a newsgroup is selected. | |
675 | ||
676 | If you'd like to simplify subjects like the | |
677 | `gnus-summary-next-same-subject' command does, you can use the | |
678 | following hook: | |
679 | ||
680 | (setq gnus-select-group-hook | |
681 | (list | |
682 | (lambda () | |
683 | (mapcar (lambda (header) | |
684 | (mail-header-set-subject | |
685 | header | |
686 | (gnus-simplify-subject | |
687 | (mail-header-subject header) 're-only))) | |
688 | gnus-newsgroup-headers))))" | |
689 | :group 'gnus-group-select | |
690 | :type 'hook) | |
691 | ||
692 | (defcustom gnus-select-article-hook nil | |
693 | "*A hook called when an article is selected." | |
694 | :group 'gnus-summary-choose | |
695 | :type 'hook) | |
696 | ||
697 | (defcustom gnus-visual-mark-article-hook | |
698 | (list 'gnus-highlight-selected-summary) | |
699 | "*Hook run after selecting an article in the summary buffer. | |
700 | It is meant to be used for highlighting the article in some way. It | |
701 | is not run if `gnus-visual' is nil." | |
702 | :group 'gnus-summary-visual | |
703 | :type 'hook) | |
704 | ||
16409b0b | 705 | (defcustom gnus-parse-headers-hook nil |
eec82323 LMI |
706 | "*A hook called before parsing the headers." |
707 | :group 'gnus-various | |
708 | :type 'hook) | |
709 | ||
710 | (defcustom gnus-exit-group-hook nil | |
16409b0b GM |
711 | "*A hook called when exiting summary mode. |
712 | This hook is not called from the non-updating exit commands like `Q'." | |
eec82323 LMI |
713 | :group 'gnus-various |
714 | :type 'hook) | |
715 | ||
716 | (defcustom gnus-summary-update-hook | |
717 | (list 'gnus-summary-highlight-line) | |
718 | "*A hook called when a summary line is changed. | |
719 | The hook will not be called if `gnus-visual' is nil. | |
720 | ||
721 | The default function `gnus-summary-highlight-line' will | |
722 | highlight the line according to the `gnus-summary-highlight' | |
723 | variable." | |
724 | :group 'gnus-summary-visual | |
725 | :type 'hook) | |
726 | ||
727 | (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read) | |
728 | "*A hook called when an article is selected for the first time. | |
729 | The hook is intended to mark an article as read (or unread) | |
730 | automatically when it is selected." | |
731 | :group 'gnus-summary-choose | |
732 | :type 'hook) | |
733 | ||
734 | (defcustom gnus-group-no-more-groups-hook nil | |
735 | "*A hook run when returning to group mode having no more (unread) groups." | |
736 | :group 'gnus-group-select | |
737 | :type 'hook) | |
738 | ||
739 | (defcustom gnus-ps-print-hook nil | |
740 | "*A hook run before ps-printing something from Gnus." | |
741 | :group 'gnus-summary | |
742 | :type 'hook) | |
743 | ||
744 | (defcustom gnus-summary-selected-face 'gnus-summary-selected-face | |
745 | "Face used for highlighting the current article in the summary buffer." | |
746 | :group 'gnus-summary-visual | |
747 | :type 'face) | |
748 | ||
749 | (defcustom gnus-summary-highlight | |
750 | '(((= mark gnus-canceled-mark) | |
751 | . gnus-summary-cancelled-face) | |
752 | ((and (> score default) | |
753 | (or (= mark gnus-dormant-mark) | |
754 | (= mark gnus-ticked-mark))) | |
755 | . gnus-summary-high-ticked-face) | |
756 | ((and (< score default) | |
757 | (or (= mark gnus-dormant-mark) | |
758 | (= mark gnus-ticked-mark))) | |
759 | . gnus-summary-low-ticked-face) | |
760 | ((or (= mark gnus-dormant-mark) | |
761 | (= mark gnus-ticked-mark)) | |
762 | . gnus-summary-normal-ticked-face) | |
763 | ((and (> score default) (= mark gnus-ancient-mark)) | |
764 | . gnus-summary-high-ancient-face) | |
765 | ((and (< score default) (= mark gnus-ancient-mark)) | |
766 | . gnus-summary-low-ancient-face) | |
767 | ((= mark gnus-ancient-mark) | |
768 | . gnus-summary-normal-ancient-face) | |
769 | ((and (> score default) (= mark gnus-unread-mark)) | |
770 | . gnus-summary-high-unread-face) | |
771 | ((and (< score default) (= mark gnus-unread-mark)) | |
772 | . gnus-summary-low-unread-face) | |
6748645f LMI |
773 | ((= mark gnus-unread-mark) |
774 | . gnus-summary-normal-unread-face) | |
775 | ((and (> score default) (memq mark (list gnus-downloadable-mark | |
776 | gnus-undownloaded-mark))) | |
777 | . gnus-summary-high-unread-face) | |
778 | ((and (< score default) (memq mark (list gnus-downloadable-mark | |
779 | gnus-undownloaded-mark))) | |
780 | . gnus-summary-low-unread-face) | |
781 | ((memq mark (list gnus-downloadable-mark gnus-undownloaded-mark)) | |
eec82323 LMI |
782 | . gnus-summary-normal-unread-face) |
783 | ((> score default) | |
784 | . gnus-summary-high-read-face) | |
785 | ((< score default) | |
786 | . gnus-summary-low-read-face) | |
787 | (t | |
788 | . gnus-summary-normal-read-face)) | |
6748645f | 789 | "*Controls the highlighting of summary buffer lines. |
eec82323 LMI |
790 | |
791 | A list of (FORM . FACE) pairs. When deciding how a a particular | |
792 | summary line should be displayed, each form is evaluated. The content | |
793 | of the face field after the first true form is used. You can change | |
794 | how those summary lines are displayed, by editing the face field. | |
795 | ||
796 | You can use the following variables in the FORM field. | |
797 | ||
798 | score: The articles score | |
799 | default: The default article score. | |
800 | below: The score below which articles are automatically marked as read. | |
801 | mark: The articles mark." | |
802 | :group 'gnus-summary-visual | |
803 | :type '(repeat (cons (sexp :tag "Form" nil) | |
804 | face))) | |
805 | ||
6748645f LMI |
806 | (defcustom gnus-alter-header-function nil |
807 | "Function called to allow alteration of article header structures. | |
808 | The function is called with one parameter, the article header vector, | |
809 | which it may alter in any way.") | |
eec82323 | 810 | |
16409b0b GM |
811 | (defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string |
812 | "Variable that says which function should be used to decode a string with encoded words.") | |
813 | ||
814 | (defcustom gnus-extra-headers nil | |
815 | "*Extra headers to parse." | |
58e39d05 | 816 | :version "21.1" |
16409b0b GM |
817 | :group 'gnus-summary |
818 | :type '(repeat symbol)) | |
819 | ||
820 | (defcustom gnus-ignored-from-addresses | |
821 | (and user-mail-address (regexp-quote user-mail-address)) | |
822 | "*Regexp of From headers that may be suppressed in favor of To headers." | |
58e39d05 | 823 | :version "21.1" |
16409b0b GM |
824 | :group 'gnus-summary |
825 | :type 'regexp) | |
826 | ||
827 | (defcustom gnus-group-charset-alist | |
828 | '(("^hk\\>\\|^tw\\>\\|\\<big5\\>" cn-big5) | |
829 | ("^cn\\>\\|\\<chinese\\>" cn-gb-2312) | |
830 | ("^fj\\>\\|^japan\\>" iso-2022-jp-2) | |
831 | ("^tnn\\>\\|^pin\\>\\|^sci.lang.japan" iso-2022-7bit) | |
832 | ("^relcom\\>" koi8-r) | |
833 | ("^fido7\\>" koi8-r) | |
834 | ("^\\(cz\\|hun\\|pl\\|sk\\|hr\\)\\>" iso-8859-2) | |
835 | ("^israel\\>" iso-8859-1) | |
836 | ("^han\\>" euc-kr) | |
837 | ("^alt.chinese.text.big5\\>" chinese-big5) | |
838 | ("^soc.culture.vietnamese\\>" vietnamese-viqr) | |
839 | ("^\\(comp\\|rec\\|alt\\|sci\\|soc\\|news\\|gnu\\|bofh\\)\\>" iso-8859-1) | |
840 | (".*" iso-8859-1)) | |
841 | "Alist of regexps (to match group names) and default charsets to be used when reading." | |
842 | :type '(repeat (list (regexp :tag "Group") | |
843 | (symbol :tag "Charset"))) | |
844 | :group 'gnus-charset) | |
845 | ||
846 | (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown) | |
847 | "List of charsets that should be ignored. | |
848 | When these charsets are used in the \"charset\" parameter, the | |
849 | default charset will be used instead." | |
58e39d05 | 850 | :version "21.1" |
16409b0b GM |
851 | :type '(repeat symbol) |
852 | :group 'gnus-charset) | |
853 | ||
854 | (defcustom gnus-group-ignored-charsets-alist | |
855 | '(("alt\\.chinese\\.text" iso-8859-1)) | |
856 | "Alist of regexps (to match group names) and charsets that should be ignored. | |
857 | When these charsets are used in the \"charset\" parameter, the | |
858 | default charset will be used instead." | |
859 | :type '(repeat (cons (regexp :tag "Group") | |
860 | (repeat symbol))) | |
861 | :group 'gnus-charset) | |
862 | ||
863 | (defcustom gnus-group-highlight-words-alist nil | |
864 | "Alist of group regexps and highlight regexps. | |
865 | This variable uses the same syntax as `gnus-emphasis-alist'." | |
58e39d05 | 866 | :version "21.1" |
16409b0b GM |
867 | :type '(repeat (cons (regexp :tag "Group") |
868 | (repeat (list (regexp :tag "Highlight regexp") | |
869 | (number :tag "Group for entire word" 0) | |
870 | (number :tag "Group for displayed part" 0) | |
871 | (symbol :tag "Face" | |
872 | gnus-emphasis-highlight-words))))) | |
873 | :group 'gnus-summary-visual) | |
874 | ||
875 | (defcustom gnus-summary-show-article-charset-alist | |
876 | nil | |
877 | "Alist of number and charset. | |
878 | The article will be shown with the charset corresponding to the | |
879 | numbered argument. | |
880 | For example: ((1 . cn-gb-2312) (2 . big5))." | |
58e39d05 | 881 | :version "21.1" |
16409b0b GM |
882 | :type '(repeat (cons (number :tag "Argument" 1) |
883 | (symbol :tag "Charset"))) | |
884 | :group 'gnus-charset) | |
885 | ||
886 | (defcustom gnus-preserve-marks t | |
887 | "Whether marks are preserved when moving, copying and respooling messages." | |
58e39d05 | 888 | :version "21.1" |
16409b0b GM |
889 | :type 'boolean |
890 | :group 'gnus-summary-marks) | |
891 | ||
892 | (defcustom gnus-alter-articles-to-read-function nil | |
893 | "Function to be called to alter the list of articles to be selected." | |
8fc7a9a1 | 894 | :type '(choice (const nil) function) |
16409b0b GM |
895 | :group 'gnus-summary) |
896 | ||
897 | (defcustom gnus-orphan-score nil | |
898 | "*All orphans get this score added. Set in the score file." | |
899 | :group 'gnus-score-default | |
900 | :type '(choice (const nil) | |
901 | integer)) | |
902 | ||
8b93df01 DL |
903 | (defcustom gnus-summary-save-parts-default-mime "image/.*" |
904 | "*A regexp to match MIME parts when saving multiple parts of a message | |
905 | with gnus-summary-save-parts (X m). This regexp will be used by default | |
906 | when prompting the user for which type of files to save." | |
907 | :group 'gnus-summary | |
908 | :type 'regexp) | |
909 | ||
910 | ||
eec82323 LMI |
911 | ;;; Internal variables |
912 | ||
16409b0b GM |
913 | (defvar gnus-article-mime-handles nil) |
914 | (defvar gnus-article-decoded-p nil) | |
eec82323 LMI |
915 | (defvar gnus-scores-exclude-files nil) |
916 | (defvar gnus-page-broken nil) | |
16409b0b | 917 | (defvar gnus-inhibit-mime-unbuttonizing nil) |
eec82323 LMI |
918 | |
919 | (defvar gnus-original-article nil) | |
920 | (defvar gnus-article-internal-prepare-hook nil) | |
921 | (defvar gnus-newsgroup-process-stack nil) | |
922 | ||
923 | (defvar gnus-thread-indent-array nil) | |
924 | (defvar gnus-thread-indent-array-level gnus-thread-indent-level) | |
16409b0b GM |
925 | (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number |
926 | "Function called to sort the articles within a thread after it has been gathered together.") | |
eec82323 | 927 | |
8b93df01 DL |
928 | (defvar gnus-summary-save-parts-type-history nil) |
929 | (defvar gnus-summary-save-parts-last-directory nil) | |
930 | ||
eec82323 LMI |
931 | ;; Avoid highlighting in kill files. |
932 | (defvar gnus-summary-inhibit-highlight nil) | |
933 | (defvar gnus-newsgroup-selected-overlay nil) | |
934 | (defvar gnus-inhibit-limiting nil) | |
935 | (defvar gnus-newsgroup-adaptive-score-file nil) | |
936 | (defvar gnus-current-score-file nil) | |
937 | (defvar gnus-current-move-group nil) | |
938 | (defvar gnus-current-copy-group nil) | |
939 | (defvar gnus-current-crosspost-group nil) | |
940 | ||
941 | (defvar gnus-newsgroup-dependencies nil) | |
942 | (defvar gnus-newsgroup-adaptive nil) | |
943 | (defvar gnus-summary-display-article-function nil) | |
944 | (defvar gnus-summary-highlight-line-function nil | |
945 | "Function called after highlighting a summary line.") | |
946 | ||
947 | (defvar gnus-summary-line-format-alist | |
948 | `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d) | |
949 | (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s) | |
950 | (?s gnus-tmp-subject-or-nil ?s) | |
951 | (?n gnus-tmp-name ?s) | |
952 | (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from))) | |
953 | ?s) | |
954 | (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from)) | |
955 | gnus-tmp-from) ?s) | |
956 | (?F gnus-tmp-from ?s) | |
957 | (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s) | |
958 | (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s) | |
959 | (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s) | |
6748645f | 960 | (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s) |
eec82323 LMI |
961 | (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s) |
962 | (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s) | |
963 | (?c (or (mail-header-chars gnus-tmp-header) 0) ?d) | |
964 | (?L gnus-tmp-lines ?d) | |
965 | (?I gnus-tmp-indentation ?s) | |
966 | (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s) | |
967 | (?R gnus-tmp-replied ?c) | |
968 | (?\[ gnus-tmp-opening-bracket ?c) | |
969 | (?\] gnus-tmp-closing-bracket ?c) | |
970 | (?\> (make-string gnus-tmp-level ? ) ?s) | |
971 | (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s) | |
972 | (?i gnus-tmp-score ?d) | |
973 | (?z gnus-tmp-score-char ?c) | |
974 | (?l (bbb-grouplens-score gnus-tmp-header) ?s) | |
975 | (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d) | |
976 | (?U gnus-tmp-unread ?c) | |
16409b0b | 977 | (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header) ?s) |
eec82323 LMI |
978 | (?t (gnus-summary-number-of-articles-in-thread |
979 | (and (boundp 'thread) (car thread)) gnus-tmp-level) | |
980 | ?d) | |
981 | (?e (gnus-summary-number-of-articles-in-thread | |
982 | (and (boundp 'thread) (car thread)) gnus-tmp-level t) | |
983 | ?c) | |
984 | (?u gnus-tmp-user-defined ?s) | |
985 | (?P (gnus-pick-line-number) ?d)) | |
16409b0b GM |
986 | "An alist of format specifications that can appear in summary lines. |
987 | These are paired with what variables they correspond with, along with | |
988 | the type of the variable (string, integer, character, etc).") | |
eec82323 LMI |
989 | |
990 | (defvar gnus-summary-dummy-line-format-alist | |
991 | `((?S gnus-tmp-subject ?s) | |
992 | (?N gnus-tmp-number ?d) | |
993 | (?u gnus-tmp-user-defined ?s))) | |
994 | ||
995 | (defvar gnus-summary-mode-line-format-alist | |
996 | `((?G gnus-tmp-group-name ?s) | |
997 | (?g (gnus-short-group-name gnus-tmp-group-name) ?s) | |
998 | (?p (gnus-group-real-name gnus-tmp-group-name) ?s) | |
999 | (?A gnus-tmp-article-number ?d) | |
1000 | (?Z gnus-tmp-unread-and-unselected ?s) | |
1001 | (?V gnus-version ?s) | |
1002 | (?U gnus-tmp-unread-and-unticked ?d) | |
1003 | (?S gnus-tmp-subject ?s) | |
1004 | (?e gnus-tmp-unselected ?d) | |
1005 | (?u gnus-tmp-user-defined ?s) | |
1006 | (?d (length gnus-newsgroup-dormant) ?d) | |
1007 | (?t (length gnus-newsgroup-marked) ?d) | |
1008 | (?r (length gnus-newsgroup-reads) ?d) | |
6748645f | 1009 | (?z (gnus-summary-article-score gnus-tmp-article-number) ?d) |
eec82323 LMI |
1010 | (?E gnus-newsgroup-expunged-tally ?d) |
1011 | (?s (gnus-current-score-file-nondirectory) ?s))) | |
1012 | ||
1013 | (defvar gnus-last-search-regexp nil | |
1014 | "Default regexp for article search command.") | |
1015 | ||
1016 | (defvar gnus-last-shell-command nil | |
1017 | "Default shell command on article.") | |
1018 | ||
1019 | (defvar gnus-newsgroup-begin nil) | |
1020 | (defvar gnus-newsgroup-end nil) | |
1021 | (defvar gnus-newsgroup-last-rmail nil) | |
1022 | (defvar gnus-newsgroup-last-mail nil) | |
1023 | (defvar gnus-newsgroup-last-folder nil) | |
1024 | (defvar gnus-newsgroup-last-file nil) | |
1025 | (defvar gnus-newsgroup-auto-expire nil) | |
1026 | (defvar gnus-newsgroup-active nil) | |
1027 | ||
1028 | (defvar gnus-newsgroup-data nil) | |
1029 | (defvar gnus-newsgroup-data-reverse nil) | |
1030 | (defvar gnus-newsgroup-limit nil) | |
1031 | (defvar gnus-newsgroup-limits nil) | |
1032 | ||
1033 | (defvar gnus-newsgroup-unreads nil | |
1034 | "List of unread articles in the current newsgroup.") | |
1035 | ||
1036 | (defvar gnus-newsgroup-unselected nil | |
1037 | "List of unselected unread articles in the current newsgroup.") | |
1038 | ||
1039 | (defvar gnus-newsgroup-reads nil | |
1040 | "Alist of read articles and article marks in the current newsgroup.") | |
1041 | ||
1042 | (defvar gnus-newsgroup-expunged-tally nil) | |
1043 | ||
1044 | (defvar gnus-newsgroup-marked nil | |
1045 | "List of ticked articles in the current newsgroup (a subset of unread art).") | |
1046 | ||
1047 | (defvar gnus-newsgroup-killed nil | |
1048 | "List of ranges of articles that have been through the scoring process.") | |
1049 | ||
1050 | (defvar gnus-newsgroup-cached nil | |
1051 | "List of articles that come from the article cache.") | |
1052 | ||
1053 | (defvar gnus-newsgroup-saved nil | |
1054 | "List of articles that have been saved.") | |
1055 | ||
1056 | (defvar gnus-newsgroup-kill-headers nil) | |
1057 | ||
1058 | (defvar gnus-newsgroup-replied nil | |
1059 | "List of articles that have been replied to in the current newsgroup.") | |
1060 | ||
1061 | (defvar gnus-newsgroup-expirable nil | |
1062 | "List of articles in the current newsgroup that can be expired.") | |
1063 | ||
1064 | (defvar gnus-newsgroup-processable nil | |
1065 | "List of articles in the current newsgroup that can be processed.") | |
1066 | ||
6748645f LMI |
1067 | (defvar gnus-newsgroup-downloadable nil |
1068 | "List of articles in the current newsgroup that can be processed.") | |
1069 | ||
1070 | (defvar gnus-newsgroup-undownloaded nil | |
1071 | "List of articles in the current newsgroup that haven't been downloaded..") | |
1072 | ||
1073 | (defvar gnus-newsgroup-unsendable nil | |
1074 | "List of articles in the current newsgroup that won't be sent.") | |
1075 | ||
eec82323 LMI |
1076 | (defvar gnus-newsgroup-bookmarks nil |
1077 | "List of articles in the current newsgroup that have bookmarks.") | |
1078 | ||
1079 | (defvar gnus-newsgroup-dormant nil | |
1080 | "List of dormant articles in the current newsgroup.") | |
1081 | ||
1082 | (defvar gnus-newsgroup-scored nil | |
1083 | "List of scored articles in the current newsgroup.") | |
1084 | ||
1085 | (defvar gnus-newsgroup-headers nil | |
1086 | "List of article headers in the current newsgroup.") | |
1087 | ||
1088 | (defvar gnus-newsgroup-threads nil) | |
1089 | ||
1090 | (defvar gnus-newsgroup-prepared nil | |
1091 | "Whether the current group has been prepared properly.") | |
1092 | ||
1093 | (defvar gnus-newsgroup-ancient nil | |
1094 | "List of `gnus-fetch-old-headers' articles in the current newsgroup.") | |
1095 | ||
1096 | (defvar gnus-newsgroup-sparse nil) | |
1097 | ||
1098 | (defvar gnus-current-article nil) | |
1099 | (defvar gnus-article-current nil) | |
1100 | (defvar gnus-current-headers nil) | |
1101 | (defvar gnus-have-all-headers nil) | |
1102 | (defvar gnus-last-article nil) | |
1103 | (defvar gnus-newsgroup-history nil) | |
16409b0b GM |
1104 | (defvar gnus-newsgroup-charset nil) |
1105 | (defvar gnus-newsgroup-ephemeral-charset nil) | |
1106 | (defvar gnus-newsgroup-ephemeral-ignored-charsets nil) | |
eec82323 LMI |
1107 | |
1108 | (defconst gnus-summary-local-variables | |
1109 | '(gnus-newsgroup-name | |
1110 | gnus-newsgroup-begin gnus-newsgroup-end | |
1111 | gnus-newsgroup-last-rmail gnus-newsgroup-last-mail | |
1112 | gnus-newsgroup-last-folder gnus-newsgroup-last-file | |
1113 | gnus-newsgroup-auto-expire gnus-newsgroup-unreads | |
1114 | gnus-newsgroup-unselected gnus-newsgroup-marked | |
1115 | gnus-newsgroup-reads gnus-newsgroup-saved | |
1116 | gnus-newsgroup-replied gnus-newsgroup-expirable | |
1117 | gnus-newsgroup-processable gnus-newsgroup-killed | |
6748645f LMI |
1118 | gnus-newsgroup-downloadable gnus-newsgroup-undownloaded |
1119 | gnus-newsgroup-unsendable | |
eec82323 LMI |
1120 | gnus-newsgroup-bookmarks gnus-newsgroup-dormant |
1121 | gnus-newsgroup-headers gnus-newsgroup-threads | |
1122 | gnus-newsgroup-prepared gnus-summary-highlight-line-function | |
1123 | gnus-current-article gnus-current-headers gnus-have-all-headers | |
1124 | gnus-last-article gnus-article-internal-prepare-hook | |
1125 | gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay | |
1126 | gnus-newsgroup-scored gnus-newsgroup-kill-headers | |
1127 | gnus-thread-expunge-below | |
16409b0b GM |
1128 | gnus-score-alist gnus-current-score-file |
1129 | (gnus-summary-expunge-below . global) | |
eec82323 | 1130 | (gnus-summary-mark-below . global) |
16409b0b | 1131 | (gnus-orphan-score . global) |
eec82323 LMI |
1132 | gnus-newsgroup-active gnus-scores-exclude-files |
1133 | gnus-newsgroup-history gnus-newsgroup-ancient | |
1134 | gnus-newsgroup-sparse gnus-newsgroup-process-stack | |
1135 | (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring) | |
1136 | gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1) | |
1137 | (gnus-newsgroup-expunged-tally . 0) | |
1138 | gnus-cache-removable-articles gnus-newsgroup-cached | |
1139 | gnus-newsgroup-data gnus-newsgroup-data-reverse | |
16409b0b GM |
1140 | gnus-newsgroup-limit gnus-newsgroup-limits |
1141 | gnus-newsgroup-charset) | |
eec82323 LMI |
1142 | "Variables that are buffer-local to the summary buffers.") |
1143 | ||
1144 | ;; Byte-compiler warning. | |
60bd5589 | 1145 | (eval-when-compile (defvar gnus-article-mode-map)) |
eec82323 | 1146 | |
16409b0b GM |
1147 | ;; MIME stuff. |
1148 | ||
1149 | (defvar gnus-decode-encoded-word-methods | |
1150 | '(mail-decode-encoded-word-string) | |
1151 | "List of methods used to decode encoded words. | |
1152 | ||
1153 | This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item is | |
1154 | FUNCTION, FUNCTION will be apply to all newsgroups. If item is a | |
1155 | (REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups | |
1156 | whose names match REGEXP. | |
1157 | ||
1158 | For example: | |
1159 | ((\"chinese\" . gnus-decode-encoded-word-string-by-guess) | |
1160 | mail-decode-encoded-word-string | |
1161 | (\"chinese\" . rfc1843-decode-string))") | |
1162 | ||
1163 | (defvar gnus-decode-encoded-word-methods-cache nil) | |
1164 | ||
1165 | (defun gnus-multi-decode-encoded-word-string (string) | |
1166 | "Apply the functions from `gnus-encoded-word-methods' that match." | |
1167 | (unless (and gnus-decode-encoded-word-methods-cache | |
1168 | (eq gnus-newsgroup-name | |
1169 | (car gnus-decode-encoded-word-methods-cache))) | |
1170 | (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name)) | |
1171 | (mapcar (lambda (x) | |
1172 | (if (symbolp x) | |
1173 | (nconc gnus-decode-encoded-word-methods-cache (list x)) | |
1174 | (if (and gnus-newsgroup-name | |
1175 | (string-match (car x) gnus-newsgroup-name)) | |
1176 | (nconc gnus-decode-encoded-word-methods-cache | |
1177 | (list (cdr x)))))) | |
1178 | gnus-decode-encoded-word-methods)) | |
1179 | (let ((xlist gnus-decode-encoded-word-methods-cache)) | |
1180 | (pop xlist) | |
1181 | (while xlist | |
1182 | (setq string (funcall (pop xlist) string)))) | |
1183 | string) | |
1184 | ||
eec82323 LMI |
1185 | ;; Subject simplification. |
1186 | ||
6748645f | 1187 | (defun gnus-simplify-whitespace (str) |
16409b0b | 1188 | "Remove excessive whitespace from STR." |
6748645f LMI |
1189 | (let ((mystr str)) |
1190 | ;; Multiple spaces. | |
1191 | (while (string-match "[ \t][ \t]+" mystr) | |
1192 | (setq mystr (concat (substring mystr 0 (match-beginning 0)) | |
1193 | " " | |
1194 | (substring mystr (match-end 0))))) | |
1195 | ;; Leading spaces. | |
1196 | (when (string-match "^[ \t]+" mystr) | |
1197 | (setq mystr (substring mystr (match-end 0)))) | |
1198 | ;; Trailing spaces. | |
1199 | (when (string-match "[ \t]+$" mystr) | |
1200 | (setq mystr (substring mystr 0 (match-beginning 0)))) | |
1201 | mystr)) | |
1202 | ||
eec82323 LMI |
1203 | (defsubst gnus-simplify-subject-re (subject) |
1204 | "Remove \"Re:\" from subject lines." | |
1205 | (if (string-match "^[Rr][Ee]: *" subject) | |
1206 | (substring subject (match-end 0)) | |
1207 | subject)) | |
1208 | ||
1209 | (defun gnus-simplify-subject (subject &optional re-only) | |
1210 | "Remove `Re:' and words in parentheses. | |
1211 | If RE-ONLY is non-nil, strip leading `Re:'s only." | |
1212 | (let ((case-fold-search t)) ;Ignore case. | |
1213 | ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'. | |
1214 | (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject) | |
1215 | (setq subject (substring subject (match-end 0)))) | |
1216 | ;; Remove uninteresting prefixes. | |
1217 | (when (and (not re-only) | |
1218 | gnus-simplify-ignored-prefixes | |
1219 | (string-match gnus-simplify-ignored-prefixes subject)) | |
1220 | (setq subject (substring subject (match-end 0)))) | |
1221 | ;; Remove words in parentheses from end. | |
1222 | (unless re-only | |
1223 | (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject) | |
1224 | (setq subject (substring subject 0 (match-beginning 0))))) | |
1225 | ;; Return subject string. | |
1226 | subject)) | |
1227 | ||
1228 | ;; Remove any leading "re:"s, any trailing paren phrases, and simplify | |
1229 | ;; all whitespace. | |
1230 | (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext) | |
1231 | (goto-char (point-min)) | |
1232 | (while (re-search-forward regexp nil t) | |
16409b0b | 1233 | (replace-match (or newtext "")))) |
eec82323 LMI |
1234 | |
1235 | (defun gnus-simplify-buffer-fuzzy () | |
1236 | "Simplify string in the buffer fuzzily. | |
1237 | The string in the accessible portion of the current buffer is simplified. | |
1238 | It is assumed to be a single-line subject. | |
1239 | Whitespace is generally cleaned up, and miscellaneous leading/trailing | |
1240 | matter is removed. Additional things can be deleted by setting | |
16409b0b | 1241 | `gnus-simplify-subject-fuzzy-regexp'." |
eec82323 LMI |
1242 | (let ((case-fold-search t) |
1243 | (modified-tick)) | |
1244 | (gnus-simplify-buffer-fuzzy-step "\t" " ") | |
1245 | ||
1246 | (while (not (eq modified-tick (buffer-modified-tick))) | |
1247 | (setq modified-tick (buffer-modified-tick)) | |
1248 | (cond | |
1249 | ((listp gnus-simplify-subject-fuzzy-regexp) | |
1250 | (mapcar 'gnus-simplify-buffer-fuzzy-step | |
1251 | gnus-simplify-subject-fuzzy-regexp)) | |
1252 | (gnus-simplify-subject-fuzzy-regexp | |
1253 | (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp))) | |
1254 | (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *") | |
1255 | (gnus-simplify-buffer-fuzzy-step | |
1256 | "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *") | |
1257 | (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1")) | |
1258 | ||
1259 | (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$") | |
1260 | (gnus-simplify-buffer-fuzzy-step " +" " ") | |
1261 | (gnus-simplify-buffer-fuzzy-step " $") | |
1262 | (gnus-simplify-buffer-fuzzy-step "^ +"))) | |
1263 | ||
1264 | (defun gnus-simplify-subject-fuzzy (subject) | |
1265 | "Simplify a subject string fuzzily. | |
6748645f | 1266 | See `gnus-simplify-buffer-fuzzy' for details." |
eec82323 LMI |
1267 | (save-excursion |
1268 | (gnus-set-work-buffer) | |
1269 | (let ((case-fold-search t)) | |
6748645f LMI |
1270 | ;; Remove uninteresting prefixes. |
1271 | (when (and gnus-simplify-ignored-prefixes | |
1272 | (string-match gnus-simplify-ignored-prefixes subject)) | |
1273 | (setq subject (substring subject (match-end 0)))) | |
eec82323 LMI |
1274 | (insert subject) |
1275 | (inline (gnus-simplify-buffer-fuzzy)) | |
1276 | (buffer-string)))) | |
1277 | ||
1278 | (defsubst gnus-simplify-subject-fully (subject) | |
1279 | "Simplify a subject string according to gnus-summary-gather-subject-limit." | |
1280 | (cond | |
6748645f LMI |
1281 | (gnus-simplify-subject-functions |
1282 | (gnus-map-function gnus-simplify-subject-functions subject)) | |
eec82323 LMI |
1283 | ((null gnus-summary-gather-subject-limit) |
1284 | (gnus-simplify-subject-re subject)) | |
1285 | ((eq gnus-summary-gather-subject-limit 'fuzzy) | |
1286 | (gnus-simplify-subject-fuzzy subject)) | |
1287 | ((numberp gnus-summary-gather-subject-limit) | |
1288 | (gnus-limit-string (gnus-simplify-subject-re subject) | |
1289 | gnus-summary-gather-subject-limit)) | |
1290 | (t | |
1291 | subject))) | |
1292 | ||
1293 | (defsubst gnus-subject-equal (s1 s2 &optional simple-first) | |
6748645f LMI |
1294 | "Check whether two subjects are equal. |
1295 | If optional argument simple-first is t, first argument is already | |
1296 | simplified." | |
eec82323 LMI |
1297 | (cond |
1298 | ((null simple-first) | |
1299 | (equal (gnus-simplify-subject-fully s1) | |
1300 | (gnus-simplify-subject-fully s2))) | |
1301 | (t | |
1302 | (equal s1 | |
1303 | (gnus-simplify-subject-fully s2))))) | |
1304 | ||
1305 | (defun gnus-summary-bubble-group () | |
1306 | "Increase the score of the current group. | |
1307 | This is a handy function to add to `gnus-summary-exit-hook' to | |
1308 | increase the score of each group you read." | |
1309 | (gnus-group-add-score gnus-newsgroup-name)) | |
1310 | ||
1311 | \f | |
1312 | ;;; | |
1313 | ;;; Gnus summary mode | |
1314 | ;;; | |
1315 | ||
1316 | (put 'gnus-summary-mode 'mode-class 'special) | |
1317 | ||
1653df0f SZ |
1318 | (defvar gnus-article-commands-menu) |
1319 | ||
eec82323 LMI |
1320 | (when t |
1321 | ;; Non-orthogonal keys | |
1322 | ||
1323 | (gnus-define-keys gnus-summary-mode-map | |
1324 | " " gnus-summary-next-page | |
1325 | "\177" gnus-summary-prev-page | |
1326 | [delete] gnus-summary-prev-page | |
6748645f | 1327 | [backspace] gnus-summary-prev-page |
eec82323 | 1328 | "\r" gnus-summary-scroll-up |
6748645f | 1329 | "\M-\r" gnus-summary-scroll-down |
eec82323 LMI |
1330 | "n" gnus-summary-next-unread-article |
1331 | "p" gnus-summary-prev-unread-article | |
1332 | "N" gnus-summary-next-article | |
1333 | "P" gnus-summary-prev-article | |
1334 | "\M-\C-n" gnus-summary-next-same-subject | |
1335 | "\M-\C-p" gnus-summary-prev-same-subject | |
1336 | "\M-n" gnus-summary-next-unread-subject | |
1337 | "\M-p" gnus-summary-prev-unread-subject | |
1338 | "." gnus-summary-first-unread-article | |
1339 | "," gnus-summary-best-unread-article | |
1340 | "\M-s" gnus-summary-search-article-forward | |
1341 | "\M-r" gnus-summary-search-article-backward | |
1342 | "<" gnus-summary-beginning-of-article | |
1343 | ">" gnus-summary-end-of-article | |
1344 | "j" gnus-summary-goto-article | |
1345 | "^" gnus-summary-refer-parent-article | |
1346 | "\M-^" gnus-summary-refer-article | |
1347 | "u" gnus-summary-tick-article-forward | |
1348 | "!" gnus-summary-tick-article-forward | |
1349 | "U" gnus-summary-tick-article-backward | |
1350 | "d" gnus-summary-mark-as-read-forward | |
1351 | "D" gnus-summary-mark-as-read-backward | |
1352 | "E" gnus-summary-mark-as-expirable | |
1353 | "\M-u" gnus-summary-clear-mark-forward | |
1354 | "\M-U" gnus-summary-clear-mark-backward | |
1355 | "k" gnus-summary-kill-same-subject-and-select | |
1356 | "\C-k" gnus-summary-kill-same-subject | |
1357 | "\M-\C-k" gnus-summary-kill-thread | |
1358 | "\M-\C-l" gnus-summary-lower-thread | |
1359 | "e" gnus-summary-edit-article | |
1360 | "#" gnus-summary-mark-as-processable | |
1361 | "\M-#" gnus-summary-unmark-as-processable | |
1362 | "\M-\C-t" gnus-summary-toggle-threads | |
1363 | "\M-\C-s" gnus-summary-show-thread | |
1364 | "\M-\C-h" gnus-summary-hide-thread | |
1365 | "\M-\C-f" gnus-summary-next-thread | |
1366 | "\M-\C-b" gnus-summary-prev-thread | |
16409b0b GM |
1367 | [(meta down)] gnus-summary-next-thread |
1368 | [(meta up)] gnus-summary-prev-thread | |
eec82323 LMI |
1369 | "\M-\C-u" gnus-summary-up-thread |
1370 | "\M-\C-d" gnus-summary-down-thread | |
1371 | "&" gnus-summary-execute-command | |
1372 | "c" gnus-summary-catchup-and-exit | |
1373 | "\C-w" gnus-summary-mark-region-as-read | |
1374 | "\C-t" gnus-summary-toggle-truncation | |
1375 | "?" gnus-summary-mark-as-dormant | |
1376 | "\C-c\M-\C-s" gnus-summary-limit-include-expunged | |
1377 | "\C-c\C-s\C-n" gnus-summary-sort-by-number | |
1378 | "\C-c\C-s\C-l" gnus-summary-sort-by-lines | |
16409b0b | 1379 | "\C-c\C-s\C-c" gnus-summary-sort-by-chars |
eec82323 LMI |
1380 | "\C-c\C-s\C-a" gnus-summary-sort-by-author |
1381 | "\C-c\C-s\C-s" gnus-summary-sort-by-subject | |
1382 | "\C-c\C-s\C-d" gnus-summary-sort-by-date | |
1383 | "\C-c\C-s\C-i" gnus-summary-sort-by-score | |
1384 | "=" gnus-summary-expand-window | |
1385 | "\C-x\C-s" gnus-summary-reselect-current-group | |
1386 | "\M-g" gnus-summary-rescan-group | |
1387 | "w" gnus-summary-stop-page-breaking | |
1388 | "\C-c\C-r" gnus-summary-caesar-message | |
eec82323 LMI |
1389 | "f" gnus-summary-followup |
1390 | "F" gnus-summary-followup-with-original | |
1391 | "C" gnus-summary-cancel-article | |
1392 | "r" gnus-summary-reply | |
1393 | "R" gnus-summary-reply-with-original | |
1394 | "\C-c\C-f" gnus-summary-mail-forward | |
1395 | "o" gnus-summary-save-article | |
1396 | "\C-o" gnus-summary-save-article-mail | |
1397 | "|" gnus-summary-pipe-output | |
1398 | "\M-k" gnus-summary-edit-local-kill | |
1399 | "\M-K" gnus-summary-edit-global-kill | |
1400 | ;; "V" gnus-version | |
1401 | "\C-c\C-d" gnus-summary-describe-group | |
1402 | "q" gnus-summary-exit | |
1403 | "Q" gnus-summary-exit-no-update | |
1404 | "\C-c\C-i" gnus-info-find-node | |
1405 | gnus-mouse-2 gnus-mouse-pick-article | |
1406 | "m" gnus-summary-mail-other-window | |
1407 | "a" gnus-summary-post-news | |
1408 | "x" gnus-summary-limit-to-unread | |
1409 | "s" gnus-summary-isearch-article | |
16409b0b | 1410 | "t" gnus-summary-toggle-header |
eec82323 LMI |
1411 | "g" gnus-summary-show-article |
1412 | "l" gnus-summary-goto-last-article | |
1413 | "\C-c\C-v\C-v" gnus-uu-decode-uu-view | |
1414 | "\C-d" gnus-summary-enter-digest-group | |
1415 | "\M-\C-d" gnus-summary-read-document | |
6748645f | 1416 | "\M-\C-e" gnus-summary-edit-parameters |
16409b0b | 1417 | "\M-\C-a" gnus-summary-customize-parameters |
eec82323 LMI |
1418 | "\C-c\C-b" gnus-bug |
1419 | "*" gnus-cache-enter-article | |
1420 | "\M-*" gnus-cache-remove-article | |
1421 | "\M-&" gnus-summary-universal-argument | |
1422 | "\C-l" gnus-recenter | |
1423 | "I" gnus-summary-increase-score | |
1424 | "L" gnus-summary-lower-score | |
6748645f LMI |
1425 | "\M-i" gnus-symbolic-argument |
1426 | "h" gnus-summary-select-article-buffer | |
eec82323 | 1427 | |
16409b0b GM |
1428 | "b" gnus-article-view-part |
1429 | "\M-t" gnus-summary-toggle-display-buttonized | |
1430 | ||
eec82323 LMI |
1431 | "V" gnus-summary-score-map |
1432 | "X" gnus-uu-extract-map | |
1433 | "S" gnus-summary-send-map) | |
1434 | ||
1435 | ;; Sort of orthogonal keymap | |
1436 | (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map) | |
1437 | "t" gnus-summary-tick-article-forward | |
1438 | "!" gnus-summary-tick-article-forward | |
1439 | "d" gnus-summary-mark-as-read-forward | |
1440 | "r" gnus-summary-mark-as-read-forward | |
1441 | "c" gnus-summary-clear-mark-forward | |
1442 | " " gnus-summary-clear-mark-forward | |
1443 | "e" gnus-summary-mark-as-expirable | |
1444 | "x" gnus-summary-mark-as-expirable | |
1445 | "?" gnus-summary-mark-as-dormant | |
1446 | "b" gnus-summary-set-bookmark | |
1447 | "B" gnus-summary-remove-bookmark | |
1448 | "#" gnus-summary-mark-as-processable | |
1449 | "\M-#" gnus-summary-unmark-as-processable | |
1450 | "S" gnus-summary-limit-include-expunged | |
1451 | "C" gnus-summary-catchup | |
1452 | "H" gnus-summary-catchup-to-here | |
1453 | "\C-c" gnus-summary-catchup-all | |
1454 | "k" gnus-summary-kill-same-subject-and-select | |
1455 | "K" gnus-summary-kill-same-subject | |
1456 | "P" gnus-uu-mark-map) | |
1457 | ||
1458 | (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map) | |
1459 | "c" gnus-summary-clear-above | |
1460 | "u" gnus-summary-tick-above | |
1461 | "m" gnus-summary-mark-above | |
1462 | "k" gnus-summary-kill-below) | |
1463 | ||
1464 | (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map) | |
1465 | "/" gnus-summary-limit-to-subject | |
1466 | "n" gnus-summary-limit-to-articles | |
1467 | "w" gnus-summary-pop-limit | |
1468 | "s" gnus-summary-limit-to-subject | |
1469 | "a" gnus-summary-limit-to-author | |
1470 | "u" gnus-summary-limit-to-unread | |
1471 | "m" gnus-summary-limit-to-marks | |
16409b0b | 1472 | "M" gnus-summary-limit-exclude-marks |
eec82323 | 1473 | "v" gnus-summary-limit-to-score |
6748645f | 1474 | "*" gnus-summary-limit-include-cached |
eec82323 | 1475 | "D" gnus-summary-limit-include-dormant |
6748645f | 1476 | "T" gnus-summary-limit-include-thread |
eec82323 LMI |
1477 | "d" gnus-summary-limit-exclude-dormant |
1478 | "t" gnus-summary-limit-to-age | |
16409b0b | 1479 | "x" gnus-summary-limit-to-extra |
eec82323 LMI |
1480 | "E" gnus-summary-limit-include-expunged |
1481 | "c" gnus-summary-limit-exclude-childless-dormant | |
1482 | "C" gnus-summary-limit-mark-excluded-as-read) | |
1483 | ||
1484 | (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map) | |
1485 | "n" gnus-summary-next-unread-article | |
1486 | "p" gnus-summary-prev-unread-article | |
1487 | "N" gnus-summary-next-article | |
1488 | "P" gnus-summary-prev-article | |
1489 | "\C-n" gnus-summary-next-same-subject | |
1490 | "\C-p" gnus-summary-prev-same-subject | |
1491 | "\M-n" gnus-summary-next-unread-subject | |
1492 | "\M-p" gnus-summary-prev-unread-subject | |
1493 | "f" gnus-summary-first-unread-article | |
1494 | "b" gnus-summary-best-unread-article | |
1495 | "j" gnus-summary-goto-article | |
1496 | "g" gnus-summary-goto-subject | |
1497 | "l" gnus-summary-goto-last-article | |
a8151ef7 | 1498 | "o" gnus-summary-pop-article) |
eec82323 LMI |
1499 | |
1500 | (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map) | |
1501 | "k" gnus-summary-kill-thread | |
1502 | "l" gnus-summary-lower-thread | |
1503 | "i" gnus-summary-raise-thread | |
1504 | "T" gnus-summary-toggle-threads | |
1505 | "t" gnus-summary-rethread-current | |
1506 | "^" gnus-summary-reparent-thread | |
1507 | "s" gnus-summary-show-thread | |
1508 | "S" gnus-summary-show-all-threads | |
1509 | "h" gnus-summary-hide-thread | |
1510 | "H" gnus-summary-hide-all-threads | |
1511 | "n" gnus-summary-next-thread | |
1512 | "p" gnus-summary-prev-thread | |
1513 | "u" gnus-summary-up-thread | |
1514 | "o" gnus-summary-top-thread | |
1515 | "d" gnus-summary-down-thread | |
1516 | "#" gnus-uu-mark-thread | |
1517 | "\M-#" gnus-uu-unmark-thread) | |
1518 | ||
1519 | (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map) | |
1520 | "g" gnus-summary-prepare | |
1521 | "c" gnus-summary-insert-cached-articles) | |
1522 | ||
1523 | (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map) | |
1524 | "c" gnus-summary-catchup-and-exit | |
1525 | "C" gnus-summary-catchup-all-and-exit | |
1526 | "E" gnus-summary-exit-no-update | |
1527 | "Q" gnus-summary-exit | |
1528 | "Z" gnus-summary-exit | |
1529 | "n" gnus-summary-catchup-and-goto-next-group | |
1530 | "R" gnus-summary-reselect-current-group | |
1531 | "G" gnus-summary-rescan-group | |
1532 | "N" gnus-summary-next-group | |
1533 | "s" gnus-summary-save-newsrc | |
1534 | "P" gnus-summary-prev-group) | |
1535 | ||
1536 | (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map) | |
1537 | " " gnus-summary-next-page | |
1538 | "n" gnus-summary-next-page | |
1539 | "\177" gnus-summary-prev-page | |
1540 | [delete] gnus-summary-prev-page | |
1541 | "p" gnus-summary-prev-page | |
1542 | "\r" gnus-summary-scroll-up | |
6748645f | 1543 | "\M-\r" gnus-summary-scroll-down |
eec82323 LMI |
1544 | "<" gnus-summary-beginning-of-article |
1545 | ">" gnus-summary-end-of-article | |
1546 | "b" gnus-summary-beginning-of-article | |
1547 | "e" gnus-summary-end-of-article | |
1548 | "^" gnus-summary-refer-parent-article | |
1549 | "r" gnus-summary-refer-parent-article | |
16409b0b | 1550 | "D" gnus-summary-enter-digest-group |
eec82323 | 1551 | "R" gnus-summary-refer-references |
6748645f | 1552 | "T" gnus-summary-refer-thread |
eec82323 LMI |
1553 | "g" gnus-summary-show-article |
1554 | "s" gnus-summary-isearch-article | |
16409b0b GM |
1555 | "P" gnus-summary-print-article |
1556 | "t" gnus-article-babel) | |
eec82323 LMI |
1557 | |
1558 | (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map) | |
1559 | "b" gnus-article-add-buttons | |
1560 | "B" gnus-article-add-buttons-to-head | |
1561 | "o" gnus-article-treat-overstrike | |
1562 | "e" gnus-article-emphasize | |
1563 | "w" gnus-article-fill-cited-article | |
16409b0b GM |
1564 | "Q" gnus-article-fill-long-lines |
1565 | "C" gnus-article-capitalize-sentences | |
eec82323 LMI |
1566 | "c" gnus-article-remove-cr |
1567 | "q" gnus-article-de-quoted-unreadable | |
16409b0b GM |
1568 | "6" gnus-article-de-base64-unreadable |
1569 | "Z" gnus-article-decode-HZ | |
1570 | "h" gnus-article-wash-html | |
eec82323 LMI |
1571 | "f" gnus-article-display-x-face |
1572 | "l" gnus-summary-stop-page-breaking | |
1573 | "r" gnus-summary-caesar-message | |
16409b0b | 1574 | "t" gnus-summary-toggle-header |
eec82323 | 1575 | "v" gnus-summary-verbose-headers |
16409b0b | 1576 | "H" gnus-article-strip-headers-in-body |
6748645f | 1577 | "d" gnus-article-treat-dumbquotes) |
eec82323 LMI |
1578 | |
1579 | (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map) | |
1580 | "a" gnus-article-hide | |
1581 | "h" gnus-article-hide-headers | |
1582 | "b" gnus-article-hide-boring-headers | |
1583 | "s" gnus-article-hide-signature | |
1584 | "c" gnus-article-hide-citation | |
6748645f | 1585 | "C" gnus-article-hide-citation-in-followups |
16409b0b | 1586 | "l" gnus-article-hide-list-identifiers |
eec82323 | 1587 | "p" gnus-article-hide-pgp |
16409b0b | 1588 | "B" gnus-article-strip-banner |
eec82323 LMI |
1589 | "P" gnus-article-hide-pem |
1590 | "\C-c" gnus-article-hide-citation-maybe) | |
1591 | ||
1592 | (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map) | |
1593 | "a" gnus-article-highlight | |
1594 | "h" gnus-article-highlight-headers | |
1595 | "c" gnus-article-highlight-citation | |
1596 | "s" gnus-article-highlight-signature) | |
1597 | ||
16409b0b GM |
1598 | (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map) |
1599 | "w" gnus-article-decode-mime-words | |
1600 | "c" gnus-article-decode-charset | |
1601 | "v" gnus-mime-view-all-parts | |
1602 | "b" gnus-article-view-part) | |
1603 | ||
eec82323 LMI |
1604 | (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map) |
1605 | "z" gnus-article-date-ut | |
1606 | "u" gnus-article-date-ut | |
1607 | "l" gnus-article-date-local | |
1608 | "e" gnus-article-date-lapsed | |
1609 | "o" gnus-article-date-original | |
6748645f | 1610 | "i" gnus-article-date-iso8601 |
eec82323 LMI |
1611 | "s" gnus-article-date-user) |
1612 | ||
1613 | (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map) | |
1614 | "t" gnus-article-remove-trailing-blank-lines | |
1615 | "l" gnus-article-strip-leading-blank-lines | |
1616 | "m" gnus-article-strip-multiple-blank-lines | |
1617 | "a" gnus-article-strip-blank-lines | |
6748645f | 1618 | "A" gnus-article-strip-all-blank-lines |
16409b0b GM |
1619 | "s" gnus-article-strip-leading-space |
1620 | "e" gnus-article-strip-trailing-space) | |
eec82323 LMI |
1621 | |
1622 | (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map) | |
1623 | "v" gnus-version | |
1624 | "f" gnus-summary-fetch-faq | |
1625 | "d" gnus-summary-describe-group | |
1626 | "h" gnus-summary-describe-briefly | |
1627 | "i" gnus-info-find-node) | |
1628 | ||
1629 | (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map) | |
1630 | "e" gnus-summary-expire-articles | |
1631 | "\M-\C-e" gnus-summary-expire-articles-now | |
1632 | "\177" gnus-summary-delete-article | |
1633 | [delete] gnus-summary-delete-article | |
16409b0b | 1634 | [backspace] gnus-summary-delete-article |
eec82323 LMI |
1635 | "m" gnus-summary-move-article |
1636 | "r" gnus-summary-respool-article | |
1637 | "w" gnus-summary-edit-article | |
1638 | "c" gnus-summary-copy-article | |
1639 | "B" gnus-summary-crosspost-article | |
1640 | "q" gnus-summary-respool-query | |
6748645f | 1641 | "t" gnus-summary-respool-trace |
eec82323 LMI |
1642 | "i" gnus-summary-import-article |
1643 | "p" gnus-summary-article-posted-p) | |
1644 | ||
1645 | (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map) | |
1646 | "o" gnus-summary-save-article | |
1647 | "m" gnus-summary-save-article-mail | |
1648 | "F" gnus-summary-write-article-file | |
1649 | "r" gnus-summary-save-article-rmail | |
1650 | "f" gnus-summary-save-article-file | |
1651 | "b" gnus-summary-save-article-body-file | |
1652 | "h" gnus-summary-save-article-folder | |
1653 | "v" gnus-summary-save-article-vm | |
1654 | "p" gnus-summary-pipe-output | |
16409b0b GM |
1655 | "s" gnus-soup-add-article) |
1656 | ||
1657 | (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map) | |
1658 | "b" gnus-summary-display-buttonized | |
1659 | "m" gnus-summary-repair-multipart | |
1660 | "v" gnus-article-view-part | |
1661 | "o" gnus-article-save-part | |
1662 | "c" gnus-article-copy-part | |
1663 | "e" gnus-article-externalize-part | |
1664 | "i" gnus-article-inline-part | |
1665 | "|" gnus-article-pipe-part)) | |
eec82323 LMI |
1666 | |
1667 | (defun gnus-summary-make-menu-bar () | |
1668 | (gnus-turn-off-edit-menu 'summary) | |
1669 | ||
1670 | (unless (boundp 'gnus-summary-misc-menu) | |
1671 | ||
1672 | (easy-menu-define | |
1673 | gnus-summary-kill-menu gnus-summary-mode-map "" | |
1674 | (cons | |
1675 | "Score" | |
1676 | (nconc | |
1677 | (list | |
1678 | ["Enter score..." gnus-summary-score-entry t] | |
1679 | ["Customize" gnus-score-customize t]) | |
1680 | (gnus-make-score-map 'increase) | |
1681 | (gnus-make-score-map 'lower) | |
1682 | '(("Mark" | |
1683 | ["Kill below" gnus-summary-kill-below t] | |
1684 | ["Mark above" gnus-summary-mark-above t] | |
1685 | ["Tick above" gnus-summary-tick-above t] | |
1686 | ["Clear above" gnus-summary-clear-above t]) | |
1687 | ["Current score" gnus-summary-current-score t] | |
1688 | ["Set score" gnus-summary-set-score t] | |
1689 | ["Switch current score file..." gnus-score-change-score-file t] | |
1690 | ["Set mark below..." gnus-score-set-mark-below t] | |
1691 | ["Set expunge below..." gnus-score-set-expunge-below t] | |
1692 | ["Edit current score file" gnus-score-edit-current-scores t] | |
1693 | ["Edit score file" gnus-score-edit-file t] | |
1694 | ["Trace score" gnus-score-find-trace t] | |
1695 | ["Find words" gnus-score-find-favourite-words t] | |
1696 | ["Rescore buffer" gnus-summary-rescore t] | |
1697 | ["Increase score..." gnus-summary-increase-score t] | |
1698 | ["Lower score..." gnus-summary-lower-score t])))) | |
1699 | ||
6748645f LMI |
1700 | ;; Define both the Article menu in the summary buffer and the equivalent |
1701 | ;; Commands menu in the article buffer here for consistency. | |
1702 | (let ((innards | |
1703 | '(("Hide" | |
1704 | ["All" gnus-article-hide t] | |
1705 | ["Headers" gnus-article-hide-headers t] | |
1706 | ["Signature" gnus-article-hide-signature t] | |
1707 | ["Citation" gnus-article-hide-citation t] | |
16409b0b | 1708 | ["List identifiers" gnus-article-hide-list-identifiers t] |
6748645f | 1709 | ["PGP" gnus-article-hide-pgp t] |
16409b0b | 1710 | ["Banner" gnus-article-strip-banner t] |
6748645f LMI |
1711 | ["Boring headers" gnus-article-hide-boring-headers t]) |
1712 | ("Highlight" | |
1713 | ["All" gnus-article-highlight t] | |
1714 | ["Headers" gnus-article-highlight-headers t] | |
1715 | ["Signature" gnus-article-highlight-signature t] | |
1716 | ["Citation" gnus-article-highlight-citation t]) | |
16409b0b GM |
1717 | ("MIME" |
1718 | ["Words" gnus-article-decode-mime-words t] | |
1719 | ["Charset" gnus-article-decode-charset t] | |
1720 | ["QP" gnus-article-de-quoted-unreadable t] | |
1721 | ["Base64" gnus-article-de-base64-unreadable t] | |
1722 | ["View all" gnus-mime-view-all-parts t]) | |
6748645f LMI |
1723 | ("Date" |
1724 | ["Local" gnus-article-date-local t] | |
1725 | ["ISO8601" gnus-article-date-iso8601 t] | |
1726 | ["UT" gnus-article-date-ut t] | |
1727 | ["Original" gnus-article-date-original t] | |
1728 | ["Lapsed" gnus-article-date-lapsed t] | |
1729 | ["User-defined" gnus-article-date-user t]) | |
1730 | ("Washing" | |
1731 | ("Remove Blanks" | |
1732 | ["Leading" gnus-article-strip-leading-blank-lines t] | |
1733 | ["Multiple" gnus-article-strip-multiple-blank-lines t] | |
1734 | ["Trailing" gnus-article-remove-trailing-blank-lines t] | |
1735 | ["All of the above" gnus-article-strip-blank-lines t] | |
1736 | ["All" gnus-article-strip-all-blank-lines t] | |
16409b0b GM |
1737 | ["Leading space" gnus-article-strip-leading-space t] |
1738 | ["Trailing space" gnus-article-strip-trailing-space t]) | |
6748645f LMI |
1739 | ["Overstrike" gnus-article-treat-overstrike t] |
1740 | ["Dumb quotes" gnus-article-treat-dumbquotes t] | |
1741 | ["Emphasis" gnus-article-emphasize t] | |
1742 | ["Word wrap" gnus-article-fill-cited-article t] | |
16409b0b GM |
1743 | ["Fill long lines" gnus-article-fill-long-lines t] |
1744 | ["Capitalize sentences" gnus-article-capitalize-sentences t] | |
6748645f LMI |
1745 | ["CR" gnus-article-remove-cr t] |
1746 | ["Show X-Face" gnus-article-display-x-face t] | |
1747 | ["Quoted-Printable" gnus-article-de-quoted-unreadable t] | |
16409b0b | 1748 | ["Base64" gnus-article-de-base64-unreadable t] |
60bd5589 DL |
1749 | ["Rot 13" gnus-summary-caesar-message |
1750 | :help "\"Caesar rotate\" article by 13"] | |
6748645f LMI |
1751 | ["Unix pipe" gnus-summary-pipe-message t] |
1752 | ["Add buttons" gnus-article-add-buttons t] | |
1753 | ["Add buttons to head" gnus-article-add-buttons-to-head t] | |
1754 | ["Stop page breaking" gnus-summary-stop-page-breaking t] | |
6748645f | 1755 | ["Verbose header" gnus-summary-verbose-headers t] |
16409b0b GM |
1756 | ["Toggle header" gnus-summary-toggle-header t] |
1757 | ["Html" gnus-article-wash-html t] | |
1758 | ["HZ" gnus-article-decode-HZ t]) | |
6748645f | 1759 | ("Output" |
60bd5589 DL |
1760 | ["Save in default format" gnus-summary-save-article |
1761 | :help "Save article using default method"] | |
1762 | ["Save in file" gnus-summary-save-article-file | |
1763 | :help "Save article in file"] | |
6748645f LMI |
1764 | ["Save in Unix mail format" gnus-summary-save-article-mail t] |
1765 | ["Save in MH folder" gnus-summary-save-article-folder t] | |
1766 | ["Save in VM folder" gnus-summary-save-article-vm t] | |
1767 | ["Save in RMAIL mbox" gnus-summary-save-article-rmail t] | |
1768 | ["Save body in file" gnus-summary-save-article-body-file t] | |
1769 | ["Pipe through a filter" gnus-summary-pipe-output t] | |
1770 | ["Add to SOUP packet" gnus-soup-add-article t] | |
1771 | ["Print" gnus-summary-print-article t]) | |
1772 | ("Backend" | |
1773 | ["Respool article..." gnus-summary-respool-article t] | |
1774 | ["Move article..." gnus-summary-move-article | |
1775 | (gnus-check-backend-function | |
1776 | 'request-move-article gnus-newsgroup-name)] | |
1777 | ["Copy article..." gnus-summary-copy-article t] | |
1778 | ["Crosspost article..." gnus-summary-crosspost-article | |
1779 | (gnus-check-backend-function | |
1780 | 'request-replace-article gnus-newsgroup-name)] | |
1781 | ["Import file..." gnus-summary-import-article t] | |
1782 | ["Check if posted" gnus-summary-article-posted-p t] | |
1783 | ["Edit article" gnus-summary-edit-article | |
1784 | (not (gnus-group-read-only-p))] | |
1785 | ["Delete article" gnus-summary-delete-article | |
1786 | (gnus-check-backend-function | |
1787 | 'request-expire-articles gnus-newsgroup-name)] | |
1788 | ["Query respool" gnus-summary-respool-query t] | |
1789 | ["Trace respool" gnus-summary-respool-trace t] | |
1790 | ["Delete expirable articles" gnus-summary-expire-articles-now | |
1791 | (gnus-check-backend-function | |
1792 | 'request-expire-articles gnus-newsgroup-name)]) | |
1793 | ("Extract" | |
60bd5589 DL |
1794 | ["Uudecode" gnus-uu-decode-uu |
1795 | :help "Decode uuencoded article(s)"] | |
6748645f LMI |
1796 | ["Uudecode and save" gnus-uu-decode-uu-and-save t] |
1797 | ["Unshar" gnus-uu-decode-unshar t] | |
1798 | ["Unshar and save" gnus-uu-decode-unshar-and-save t] | |
1799 | ["Save" gnus-uu-decode-save t] | |
1800 | ["Binhex" gnus-uu-decode-binhex t] | |
1801 | ["Postscript" gnus-uu-decode-postscript t]) | |
1802 | ("Cache" | |
1803 | ["Enter article" gnus-cache-enter-article t] | |
1804 | ["Remove article" gnus-cache-remove-article t]) | |
16409b0b | 1805 | ["Translate" gnus-article-babel t] |
6748645f LMI |
1806 | ["Select article buffer" gnus-summary-select-article-buffer t] |
1807 | ["Enter digest buffer" gnus-summary-enter-digest-group t] | |
1808 | ["Isearch article..." gnus-summary-isearch-article t] | |
1809 | ["Beginning of the article" gnus-summary-beginning-of-article t] | |
1810 | ["End of the article" gnus-summary-end-of-article t] | |
1811 | ["Fetch parent of article" gnus-summary-refer-parent-article t] | |
1812 | ["Fetch referenced articles" gnus-summary-refer-references t] | |
1813 | ["Fetch current thread" gnus-summary-refer-thread t] | |
1814 | ["Fetch article with id..." gnus-summary-refer-article t] | |
1815 | ["Redisplay" gnus-summary-show-article t]))) | |
1816 | (easy-menu-define | |
1817 | gnus-summary-article-menu gnus-summary-mode-map "" | |
1818 | (cons "Article" innards)) | |
1819 | ||
1653df0f SZ |
1820 | (if (not (keymapp gnus-summary-article-menu)) |
1821 | (easy-menu-define | |
1822 | gnus-article-commands-menu gnus-article-mode-map "" | |
1823 | (cons "Commands" innards)) | |
1824 | ;; in Emacs, don't share menu. | |
1825 | (setq gnus-article-commands-menu | |
1826 | (copy-keymap gnus-summary-article-menu)) | |
1827 | (define-key gnus-article-mode-map [menu-bar commands] | |
1828 | (cons "Commands" gnus-article-commands-menu)))) | |
eec82323 LMI |
1829 | |
1830 | (easy-menu-define | |
1831 | gnus-summary-thread-menu gnus-summary-mode-map "" | |
1832 | '("Threads" | |
1833 | ["Toggle threading" gnus-summary-toggle-threads t] | |
1834 | ["Hide threads" gnus-summary-hide-all-threads t] | |
1835 | ["Show threads" gnus-summary-show-all-threads t] | |
1836 | ["Hide thread" gnus-summary-hide-thread t] | |
1837 | ["Show thread" gnus-summary-show-thread t] | |
1838 | ["Go to next thread" gnus-summary-next-thread t] | |
1839 | ["Go to previous thread" gnus-summary-prev-thread t] | |
1840 | ["Go down thread" gnus-summary-down-thread t] | |
1841 | ["Go up thread" gnus-summary-up-thread t] | |
1842 | ["Top of thread" gnus-summary-top-thread t] | |
1843 | ["Mark thread as read" gnus-summary-kill-thread t] | |
1844 | ["Lower thread score" gnus-summary-lower-thread t] | |
1845 | ["Raise thread score" gnus-summary-raise-thread t] | |
16409b0b | 1846 | ["Rethread current" gnus-summary-rethread-current t])) |
eec82323 LMI |
1847 | |
1848 | (easy-menu-define | |
1849 | gnus-summary-post-menu gnus-summary-mode-map "" | |
1850 | '("Post" | |
60bd5589 DL |
1851 | ["Post an article" gnus-summary-post-news |
1852 | :help "Post an article"] | |
1853 | ["Followup" gnus-summary-followup | |
1854 | :help "Post followup to this article"] | |
1855 | ["Followup and yank" gnus-summary-followup-with-original | |
1856 | :help "Post followup to this article, quoting its contents"] | |
eec82323 | 1857 | ["Supersede article" gnus-summary-supersede-article t] |
60bd5589 DL |
1858 | ["Cancel article" gnus-summary-cancel-article |
1859 | :help "Cancel an article you posted"] | |
eec82323 LMI |
1860 | ["Reply" gnus-summary-reply t] |
1861 | ["Reply and yank" gnus-summary-reply-with-original t] | |
1862 | ["Wide reply" gnus-summary-wide-reply t] | |
60bd5589 DL |
1863 | ["Wide reply and yank" gnus-summary-wide-reply-with-original |
1864 | :help "Mail a reply, quoting this article"] | |
eec82323 LMI |
1865 | ["Mail forward" gnus-summary-mail-forward t] |
1866 | ["Post forward" gnus-summary-post-forward t] | |
1867 | ["Digest and mail" gnus-uu-digest-mail-forward t] | |
1868 | ["Digest and post" gnus-uu-digest-post-forward t] | |
1869 | ["Resend message" gnus-summary-resend-message t] | |
1870 | ["Send bounced mail" gnus-summary-resend-bounced-mail t] | |
1871 | ["Send a mail" gnus-summary-mail-other-window t] | |
60bd5589 DL |
1872 | ["Uuencode and post" gnus-uu-post-news |
1873 | :help "Post a uuencoded article"] | |
eec82323 LMI |
1874 | ["Followup via news" gnus-summary-followup-to-mail t] |
1875 | ["Followup via news and yank" | |
1876 | gnus-summary-followup-to-mail-with-original t] | |
1877 | ;;("Draft" | |
1878 | ;;["Send" gnus-summary-send-draft t] | |
1879 | ;;["Send bounced" gnus-resend-bounced-mail t]) | |
1880 | )) | |
1881 | ||
1882 | (easy-menu-define | |
1883 | gnus-summary-misc-menu gnus-summary-mode-map "" | |
1884 | '("Misc" | |
1885 | ("Mark Read" | |
1886 | ["Mark as read" gnus-summary-mark-as-read-forward t] | |
1887 | ["Mark same subject and select" | |
1888 | gnus-summary-kill-same-subject-and-select t] | |
1889 | ["Mark same subject" gnus-summary-kill-same-subject t] | |
60bd5589 DL |
1890 | ["Catchup" gnus-summary-catchup |
1891 | :help "Mark unread articles in this group as read"] | |
eec82323 LMI |
1892 | ["Catchup all" gnus-summary-catchup-all t] |
1893 | ["Catchup to here" gnus-summary-catchup-to-here t] | |
1894 | ["Catchup region" gnus-summary-mark-region-as-read t] | |
1895 | ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t]) | |
1896 | ("Mark Various" | |
1897 | ["Tick" gnus-summary-tick-article-forward t] | |
1898 | ["Mark as dormant" gnus-summary-mark-as-dormant t] | |
1899 | ["Remove marks" gnus-summary-clear-mark-forward t] | |
1900 | ["Set expirable mark" gnus-summary-mark-as-expirable t] | |
1901 | ["Set bookmark" gnus-summary-set-bookmark t] | |
1902 | ["Remove bookmark" gnus-summary-remove-bookmark t]) | |
1903 | ("Mark Limit" | |
1904 | ["Marks..." gnus-summary-limit-to-marks t] | |
1905 | ["Subject..." gnus-summary-limit-to-subject t] | |
1906 | ["Author..." gnus-summary-limit-to-author t] | |
1907 | ["Age..." gnus-summary-limit-to-age t] | |
16409b0b | 1908 | ["Extra..." gnus-summary-limit-to-extra t] |
eec82323 LMI |
1909 | ["Score" gnus-summary-limit-to-score t] |
1910 | ["Unread" gnus-summary-limit-to-unread t] | |
1911 | ["Non-dormant" gnus-summary-limit-exclude-dormant t] | |
1912 | ["Articles" gnus-summary-limit-to-articles t] | |
1913 | ["Pop limit" gnus-summary-pop-limit t] | |
1914 | ["Show dormant" gnus-summary-limit-include-dormant t] | |
1915 | ["Hide childless dormant" | |
1916 | gnus-summary-limit-exclude-childless-dormant t] | |
1917 | ;;["Hide thread" gnus-summary-limit-exclude-thread t] | |
16409b0b | 1918 | ["Hide marked" gnus-summary-limit-exclude-marks t] |
eec82323 LMI |
1919 | ["Show expunged" gnus-summary-show-all-expunged t]) |
1920 | ("Process Mark" | |
1921 | ["Set mark" gnus-summary-mark-as-processable t] | |
1922 | ["Remove mark" gnus-summary-unmark-as-processable t] | |
1923 | ["Remove all marks" gnus-summary-unmark-all-processable t] | |
1924 | ["Mark above" gnus-uu-mark-over t] | |
1925 | ["Mark series" gnus-uu-mark-series t] | |
1926 | ["Mark region" gnus-uu-mark-region t] | |
6748645f | 1927 | ["Unmark region" gnus-uu-unmark-region t] |
eec82323 | 1928 | ["Mark by regexp..." gnus-uu-mark-by-regexp t] |
6748645f | 1929 | ["Unmark by regexp..." gnus-uu-unmark-by-regexp t] |
eec82323 LMI |
1930 | ["Mark all" gnus-uu-mark-all t] |
1931 | ["Mark buffer" gnus-uu-mark-buffer t] | |
1932 | ["Mark sparse" gnus-uu-mark-sparse t] | |
1933 | ["Mark thread" gnus-uu-mark-thread t] | |
1934 | ["Unmark thread" gnus-uu-unmark-thread t] | |
1935 | ("Process Mark Sets" | |
1936 | ["Kill" gnus-summary-kill-process-mark t] | |
1937 | ["Yank" gnus-summary-yank-process-mark | |
1938 | gnus-newsgroup-process-stack] | |
1939 | ["Save" gnus-summary-save-process-mark t])) | |
1940 | ("Scroll article" | |
60bd5589 DL |
1941 | ["Page forward" gnus-summary-next-page |
1942 | :help "Show next page of article"] | |
1943 | ["Page backward" gnus-summary-prev-page | |
1944 | :help "Show previous page of article"] | |
eec82323 LMI |
1945 | ["Line forward" gnus-summary-scroll-up t]) |
1946 | ("Move" | |
1947 | ["Next unread article" gnus-summary-next-unread-article t] | |
1948 | ["Previous unread article" gnus-summary-prev-unread-article t] | |
1949 | ["Next article" gnus-summary-next-article t] | |
1950 | ["Previous article" gnus-summary-prev-article t] | |
1951 | ["Next unread subject" gnus-summary-next-unread-subject t] | |
1952 | ["Previous unread subject" gnus-summary-prev-unread-subject t] | |
1953 | ["Next article same subject" gnus-summary-next-same-subject t] | |
1954 | ["Previous article same subject" gnus-summary-prev-same-subject t] | |
1955 | ["First unread article" gnus-summary-first-unread-article t] | |
1956 | ["Best unread article" gnus-summary-best-unread-article t] | |
1957 | ["Go to subject number..." gnus-summary-goto-subject t] | |
1958 | ["Go to article number..." gnus-summary-goto-article t] | |
1959 | ["Go to the last article" gnus-summary-goto-last-article t] | |
1960 | ["Pop article off history" gnus-summary-pop-article t]) | |
1961 | ("Sort" | |
1962 | ["Sort by number" gnus-summary-sort-by-number t] | |
1963 | ["Sort by author" gnus-summary-sort-by-author t] | |
1964 | ["Sort by subject" gnus-summary-sort-by-subject t] | |
1965 | ["Sort by date" gnus-summary-sort-by-date t] | |
1966 | ["Sort by score" gnus-summary-sort-by-score t] | |
16409b0b GM |
1967 | ["Sort by lines" gnus-summary-sort-by-lines t] |
1968 | ["Sort by characters" gnus-summary-sort-by-chars t]) | |
eec82323 LMI |
1969 | ("Help" |
1970 | ["Fetch group FAQ" gnus-summary-fetch-faq t] | |
1971 | ["Describe group" gnus-summary-describe-group t] | |
1972 | ["Read manual" gnus-info-find-node t]) | |
1973 | ("Modes" | |
1974 | ["Pick and read" gnus-pick-mode t] | |
1975 | ["Binary" gnus-binary-mode t]) | |
1976 | ("Regeneration" | |
1977 | ["Regenerate" gnus-summary-prepare t] | |
1978 | ["Insert cached articles" gnus-summary-insert-cached-articles t] | |
1979 | ["Toggle threading" gnus-summary-toggle-threads t]) | |
1980 | ["Filter articles..." gnus-summary-execute-command t] | |
1981 | ["Run command on subjects..." gnus-summary-universal-argument t] | |
1982 | ["Search articles forward..." gnus-summary-search-article-forward t] | |
1983 | ["Search articles backward..." gnus-summary-search-article-backward t] | |
1984 | ["Toggle line truncation" gnus-summary-toggle-truncation t] | |
1985 | ["Expand window" gnus-summary-expand-window t] | |
1986 | ["Expire expirable articles" gnus-summary-expire-articles | |
1987 | (gnus-check-backend-function | |
1988 | 'request-expire-articles gnus-newsgroup-name)] | |
1989 | ["Edit local kill file" gnus-summary-edit-local-kill t] | |
1990 | ["Edit main kill file" gnus-summary-edit-global-kill t] | |
6748645f | 1991 | ["Edit group parameters" gnus-summary-edit-parameters t] |
16409b0b | 1992 | ["Customize group parameters" gnus-summary-customize-parameters t] |
6748645f | 1993 | ["Send a bug report" gnus-bug t] |
eec82323 | 1994 | ("Exit" |
60bd5589 DL |
1995 | ["Catchup and exit" gnus-summary-catchup-and-exit |
1996 | :help "Mark unread articles in this group as read, then exit"] | |
6748645f | 1997 | ["Catchup all and exit" gnus-summary-catchup-all-and-exit t] |
eec82323 | 1998 | ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t] |
60bd5589 DL |
1999 | ["Exit group" gnus-summary-exit |
2000 | :help "Exit current group, return to group selection mode"] | |
eec82323 LMI |
2001 | ["Exit group without updating" gnus-summary-exit-no-update t] |
2002 | ["Exit and goto next group" gnus-summary-next-group t] | |
2003 | ["Exit and goto prev group" gnus-summary-prev-group t] | |
2004 | ["Reselect group" gnus-summary-reselect-current-group t] | |
2005 | ["Rescan group" gnus-summary-rescan-group t] | |
2006 | ["Update dribble" gnus-summary-save-newsrc t]))) | |
2007 | ||
6748645f | 2008 | (gnus-run-hooks 'gnus-summary-menu-hook))) |
eec82323 | 2009 | |
60bd5589 DL |
2010 | (defvar gnus-summary-tool-bar-map nil) |
2011 | ||
9a0026a6 | 2012 | ;; Emacs 21 tool bar. Should be no-op otherwise. |
60bd5589 DL |
2013 | (defun gnus-summary-make-tool-bar () |
2014 | (if (and (fboundp 'tool-bar-add-item-from-menu) | |
2015 | (default-value 'tool-bar-mode) | |
2016 | (not gnus-summary-tool-bar-map)) | |
2017 | (setq gnus-summary-tool-bar-map | |
2018 | (let ((tool-bar-map (make-sparse-keymap))) | |
2019 | (tool-bar-add-item-from-menu | |
2020 | 'gnus-summary-prev-unread "prev-ur" gnus-summary-mode-map) | |
2021 | (tool-bar-add-item-from-menu | |
2022 | 'gnus-summary-next-unread "next-ur" gnus-summary-mode-map) | |
2023 | (tool-bar-add-item-from-menu | |
2024 | 'gnus-summary-post-news "post" gnus-summary-mode-map) | |
2025 | (tool-bar-add-item-from-menu | |
2026 | 'gnus-summary-followup-with-original "fuwo" gnus-summary-mode-map) | |
2027 | (tool-bar-add-item-from-menu | |
2028 | 'gnus-summary-followup "followup" gnus-summary-mode-map) | |
2029 | (tool-bar-add-item-from-menu | |
2030 | 'gnus-summary-reply-with-original "reply-wo" gnus-summary-mode-map) | |
2031 | (tool-bar-add-item-from-menu | |
2032 | 'gnus-summary-reply "reply" gnus-summary-mode-map) | |
2033 | (tool-bar-add-item-from-menu | |
2034 | 'gnus-summary-caesar-message "rot13" gnus-summary-mode-map) | |
2035 | (tool-bar-add-item-from-menu | |
2036 | 'gnus-uu-decode-uu "uu-decode" gnus-summary-mode-map) | |
2037 | (tool-bar-add-item-from-menu | |
2038 | 'gnus-summary-save-article-file "save-aif" gnus-summary-mode-map) | |
2039 | (tool-bar-add-item-from-menu | |
2040 | 'gnus-summary-save-article "save-art" gnus-summary-mode-map) | |
2041 | (tool-bar-add-item-from-menu | |
2042 | 'gnus-uu-post-news "uu-post" gnus-summary-mode-map) | |
2043 | (tool-bar-add-item-from-menu | |
2044 | 'gnus-summary-catchup "catchup" gnus-summary-mode-map) | |
2045 | (tool-bar-add-item-from-menu | |
2046 | 'gnus-summary-catchup-and-exit "cu-exit" gnus-summary-mode-map) | |
2047 | (tool-bar-add-item-from-menu | |
2048 | 'gnus-summary-exit "exit-summ" gnus-summary-mode-map) | |
2049 | tool-bar-map))) | |
2050 | (if gnus-summary-tool-bar-map | |
2051 | (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map))) | |
2052 | ||
eec82323 LMI |
2053 | (defun gnus-score-set-default (var value) |
2054 | "A version of set that updates the GNU Emacs menu-bar." | |
2055 | (set var value) | |
2056 | ;; It is the message that forces the active status to be updated. | |
2057 | (message "")) | |
2058 | ||
2059 | (defun gnus-make-score-map (type) | |
2060 | "Make a summary score map of type TYPE." | |
2061 | (if t | |
2062 | nil | |
2063 | (let ((headers '(("author" "from" string) | |
2064 | ("subject" "subject" string) | |
2065 | ("article body" "body" string) | |
2066 | ("article head" "head" string) | |
2067 | ("xref" "xref" string) | |
16409b0b | 2068 | ("extra header" "extra" string) |
eec82323 LMI |
2069 | ("lines" "lines" number) |
2070 | ("followups to author" "followup" string))) | |
2071 | (types '((number ("less than" <) | |
2072 | ("greater than" >) | |
2073 | ("equal" =)) | |
2074 | (string ("substring" s) | |
2075 | ("exact string" e) | |
2076 | ("fuzzy string" f) | |
2077 | ("regexp" r)))) | |
2078 | (perms '(("temporary" (current-time-string)) | |
2079 | ("permanent" nil) | |
2080 | ("immediate" now))) | |
2081 | header) | |
2082 | (list | |
2083 | (apply | |
2084 | 'nconc | |
2085 | (list | |
2086 | (if (eq type 'lower) | |
2087 | "Lower score" | |
2088 | "Increase score")) | |
2089 | (let (outh) | |
2090 | (while headers | |
2091 | (setq header (car headers)) | |
2092 | (setq outh | |
2093 | (cons | |
2094 | (apply | |
2095 | 'nconc | |
2096 | (list (car header)) | |
2097 | (let ((ts (cdr (assoc (nth 2 header) types))) | |
2098 | outt) | |
2099 | (while ts | |
2100 | (setq outt | |
2101 | (cons | |
2102 | (apply | |
2103 | 'nconc | |
2104 | (list (caar ts)) | |
2105 | (let ((ps perms) | |
2106 | outp) | |
2107 | (while ps | |
2108 | (setq outp | |
2109 | (cons | |
2110 | (vector | |
2111 | (caar ps) | |
2112 | (list | |
2113 | 'gnus-summary-score-entry | |
2114 | (nth 1 header) | |
2115 | (if (or (string= (nth 1 header) | |
2116 | "head") | |
2117 | (string= (nth 1 header) | |
2118 | "body")) | |
2119 | "" | |
2120 | (list 'gnus-summary-header | |
2121 | (nth 1 header))) | |
2122 | (list 'quote (nth 1 (car ts))) | |
16409b0b GM |
2123 | (list 'gnus-score-delta-default |
2124 | nil) | |
eec82323 LMI |
2125 | (nth 1 (car ps)) |
2126 | t) | |
2127 | t) | |
2128 | outp)) | |
2129 | (setq ps (cdr ps))) | |
2130 | (list (nreverse outp)))) | |
2131 | outt)) | |
2132 | (setq ts (cdr ts))) | |
2133 | (list (nreverse outt)))) | |
2134 | outh)) | |
2135 | (setq headers (cdr headers))) | |
2136 | (list (nreverse outh)))))))) | |
2137 | ||
2138 | \f | |
2139 | ||
2140 | (defun gnus-summary-mode (&optional group) | |
2141 | "Major mode for reading articles. | |
2142 | ||
2143 | All normal editing commands are switched off. | |
2144 | \\<gnus-summary-mode-map> | |
2145 | Each line in this buffer represents one article. To read an | |
2146 | article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards | |
2147 | and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]', | |
2148 | respectively. | |
2149 | ||
2150 | You can also post articles and send mail from this buffer. To | |
2151 | follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author | |
2152 | of an article, type `\\[gnus-summary-reply]'. | |
2153 | ||
2154 | There are approx. one gazillion commands you can execute in this | |
2155 | buffer; read the info pages for more information (`\\[gnus-info-find-node]'). | |
2156 | ||
2157 | The following commands are available: | |
2158 | ||
2159 | \\{gnus-summary-mode-map}" | |
2160 | (interactive) | |
eec82323 | 2161 | (kill-all-local-variables) |
60bd5589 DL |
2162 | (when (gnus-visual-p 'summary-menu 'menu) |
2163 | (gnus-summary-make-menu-bar) | |
2164 | (gnus-summary-make-tool-bar)) | |
eec82323 LMI |
2165 | (gnus-summary-make-local-variables) |
2166 | (gnus-make-thread-indent-array) | |
2167 | (gnus-simplify-mode-line) | |
2168 | (setq major-mode 'gnus-summary-mode) | |
2169 | (setq mode-name "Summary") | |
2170 | (make-local-variable 'minor-mode-alist) | |
2171 | (use-local-map gnus-summary-mode-map) | |
16409b0b | 2172 | (buffer-disable-undo) |
eec82323 LMI |
2173 | (setq buffer-read-only t) ;Disable modification |
2174 | (setq truncate-lines t) | |
2175 | (setq selective-display t) | |
2176 | (setq selective-display-ellipses t) ;Display `...' | |
2177 | (gnus-summary-set-display-table) | |
2178 | (gnus-set-default-directory) | |
2179 | (setq gnus-newsgroup-name group) | |
2180 | (make-local-variable 'gnus-summary-line-format) | |
2181 | (make-local-variable 'gnus-summary-line-format-spec) | |
6748645f LMI |
2182 | (make-local-variable 'gnus-summary-dummy-line-format) |
2183 | (make-local-variable 'gnus-summary-dummy-line-format-spec) | |
eec82323 | 2184 | (make-local-variable 'gnus-summary-mark-positions) |
6748645f LMI |
2185 | (make-local-hook 'pre-command-hook) |
2186 | (add-hook 'pre-command-hook 'gnus-set-global-variables nil t) | |
2187 | (gnus-run-hooks 'gnus-summary-mode-hook) | |
d4dfaa19 | 2188 | (mm-enable-multibyte-mule4) |
eec82323 LMI |
2189 | (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy) |
2190 | (gnus-update-summary-mark-positions)) | |
2191 | ||
2192 | (defun gnus-summary-make-local-variables () | |
2193 | "Make all the local summary buffer variables." | |
16409b0b GM |
2194 | (let (global) |
2195 | (dolist (local gnus-summary-local-variables) | |
eec82323 LMI |
2196 | (if (consp local) |
2197 | (progn | |
2198 | (if (eq (cdr local) 'global) | |
2199 | ;; Copy the global value of the variable. | |
2200 | (setq global (symbol-value (car local))) | |
2201 | ;; Use the value from the list. | |
2202 | (setq global (eval (cdr local)))) | |
16409b0b | 2203 | (set (make-local-variable (car local)) global)) |
eec82323 | 2204 | ;; Simple nil-valued local variable. |
16409b0b | 2205 | (set (make-local-variable local) nil))))) |
eec82323 LMI |
2206 | |
2207 | (defun gnus-summary-clear-local-variables () | |
2208 | (let ((locals gnus-summary-local-variables)) | |
2209 | (while locals | |
2210 | (if (consp (car locals)) | |
2211 | (and (vectorp (caar locals)) | |
2212 | (set (caar locals) nil)) | |
2213 | (and (vectorp (car locals)) | |
2214 | (set (car locals) nil))) | |
2215 | (setq locals (cdr locals))))) | |
2216 | ||
2217 | ;; Summary data functions. | |
2218 | ||
2219 | (defmacro gnus-data-number (data) | |
2220 | `(car ,data)) | |
2221 | ||
2222 | (defmacro gnus-data-set-number (data number) | |
2223 | `(setcar ,data ,number)) | |
2224 | ||
2225 | (defmacro gnus-data-mark (data) | |
2226 | `(nth 1 ,data)) | |
2227 | ||
2228 | (defmacro gnus-data-set-mark (data mark) | |
2229 | `(setcar (nthcdr 1 ,data) ,mark)) | |
2230 | ||
2231 | (defmacro gnus-data-pos (data) | |
2232 | `(nth 2 ,data)) | |
2233 | ||
2234 | (defmacro gnus-data-set-pos (data pos) | |
2235 | `(setcar (nthcdr 2 ,data) ,pos)) | |
2236 | ||
2237 | (defmacro gnus-data-header (data) | |
2238 | `(nth 3 ,data)) | |
2239 | ||
2240 | (defmacro gnus-data-set-header (data header) | |
2241 | `(setf (nth 3 ,data) ,header)) | |
2242 | ||
2243 | (defmacro gnus-data-level (data) | |
2244 | `(nth 4 ,data)) | |
2245 | ||
2246 | (defmacro gnus-data-unread-p (data) | |
2247 | `(= (nth 1 ,data) gnus-unread-mark)) | |
2248 | ||
2249 | (defmacro gnus-data-read-p (data) | |
2250 | `(/= (nth 1 ,data) gnus-unread-mark)) | |
2251 | ||
2252 | (defmacro gnus-data-pseudo-p (data) | |
2253 | `(consp (nth 3 ,data))) | |
2254 | ||
2255 | (defmacro gnus-data-find (number) | |
2256 | `(assq ,number gnus-newsgroup-data)) | |
2257 | ||
2258 | (defmacro gnus-data-find-list (number &optional data) | |
2259 | `(let ((bdata ,(or data 'gnus-newsgroup-data))) | |
2260 | (memq (assq ,number bdata) | |
2261 | bdata))) | |
2262 | ||
2263 | (defmacro gnus-data-make (number mark pos header level) | |
2264 | `(list ,number ,mark ,pos ,header ,level)) | |
2265 | ||
2266 | (defun gnus-data-enter (after-article number mark pos header level offset) | |
2267 | (let ((data (gnus-data-find-list after-article))) | |
2268 | (unless data | |
2269 | (error "No such article: %d" after-article)) | |
2270 | (setcdr data (cons (gnus-data-make number mark pos header level) | |
2271 | (cdr data))) | |
2272 | (setq gnus-newsgroup-data-reverse nil) | |
2273 | (gnus-data-update-list (cddr data) offset))) | |
2274 | ||
2275 | (defun gnus-data-enter-list (after-article list &optional offset) | |
2276 | (when list | |
2277 | (let ((data (and after-article (gnus-data-find-list after-article))) | |
2278 | (ilist list)) | |
6748645f LMI |
2279 | (if (not (or data |
2280 | after-article)) | |
2281 | (let ((odata gnus-newsgroup-data)) | |
2282 | (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data)) | |
eec82323 | 2283 | (when offset |
6748645f LMI |
2284 | (gnus-data-update-list odata offset))) |
2285 | ;; Find the last element in the list to be spliced into the main | |
2286 | ;; list. | |
2287 | (while (cdr list) | |
2288 | (setq list (cdr list))) | |
2289 | (if (not data) | |
2290 | (progn | |
2291 | (setcdr list gnus-newsgroup-data) | |
2292 | (setq gnus-newsgroup-data ilist) | |
2293 | (when offset | |
2294 | (gnus-data-update-list (cdr list) offset))) | |
2295 | (setcdr list (cdr data)) | |
2296 | (setcdr data ilist) | |
2297 | (when offset | |
2298 | (gnus-data-update-list (cdr list) offset)))) | |
eec82323 LMI |
2299 | (setq gnus-newsgroup-data-reverse nil)))) |
2300 | ||
2301 | (defun gnus-data-remove (article &optional offset) | |
2302 | (let ((data gnus-newsgroup-data)) | |
2303 | (if (= (gnus-data-number (car data)) article) | |
2304 | (progn | |
2305 | (setq gnus-newsgroup-data (cdr gnus-newsgroup-data) | |
2306 | gnus-newsgroup-data-reverse nil) | |
2307 | (when offset | |
2308 | (gnus-data-update-list gnus-newsgroup-data offset))) | |
2309 | (while (cdr data) | |
2310 | (when (= (gnus-data-number (cadr data)) article) | |
2311 | (setcdr data (cddr data)) | |
2312 | (when offset | |
2313 | (gnus-data-update-list (cdr data) offset)) | |
2314 | (setq data nil | |
2315 | gnus-newsgroup-data-reverse nil)) | |
2316 | (setq data (cdr data)))))) | |
2317 | ||
2318 | (defmacro gnus-data-list (backward) | |
2319 | `(if ,backward | |
2320 | (or gnus-newsgroup-data-reverse | |
2321 | (setq gnus-newsgroup-data-reverse | |
2322 | (reverse gnus-newsgroup-data))) | |
2323 | gnus-newsgroup-data)) | |
2324 | ||
2325 | (defun gnus-data-update-list (data offset) | |
2326 | "Add OFFSET to the POS of all data entries in DATA." | |
6748645f | 2327 | (setq gnus-newsgroup-data-reverse nil) |
eec82323 LMI |
2328 | (while data |
2329 | (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data)))) | |
2330 | (setq data (cdr data)))) | |
2331 | ||
eec82323 LMI |
2332 | (defun gnus-summary-article-pseudo-p (article) |
2333 | "Say whether this article is a pseudo article or not." | |
2334 | (not (vectorp (gnus-data-header (gnus-data-find article))))) | |
2335 | ||
2336 | (defmacro gnus-summary-article-sparse-p (article) | |
2337 | "Say whether this article is a sparse article or not." | |
a8151ef7 | 2338 | `(memq ,article gnus-newsgroup-sparse)) |
eec82323 LMI |
2339 | |
2340 | (defmacro gnus-summary-article-ancient-p (article) | |
2341 | "Say whether this article is a sparse article or not." | |
2342 | `(memq ,article gnus-newsgroup-ancient)) | |
2343 | ||
2344 | (defun gnus-article-parent-p (number) | |
2345 | "Say whether this article is a parent or not." | |
2346 | (let ((data (gnus-data-find-list number))) | |
2347 | (and (cdr data) ; There has to be an article after... | |
2348 | (< (gnus-data-level (car data)) ; And it has to have a higher level. | |
2349 | (gnus-data-level (nth 1 data)))))) | |
2350 | ||
2351 | (defun gnus-article-children (number) | |
2352 | "Return a list of all children to NUMBER." | |
2353 | (let* ((data (gnus-data-find-list number)) | |
2354 | (level (gnus-data-level (car data))) | |
2355 | children) | |
2356 | (setq data (cdr data)) | |
2357 | (while (and data | |
2358 | (= (gnus-data-level (car data)) (1+ level))) | |
2359 | (push (gnus-data-number (car data)) children) | |
2360 | (setq data (cdr data))) | |
2361 | children)) | |
2362 | ||
2363 | (defmacro gnus-summary-skip-intangible () | |
2364 | "If the current article is intangible, then jump to a different article." | |
2365 | '(let ((to (get-text-property (point) 'gnus-intangible))) | |
2366 | (and to (gnus-summary-goto-subject to)))) | |
2367 | ||
2368 | (defmacro gnus-summary-article-intangible-p () | |
2369 | "Say whether this article is intangible or not." | |
2370 | '(get-text-property (point) 'gnus-intangible)) | |
2371 | ||
2372 | (defun gnus-article-read-p (article) | |
2373 | "Say whether ARTICLE is read or not." | |
2374 | (not (or (memq article gnus-newsgroup-marked) | |
2375 | (memq article gnus-newsgroup-unreads) | |
2376 | (memq article gnus-newsgroup-unselected) | |
2377 | (memq article gnus-newsgroup-dormant)))) | |
2378 | ||
2379 | ;; Some summary mode macros. | |
2380 | ||
2381 | (defmacro gnus-summary-article-number () | |
2382 | "The article number of the article on the current line. | |
2383 | If there isn's an article number here, then we return the current | |
2384 | article number." | |
2385 | '(progn | |
2386 | (gnus-summary-skip-intangible) | |
2387 | (or (get-text-property (point) 'gnus-number) | |
2388 | (gnus-summary-last-subject)))) | |
2389 | ||
2390 | (defmacro gnus-summary-article-header (&optional number) | |
6748645f | 2391 | "Return the header of article NUMBER." |
eec82323 LMI |
2392 | `(gnus-data-header (gnus-data-find |
2393 | ,(or number '(gnus-summary-article-number))))) | |
2394 | ||
2395 | (defmacro gnus-summary-thread-level (&optional number) | |
6748645f | 2396 | "Return the level of thread that starts with article NUMBER." |
eec82323 LMI |
2397 | `(if (and (eq gnus-summary-make-false-root 'dummy) |
2398 | (get-text-property (point) 'gnus-intangible)) | |
2399 | 0 | |
2400 | (gnus-data-level (gnus-data-find | |
2401 | ,(or number '(gnus-summary-article-number)))))) | |
2402 | ||
2403 | (defmacro gnus-summary-article-mark (&optional number) | |
6748645f | 2404 | "Return the mark of article NUMBER." |
eec82323 LMI |
2405 | `(gnus-data-mark (gnus-data-find |
2406 | ,(or number '(gnus-summary-article-number))))) | |
2407 | ||
2408 | (defmacro gnus-summary-article-pos (&optional number) | |
6748645f | 2409 | "Return the position of the line of article NUMBER." |
eec82323 LMI |
2410 | `(gnus-data-pos (gnus-data-find |
2411 | ,(or number '(gnus-summary-article-number))))) | |
2412 | ||
2413 | (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject) | |
2414 | (defmacro gnus-summary-article-subject (&optional number) | |
2415 | "Return current subject string or nil if nothing." | |
2416 | `(let ((headers | |
2417 | ,(if number | |
2418 | `(gnus-data-header (assq ,number gnus-newsgroup-data)) | |
2419 | '(gnus-data-header (assq (gnus-summary-article-number) | |
2420 | gnus-newsgroup-data))))) | |
2421 | (and headers | |
2422 | (vectorp headers) | |
2423 | (mail-header-subject headers)))) | |
2424 | ||
2425 | (defmacro gnus-summary-article-score (&optional number) | |
2426 | "Return current article score." | |
2427 | `(or (cdr (assq ,(or number '(gnus-summary-article-number)) | |
2428 | gnus-newsgroup-scored)) | |
2429 | gnus-summary-default-score 0)) | |
2430 | ||
2431 | (defun gnus-summary-article-children (&optional number) | |
6748645f | 2432 | "Return a list of article numbers that are children of article NUMBER." |
eec82323 LMI |
2433 | (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number)))) |
2434 | (level (gnus-data-level (car data))) | |
2435 | l children) | |
2436 | (while (and (setq data (cdr data)) | |
2437 | (> (setq l (gnus-data-level (car data))) level)) | |
2438 | (and (= (1+ level) l) | |
2439 | (push (gnus-data-number (car data)) | |
2440 | children))) | |
2441 | (nreverse children))) | |
2442 | ||
2443 | (defun gnus-summary-article-parent (&optional number) | |
6748645f | 2444 | "Return the article number of the parent of article NUMBER." |
eec82323 LMI |
2445 | (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number)) |
2446 | (gnus-data-list t))) | |
2447 | (level (gnus-data-level (car data)))) | |
2448 | (if (zerop level) | |
2449 | () ; This is a root. | |
2450 | ;; We search until we find an article with a level less than | |
2451 | ;; this one. That function has to be the parent. | |
2452 | (while (and (setq data (cdr data)) | |
2453 | (not (< (gnus-data-level (car data)) level)))) | |
2454 | (and data (gnus-data-number (car data)))))) | |
2455 | ||
2456 | (defun gnus-unread-mark-p (mark) | |
2457 | "Say whether MARK is the unread mark." | |
2458 | (= mark gnus-unread-mark)) | |
2459 | ||
2460 | (defun gnus-read-mark-p (mark) | |
2461 | "Say whether MARK is one of the marks that mark as read. | |
2462 | This is all marks except unread, ticked, dormant, and expirable." | |
2463 | (not (or (= mark gnus-unread-mark) | |
2464 | (= mark gnus-ticked-mark) | |
2465 | (= mark gnus-dormant-mark) | |
2466 | (= mark gnus-expirable-mark)))) | |
2467 | ||
2468 | (defmacro gnus-article-mark (number) | |
6748645f LMI |
2469 | "Return the MARK of article NUMBER. |
2470 | This macro should only be used when computing the mark the \"first\" | |
2471 | time; i.e., when generating the summary lines. After that, | |
2472 | `gnus-summary-article-mark' should be used to examine the | |
2473 | marks of articles." | |
eec82323 | 2474 | `(cond |
6748645f LMI |
2475 | ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark) |
2476 | ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark) | |
2477 | ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark) | |
eec82323 LMI |
2478 | ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark) |
2479 | ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark) | |
2480 | ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark) | |
2481 | ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark) | |
2482 | (t (or (cdr (assq ,number gnus-newsgroup-reads)) | |
2483 | gnus-ancient-mark)))) | |
2484 | ||
2485 | ;; Saving hidden threads. | |
2486 | ||
2487 | (put 'gnus-save-hidden-threads 'lisp-indent-function 0) | |
2488 | (put 'gnus-save-hidden-threads 'edebug-form-spec '(body)) | |
2489 | ||
2490 | (defmacro gnus-save-hidden-threads (&rest forms) | |
2491 | "Save hidden threads, eval FORMS, and restore the hidden threads." | |
2492 | (let ((config (make-symbol "config"))) | |
2493 | `(let ((,config (gnus-hidden-threads-configuration))) | |
2494 | (unwind-protect | |
2495 | (save-excursion | |
2496 | ,@forms) | |
2497 | (gnus-restore-hidden-threads-configuration ,config))))) | |
2498 | ||
107ecebb AS |
2499 | (defun gnus-data-compute-positions () |
2500 | "Compute the positions of all articles." | |
2501 | (setq gnus-newsgroup-data-reverse nil) | |
2502 | (let ((data gnus-newsgroup-data)) | |
2503 | (save-excursion | |
2504 | (gnus-save-hidden-threads | |
2505 | (gnus-summary-show-all-threads) | |
2506 | (goto-char (point-min)) | |
2507 | (while data | |
2508 | (while (get-text-property (point) 'gnus-intangible) | |
2509 | (forward-line 1)) | |
2510 | (gnus-data-set-pos (car data) (+ (point) 3)) | |
2511 | (setq data (cdr data)) | |
2512 | (forward-line 1)))))) | |
2513 | ||
16409b0b GM |
2514 | (defun gnus-hidden-threads-configuration () |
2515 | "Return the current hidden threads configuration." | |
2516 | (save-excursion | |
2517 | (let (config) | |
2518 | (goto-char (point-min)) | |
2519 | (while (search-forward "\r" nil t) | |
2520 | (push (1- (point)) config)) | |
2521 | config))) | |
2522 | ||
2523 | (defun gnus-restore-hidden-threads-configuration (config) | |
2524 | "Restore hidden threads configuration from CONFIG." | |
2525 | (save-excursion | |
2526 | (let (point buffer-read-only) | |
2527 | (while (setq point (pop config)) | |
2528 | (when (and (< point (point-max)) | |
2529 | (goto-char point) | |
2530 | (eq (char-after) ?\n)) | |
2531 | (subst-char-in-region point (1+ point) ?\n ?\r)))))) | |
2532 | ||
eec82323 LMI |
2533 | ;; Various summary mode internalish functions. |
2534 | ||
2535 | (defun gnus-mouse-pick-article (e) | |
2536 | (interactive "e") | |
2537 | (mouse-set-point e) | |
2538 | (gnus-summary-next-page nil t)) | |
2539 | ||
2540 | (defun gnus-summary-set-display-table () | |
16409b0b GM |
2541 | "Change the display table. |
2542 | Odd characters have a tendency to mess | |
2543 | up nicely formatted displays - we make all possible glyphs | |
2544 | display only a single character." | |
eec82323 LMI |
2545 | |
2546 | ;; We start from the standard display table, if any. | |
2547 | (let ((table (or (copy-sequence standard-display-table) | |
2548 | (make-display-table))) | |
2549 | (i 32)) | |
2550 | ;; Nix out all the control chars... | |
2551 | (while (>= (setq i (1- i)) 0) | |
2552 | (aset table i [??])) | |
2553 | ;; ... but not newline and cr, of course. (cr is necessary for the | |
2554 | ;; selective display). | |
2555 | (aset table ?\n nil) | |
2556 | (aset table ?\r nil) | |
6748645f LMI |
2557 | ;; We keep TAB as well. |
2558 | (aset table ?\t nil) | |
eec82323 LMI |
2559 | ;; We nix out any glyphs over 126 that are not set already. |
2560 | (let ((i 256)) | |
2561 | (while (>= (setq i (1- i)) 127) | |
2562 | ;; Only modify if the entry is nil. | |
2563 | (unless (aref table i) | |
2564 | (aset table i [??])))) | |
2565 | (setq buffer-display-table table))) | |
2566 | ||
2567 | (defun gnus-summary-setup-buffer (group) | |
2568 | "Initialize summary buffer." | |
2569 | (let ((buffer (concat "*Summary " group "*"))) | |
2570 | (if (get-buffer buffer) | |
2571 | (progn | |
2572 | (set-buffer buffer) | |
2573 | (setq gnus-summary-buffer (current-buffer)) | |
2574 | (not gnus-newsgroup-prepared)) | |
2575 | ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu> | |
6748645f | 2576 | (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer))) |
eec82323 LMI |
2577 | (gnus-summary-mode group) |
2578 | (when gnus-carpal | |
2579 | (gnus-carpal-setup-buffer 'summary)) | |
2580 | (unless gnus-single-article-buffer | |
2581 | (make-local-variable 'gnus-article-buffer) | |
2582 | (make-local-variable 'gnus-article-current) | |
2583 | (make-local-variable 'gnus-original-article-buffer)) | |
2584 | (setq gnus-newsgroup-name group) | |
2585 | t))) | |
2586 | ||
2587 | (defun gnus-set-global-variables () | |
16409b0b GM |
2588 | "Set the global equivalents of the buffer-local variables. |
2589 | They are set to the latest values they had. These reflect the summary | |
2590 | buffer that was in action when the last article was fetched." | |
eec82323 LMI |
2591 | (when (eq major-mode 'gnus-summary-mode) |
2592 | (setq gnus-summary-buffer (current-buffer)) | |
2593 | (let ((name gnus-newsgroup-name) | |
2594 | (marked gnus-newsgroup-marked) | |
2595 | (unread gnus-newsgroup-unreads) | |
2596 | (headers gnus-current-headers) | |
2597 | (data gnus-newsgroup-data) | |
2598 | (summary gnus-summary-buffer) | |
2599 | (article-buffer gnus-article-buffer) | |
2600 | (original gnus-original-article-buffer) | |
2601 | (gac gnus-article-current) | |
2602 | (reffed gnus-reffed-article-number) | |
16409b0b GM |
2603 | (score-file gnus-current-score-file) |
2604 | (default-charset gnus-newsgroup-charset)) | |
eec82323 LMI |
2605 | (save-excursion |
2606 | (set-buffer gnus-group-buffer) | |
6748645f LMI |
2607 | (setq gnus-newsgroup-name name |
2608 | gnus-newsgroup-marked marked | |
2609 | gnus-newsgroup-unreads unread | |
2610 | gnus-current-headers headers | |
2611 | gnus-newsgroup-data data | |
2612 | gnus-article-current gac | |
2613 | gnus-summary-buffer summary | |
2614 | gnus-article-buffer article-buffer | |
2615 | gnus-original-article-buffer original | |
2616 | gnus-reffed-article-number reffed | |
16409b0b GM |
2617 | gnus-current-score-file score-file |
2618 | gnus-newsgroup-charset default-charset) | |
eec82323 LMI |
2619 | ;; The article buffer also has local variables. |
2620 | (when (gnus-buffer-live-p gnus-article-buffer) | |
2621 | (set-buffer gnus-article-buffer) | |
2622 | (setq gnus-summary-buffer summary)))))) | |
2623 | ||
2624 | (defun gnus-summary-article-unread-p (article) | |
2625 | "Say whether ARTICLE is unread or not." | |
2626 | (memq article gnus-newsgroup-unreads)) | |
2627 | ||
2628 | (defun gnus-summary-first-article-p (&optional article) | |
2629 | "Return whether ARTICLE is the first article in the buffer." | |
2630 | (if (not (setq article (or article (gnus-summary-article-number)))) | |
2631 | nil | |
2632 | (eq article (caar gnus-newsgroup-data)))) | |
2633 | ||
2634 | (defun gnus-summary-last-article-p (&optional article) | |
2635 | "Return whether ARTICLE is the last article in the buffer." | |
2636 | (if (not (setq article (or article (gnus-summary-article-number)))) | |
16409b0b GM |
2637 | ;; All non-existent numbers are the last article. :-) |
2638 | t | |
eec82323 LMI |
2639 | (not (cdr (gnus-data-find-list article))))) |
2640 | ||
2641 | (defun gnus-make-thread-indent-array () | |
2642 | (let ((n 200)) | |
2643 | (unless (and gnus-thread-indent-array | |
2644 | (= gnus-thread-indent-level gnus-thread-indent-array-level)) | |
2645 | (setq gnus-thread-indent-array (make-vector 201 "") | |
2646 | gnus-thread-indent-array-level gnus-thread-indent-level) | |
2647 | (while (>= n 0) | |
2648 | (aset gnus-thread-indent-array n | |
2649 | (make-string (* n gnus-thread-indent-level) ? )) | |
2650 | (setq n (1- n)))))) | |
2651 | ||
2652 | (defun gnus-update-summary-mark-positions () | |
2653 | "Compute where the summary marks are to go." | |
2654 | (save-excursion | |
6748645f | 2655 | (when (gnus-buffer-exists-p gnus-summary-buffer) |
eec82323 LMI |
2656 | (set-buffer gnus-summary-buffer)) |
2657 | (let ((gnus-replied-mark 129) | |
2658 | (gnus-score-below-mark 130) | |
2659 | (gnus-score-over-mark 130) | |
6748645f | 2660 | (gnus-download-mark 131) |
eec82323 | 2661 | (spec gnus-summary-line-format-spec) |
6748645f | 2662 | gnus-visual pos) |
eec82323 LMI |
2663 | (save-excursion |
2664 | (gnus-set-work-buffer) | |
6748645f LMI |
2665 | (let ((gnus-summary-line-format-spec spec) |
2666 | (gnus-newsgroup-downloadable '((0 . t)))) | |
eec82323 | 2667 | (gnus-summary-insert-line |
16409b0b | 2668 | [0 "" "" "" "" "" 0 0 "" nil] 0 nil 128 t nil "" nil 1) |
eec82323 LMI |
2669 | (goto-char (point-min)) |
2670 | (setq pos (list (cons 'unread (and (search-forward "\200" nil t) | |
2671 | (- (point) 2))))) | |
2672 | (goto-char (point-min)) | |
2673 | (push (cons 'replied (and (search-forward "\201" nil t) | |
2674 | (- (point) 2))) | |
2675 | pos) | |
2676 | (goto-char (point-min)) | |
2677 | (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2))) | |
6748645f LMI |
2678 | pos) |
2679 | (goto-char (point-min)) | |
2680 | (push (cons 'download | |
2681 | (and (search-forward "\203" nil t) (- (point) 2))) | |
eec82323 LMI |
2682 | pos))) |
2683 | (setq gnus-summary-mark-positions pos)))) | |
2684 | ||
2685 | (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number) | |
2686 | "Insert a dummy root in the summary buffer." | |
2687 | (beginning-of-line) | |
2688 | (gnus-add-text-properties | |
2689 | (point) (progn (eval gnus-summary-dummy-line-format-spec) (point)) | |
2690 | (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number))) | |
2691 | ||
16409b0b GM |
2692 | (defun gnus-summary-from-or-to-or-newsgroups (header) |
2693 | (let ((to (cdr (assq 'To (mail-header-extra header)))) | |
2694 | (newsgroups (cdr (assq 'Newsgroups (mail-header-extra header)))) | |
2695 | (mail-parse-charset gnus-newsgroup-charset) | |
2696 | (mail-parse-ignored-charsets | |
2697 | (save-excursion (set-buffer gnus-summary-buffer) | |
2698 | gnus-newsgroup-ignored-charsets))) | |
2699 | (cond | |
2700 | ((and to | |
2701 | gnus-ignored-from-addresses | |
2702 | (string-match gnus-ignored-from-addresses | |
2703 | (mail-header-from header))) | |
2704 | (concat "-> " | |
2705 | (or (car (funcall gnus-extract-address-components | |
2706 | (funcall | |
2707 | gnus-decode-encoded-word-function to))) | |
2708 | (funcall gnus-decode-encoded-word-function to)))) | |
2709 | ((and newsgroups | |
2710 | gnus-ignored-from-addresses | |
2711 | (string-match gnus-ignored-from-addresses | |
2712 | (mail-header-from header))) | |
2713 | (concat "=> " newsgroups)) | |
2714 | (t | |
2715 | (or (car (funcall gnus-extract-address-components | |
2716 | (mail-header-from header))) | |
2717 | (mail-header-from header)))))) | |
2718 | ||
eec82323 LMI |
2719 | (defun gnus-summary-insert-line (gnus-tmp-header |
2720 | gnus-tmp-level gnus-tmp-current | |
2721 | gnus-tmp-unread gnus-tmp-replied | |
2722 | gnus-tmp-expirable gnus-tmp-subject-or-nil | |
2723 | &optional gnus-tmp-dummy gnus-tmp-score | |
2724 | gnus-tmp-process) | |
2725 | (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level)) | |
2726 | (gnus-tmp-lines (mail-header-lines gnus-tmp-header)) | |
2727 | (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0)) | |
2728 | (gnus-tmp-score-char | |
2729 | (if (or (null gnus-summary-default-score) | |
2730 | (<= (abs (- gnus-tmp-score gnus-summary-default-score)) | |
2731 | gnus-summary-zcore-fuzz)) | |
16409b0b | 2732 | ? ;Whitespace |
eec82323 LMI |
2733 | (if (< gnus-tmp-score gnus-summary-default-score) |
2734 | gnus-score-below-mark gnus-score-over-mark))) | |
2735 | (gnus-tmp-replied | |
2736 | (cond (gnus-tmp-process gnus-process-mark) | |
2737 | ((memq gnus-tmp-current gnus-newsgroup-cached) | |
2738 | gnus-cached-mark) | |
2739 | (gnus-tmp-replied gnus-replied-mark) | |
2740 | ((memq gnus-tmp-current gnus-newsgroup-saved) | |
2741 | gnus-saved-mark) | |
2742 | (t gnus-unread-mark))) | |
2743 | (gnus-tmp-from (mail-header-from gnus-tmp-header)) | |
2744 | (gnus-tmp-name | |
2745 | (cond | |
2746 | ((string-match "<[^>]+> *$" gnus-tmp-from) | |
2747 | (let ((beg (match-beginning 0))) | |
2748 | (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from) | |
2749 | (substring gnus-tmp-from (1+ (match-beginning 0)) | |
2750 | (1- (match-end 0)))) | |
2751 | (substring gnus-tmp-from 0 beg)))) | |
2752 | ((string-match "(.+)" gnus-tmp-from) | |
2753 | (substring gnus-tmp-from | |
2754 | (1+ (match-beginning 0)) (1- (match-end 0)))) | |
2755 | (t gnus-tmp-from))) | |
2756 | (gnus-tmp-subject (mail-header-subject gnus-tmp-header)) | |
2757 | (gnus-tmp-number (mail-header-number gnus-tmp-header)) | |
2758 | (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[)) | |
2759 | (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\])) | |
2760 | (buffer-read-only nil)) | |
2761 | (when (string= gnus-tmp-name "") | |
2762 | (setq gnus-tmp-name gnus-tmp-from)) | |
2763 | (unless (numberp gnus-tmp-lines) | |
2764 | (setq gnus-tmp-lines 0)) | |
16409b0b | 2765 | (gnus-put-text-property |
eec82323 LMI |
2766 | (point) |
2767 | (progn (eval gnus-summary-line-format-spec) (point)) | |
2768 | 'gnus-number gnus-tmp-number) | |
2769 | (when (gnus-visual-p 'summary-highlight 'highlight) | |
2770 | (forward-line -1) | |
6748645f | 2771 | (gnus-run-hooks 'gnus-summary-update-hook) |
eec82323 LMI |
2772 | (forward-line 1)))) |
2773 | ||
2774 | (defun gnus-summary-update-line (&optional dont-update) | |
16409b0b | 2775 | "Update summary line after change." |
eec82323 LMI |
2776 | (when (and gnus-summary-default-score |
2777 | (not gnus-summary-inhibit-highlight)) | |
2778 | (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion. | |
2779 | (article (gnus-summary-article-number)) | |
2780 | (score (gnus-summary-article-score article))) | |
2781 | (unless dont-update | |
2782 | (if (and gnus-summary-mark-below | |
2783 | (< (gnus-summary-article-score) | |
2784 | gnus-summary-mark-below)) | |
2785 | ;; This article has a low score, so we mark it as read. | |
2786 | (when (memq article gnus-newsgroup-unreads) | |
2787 | (gnus-summary-mark-article-as-read gnus-low-score-mark)) | |
2788 | (when (eq (gnus-summary-article-mark) gnus-low-score-mark) | |
2789 | ;; This article was previously marked as read on account | |
2790 | ;; of a low score, but now it has risen, so we mark it as | |
2791 | ;; unread. | |
2792 | (gnus-summary-mark-article-as-unread gnus-unread-mark))) | |
2793 | (gnus-summary-update-mark | |
2794 | (if (or (null gnus-summary-default-score) | |
2795 | (<= (abs (- score gnus-summary-default-score)) | |
2796 | gnus-summary-zcore-fuzz)) | |
16409b0b | 2797 | ? ;Whitespace |
eec82323 LMI |
2798 | (if (< score gnus-summary-default-score) |
2799 | gnus-score-below-mark gnus-score-over-mark)) | |
2800 | 'score)) | |
2801 | ;; Do visual highlighting. | |
2802 | (when (gnus-visual-p 'summary-highlight 'highlight) | |
6748645f | 2803 | (gnus-run-hooks 'gnus-summary-update-hook))))) |
eec82323 LMI |
2804 | |
2805 | (defvar gnus-tmp-new-adopts nil) | |
2806 | ||
2807 | (defun gnus-summary-number-of-articles-in-thread (thread &optional level char) | |
2808 | "Return the number of articles in THREAD. | |
2809 | This may be 0 in some cases -- if none of the articles in | |
2810 | the thread are to be displayed." | |
2811 | (let* ((number | |
2812 | ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>. | |
2813 | (cond | |
2814 | ((not (listp thread)) | |
2815 | 1) | |
2816 | ((and (consp thread) (cdr thread)) | |
2817 | (apply | |
2818 | '+ 1 (mapcar | |
2819 | 'gnus-summary-number-of-articles-in-thread (cdr thread)))) | |
2820 | ((null thread) | |
2821 | 1) | |
2822 | ((memq (mail-header-number (car thread)) gnus-newsgroup-limit) | |
2823 | 1) | |
2824 | (t 0)))) | |
2825 | (when (and level (zerop level) gnus-tmp-new-adopts) | |
2826 | (incf number | |
2827 | (apply '+ (mapcar | |
2828 | 'gnus-summary-number-of-articles-in-thread | |
2829 | gnus-tmp-new-adopts)))) | |
2830 | (if char | |
2831 | (if (> number 1) gnus-not-empty-thread-mark | |
2832 | gnus-empty-thread-mark) | |
2833 | number))) | |
2834 | ||
2835 | (defun gnus-summary-set-local-parameters (group) | |
2836 | "Go through the local params of GROUP and set all variable specs in that list." | |
2837 | (let ((params (gnus-group-find-parameter group)) | |
2838 | elem) | |
2839 | (while params | |
2840 | (setq elem (car params) | |
2841 | params (cdr params)) | |
2842 | (and (consp elem) ; Has to be a cons. | |
2843 | (consp (cdr elem)) ; The cdr has to be a list. | |
2844 | (symbolp (car elem)) ; Has to be a symbol in there. | |
6748645f | 2845 | (not (memq (car elem) '(quit-config))) ; Ignore quit-config. |
eec82323 LMI |
2846 | (ignore-errors ; So we set it. |
2847 | (make-local-variable (car elem)) | |
2848 | (set (car elem) (eval (nth 1 elem)))))))) | |
2849 | ||
2850 | (defun gnus-summary-read-group (group &optional show-all no-article | |
6748645f LMI |
2851 | kill-buffer no-display backward |
2852 | select-articles) | |
eec82323 LMI |
2853 | "Start reading news in newsgroup GROUP. |
2854 | If SHOW-ALL is non-nil, already read articles are also listed. | |
2855 | If NO-ARTICLE is non-nil, no article is selected initially. | |
2856 | If NO-DISPLAY, don't generate a summary buffer." | |
2857 | (let (result) | |
2858 | (while (and group | |
2859 | (null (setq result | |
2860 | (let ((gnus-auto-select-next nil)) | |
6748645f LMI |
2861 | (or (gnus-summary-read-group-1 |
2862 | group show-all no-article | |
2863 | kill-buffer no-display | |
2864 | select-articles) | |
2865 | (setq show-all nil | |
16409b0b | 2866 | select-articles nil))))) |
eec82323 LMI |
2867 | (eq gnus-auto-select-next 'quietly)) |
2868 | (set-buffer gnus-group-buffer) | |
6748645f LMI |
2869 | ;; The entry function called above goes to the next |
2870 | ;; group automatically, so we go two groups back | |
2871 | ;; if we are searching for the previous group. | |
2872 | (when backward | |
2873 | (gnus-group-prev-unread-group 2)) | |
eec82323 LMI |
2874 | (if (not (equal group (gnus-group-group-name))) |
2875 | (setq group (gnus-group-group-name)) | |
2876 | (setq group nil))) | |
2877 | result)) | |
2878 | ||
2879 | (defun gnus-summary-read-group-1 (group show-all no-article | |
6748645f LMI |
2880 | kill-buffer no-display |
2881 | &optional select-articles) | |
eec82323 LMI |
2882 | ;; Killed foreign groups can't be entered. |
2883 | (when (and (not (gnus-group-native-p group)) | |
2884 | (not (gnus-gethash group gnus-newsrc-hashtb))) | |
2885 | (error "Dead non-native groups can't be entered")) | |
2886 | (gnus-message 5 "Retrieving newsgroup: %s..." group) | |
2887 | (let* ((new-group (gnus-summary-setup-buffer group)) | |
2888 | (quit-config (gnus-group-quit-config group)) | |
6748645f LMI |
2889 | (did-select (and new-group (gnus-select-newsgroup |
2890 | group show-all select-articles)))) | |
eec82323 LMI |
2891 | (cond |
2892 | ;; This summary buffer exists already, so we just select it. | |
2893 | ((not new-group) | |
2894 | (gnus-set-global-variables) | |
2895 | (when kill-buffer | |
2896 | (gnus-kill-or-deaden-summary kill-buffer)) | |
2897 | (gnus-configure-windows 'summary 'force) | |
2898 | (gnus-set-mode-line 'summary) | |
2899 | (gnus-summary-position-point) | |
2900 | (message "") | |
2901 | t) | |
2902 | ;; We couldn't select this group. | |
2903 | ((null did-select) | |
2904 | (when (and (eq major-mode 'gnus-summary-mode) | |
2905 | (not (equal (current-buffer) kill-buffer))) | |
2906 | (kill-buffer (current-buffer)) | |
2907 | (if (not quit-config) | |
2908 | (progn | |
6748645f LMI |
2909 | ;; Update the info -- marks might need to be removed, |
2910 | ;; for instance. | |
2911 | (gnus-summary-update-info) | |
eec82323 LMI |
2912 | (set-buffer gnus-group-buffer) |
2913 | (gnus-group-jump-to-group group) | |
2914 | (gnus-group-next-unread-group 1)) | |
2915 | (gnus-handle-ephemeral-exit quit-config))) | |
2916 | (gnus-message 3 "Can't select group") | |
2917 | nil) | |
2918 | ;; The user did a `C-g' while prompting for number of articles, | |
2919 | ;; so we exit this group. | |
2920 | ((eq did-select 'quit) | |
2921 | (and (eq major-mode 'gnus-summary-mode) | |
2922 | (not (equal (current-buffer) kill-buffer)) | |
2923 | (kill-buffer (current-buffer))) | |
2924 | (when kill-buffer | |
2925 | (gnus-kill-or-deaden-summary kill-buffer)) | |
2926 | (if (not quit-config) | |
2927 | (progn | |
2928 | (set-buffer gnus-group-buffer) | |
2929 | (gnus-group-jump-to-group group) | |
2930 | (gnus-group-next-unread-group 1) | |
2931 | (gnus-configure-windows 'group 'force)) | |
2932 | (gnus-handle-ephemeral-exit quit-config)) | |
2933 | ;; Finally signal the quit. | |
2934 | (signal 'quit nil)) | |
2935 | ;; The group was successfully selected. | |
2936 | (t | |
2937 | (gnus-set-global-variables) | |
2938 | ;; Save the active value in effect when the group was entered. | |
2939 | (setq gnus-newsgroup-active | |
2940 | (gnus-copy-sequence | |
2941 | (gnus-active gnus-newsgroup-name))) | |
2942 | ;; You can change the summary buffer in some way with this hook. | |
6748645f | 2943 | (gnus-run-hooks 'gnus-select-group-hook) |
eec82323 LMI |
2944 | ;; Set any local variables in the group parameters. |
2945 | (gnus-summary-set-local-parameters gnus-newsgroup-name) | |
2946 | (gnus-update-format-specifications | |
2947 | nil 'summary 'summary-mode 'summary-dummy) | |
16409b0b | 2948 | (gnus-update-summary-mark-positions) |
eec82323 LMI |
2949 | ;; Do score processing. |
2950 | (when gnus-use-scoring | |
2951 | (gnus-possibly-score-headers)) | |
2952 | ;; Check whether to fill in the gaps in the threads. | |
2953 | (when gnus-build-sparse-threads | |
2954 | (gnus-build-sparse-threads)) | |
2955 | ;; Find the initial limit. | |
2956 | (if gnus-show-threads | |
2957 | (if show-all | |
2958 | (let ((gnus-newsgroup-dormant nil)) | |
2959 | (gnus-summary-initial-limit show-all)) | |
2960 | (gnus-summary-initial-limit show-all)) | |
16409b0b | 2961 | ;; When untreaded, all articles are always shown. |
eec82323 LMI |
2962 | (setq gnus-newsgroup-limit |
2963 | (mapcar | |
2964 | (lambda (header) (mail-header-number header)) | |
2965 | gnus-newsgroup-headers))) | |
2966 | ;; Generate the summary buffer. | |
2967 | (unless no-display | |
2968 | (gnus-summary-prepare)) | |
2969 | (when gnus-use-trees | |
2970 | (gnus-tree-open group) | |
2971 | (setq gnus-summary-highlight-line-function | |
2972 | 'gnus-tree-highlight-article)) | |
2973 | ;; If the summary buffer is empty, but there are some low-scored | |
2974 | ;; articles or some excluded dormants, we include these in the | |
2975 | ;; buffer. | |
2976 | (when (and (zerop (buffer-size)) | |
2977 | (not no-display)) | |
2978 | (cond (gnus-newsgroup-dormant | |
2979 | (gnus-summary-limit-include-dormant)) | |
2980 | ((and gnus-newsgroup-scored show-all) | |
2981 | (gnus-summary-limit-include-expunged t)))) | |
2982 | ;; Function `gnus-apply-kill-file' must be called in this hook. | |
6748645f | 2983 | (gnus-run-hooks 'gnus-apply-kill-hook) |
eec82323 LMI |
2984 | (if (and (zerop (buffer-size)) |
2985 | (not no-display)) | |
2986 | (progn | |
2987 | ;; This newsgroup is empty. | |
2988 | (gnus-summary-catchup-and-exit nil t) | |
2989 | (gnus-message 6 "No unread news") | |
2990 | (when kill-buffer | |
2991 | (gnus-kill-or-deaden-summary kill-buffer)) | |
2992 | ;; Return nil from this function. | |
2993 | nil) | |
2994 | ;; Hide conversation thread subtrees. We cannot do this in | |
2995 | ;; gnus-summary-prepare-hook since kill processing may not | |
2996 | ;; work with hidden articles. | |
2997 | (and gnus-show-threads | |
2998 | gnus-thread-hide-subtree | |
2999 | (gnus-summary-hide-all-threads)) | |
6748645f LMI |
3000 | (when kill-buffer |
3001 | (gnus-kill-or-deaden-summary kill-buffer)) | |
eec82323 LMI |
3002 | ;; Show first unread article if requested. |
3003 | (if (and (not no-article) | |
3004 | (not no-display) | |
3005 | gnus-newsgroup-unreads | |
3006 | gnus-auto-select-first) | |
16409b0b GM |
3007 | (progn |
3008 | (gnus-configure-windows 'summary) | |
3009 | (cond | |
3010 | ((eq gnus-auto-select-first 'best) | |
3011 | (gnus-summary-best-unread-article)) | |
3012 | ((eq gnus-auto-select-first t) | |
3013 | (gnus-summary-first-unread-article)) | |
3014 | ((gnus-functionp gnus-auto-select-first) | |
3015 | (funcall gnus-auto-select-first)))) | |
eec82323 LMI |
3016 | ;; Don't select any articles, just move point to the first |
3017 | ;; article in the group. | |
3018 | (goto-char (point-min)) | |
3019 | (gnus-summary-position-point) | |
6748645f LMI |
3020 | (gnus-configure-windows 'summary 'force) |
3021 | (gnus-set-mode-line 'summary)) | |
eec82323 LMI |
3022 | (when (get-buffer-window gnus-group-buffer t) |
3023 | ;; Gotta use windows, because recenter does weird stuff if | |
3024 | ;; the current buffer ain't the displayed window. | |
3025 | (let ((owin (selected-window))) | |
3026 | (select-window (get-buffer-window gnus-group-buffer t)) | |
3027 | (when (gnus-group-goto-group group) | |
3028 | (recenter)) | |
3029 | (select-window owin))) | |
3030 | ;; Mark this buffer as "prepared". | |
3031 | (setq gnus-newsgroup-prepared t) | |
6748645f | 3032 | (gnus-run-hooks 'gnus-summary-prepared-hook) |
eec82323 LMI |
3033 | t))))) |
3034 | ||
3035 | (defun gnus-summary-prepare () | |
3036 | "Generate the summary buffer." | |
3037 | (interactive) | |
3038 | (let ((buffer-read-only nil)) | |
3039 | (erase-buffer) | |
3040 | (setq gnus-newsgroup-data nil | |
3041 | gnus-newsgroup-data-reverse nil) | |
6748645f | 3042 | (gnus-run-hooks 'gnus-summary-generate-hook) |
eec82323 LMI |
3043 | ;; Generate the buffer, either with threads or without. |
3044 | (when gnus-newsgroup-headers | |
3045 | (gnus-summary-prepare-threads | |
3046 | (if gnus-show-threads | |
3047 | (gnus-sort-gathered-threads | |
3048 | (funcall gnus-summary-thread-gathering-function | |
3049 | (gnus-sort-threads | |
3050 | (gnus-cut-threads (gnus-make-threads))))) | |
3051 | ;; Unthreaded display. | |
3052 | (gnus-sort-articles gnus-newsgroup-headers)))) | |
3053 | (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data)) | |
3054 | ;; Call hooks for modifying summary buffer. | |
3055 | (goto-char (point-min)) | |
6748645f | 3056 | (gnus-run-hooks 'gnus-summary-prepare-hook))) |
eec82323 LMI |
3057 | |
3058 | (defsubst gnus-general-simplify-subject (subject) | |
3059 | "Simply subject by the same rules as gnus-gather-threads-by-subject." | |
3060 | (setq subject | |
3061 | (cond | |
3062 | ;; Truncate the subject. | |
6748645f LMI |
3063 | (gnus-simplify-subject-functions |
3064 | (gnus-map-function gnus-simplify-subject-functions subject)) | |
eec82323 LMI |
3065 | ((numberp gnus-summary-gather-subject-limit) |
3066 | (setq subject (gnus-simplify-subject-re subject)) | |
3067 | (if (> (length subject) gnus-summary-gather-subject-limit) | |
3068 | (substring subject 0 gnus-summary-gather-subject-limit) | |
3069 | subject)) | |
3070 | ;; Fuzzily simplify it. | |
3071 | ((eq 'fuzzy gnus-summary-gather-subject-limit) | |
3072 | (gnus-simplify-subject-fuzzy subject)) | |
3073 | ;; Just remove the leading "Re:". | |
3074 | (t | |
3075 | (gnus-simplify-subject-re subject)))) | |
3076 | ||
3077 | (if (and gnus-summary-gather-exclude-subject | |
3078 | (string-match gnus-summary-gather-exclude-subject subject)) | |
3079 | nil ; This article shouldn't be gathered | |
3080 | subject)) | |
3081 | ||
3082 | (defun gnus-summary-simplify-subject-query () | |
3083 | "Query where the respool algorithm would put this article." | |
3084 | (interactive) | |
eec82323 LMI |
3085 | (gnus-summary-select-article) |
3086 | (message (gnus-general-simplify-subject (gnus-summary-article-subject)))) | |
3087 | ||
3088 | (defun gnus-gather-threads-by-subject (threads) | |
3089 | "Gather threads by looking at Subject headers." | |
3090 | (if (not gnus-summary-make-false-root) | |
3091 | threads | |
3092 | (let ((hashtb (gnus-make-hashtable 1024)) | |
3093 | (prev threads) | |
3094 | (result threads) | |
3095 | subject hthread whole-subject) | |
3096 | (while threads | |
3097 | (setq subject (gnus-general-simplify-subject | |
3098 | (setq whole-subject (mail-header-subject | |
3099 | (caar threads))))) | |
3100 | (when subject | |
3101 | (if (setq hthread (gnus-gethash subject hashtb)) | |
3102 | (progn | |
3103 | ;; We enter a dummy root into the thread, if we | |
3104 | ;; haven't done that already. | |
3105 | (unless (stringp (caar hthread)) | |
3106 | (setcar hthread (list whole-subject (car hthread)))) | |
3107 | ;; We add this new gathered thread to this gathered | |
3108 | ;; thread. | |
3109 | (setcdr (car hthread) | |
3110 | (nconc (cdar hthread) (list (car threads)))) | |
3111 | ;; Remove it from the list of threads. | |
3112 | (setcdr prev (cdr threads)) | |
3113 | (setq threads prev)) | |
3114 | ;; Enter this thread into the hash table. | |
3115 | (gnus-sethash subject threads hashtb))) | |
3116 | (setq prev threads) | |
3117 | (setq threads (cdr threads))) | |
3118 | result))) | |
3119 | ||
3120 | (defun gnus-gather-threads-by-references (threads) | |
3121 | "Gather threads by looking at References headers." | |
3122 | (let ((idhashtb (gnus-make-hashtable 1024)) | |
3123 | (thhashtb (gnus-make-hashtable 1024)) | |
3124 | (prev threads) | |
3125 | (result threads) | |
3126 | ids references id gthread gid entered ref) | |
3127 | (while threads | |
3128 | (when (setq references (mail-header-references (caar threads))) | |
3129 | (setq id (mail-header-id (caar threads)) | |
3130 | ids (gnus-split-references references) | |
3131 | entered nil) | |
3132 | (while (setq ref (pop ids)) | |
3133 | (setq ids (delete ref ids)) | |
3134 | (if (not (setq gid (gnus-gethash ref idhashtb))) | |
3135 | (progn | |
3136 | (gnus-sethash ref id idhashtb) | |
3137 | (gnus-sethash id threads thhashtb)) | |
3138 | (setq gthread (gnus-gethash gid thhashtb)) | |
3139 | (unless entered | |
3140 | ;; We enter a dummy root into the thread, if we | |
3141 | ;; haven't done that already. | |
3142 | (unless (stringp (caar gthread)) | |
3143 | (setcar gthread (list (mail-header-subject (caar gthread)) | |
3144 | (car gthread)))) | |
3145 | ;; We add this new gathered thread to this gathered | |
3146 | ;; thread. | |
3147 | (setcdr (car gthread) | |
3148 | (nconc (cdar gthread) (list (car threads))))) | |
3149 | ;; Add it into the thread hash table. | |
3150 | (gnus-sethash id gthread thhashtb) | |
3151 | (setq entered t) | |
3152 | ;; Remove it from the list of threads. | |
3153 | (setcdr prev (cdr threads)) | |
3154 | (setq threads prev)))) | |
3155 | (setq prev threads) | |
3156 | (setq threads (cdr threads))) | |
3157 | result)) | |
3158 | ||
3159 | (defun gnus-sort-gathered-threads (threads) | |
16409b0b | 3160 | "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'." |
eec82323 LMI |
3161 | (let ((result threads)) |
3162 | (while threads | |
3163 | (when (stringp (caar threads)) | |
3164 | (setcdr (car threads) | |
16409b0b | 3165 | (sort (cdar threads) gnus-sort-gathered-threads-function))) |
eec82323 LMI |
3166 | (setq threads (cdr threads))) |
3167 | result)) | |
3168 | ||
3169 | (defun gnus-thread-loop-p (root thread) | |
3170 | "Say whether ROOT is in THREAD." | |
3171 | (let ((stack (list thread)) | |
3172 | (infloop 0) | |
3173 | th) | |
3174 | (while (setq thread (pop stack)) | |
3175 | (setq th (cdr thread)) | |
3176 | (while (and th | |
3177 | (not (eq (caar th) root))) | |
3178 | (pop th)) | |
3179 | (if th | |
3180 | ;; We have found a loop. | |
3181 | (let (ref-dep) | |
3182 | (setcdr thread (delq (car th) (cdr thread))) | |
3183 | (if (boundp (setq ref-dep (intern "none" | |
3184 | gnus-newsgroup-dependencies))) | |
3185 | (setcdr (symbol-value ref-dep) | |
3186 | (nconc (cdr (symbol-value ref-dep)) | |
3187 | (list (car th)))) | |
3188 | (set ref-dep (list nil (car th)))) | |
3189 | (setq infloop 1 | |
3190 | stack nil)) | |
3191 | ;; Push all the subthreads onto the stack. | |
3192 | (push (cdr thread) stack))) | |
3193 | infloop)) | |
3194 | ||
3195 | (defun gnus-make-threads () | |
3196 | "Go through the dependency hashtb and find the roots. Return all threads." | |
3197 | (let (threads) | |
3198 | (while (catch 'infloop | |
3199 | (mapatoms | |
3200 | (lambda (refs) | |
3201 | ;; Deal with self-referencing References loops. | |
3202 | (when (and (car (symbol-value refs)) | |
3203 | (not (zerop | |
3204 | (apply | |
3205 | '+ | |
3206 | (mapcar | |
3207 | (lambda (thread) | |
3208 | (gnus-thread-loop-p | |
3209 | (car (symbol-value refs)) thread)) | |
3210 | (cdr (symbol-value refs))))))) | |
3211 | (setq threads nil) | |
3212 | (throw 'infloop t)) | |
3213 | (unless (car (symbol-value refs)) | |
3214 | ;; These threads do not refer back to any other articles, | |
3215 | ;; so they're roots. | |
3216 | (setq threads (append (cdr (symbol-value refs)) threads)))) | |
3217 | gnus-newsgroup-dependencies))) | |
3218 | threads)) | |
3219 | ||
6748645f | 3220 | ;; Build the thread tree. |
16409b0b | 3221 | (defsubst gnus-dependencies-add-header (header dependencies force-new) |
6748645f LMI |
3222 | "Enter HEADER into the DEPENDENCIES table if it is not already there. |
3223 | ||
3224 | If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even | |
3225 | if it was already present. | |
3226 | ||
3227 | If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs | |
3228 | will not be entered in the DEPENDENCIES table. Otherwise duplicate | |
3229 | Message-IDs will be renamed be renamed to a unique Message-ID before | |
3230 | being entered. | |
3231 | ||
3232 | Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise." | |
3233 | (let* ((id (mail-header-id header)) | |
3234 | (id-dep (and id (intern id dependencies))) | |
3235 | ref ref-dep ref-header) | |
3236 | ;; Enter this `header' in the `dependencies' table. | |
3237 | (cond | |
3238 | ((not id-dep) | |
3239 | (setq header nil)) | |
3240 | ;; The first two cases do the normal part: enter a new `header' | |
3241 | ;; in the `dependencies' table. | |
3242 | ((not (boundp id-dep)) | |
3243 | (set id-dep (list header))) | |
3244 | ((null (car (symbol-value id-dep))) | |
3245 | (setcar (symbol-value id-dep) header)) | |
3246 | ||
3247 | ;; From here the `header' was already present in the | |
3248 | ;; `dependencies' table. | |
3249 | (force-new | |
3250 | ;; Overrides an existing entry; | |
3251 | ;; just set the header part of the entry. | |
3252 | (setcar (symbol-value id-dep) header)) | |
3253 | ||
3254 | ;; Renames the existing `header' to a unique Message-ID. | |
3255 | ((not gnus-summary-ignore-duplicates) | |
3256 | ;; An article with this Message-ID has already been seen. | |
3257 | ;; We rename the Message-ID. | |
3258 | (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies)) | |
3259 | (list header)) | |
3260 | (mail-header-set-id header id)) | |
3261 | ||
3262 | ;; The last case ignores an existing entry, except it adds any | |
3263 | ;; additional Xrefs (in case the two articles came from different | |
3264 | ;; servers. | |
3265 | ;; Also sets `header' to `nil' meaning that the `dependencies' | |
3266 | ;; table was *not* modified. | |
3267 | (t | |
3268 | (mail-header-set-xref | |
3269 | (car (symbol-value id-dep)) | |
3270 | (concat (or (mail-header-xref (car (symbol-value id-dep))) | |
3271 | "") | |
3272 | (or (mail-header-xref header) ""))) | |
3273 | (setq header nil))) | |
3274 | ||
3275 | (when header | |
3276 | ;; First check if that we are not creating a References loop. | |
3277 | (setq ref (gnus-parent-id (mail-header-references header))) | |
3278 | (while (and ref | |
3279 | (setq ref-dep (intern-soft ref dependencies)) | |
3280 | (boundp ref-dep) | |
3281 | (setq ref-header (car (symbol-value ref-dep)))) | |
3282 | (if (string= id ref) | |
3283 | ;; Yuk! This is a reference loop. Make the article be a | |
3284 | ;; root article. | |
3285 | (progn | |
3286 | (mail-header-set-references (car (symbol-value id-dep)) "none") | |
3287 | (setq ref nil)) | |
3288 | (setq ref (gnus-parent-id (mail-header-references ref-header))))) | |
3289 | (setq ref (gnus-parent-id (mail-header-references header))) | |
3290 | (setq ref-dep (intern (or ref "none") dependencies)) | |
3291 | (if (boundp ref-dep) | |
3292 | (setcdr (symbol-value ref-dep) | |
3293 | (nconc (cdr (symbol-value ref-dep)) | |
3294 | (list (symbol-value id-dep)))) | |
3295 | (set ref-dep (list nil (symbol-value id-dep))))) | |
3296 | header)) | |
3297 | ||
eec82323 LMI |
3298 | (defun gnus-build-sparse-threads () |
3299 | (let ((headers gnus-newsgroup-headers) | |
16409b0b | 3300 | (mail-parse-charset gnus-newsgroup-charset) |
6748645f | 3301 | (gnus-summary-ignore-duplicates t) |
eec82323 | 3302 | header references generation relations |
6748645f | 3303 | subject child end new-child date) |
eec82323 LMI |
3304 | ;; First we create an alist of generations/relations, where |
3305 | ;; generations is how much we trust the relation, and the relation | |
3306 | ;; is parent/child. | |
3307 | (gnus-message 7 "Making sparse threads...") | |
3308 | (save-excursion | |
3309 | (nnheader-set-temp-buffer " *gnus sparse threads*") | |
3310 | (while (setq header (pop headers)) | |
3311 | (when (and (setq references (mail-header-references header)) | |
3312 | (not (string= references ""))) | |
3313 | (insert references) | |
3314 | (setq child (mail-header-id header) | |
6748645f LMI |
3315 | subject (mail-header-subject header) |
3316 | date (mail-header-date header) | |
3317 | generation 0) | |
eec82323 LMI |
3318 | (while (search-backward ">" nil t) |
3319 | (setq end (1+ (point))) | |
3320 | (when (search-backward "<" nil t) | |
6748645f | 3321 | (setq new-child (buffer-substring (point) end)) |
eec82323 | 3322 | (push (list (incf generation) |
6748645f LMI |
3323 | child (setq child new-child) |
3324 | subject date) | |
eec82323 | 3325 | relations))) |
6748645f LMI |
3326 | (when child |
3327 | (push (list (1+ generation) child nil subject) relations)) | |
eec82323 LMI |
3328 | (erase-buffer))) |
3329 | (kill-buffer (current-buffer))) | |
3330 | ;; Sort over trustworthiness. | |
6748645f LMI |
3331 | (mapcar |
3332 | (lambda (relation) | |
3333 | (when (gnus-dependencies-add-header | |
3334 | (make-full-mail-header | |
3335 | gnus-reffed-article-number | |
3336 | (nth 3 relation) "" (or (nth 4 relation) "") | |
3337 | (nth 1 relation) | |
3338 | (or (nth 2 relation) "") 0 0 "") | |
3339 | gnus-newsgroup-dependencies nil) | |
3340 | (push gnus-reffed-article-number gnus-newsgroup-limit) | |
3341 | (push gnus-reffed-article-number gnus-newsgroup-sparse) | |
3342 | (push (cons gnus-reffed-article-number gnus-sparse-mark) | |
3343 | gnus-newsgroup-reads) | |
3344 | (decf gnus-reffed-article-number))) | |
3345 | (sort relations 'car-less-than-car)) | |
eec82323 LMI |
3346 | (gnus-message 7 "Making sparse threads...done"))) |
3347 | ||
3348 | (defun gnus-build-old-threads () | |
3349 | ;; Look at all the articles that refer back to old articles, and | |
3350 | ;; fetch the headers for the articles that aren't there. This will | |
3351 | ;; build complete threads - if the roots haven't been expired by the | |
3352 | ;; server, that is. | |
16409b0b GM |
3353 | (let ((mail-parse-charset gnus-newsgroup-charset) |
3354 | id heads) | |
eec82323 LMI |
3355 | (mapatoms |
3356 | (lambda (refs) | |
3357 | (when (not (car (symbol-value refs))) | |
3358 | (setq heads (cdr (symbol-value refs))) | |
3359 | (while heads | |
3360 | (if (memq (mail-header-number (caar heads)) | |
3361 | gnus-newsgroup-dormant) | |
3362 | (setq heads (cdr heads)) | |
3363 | (setq id (symbol-name refs)) | |
3364 | (while (and (setq id (gnus-build-get-header id)) | |
6748645f | 3365 | (not (car (gnus-id-to-thread id))))) |
eec82323 LMI |
3366 | (setq heads nil))))) |
3367 | gnus-newsgroup-dependencies))) | |
3368 | ||
6748645f LMI |
3369 | ;; This function has to be called with point after the article number |
3370 | ;; on the beginning of the line. | |
3371 | (defsubst gnus-nov-parse-line (number dependencies &optional force-new) | |
3372 | (let ((eol (gnus-point-at-eol)) | |
3373 | (buffer (current-buffer)) | |
3374 | header) | |
3375 | ||
3376 | ;; overview: [num subject from date id refs chars lines misc] | |
3377 | (unwind-protect | |
3378 | (progn | |
3379 | (narrow-to-region (point) eol) | |
3380 | (unless (eobp) | |
3381 | (forward-char)) | |
3382 | ||
3383 | (setq header | |
3384 | (make-full-mail-header | |
3385 | number ; number | |
16409b0b GM |
3386 | (funcall gnus-decode-encoded-word-function |
3387 | (nnheader-nov-field)) ; subject | |
3388 | (funcall gnus-decode-encoded-word-function | |
3389 | (nnheader-nov-field)) ; from | |
3390 | (nnheader-nov-field) ; date | |
3391 | (nnheader-nov-read-message-id) ; id | |
3392 | (nnheader-nov-field) ; refs | |
3393 | (nnheader-nov-read-integer) ; chars | |
3394 | (nnheader-nov-read-integer) ; lines | |
3395 | (unless (eobp) | |
8b93df01 DL |
3396 | (if (looking-at "Xref: ") |
3397 | (goto-char (match-end 0))) | |
3398 | (nnheader-nov-field)) ; Xref | |
16409b0b | 3399 | (nnheader-nov-parse-extra)))) ; extra |
6748645f LMI |
3400 | |
3401 | (widen)) | |
3402 | ||
3403 | (when gnus-alter-header-function | |
3404 | (funcall gnus-alter-header-function header)) | |
3405 | (gnus-dependencies-add-header header dependencies force-new))) | |
3406 | ||
eec82323 | 3407 | (defun gnus-build-get-header (id) |
16409b0b GM |
3408 | "Look through the buffer of NOV lines and find the header to ID. |
3409 | Enter this line into the dependencies hash table, and return | |
3410 | the id of the parent article (if any)." | |
eec82323 LMI |
3411 | (let ((deps gnus-newsgroup-dependencies) |
3412 | found header) | |
3413 | (prog1 | |
3414 | (save-excursion | |
3415 | (set-buffer nntp-server-buffer) | |
3416 | (let ((case-fold-search nil)) | |
3417 | (goto-char (point-min)) | |
3418 | (while (and (not found) | |
3419 | (search-forward id nil t)) | |
3420 | (beginning-of-line) | |
3421 | (setq found (looking-at | |
3422 | (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s" | |
3423 | (regexp-quote id)))) | |
3424 | (or found (beginning-of-line 2))) | |
3425 | (when found | |
3426 | (beginning-of-line) | |
3427 | (and | |
3428 | (setq header (gnus-nov-parse-line | |
3429 | (read (current-buffer)) deps)) | |
3430 | (gnus-parent-id (mail-header-references header)))))) | |
3431 | (when header | |
3432 | (let ((number (mail-header-number header))) | |
3433 | (push number gnus-newsgroup-limit) | |
3434 | (push header gnus-newsgroup-headers) | |
3435 | (if (memq number gnus-newsgroup-unselected) | |
3436 | (progn | |
3437 | (push number gnus-newsgroup-unreads) | |
3438 | (setq gnus-newsgroup-unselected | |
3439 | (delq number gnus-newsgroup-unselected))) | |
3440 | (push number gnus-newsgroup-ancient))))))) | |
3441 | ||
6748645f LMI |
3442 | (defun gnus-build-all-threads () |
3443 | "Read all the headers." | |
3444 | (let ((gnus-summary-ignore-duplicates t) | |
16409b0b | 3445 | (mail-parse-charset gnus-newsgroup-charset) |
6748645f LMI |
3446 | (dependencies gnus-newsgroup-dependencies) |
3447 | header article) | |
3448 | (save-excursion | |
3449 | (set-buffer nntp-server-buffer) | |
3450 | (let ((case-fold-search nil)) | |
3451 | (goto-char (point-min)) | |
3452 | (while (not (eobp)) | |
3453 | (ignore-errors | |
3454 | (setq article (read (current-buffer)) | |
16409b0b | 3455 | header (gnus-nov-parse-line article dependencies))) |
6748645f LMI |
3456 | (when header |
3457 | (save-excursion | |
3458 | (set-buffer gnus-summary-buffer) | |
3459 | (push header gnus-newsgroup-headers) | |
3460 | (if (memq (setq article (mail-header-number header)) | |
3461 | gnus-newsgroup-unselected) | |
3462 | (progn | |
3463 | (push article gnus-newsgroup-unreads) | |
3464 | (setq gnus-newsgroup-unselected | |
3465 | (delq article gnus-newsgroup-unselected))) | |
3466 | (push article gnus-newsgroup-ancient))) | |
3467 | (forward-line 1))))))) | |
3468 | ||
eec82323 LMI |
3469 | (defun gnus-summary-update-article-line (article header) |
3470 | "Update the line for ARTICLE using HEADERS." | |
3471 | (let* ((id (mail-header-id header)) | |
3472 | (thread (gnus-id-to-thread id))) | |
3473 | (unless thread | |
3474 | (error "Article in no thread")) | |
3475 | ;; Update the thread. | |
3476 | (setcar thread header) | |
3477 | (gnus-summary-goto-subject article) | |
3478 | (let* ((datal (gnus-data-find-list article)) | |
3479 | (data (car datal)) | |
3480 | (length (when (cdr datal) | |
3481 | (- (gnus-data-pos data) | |
3482 | (gnus-data-pos (cadr datal))))) | |
3483 | (buffer-read-only nil) | |
3484 | (level (gnus-summary-thread-level))) | |
3485 | (gnus-delete-line) | |
3486 | (gnus-summary-insert-line | |
3487 | header level nil (gnus-article-mark article) | |
3488 | (memq article gnus-newsgroup-replied) | |
3489 | (memq article gnus-newsgroup-expirable) | |
3490 | ;; Only insert the Subject string when it's different | |
3491 | ;; from the previous Subject string. | |
16409b0b GM |
3492 | (if (and |
3493 | gnus-show-threads | |
3494 | (gnus-subject-equal | |
3495 | (condition-case () | |
3496 | (mail-header-subject | |
3497 | (gnus-data-header | |
3498 | (cadr | |
3499 | (gnus-data-find-list | |
3500 | article | |
3501 | (gnus-data-list t))))) | |
3502 | ;; Error on the side of excessive subjects. | |
3503 | (error "")) | |
3504 | (mail-header-subject header))) | |
eec82323 LMI |
3505 | "" |
3506 | (mail-header-subject header)) | |
3507 | nil (cdr (assq article gnus-newsgroup-scored)) | |
3508 | (memq article gnus-newsgroup-processable)) | |
3509 | (when length | |
3510 | (gnus-data-update-list | |
3511 | (cdr datal) (- length (- (gnus-data-pos data) (point)))))))) | |
3512 | ||
3513 | (defun gnus-summary-update-article (article &optional iheader) | |
3514 | "Update ARTICLE in the summary buffer." | |
3515 | (set-buffer gnus-summary-buffer) | |
6748645f | 3516 | (let* ((header (gnus-summary-article-header article)) |
eec82323 LMI |
3517 | (id (mail-header-id header)) |
3518 | (data (gnus-data-find article)) | |
3519 | (thread (gnus-id-to-thread id)) | |
3520 | (references (mail-header-references header)) | |
3521 | (parent | |
3522 | (gnus-id-to-thread | |
3523 | (or (gnus-parent-id | |
3524 | (when (and references | |
3525 | (not (equal "" references))) | |
3526 | references)) | |
3527 | "none"))) | |
3528 | (buffer-read-only nil) | |
6748645f | 3529 | (old (car thread))) |
eec82323 | 3530 | (when thread |
eec82323 | 3531 | (unless iheader |
6748645f LMI |
3532 | (setcar thread nil) |
3533 | (when parent | |
3534 | (delq thread parent))) | |
3535 | (if (gnus-summary-insert-subject id header) | |
eec82323 LMI |
3536 | ;; Set the (possibly) new article number in the data structure. |
3537 | (gnus-data-set-number data (gnus-id-to-article id)) | |
3538 | (setcar thread old) | |
3539 | nil)))) | |
3540 | ||
6748645f LMI |
3541 | (defun gnus-rebuild-thread (id &optional line) |
3542 | "Rebuild the thread containing ID. | |
3543 | If LINE, insert the rebuilt thread starting on line LINE." | |
eec82323 LMI |
3544 | (let ((buffer-read-only nil) |
3545 | old-pos current thread data) | |
3546 | (if (not gnus-show-threads) | |
3547 | (setq thread (list (car (gnus-id-to-thread id)))) | |
3548 | ;; Get the thread this article is part of. | |
3549 | (setq thread (gnus-remove-thread id))) | |
3550 | (setq old-pos (gnus-point-at-bol)) | |
3551 | (setq current (save-excursion | |
3552 | (and (zerop (forward-line -1)) | |
3553 | (gnus-summary-article-number)))) | |
3554 | ;; If this is a gathered thread, we have to go some re-gathering. | |
3555 | (when (stringp (car thread)) | |
3556 | (let ((subject (car thread)) | |
3557 | roots thr) | |
3558 | (setq thread (cdr thread)) | |
3559 | (while thread | |
3560 | (unless (memq (setq thr (gnus-id-to-thread | |
3561 | (gnus-root-id | |
3562 | (mail-header-id (caar thread))))) | |
3563 | roots) | |
3564 | (push thr roots)) | |
3565 | (setq thread (cdr thread))) | |
3566 | ;; We now have all (unique) roots. | |
3567 | (if (= (length roots) 1) | |
3568 | ;; All the loose roots are now one solid root. | |
3569 | (setq thread (car roots)) | |
3570 | (setq thread (cons subject (gnus-sort-threads roots)))))) | |
3571 | (let (threads) | |
3572 | ;; We then insert this thread into the summary buffer. | |
6748645f LMI |
3573 | (when line |
3574 | (goto-char (point-min)) | |
3575 | (forward-line (1- line))) | |
eec82323 LMI |
3576 | (let (gnus-newsgroup-data gnus-newsgroup-threads) |
3577 | (if gnus-show-threads | |
3578 | (gnus-summary-prepare-threads (gnus-cut-threads (list thread))) | |
3579 | (gnus-summary-prepare-unthreaded thread)) | |
3580 | (setq data (nreverse gnus-newsgroup-data)) | |
3581 | (setq threads gnus-newsgroup-threads)) | |
3582 | ;; We splice the new data into the data structure. | |
6748645f LMI |
3583 | ;;!!! This is kinda bogus. We assume that in LINE is non-nil, |
3584 | ;;!!! then we want to insert at the beginning of the buffer. | |
3585 | ;;!!! That happens to be true with Gnus now, but that may | |
3586 | ;;!!! change in the future. Perhaps. | |
3587 | (gnus-data-enter-list | |
3588 | (if line nil current) data (- (point) old-pos)) | |
3589 | (setq gnus-newsgroup-threads | |
3590 | (nconc threads gnus-newsgroup-threads)) | |
3591 | (gnus-data-compute-positions)))) | |
eec82323 LMI |
3592 | |
3593 | (defun gnus-number-to-header (number) | |
3594 | "Return the header for article NUMBER." | |
3595 | (let ((headers gnus-newsgroup-headers)) | |
3596 | (while (and headers | |
3597 | (not (= number (mail-header-number (car headers))))) | |
3598 | (pop headers)) | |
3599 | (when headers | |
3600 | (car headers)))) | |
3601 | ||
6748645f | 3602 | (defun gnus-parent-headers (in-headers &optional generation) |
eec82323 LMI |
3603 | "Return the headers of the GENERATIONeth parent of HEADERS." |
3604 | (unless generation | |
3605 | (setq generation 1)) | |
a8151ef7 | 3606 | (let ((parent t) |
6748645f | 3607 | (headers in-headers) |
a8151ef7 | 3608 | references) |
6748645f LMI |
3609 | (while (and parent |
3610 | (not (zerop generation)) | |
3611 | (setq references (mail-header-references headers))) | |
3612 | (setq headers (if (and references | |
3613 | (setq parent (gnus-parent-id references))) | |
3614 | (car (gnus-id-to-thread parent)) | |
3615 | nil)) | |
3616 | (decf generation)) | |
3617 | (and (not (eq headers in-headers)) | |
3618 | headers))) | |
eec82323 LMI |
3619 | |
3620 | (defun gnus-id-to-thread (id) | |
3621 | "Return the (sub-)thread where ID appears." | |
3622 | (gnus-gethash id gnus-newsgroup-dependencies)) | |
3623 | ||
3624 | (defun gnus-id-to-article (id) | |
3625 | "Return the article number of ID." | |
3626 | (let ((thread (gnus-id-to-thread id))) | |
3627 | (when (and thread | |
3628 | (car thread)) | |
3629 | (mail-header-number (car thread))))) | |
3630 | ||
3631 | (defun gnus-id-to-header (id) | |
3632 | "Return the article headers of ID." | |
3633 | (car (gnus-id-to-thread id))) | |
3634 | ||
3635 | (defun gnus-article-displayed-root-p (article) | |
3636 | "Say whether ARTICLE is a root(ish) article." | |
3637 | (let ((level (gnus-summary-thread-level article)) | |
3638 | (refs (mail-header-references (gnus-summary-article-header article))) | |
3639 | particle) | |
3640 | (cond | |
3641 | ((null level) nil) | |
3642 | ((zerop level) t) | |
3643 | ((null refs) t) | |
3644 | ((null (gnus-parent-id refs)) t) | |
3645 | ((and (= 1 level) | |
3646 | (null (setq particle (gnus-id-to-article | |
3647 | (gnus-parent-id refs)))) | |
3648 | (null (gnus-summary-thread-level particle))))))) | |
3649 | ||
3650 | (defun gnus-root-id (id) | |
3651 | "Return the id of the root of the thread where ID appears." | |
3652 | (let (last-id prev) | |
6748645f | 3653 | (while (and id (setq prev (car (gnus-id-to-thread id)))) |
eec82323 LMI |
3654 | (setq last-id id |
3655 | id (gnus-parent-id (mail-header-references prev)))) | |
3656 | last-id)) | |
3657 | ||
6748645f LMI |
3658 | (defun gnus-articles-in-thread (thread) |
3659 | "Return the list of articles in THREAD." | |
3660 | (cons (mail-header-number (car thread)) | |
3661 | (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread))))) | |
3662 | ||
eec82323 LMI |
3663 | (defun gnus-remove-thread (id &optional dont-remove) |
3664 | "Remove the thread that has ID in it." | |
6748645f | 3665 | (let (headers thread last-id) |
eec82323 | 3666 | ;; First go up in this thread until we find the root. |
6748645f LMI |
3667 | (setq last-id (gnus-root-id id) |
3668 | headers (message-flatten-list (gnus-id-to-thread last-id))) | |
eec82323 LMI |
3669 | ;; We have now found the real root of this thread. It might have |
3670 | ;; been gathered into some loose thread, so we have to search | |
3671 | ;; through the threads to find the thread we wanted. | |
3672 | (let ((threads gnus-newsgroup-threads) | |
3673 | sub) | |
3674 | (while threads | |
3675 | (setq sub (car threads)) | |
3676 | (if (stringp (car sub)) | |
3677 | ;; This is a gathered thread, so we look at the roots | |
3678 | ;; below it to find whether this article is in this | |
3679 | ;; gathered root. | |
3680 | (progn | |
3681 | (setq sub (cdr sub)) | |
3682 | (while sub | |
3683 | (when (member (caar sub) headers) | |
3684 | (setq thread (car threads) | |
3685 | threads nil | |
3686 | sub nil)) | |
3687 | (setq sub (cdr sub)))) | |
3688 | ;; It's an ordinary thread, so we check it. | |
3689 | (when (eq (car sub) (car headers)) | |
3690 | (setq thread sub | |
3691 | threads nil))) | |
3692 | (setq threads (cdr threads))) | |
3693 | ;; If this article is in no thread, then it's a root. | |
3694 | (if thread | |
3695 | (unless dont-remove | |
3696 | (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads))) | |
6748645f | 3697 | (setq thread (gnus-id-to-thread last-id))) |
eec82323 LMI |
3698 | (when thread |
3699 | (prog1 | |
3700 | thread ; We return this thread. | |
3701 | (unless dont-remove | |
3702 | (if (stringp (car thread)) | |
3703 | (progn | |
3704 | ;; If we use dummy roots, then we have to remove the | |
3705 | ;; dummy root as well. | |
3706 | (when (eq gnus-summary-make-false-root 'dummy) | |
6748645f LMI |
3707 | ;; We go to the dummy root by going to |
3708 | ;; the first sub-"thread", and then one line up. | |
3709 | (gnus-summary-goto-article | |
3710 | (mail-header-number (caadr thread))) | |
3711 | (forward-line -1) | |
eec82323 LMI |
3712 | (gnus-delete-line) |
3713 | (gnus-data-compute-positions)) | |
3714 | (setq thread (cdr thread)) | |
3715 | (while thread | |
3716 | (gnus-remove-thread-1 (car thread)) | |
3717 | (setq thread (cdr thread)))) | |
3718 | (gnus-remove-thread-1 thread)))))))) | |
3719 | ||
3720 | (defun gnus-remove-thread-1 (thread) | |
3721 | "Remove the thread THREAD recursively." | |
3722 | (let ((number (mail-header-number (pop thread))) | |
3723 | d) | |
3724 | (setq thread (reverse thread)) | |
3725 | (while thread | |
3726 | (gnus-remove-thread-1 (pop thread))) | |
3727 | (when (setq d (gnus-data-find number)) | |
3728 | (goto-char (gnus-data-pos d)) | |
16409b0b | 3729 | (gnus-summary-show-thread) |
eec82323 LMI |
3730 | (gnus-data-remove |
3731 | number | |
3732 | (- (gnus-point-at-bol) | |
3733 | (prog1 | |
3734 | (1+ (gnus-point-at-eol)) | |
3735 | (gnus-delete-line))))))) | |
3736 | ||
16409b0b GM |
3737 | (defun gnus-sort-threads-1 (threads func) |
3738 | (sort (mapcar (lambda (thread) | |
3739 | (cons (car thread) | |
3740 | (and (cdr thread) | |
3741 | (gnus-sort-threads-1 (cdr thread) func)))) | |
3742 | threads) func)) | |
3743 | ||
eec82323 LMI |
3744 | (defun gnus-sort-threads (threads) |
3745 | "Sort THREADS." | |
3746 | (if (not gnus-thread-sort-functions) | |
3747 | threads | |
6748645f | 3748 | (gnus-message 8 "Sorting threads...") |
eec82323 | 3749 | (prog1 |
16409b0b GM |
3750 | (gnus-sort-threads-1 |
3751 | threads | |
3752 | (gnus-make-sort-function gnus-thread-sort-functions)) | |
6748645f | 3753 | (gnus-message 8 "Sorting threads...done")))) |
eec82323 LMI |
3754 | |
3755 | (defun gnus-sort-articles (articles) | |
3756 | "Sort ARTICLES." | |
3757 | (when gnus-article-sort-functions | |
3758 | (gnus-message 7 "Sorting articles...") | |
3759 | (prog1 | |
3760 | (setq gnus-newsgroup-headers | |
3761 | (sort articles (gnus-make-sort-function | |
3762 | gnus-article-sort-functions))) | |
3763 | (gnus-message 7 "Sorting articles...done")))) | |
3764 | ||
3765 | ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>. | |
3766 | (defmacro gnus-thread-header (thread) | |
16409b0b GM |
3767 | "Return header of first article in THREAD. |
3768 | Note that THREAD must never, ever be anything else than a variable - | |
3769 | using some other form will lead to serious barfage." | |
eec82323 LMI |
3770 | (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread))) |
3771 | ;; (8% speedup to gnus-summary-prepare, just for fun :-) | |
16409b0b | 3772 | (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" |
eec82323 LMI |
3773 | (vector thread) 2)) |
3774 | ||
3775 | (defsubst gnus-article-sort-by-number (h1 h2) | |
3776 | "Sort articles by article number." | |
3777 | (< (mail-header-number h1) | |
3778 | (mail-header-number h2))) | |
3779 | ||
3780 | (defun gnus-thread-sort-by-number (h1 h2) | |
3781 | "Sort threads by root article number." | |
3782 | (gnus-article-sort-by-number | |
3783 | (gnus-thread-header h1) (gnus-thread-header h2))) | |
3784 | ||
3785 | (defsubst gnus-article-sort-by-lines (h1 h2) | |
3786 | "Sort articles by article Lines header." | |
3787 | (< (mail-header-lines h1) | |
3788 | (mail-header-lines h2))) | |
3789 | ||
3790 | (defun gnus-thread-sort-by-lines (h1 h2) | |
3791 | "Sort threads by root article Lines header." | |
3792 | (gnus-article-sort-by-lines | |
3793 | (gnus-thread-header h1) (gnus-thread-header h2))) | |
3794 | ||
16409b0b GM |
3795 | (defsubst gnus-article-sort-by-chars (h1 h2) |
3796 | "Sort articles by octet length." | |
3797 | (< (mail-header-chars h1) | |
3798 | (mail-header-chars h2))) | |
3799 | ||
3800 | (defun gnus-thread-sort-by-chars (h1 h2) | |
3801 | "Sort threads by root article octet length." | |
3802 | (gnus-article-sort-by-chars | |
3803 | (gnus-thread-header h1) (gnus-thread-header h2))) | |
3804 | ||
eec82323 LMI |
3805 | (defsubst gnus-article-sort-by-author (h1 h2) |
3806 | "Sort articles by root author." | |
3807 | (string-lessp | |
3808 | (let ((extract (funcall | |
3809 | gnus-extract-address-components | |
3810 | (mail-header-from h1)))) | |
3811 | (or (car extract) (cadr extract) "")) | |
3812 | (let ((extract (funcall | |
3813 | gnus-extract-address-components | |
3814 | (mail-header-from h2)))) | |
3815 | (or (car extract) (cadr extract) "")))) | |
3816 | ||
3817 | (defun gnus-thread-sort-by-author (h1 h2) | |
3818 | "Sort threads by root author." | |
3819 | (gnus-article-sort-by-author | |
3820 | (gnus-thread-header h1) (gnus-thread-header h2))) | |
3821 | ||
3822 | (defsubst gnus-article-sort-by-subject (h1 h2) | |
3823 | "Sort articles by root subject." | |
3824 | (string-lessp | |
3825 | (downcase (gnus-simplify-subject-re (mail-header-subject h1))) | |
3826 | (downcase (gnus-simplify-subject-re (mail-header-subject h2))))) | |
3827 | ||
3828 | (defun gnus-thread-sort-by-subject (h1 h2) | |
3829 | "Sort threads by root subject." | |
3830 | (gnus-article-sort-by-subject | |
3831 | (gnus-thread-header h1) (gnus-thread-header h2))) | |
3832 | ||
3833 | (defsubst gnus-article-sort-by-date (h1 h2) | |
3834 | "Sort articles by root article date." | |
16409b0b | 3835 | (time-less-p |
eec82323 LMI |
3836 | (gnus-date-get-time (mail-header-date h1)) |
3837 | (gnus-date-get-time (mail-header-date h2)))) | |
3838 | ||
3839 | (defun gnus-thread-sort-by-date (h1 h2) | |
3840 | "Sort threads by root article date." | |
3841 | (gnus-article-sort-by-date | |
3842 | (gnus-thread-header h1) (gnus-thread-header h2))) | |
3843 | ||
3844 | (defsubst gnus-article-sort-by-score (h1 h2) | |
3845 | "Sort articles by root article score. | |
3846 | Unscored articles will be counted as having a score of zero." | |
3847 | (> (or (cdr (assq (mail-header-number h1) | |
3848 | gnus-newsgroup-scored)) | |
3849 | gnus-summary-default-score 0) | |
3850 | (or (cdr (assq (mail-header-number h2) | |
3851 | gnus-newsgroup-scored)) | |
3852 | gnus-summary-default-score 0))) | |
3853 | ||
3854 | (defun gnus-thread-sort-by-score (h1 h2) | |
3855 | "Sort threads by root article score." | |
3856 | (gnus-article-sort-by-score | |
3857 | (gnus-thread-header h1) (gnus-thread-header h2))) | |
3858 | ||
3859 | (defun gnus-thread-sort-by-total-score (h1 h2) | |
3860 | "Sort threads by the sum of all scores in the thread. | |
3861 | Unscored articles will be counted as having a score of zero." | |
3862 | (> (gnus-thread-total-score h1) (gnus-thread-total-score h2))) | |
3863 | ||
3864 | (defun gnus-thread-total-score (thread) | |
16409b0b | 3865 | ;; This function find the total score of THREAD. |
eec82323 LMI |
3866 | (cond ((null thread) |
3867 | 0) | |
3868 | ((consp thread) | |
3869 | (if (stringp (car thread)) | |
3870 | (apply gnus-thread-score-function 0 | |
3871 | (mapcar 'gnus-thread-total-score-1 (cdr thread))) | |
3872 | (gnus-thread-total-score-1 thread))) | |
3873 | (t | |
3874 | (gnus-thread-total-score-1 (list thread))))) | |
3875 | ||
3876 | (defun gnus-thread-total-score-1 (root) | |
3877 | ;; This function find the total score of the thread below ROOT. | |
3878 | (setq root (car root)) | |
3879 | (apply gnus-thread-score-function | |
3880 | (or (append | |
3881 | (mapcar 'gnus-thread-total-score | |
6748645f | 3882 | (cdr (gnus-id-to-thread (mail-header-id root)))) |
eec82323 LMI |
3883 | (when (> (mail-header-number root) 0) |
3884 | (list (or (cdr (assq (mail-header-number root) | |
3885 | gnus-newsgroup-scored)) | |
3886 | gnus-summary-default-score 0)))) | |
3887 | (list gnus-summary-default-score) | |
3888 | '(0)))) | |
3889 | ||
3890 | ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>. | |
3891 | (defvar gnus-tmp-prev-subject nil) | |
3892 | (defvar gnus-tmp-false-parent nil) | |
3893 | (defvar gnus-tmp-root-expunged nil) | |
3894 | (defvar gnus-tmp-dummy-line nil) | |
3895 | ||
60bd5589 | 3896 | (eval-when-compile (defvar gnus-tmp-header)) |
16409b0b GM |
3897 | (defun gnus-extra-header (type &optional header) |
3898 | "Return the extra header of TYPE." | |
3899 | (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header)))) | |
3900 | "")) | |
3901 | ||
eec82323 LMI |
3902 | (defun gnus-summary-prepare-threads (threads) |
3903 | "Prepare summary buffer from THREADS and indentation LEVEL. | |
3904 | THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])' | |
3905 | or a straight list of headers." | |
3906 | (gnus-message 7 "Generating summary...") | |
3907 | ||
3908 | (setq gnus-newsgroup-threads threads) | |
3909 | (beginning-of-line) | |
3910 | ||
3911 | (let ((gnus-tmp-level 0) | |
3912 | (default-score (or gnus-summary-default-score 0)) | |
3913 | (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight)) | |
3914 | thread number subject stack state gnus-tmp-gathered beg-match | |
3915 | new-roots gnus-tmp-new-adopts thread-end | |
3916 | gnus-tmp-header gnus-tmp-unread | |
3917 | gnus-tmp-replied gnus-tmp-subject-or-nil | |
3918 | gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score | |
3919 | gnus-tmp-score-char gnus-tmp-from gnus-tmp-name | |
3920 | gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket) | |
3921 | ||
3922 | (setq gnus-tmp-prev-subject nil) | |
3923 | ||
3924 | (if (vectorp (car threads)) | |
3925 | ;; If this is a straight (sic) list of headers, then a | |
3926 | ;; threaded summary display isn't required, so we just create | |
3927 | ;; an unthreaded one. | |
3928 | (gnus-summary-prepare-unthreaded threads) | |
3929 | ||
3930 | ;; Do the threaded display. | |
3931 | ||
3932 | (while (or threads stack gnus-tmp-new-adopts new-roots) | |
3933 | ||
3934 | (if (and (= gnus-tmp-level 0) | |
eec82323 LMI |
3935 | (or (not stack) |
3936 | (= (caar stack) 0)) | |
3937 | (not gnus-tmp-false-parent) | |
3938 | (or gnus-tmp-new-adopts new-roots)) | |
3939 | (if gnus-tmp-new-adopts | |
3940 | (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1) | |
3941 | thread (list (car gnus-tmp-new-adopts)) | |
3942 | gnus-tmp-header (caar thread) | |
3943 | gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts)) | |
3944 | (when new-roots | |
3945 | (setq thread (list (car new-roots)) | |
3946 | gnus-tmp-header (caar thread) | |
3947 | new-roots (cdr new-roots)))) | |
3948 | ||
3949 | (if threads | |
3950 | ;; If there are some threads, we do them before the | |
3951 | ;; threads on the stack. | |
3952 | (setq thread threads | |
3953 | gnus-tmp-header (caar thread)) | |
3954 | ;; There were no current threads, so we pop something off | |
3955 | ;; the stack. | |
3956 | (setq state (car stack) | |
3957 | gnus-tmp-level (car state) | |
3958 | thread (cdr state) | |
3959 | stack (cdr stack) | |
3960 | gnus-tmp-header (caar thread)))) | |
3961 | ||
3962 | (setq gnus-tmp-false-parent nil) | |
3963 | (setq gnus-tmp-root-expunged nil) | |
3964 | (setq thread-end nil) | |
3965 | ||
3966 | (if (stringp gnus-tmp-header) | |
3967 | ;; The header is a dummy root. | |
3968 | (cond | |
3969 | ((eq gnus-summary-make-false-root 'adopt) | |
3970 | ;; We let the first article adopt the rest. | |
3971 | (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts | |
3972 | (cddar thread))) | |
3973 | (setq gnus-tmp-gathered | |
3974 | (nconc (mapcar | |
3975 | (lambda (h) (mail-header-number (car h))) | |
3976 | (cddar thread)) | |
3977 | gnus-tmp-gathered)) | |
3978 | (setq thread (cons (list (caar thread) | |
3979 | (cadar thread)) | |
3980 | (cdr thread))) | |
3981 | (setq gnus-tmp-level -1 | |
3982 | gnus-tmp-false-parent t)) | |
3983 | ((eq gnus-summary-make-false-root 'empty) | |
3984 | ;; We print adopted articles with empty subject fields. | |
3985 | (setq gnus-tmp-gathered | |
3986 | (nconc (mapcar | |
3987 | (lambda (h) (mail-header-number (car h))) | |
3988 | (cddar thread)) | |
3989 | gnus-tmp-gathered)) | |
3990 | (setq gnus-tmp-level -1)) | |
3991 | ((eq gnus-summary-make-false-root 'dummy) | |
3992 | ;; We remember that we probably want to output a dummy | |
3993 | ;; root. | |
3994 | (setq gnus-tmp-dummy-line gnus-tmp-header) | |
3995 | (setq gnus-tmp-prev-subject gnus-tmp-header)) | |
3996 | (t | |
3997 | ;; We do not make a root for the gathered | |
3998 | ;; sub-threads at all. | |
3999 | (setq gnus-tmp-level -1))) | |
4000 | ||
4001 | (setq number (mail-header-number gnus-tmp-header) | |
4002 | subject (mail-header-subject gnus-tmp-header)) | |
4003 | ||
4004 | (cond | |
4005 | ;; If the thread has changed subject, we might want to make | |
4006 | ;; this subthread into a root. | |
4007 | ((and (null gnus-thread-ignore-subject) | |
4008 | (not (zerop gnus-tmp-level)) | |
4009 | gnus-tmp-prev-subject | |
4010 | (not (inline | |
4011 | (gnus-subject-equal gnus-tmp-prev-subject subject)))) | |
4012 | (setq new-roots (nconc new-roots (list (car thread))) | |
4013 | thread-end t | |
4014 | gnus-tmp-header nil)) | |
4015 | ;; If the article lies outside the current limit, | |
4016 | ;; then we do not display it. | |
4017 | ((not (memq number gnus-newsgroup-limit)) | |
4018 | (setq gnus-tmp-gathered | |
4019 | (nconc (mapcar | |
4020 | (lambda (h) (mail-header-number (car h))) | |
4021 | (cdar thread)) | |
4022 | gnus-tmp-gathered)) | |
4023 | (setq gnus-tmp-new-adopts (if (cdar thread) | |
4024 | (append gnus-tmp-new-adopts | |
4025 | (cdar thread)) | |
4026 | gnus-tmp-new-adopts) | |
4027 | thread-end t | |
4028 | gnus-tmp-header nil) | |
4029 | (when (zerop gnus-tmp-level) | |
4030 | (setq gnus-tmp-root-expunged t))) | |
4031 | ;; Perhaps this article is to be marked as read? | |
4032 | ((and gnus-summary-mark-below | |
4033 | (< (or (cdr (assq number gnus-newsgroup-scored)) | |
4034 | default-score) | |
4035 | gnus-summary-mark-below) | |
4036 | ;; Don't touch sparse articles. | |
4037 | (not (gnus-summary-article-sparse-p number)) | |
4038 | (not (gnus-summary-article-ancient-p number))) | |
4039 | (setq gnus-newsgroup-unreads | |
4040 | (delq number gnus-newsgroup-unreads)) | |
4041 | (if gnus-newsgroup-auto-expire | |
4042 | (push number gnus-newsgroup-expirable) | |
4043 | (push (cons number gnus-low-score-mark) | |
4044 | gnus-newsgroup-reads)))) | |
4045 | ||
4046 | (when gnus-tmp-header | |
4047 | ;; We may have an old dummy line to output before this | |
4048 | ;; article. | |
6748645f LMI |
4049 | (when (and gnus-tmp-dummy-line |
4050 | (gnus-subject-equal | |
4051 | gnus-tmp-dummy-line | |
4052 | (mail-header-subject gnus-tmp-header))) | |
eec82323 LMI |
4053 | (gnus-summary-insert-dummy-line |
4054 | gnus-tmp-dummy-line (mail-header-number gnus-tmp-header)) | |
4055 | (setq gnus-tmp-dummy-line nil)) | |
4056 | ||
4057 | ;; Compute the mark. | |
4058 | (setq gnus-tmp-unread (gnus-article-mark number)) | |
4059 | ||
4060 | (push (gnus-data-make number gnus-tmp-unread (1+ (point)) | |
4061 | gnus-tmp-header gnus-tmp-level) | |
4062 | gnus-newsgroup-data) | |
4063 | ||
4064 | ;; Actually insert the line. | |
4065 | (setq | |
4066 | gnus-tmp-subject-or-nil | |
4067 | (cond | |
4068 | ((and gnus-thread-ignore-subject | |
4069 | gnus-tmp-prev-subject | |
4070 | (not (inline (gnus-subject-equal | |
4071 | gnus-tmp-prev-subject subject)))) | |
4072 | subject) | |
4073 | ((zerop gnus-tmp-level) | |
4074 | (if (and (eq gnus-summary-make-false-root 'empty) | |
4075 | (memq number gnus-tmp-gathered) | |
4076 | gnus-tmp-prev-subject | |
4077 | (inline (gnus-subject-equal | |
4078 | gnus-tmp-prev-subject subject))) | |
4079 | gnus-summary-same-subject | |
4080 | subject)) | |
4081 | (t gnus-summary-same-subject))) | |
4082 | (if (and (eq gnus-summary-make-false-root 'adopt) | |
4083 | (= gnus-tmp-level 1) | |
4084 | (memq number gnus-tmp-gathered)) | |
4085 | (setq gnus-tmp-opening-bracket ?\< | |
4086 | gnus-tmp-closing-bracket ?\>) | |
4087 | (setq gnus-tmp-opening-bracket ?\[ | |
4088 | gnus-tmp-closing-bracket ?\])) | |
4089 | (setq | |
4090 | gnus-tmp-indentation | |
4091 | (aref gnus-thread-indent-array gnus-tmp-level) | |
4092 | gnus-tmp-lines (mail-header-lines gnus-tmp-header) | |
4093 | gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored)) | |
4094 | gnus-summary-default-score 0) | |
4095 | gnus-tmp-score-char | |
4096 | (if (or (null gnus-summary-default-score) | |
4097 | (<= (abs (- gnus-tmp-score gnus-summary-default-score)) | |
4098 | gnus-summary-zcore-fuzz)) | |
16409b0b | 4099 | ? ;Whitespace |
eec82323 LMI |
4100 | (if (< gnus-tmp-score gnus-summary-default-score) |
4101 | gnus-score-below-mark gnus-score-over-mark)) | |
4102 | gnus-tmp-replied | |
4103 | (cond ((memq number gnus-newsgroup-processable) | |
4104 | gnus-process-mark) | |
4105 | ((memq number gnus-newsgroup-cached) | |
4106 | gnus-cached-mark) | |
4107 | ((memq number gnus-newsgroup-replied) | |
4108 | gnus-replied-mark) | |
4109 | ((memq number gnus-newsgroup-saved) | |
4110 | gnus-saved-mark) | |
4111 | (t gnus-unread-mark)) | |
4112 | gnus-tmp-from (mail-header-from gnus-tmp-header) | |
4113 | gnus-tmp-name | |
4114 | (cond | |
4115 | ((string-match "<[^>]+> *$" gnus-tmp-from) | |
4116 | (setq beg-match (match-beginning 0)) | |
4117 | (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from) | |
4118 | (substring gnus-tmp-from (1+ (match-beginning 0)) | |
4119 | (1- (match-end 0)))) | |
4120 | (substring gnus-tmp-from 0 beg-match))) | |
4121 | ((string-match "(.+)" gnus-tmp-from) | |
4122 | (substring gnus-tmp-from | |
4123 | (1+ (match-beginning 0)) (1- (match-end 0)))) | |
4124 | (t gnus-tmp-from))) | |
4125 | (when (string= gnus-tmp-name "") | |
4126 | (setq gnus-tmp-name gnus-tmp-from)) | |
4127 | (unless (numberp gnus-tmp-lines) | |
4128 | (setq gnus-tmp-lines 0)) | |
16409b0b | 4129 | (gnus-put-text-property |
eec82323 LMI |
4130 | (point) |
4131 | (progn (eval gnus-summary-line-format-spec) (point)) | |
4132 | 'gnus-number number) | |
4133 | (when gnus-visual-p | |
4134 | (forward-line -1) | |
6748645f | 4135 | (gnus-run-hooks 'gnus-summary-update-hook) |
eec82323 LMI |
4136 | (forward-line 1)) |
4137 | ||
4138 | (setq gnus-tmp-prev-subject subject))) | |
4139 | ||
4140 | (when (nth 1 thread) | |
4141 | (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack)) | |
4142 | (incf gnus-tmp-level) | |
4143 | (setq threads (if thread-end nil (cdar thread))) | |
4144 | (unless threads | |
4145 | (setq gnus-tmp-level 0))))) | |
4146 | (gnus-message 7 "Generating summary...done")) | |
4147 | ||
4148 | (defun gnus-summary-prepare-unthreaded (headers) | |
4149 | "Generate an unthreaded summary buffer based on HEADERS." | |
4150 | (let (header number mark) | |
4151 | ||
4152 | (beginning-of-line) | |
4153 | ||
4154 | (while headers | |
4155 | ;; We may have to root out some bad articles... | |
4156 | (when (memq (setq number (mail-header-number | |
4157 | (setq header (pop headers)))) | |
4158 | gnus-newsgroup-limit) | |
4159 | ;; Mark article as read when it has a low score. | |
4160 | (when (and gnus-summary-mark-below | |
4161 | (< (or (cdr (assq number gnus-newsgroup-scored)) | |
4162 | gnus-summary-default-score 0) | |
4163 | gnus-summary-mark-below) | |
4164 | (not (gnus-summary-article-ancient-p number))) | |
4165 | (setq gnus-newsgroup-unreads | |
4166 | (delq number gnus-newsgroup-unreads)) | |
4167 | (if gnus-newsgroup-auto-expire | |
4168 | (push number gnus-newsgroup-expirable) | |
4169 | (push (cons number gnus-low-score-mark) | |
4170 | gnus-newsgroup-reads))) | |
4171 | ||
4172 | (setq mark (gnus-article-mark number)) | |
4173 | (push (gnus-data-make number mark (1+ (point)) header 0) | |
4174 | gnus-newsgroup-data) | |
4175 | (gnus-summary-insert-line | |
4176 | header 0 number | |
4177 | mark (memq number gnus-newsgroup-replied) | |
4178 | (memq number gnus-newsgroup-expirable) | |
4179 | (mail-header-subject header) nil | |
4180 | (cdr (assq number gnus-newsgroup-scored)) | |
4181 | (memq number gnus-newsgroup-processable)))))) | |
4182 | ||
16409b0b GM |
4183 | (defun gnus-summary-remove-list-identifiers () |
4184 | "Remove list identifiers in `gnus-list-identifiers' from articles in the current group." | |
4185 | (let ((regexp (if (stringp gnus-list-identifiers) | |
4186 | gnus-list-identifiers | |
4187 | (mapconcat 'identity gnus-list-identifiers " *\\|")))) | |
4188 | (dolist (header gnus-newsgroup-headers) | |
4189 | (when (string-match (concat "\\(\\(\\(Re: +\\)?\\(" regexp | |
4190 | " *\\)\\)+\\(Re: +\\)?\\)") | |
4191 | (mail-header-subject header)) | |
4192 | (mail-header-set-subject | |
4193 | header (concat (substring (mail-header-subject header) | |
4194 | 0 (match-beginning 1)) | |
4195 | (or | |
4196 | (match-string 3 (mail-header-subject header)) | |
4197 | (match-string 5 (mail-header-subject header))) | |
4198 | (substring (mail-header-subject header) | |
4199 | (match-end 1)))))))) | |
4200 | ||
6748645f | 4201 | (defun gnus-select-newsgroup (group &optional read-all select-articles) |
eec82323 | 4202 | "Select newsgroup GROUP. |
6748645f LMI |
4203 | If READ-ALL is non-nil, all articles in the group are selected. |
4204 | If SELECT-ARTICLES, only select those articles from GROUP." | |
eec82323 LMI |
4205 | (let* ((entry (gnus-gethash group gnus-newsrc-hashtb)) |
4206 | ;;!!! Dirty hack; should be removed. | |
4207 | (gnus-summary-ignore-duplicates | |
6748645f | 4208 | (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual) |
eec82323 LMI |
4209 | t |
4210 | gnus-summary-ignore-duplicates)) | |
4211 | (info (nth 2 entry)) | |
4212 | articles fetched-articles cached) | |
4213 | ||
4214 | (unless (gnus-check-server | |
4215 | (setq gnus-current-select-method | |
4216 | (gnus-find-method-for-group group))) | |
4217 | (error "Couldn't open server")) | |
4218 | ||
4219 | (or (and entry (not (eq (car entry) t))) ; Either it's active... | |
4220 | (gnus-activate-group group) ; Or we can activate it... | |
4221 | (progn ; Or we bug out. | |
4222 | (when (equal major-mode 'gnus-summary-mode) | |
4223 | (kill-buffer (current-buffer))) | |
4224 | (error "Couldn't request group %s: %s" | |
4225 | group (gnus-status-message group)))) | |
4226 | ||
4227 | (unless (gnus-request-group group t) | |
4228 | (when (equal major-mode 'gnus-summary-mode) | |
4229 | (kill-buffer (current-buffer))) | |
4230 | (error "Couldn't request group %s: %s" | |
4231 | group (gnus-status-message group))) | |
4232 | ||
4233 | (setq gnus-newsgroup-name group) | |
4234 | (setq gnus-newsgroup-unselected nil) | |
4235 | (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group)) | |
16409b0b | 4236 | (gnus-summary-setup-default-charset) |
eec82323 LMI |
4237 | |
4238 | ;; Adjust and set lists of article marks. | |
4239 | (when info | |
4240 | (gnus-adjust-marked-articles info)) | |
4241 | ||
4242 | ;; Kludge to avoid having cached articles nixed out in virtual groups. | |
4243 | (when (gnus-virtual-group-p group) | |
4244 | (setq cached gnus-newsgroup-cached)) | |
4245 | ||
4246 | (setq gnus-newsgroup-unreads | |
4247 | (gnus-set-difference | |
4248 | (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked) | |
4249 | gnus-newsgroup-dormant)) | |
4250 | ||
4251 | (setq gnus-newsgroup-processable nil) | |
4252 | ||
4253 | (gnus-update-read-articles group gnus-newsgroup-unreads) | |
eec82323 | 4254 | |
6748645f LMI |
4255 | (if (setq articles select-articles) |
4256 | (setq gnus-newsgroup-unselected | |
4257 | (gnus-sorted-intersection | |
4258 | gnus-newsgroup-unreads | |
4259 | (gnus-sorted-complement gnus-newsgroup-unreads articles))) | |
4260 | (setq articles (gnus-articles-to-read group read-all))) | |
eec82323 LMI |
4261 | |
4262 | (cond | |
4263 | ((null articles) | |
4264 | ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display") | |
4265 | 'quit) | |
4266 | ((eq articles 0) nil) | |
4267 | (t | |
4268 | ;; Init the dependencies hash table. | |
4269 | (setq gnus-newsgroup-dependencies | |
4270 | (gnus-make-hashtable (length articles))) | |
16409b0b | 4271 | (gnus-set-global-variables) |
eec82323 LMI |
4272 | ;; Retrieve the headers and read them in. |
4273 | (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name) | |
4274 | (setq gnus-newsgroup-headers | |
4275 | (if (eq 'nov | |
4276 | (setq gnus-headers-retrieved-by | |
4277 | (gnus-retrieve-headers | |
4278 | articles gnus-newsgroup-name | |
4279 | ;; We might want to fetch old headers, but | |
4280 | ;; not if there is only 1 article. | |
6748645f | 4281 | (and (or (and |
eec82323 LMI |
4282 | (not (eq gnus-fetch-old-headers 'some)) |
4283 | (not (numberp gnus-fetch-old-headers))) | |
6748645f LMI |
4284 | (> (length articles) 1)) |
4285 | gnus-fetch-old-headers)))) | |
eec82323 LMI |
4286 | (gnus-get-newsgroup-headers-xover |
4287 | articles nil nil gnus-newsgroup-name t) | |
4288 | (gnus-get-newsgroup-headers))) | |
4289 | (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name) | |
4290 | ||
4291 | ;; Kludge to avoid having cached articles nixed out in virtual groups. | |
4292 | (when cached | |
4293 | (setq gnus-newsgroup-cached cached)) | |
4294 | ||
4295 | ;; Suppress duplicates? | |
4296 | (when gnus-suppress-duplicates | |
4297 | (gnus-dup-suppress-articles)) | |
4298 | ||
4299 | ;; Set the initial limit. | |
4300 | (setq gnus-newsgroup-limit (copy-sequence articles)) | |
4301 | ;; Remove canceled articles from the list of unread articles. | |
4302 | (setq gnus-newsgroup-unreads | |
4303 | (gnus-set-sorted-intersection | |
4304 | gnus-newsgroup-unreads | |
4305 | (setq fetched-articles | |
4306 | (mapcar (lambda (headers) (mail-header-number headers)) | |
4307 | gnus-newsgroup-headers)))) | |
4308 | ;; Removed marked articles that do not exist. | |
4309 | (gnus-update-missing-marks | |
4310 | (gnus-sorted-complement fetched-articles articles)) | |
4311 | ;; We might want to build some more threads first. | |
6748645f LMI |
4312 | (when (and gnus-fetch-old-headers |
4313 | (eq gnus-headers-retrieved-by 'nov)) | |
4314 | (if (eq gnus-fetch-old-headers 'invisible) | |
4315 | (gnus-build-all-threads) | |
4316 | (gnus-build-old-threads))) | |
4317 | ;; Let the Gnus agent mark articles as read. | |
4318 | (when gnus-agent | |
4319 | (gnus-agent-get-undownloaded-list)) | |
16409b0b GM |
4320 | ;; Remove list identifiers from subject |
4321 | (when gnus-list-identifiers | |
4322 | (gnus-summary-remove-list-identifiers)) | |
eec82323 LMI |
4323 | ;; Check whether auto-expire is to be done in this group. |
4324 | (setq gnus-newsgroup-auto-expire | |
4325 | (gnus-group-auto-expirable-p group)) | |
4326 | ;; Set up the article buffer now, if necessary. | |
4327 | (unless gnus-single-article-buffer | |
4328 | (gnus-article-setup-buffer)) | |
4329 | ;; First and last article in this newsgroup. | |
4330 | (when gnus-newsgroup-headers | |
4331 | (setq gnus-newsgroup-begin | |
4332 | (mail-header-number (car gnus-newsgroup-headers)) | |
4333 | gnus-newsgroup-end | |
4334 | (mail-header-number | |
4335 | (gnus-last-element gnus-newsgroup-headers)))) | |
4336 | ;; GROUP is successfully selected. | |
4337 | (or gnus-newsgroup-headers t))))) | |
4338 | ||
4339 | (defun gnus-articles-to-read (group &optional read-all) | |
16409b0b | 4340 | "Find out what articles the user wants to read." |
eec82323 LMI |
4341 | (let* ((articles |
4342 | ;; Select all articles if `read-all' is non-nil, or if there | |
4343 | ;; are no unread articles. | |
4344 | (if (or read-all | |
4345 | (and (zerop (length gnus-newsgroup-marked)) | |
4346 | (zerop (length gnus-newsgroup-unreads))) | |
4347 | (eq (gnus-group-find-parameter group 'display) | |
4348 | 'all)) | |
16409b0b GM |
4349 | (or |
4350 | (gnus-uncompress-range (gnus-active group)) | |
4351 | (gnus-cache-articles-in-group group)) | |
eec82323 LMI |
4352 | (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked |
4353 | (copy-sequence gnus-newsgroup-unreads)) | |
4354 | '<))) | |
4355 | (scored-list (gnus-killed-articles gnus-newsgroup-killed articles)) | |
4356 | (scored (length scored-list)) | |
4357 | (number (length articles)) | |
4358 | (marked (+ (length gnus-newsgroup-marked) | |
4359 | (length gnus-newsgroup-dormant))) | |
4360 | (select | |
4361 | (cond | |
4362 | ((numberp read-all) | |
4363 | read-all) | |
4364 | (t | |
4365 | (condition-case () | |
4366 | (cond | |
4367 | ((and (or (<= scored marked) (= scored number)) | |
4368 | (numberp gnus-large-newsgroup) | |
4369 | (> number gnus-large-newsgroup)) | |
4370 | (let ((input | |
4371 | (read-string | |
4372 | (format | |
4373 | "How many articles from %s (default %d): " | |
4374 | (gnus-limit-string gnus-newsgroup-name 35) | |
4375 | number)))) | |
4376 | (if (string-match "^[ \t]*$" input) number input))) | |
4377 | ((and (> scored marked) (< scored number) | |
4378 | (> (- scored number) 20)) | |
4379 | (let ((input | |
4380 | (read-string | |
4381 | (format "%s %s (%d scored, %d total): " | |
4382 | "How many articles from" | |
4383 | group scored number)))) | |
4384 | (if (string-match "^[ \t]*$" input) | |
4385 | number input))) | |
4386 | (t number)) | |
d4dfaa19 DL |
4387 | (quit |
4388 | (message "Quit getting the articles to read") | |
4389 | nil)))))) | |
eec82323 LMI |
4390 | (setq select (if (stringp select) (string-to-number select) select)) |
4391 | (if (or (null select) (zerop select)) | |
4392 | select | |
4393 | (if (and (not (zerop scored)) (<= (abs select) scored)) | |
4394 | (progn | |
4395 | (setq articles (sort scored-list '<)) | |
4396 | (setq number (length articles))) | |
4397 | (setq articles (copy-sequence articles))) | |
4398 | ||
4399 | (when (< (abs select) number) | |
4400 | (if (< select 0) | |
4401 | ;; Select the N oldest articles. | |
4402 | (setcdr (nthcdr (1- (abs select)) articles) nil) | |
4403 | ;; Select the N most recent articles. | |
4404 | (setq articles (nthcdr (- number select) articles)))) | |
4405 | (setq gnus-newsgroup-unselected | |
4406 | (gnus-sorted-intersection | |
4407 | gnus-newsgroup-unreads | |
4408 | (gnus-sorted-complement gnus-newsgroup-unreads articles))) | |
16409b0b GM |
4409 | (when gnus-alter-articles-to-read-function |
4410 | (setq gnus-newsgroup-unreads | |
4411 | (sort | |
4412 | (funcall gnus-alter-articles-to-read-function | |
4413 | gnus-newsgroup-name gnus-newsgroup-unreads) | |
4414 | '<))) | |
eec82323 LMI |
4415 | articles))) |
4416 | ||
4417 | (defun gnus-killed-articles (killed articles) | |
4418 | (let (out) | |
4419 | (while articles | |
4420 | (when (inline (gnus-member-of-range (car articles) killed)) | |
4421 | (push (car articles) out)) | |
4422 | (setq articles (cdr articles))) | |
4423 | out)) | |
4424 | ||
4425 | (defun gnus-uncompress-marks (marks) | |
4426 | "Uncompress the mark ranges in MARKS." | |
4427 | (let ((uncompressed '(score bookmark)) | |
4428 | out) | |
4429 | (while marks | |
4430 | (if (memq (caar marks) uncompressed) | |
4431 | (push (car marks) out) | |
4432 | (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out)) | |
4433 | (setq marks (cdr marks))) | |
4434 | out)) | |
4435 | ||
4436 | (defun gnus-adjust-marked-articles (info) | |
16409b0b | 4437 | "Set all article lists and remove all marks that are no longer valid." |
eec82323 LMI |
4438 | (let* ((marked-lists (gnus-info-marks info)) |
4439 | (active (gnus-active (gnus-info-group info))) | |
4440 | (min (car active)) | |
4441 | (max (cdr active)) | |
4442 | (types gnus-article-mark-lists) | |
4443 | (uncompressed '(score bookmark killed)) | |
4444 | marks var articles article mark) | |
4445 | ||
4446 | (while marked-lists | |
4447 | (setq marks (pop marked-lists)) | |
4448 | (set (setq var (intern (format "gnus-newsgroup-%s" | |
4449 | (car (rassq (setq mark (car marks)) | |
4450 | types))))) | |
4451 | (if (memq (car marks) uncompressed) (cdr marks) | |
4452 | (gnus-uncompress-range (cdr marks)))) | |
4453 | ||
4454 | (setq articles (symbol-value var)) | |
4455 | ||
4456 | ;; All articles have to be subsets of the active articles. | |
4457 | (cond | |
4458 | ;; Adjust "simple" lists. | |
4459 | ((memq mark '(tick dormant expire reply save)) | |
4460 | (while articles | |
4461 | (when (or (< (setq article (pop articles)) min) (> article max)) | |
4462 | (set var (delq article (symbol-value var)))))) | |
4463 | ;; Adjust assocs. | |
4464 | ((memq mark uncompressed) | |
a8151ef7 LMI |
4465 | (when (not (listp (cdr (symbol-value var)))) |
4466 | (set var (list (symbol-value var)))) | |
4467 | (when (not (listp (cdr articles))) | |
4468 | (setq articles (list articles))) | |
eec82323 LMI |
4469 | (while articles |
4470 | (when (or (not (consp (setq article (pop articles)))) | |
4471 | (< (car article) min) | |
4472 | (> (car article) max)) | |
4473 | (set var (delq article (symbol-value var)))))))))) | |
4474 | ||
4475 | (defun gnus-update-missing-marks (missing) | |
6748645f | 4476 | "Go through the list of MISSING articles and remove them from the mark lists." |
eec82323 LMI |
4477 | (when missing |
4478 | (let ((types gnus-article-mark-lists) | |
4479 | var m) | |
4480 | ;; Go through all types. | |
4481 | (while types | |
4482 | (setq var (intern (format "gnus-newsgroup-%s" (car (pop types))))) | |
4483 | (when (symbol-value var) | |
4484 | ;; This list has articles. So we delete all missing articles | |
4485 | ;; from it. | |
4486 | (setq m missing) | |
4487 | (while m | |
4488 | (set var (delq (pop m) (symbol-value var))))))))) | |
4489 | ||
4490 | (defun gnus-update-marks () | |
4491 | "Enter the various lists of marked articles into the newsgroup info list." | |
4492 | (let ((types gnus-article-mark-lists) | |
4493 | (info (gnus-get-info gnus-newsgroup-name)) | |
4494 | (uncompressed '(score bookmark killed)) | |
16409b0b | 4495 | type list newmarked symbol delta-marks) |
eec82323 | 4496 | (when info |
16409b0b | 4497 | ;; Add all marks lists to the list of marks lists. |
eec82323 | 4498 | (while (setq type (pop types)) |
16409b0b GM |
4499 | (setq list (symbol-value |
4500 | (setq symbol | |
4501 | (intern (format "gnus-newsgroup-%s" | |
4502 | (car type)))))) | |
eec82323 | 4503 | |
16409b0b | 4504 | (when list |
eec82323 LMI |
4505 | ;; Get rid of the entries of the articles that have the |
4506 | ;; default score. | |
4507 | (when (and (eq (cdr type) 'score) | |
4508 | gnus-save-score | |
4509 | list) | |
4510 | (let* ((arts list) | |
4511 | (prev (cons nil list)) | |
4512 | (all prev)) | |
4513 | (while arts | |
4514 | (if (or (not (consp (car arts))) | |
4515 | (= (cdar arts) gnus-summary-default-score)) | |
4516 | (setcdr prev (cdr arts)) | |
4517 | (setq prev arts)) | |
4518 | (setq arts (cdr arts))) | |
16409b0b GM |
4519 | (setq list (cdr all))))) |
4520 | ||
4521 | (unless (memq (cdr type) uncompressed) | |
4522 | (setq list (gnus-compress-sequence (set symbol (sort list '<)) t))) | |
4523 | ||
4524 | (when (gnus-check-backend-function | |
4525 | 'request-set-mark gnus-newsgroup-name) | |
4526 | ;; propagate flags to server, with the following exceptions: | |
4527 | ;; uncompressed:s are not proper flags (they are cons cells) | |
4528 | ;; cache is a internal gnus flag | |
4529 | ;; download are local to one gnus installation (well) | |
4530 | ;; unsend are for nndraft groups only | |
4531 | ;; xxx: generality of this? this suits nnimap anyway | |
4532 | (unless (memq (cdr type) (append '(cache download unsend) | |
4533 | uncompressed)) | |
4534 | (let* ((old (cdr (assq (cdr type) (gnus-info-marks info)))) | |
4535 | (del (gnus-remove-from-range (gnus-copy-sequence old) list)) | |
4536 | (add (gnus-remove-from-range | |
4537 | (gnus-copy-sequence list) old))) | |
4538 | (when add | |
4539 | (push (list add 'add (list (cdr type))) delta-marks)) | |
4540 | (when del | |
4541 | (push (list del 'del (list (cdr type))) delta-marks))))) | |
4542 | ||
4543 | (when list | |
4544 | (push (cons (cdr type) list) newmarked))) | |
4545 | ||
4546 | (when delta-marks | |
4547 | (unless (gnus-check-group gnus-newsgroup-name) | |
4548 | (error "Can't open server for %s" gnus-newsgroup-name)) | |
4549 | (gnus-request-set-mark gnus-newsgroup-name delta-marks)) | |
4550 | ||
eec82323 LMI |
4551 | ;; Enter these new marks into the info of the group. |
4552 | (if (nthcdr 3 info) | |
4553 | (setcar (nthcdr 3 info) newmarked) | |
4554 | ;; Add the marks lists to the end of the info. | |
4555 | (when newmarked | |
4556 | (setcdr (nthcdr 2 info) (list newmarked)))) | |
4557 | ||
4558 | ;; Cut off the end of the info if there's nothing else there. | |
4559 | (let ((i 5)) | |
4560 | (while (and (> i 2) | |
4561 | (not (nth i info))) | |
4562 | (when (nthcdr (decf i) info) | |
4563 | (setcdr (nthcdr i info) nil))))))) | |
4564 | ||
4565 | (defun gnus-set-mode-line (where) | |
16409b0b | 4566 | "Set the mode line of the article or summary buffers. |
eec82323 LMI |
4567 | If WHERE is `summary', the summary mode line format will be used." |
4568 | ;; Is this mode line one we keep updated? | |
16409b0b GM |
4569 | (when (and (memq where gnus-updated-mode-lines) |
4570 | (symbol-value | |
4571 | (intern (format "gnus-%s-mode-line-format-spec" where)))) | |
eec82323 LMI |
4572 | (let (mode-string) |
4573 | (save-excursion | |
4574 | ;; We evaluate this in the summary buffer since these | |
4575 | ;; variables are buffer-local to that buffer. | |
4576 | (set-buffer gnus-summary-buffer) | |
4577 | ;; We bind all these variables that are used in the `eval' form | |
4578 | ;; below. | |
4579 | (let* ((mformat (symbol-value | |
4580 | (intern | |
4581 | (format "gnus-%s-mode-line-format-spec" where)))) | |
16409b0b GM |
4582 | (gnus-tmp-group-name (gnus-group-name-decode |
4583 | gnus-newsgroup-name | |
4584 | (gnus-group-name-charset | |
4585 | nil | |
4586 | gnus-newsgroup-name))) | |
eec82323 LMI |
4587 | (gnus-tmp-article-number (or gnus-current-article 0)) |
4588 | (gnus-tmp-unread gnus-newsgroup-unreads) | |
4589 | (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads)) | |
4590 | (gnus-tmp-unselected (length gnus-newsgroup-unselected)) | |
4591 | (gnus-tmp-unread-and-unselected | |
4592 | (cond ((and (zerop gnus-tmp-unread-and-unticked) | |
4593 | (zerop gnus-tmp-unselected)) | |
4594 | "") | |
4595 | ((zerop gnus-tmp-unselected) | |
4596 | (format "{%d more}" gnus-tmp-unread-and-unticked)) | |
4597 | (t (format "{%d(+%d) more}" | |
4598 | gnus-tmp-unread-and-unticked | |
4599 | gnus-tmp-unselected)))) | |
4600 | (gnus-tmp-subject | |
4601 | (if (and gnus-current-headers | |
4602 | (vectorp gnus-current-headers)) | |
4603 | (gnus-mode-string-quote | |
4604 | (mail-header-subject gnus-current-headers)) | |
4605 | "")) | |
4606 | bufname-length max-len | |
4607 | gnus-tmp-header);; passed as argument to any user-format-funcs | |
4608 | (setq mode-string (eval mformat)) | |
4609 | (setq bufname-length (if (string-match "%b" mode-string) | |
4610 | (- (length | |
4611 | (buffer-name | |
4612 | (if (eq where 'summary) | |
4613 | nil | |
4614 | (get-buffer gnus-article-buffer)))) | |
4615 | 2) | |
4616 | 0)) | |
4617 | (setq max-len (max 4 (if gnus-mode-non-string-length | |
4618 | (- (window-width) | |
4619 | gnus-mode-non-string-length | |
4620 | bufname-length) | |
4621 | (length mode-string)))) | |
4622 | ;; We might have to chop a bit of the string off... | |
4623 | (when (> (length mode-string) max-len) | |
4624 | (setq mode-string | |
16409b0b | 4625 | (concat (truncate-string-to-width mode-string (- max-len 3)) |
eec82323 LMI |
4626 | "..."))) |
4627 | ;; Pad the mode string a bit. | |
4628 | (setq mode-string (format (format "%%-%ds" max-len) mode-string)))) | |
4629 | ;; Update the mode line. | |
4630 | (setq mode-line-buffer-identification | |
4631 | (gnus-mode-line-buffer-identification (list mode-string))) | |
4632 | (set-buffer-modified-p t)))) | |
4633 | ||
4634 | (defun gnus-create-xref-hashtb (from-newsgroup headers unreads) | |
4635 | "Go through the HEADERS list and add all Xrefs to a hash table. | |
4636 | The resulting hash table is returned, or nil if no Xrefs were found." | |
4637 | (let* ((virtual (gnus-virtual-group-p from-newsgroup)) | |
4638 | (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup))) | |
4639 | (xref-hashtb (gnus-make-hashtable)) | |
4640 | start group entry number xrefs header) | |
4641 | (while headers | |
4642 | (setq header (pop headers)) | |
4643 | (when (and (setq xrefs (mail-header-xref header)) | |
4644 | (not (memq (setq number (mail-header-number header)) | |
4645 | unreads))) | |
4646 | (setq start 0) | |
4647 | (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start) | |
4648 | (setq start (match-end 0)) | |
4649 | (setq group (if prefix | |
4650 | (concat prefix (substring xrefs (match-beginning 1) | |
4651 | (match-end 1))) | |
4652 | (substring xrefs (match-beginning 1) (match-end 1)))) | |
4653 | (setq number | |
4654 | (string-to-int (substring xrefs (match-beginning 2) | |
4655 | (match-end 2)))) | |
4656 | (if (setq entry (gnus-gethash group xref-hashtb)) | |
4657 | (setcdr entry (cons number (cdr entry))) | |
4658 | (gnus-sethash group (cons number nil) xref-hashtb))))) | |
4659 | (and start xref-hashtb))) | |
4660 | ||
4661 | (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads) | |
4662 | "Look through all the headers and mark the Xrefs as read." | |
4663 | (let ((virtual (gnus-virtual-group-p from-newsgroup)) | |
4664 | name entry info xref-hashtb idlist method nth4) | |
4665 | (save-excursion | |
4666 | (set-buffer gnus-group-buffer) | |
4667 | (when (setq xref-hashtb | |
4668 | (gnus-create-xref-hashtb from-newsgroup headers unreads)) | |
4669 | (mapatoms | |
4670 | (lambda (group) | |
4671 | (unless (string= from-newsgroup (setq name (symbol-name group))) | |
4672 | (setq idlist (symbol-value group)) | |
4673 | ;; Dead groups are not updated. | |
4674 | (and (prog1 | |
4675 | (setq entry (gnus-gethash name gnus-newsrc-hashtb) | |
4676 | info (nth 2 entry)) | |
4677 | (when (stringp (setq nth4 (gnus-info-method info))) | |
4678 | (setq nth4 (gnus-server-to-method nth4)))) | |
4679 | ;; Only do the xrefs if the group has the same | |
4680 | ;; select method as the group we have just read. | |
4681 | (or (gnus-methods-equal-p | |
4682 | nth4 (gnus-find-method-for-group from-newsgroup)) | |
4683 | virtual | |
4684 | (equal nth4 (setq method (gnus-find-method-for-group | |
4685 | from-newsgroup))) | |
4686 | (and (equal (car nth4) (car method)) | |
4687 | (equal (nth 1 nth4) (nth 1 method)))) | |
4688 | gnus-use-cross-reference | |
4689 | (or (not (eq gnus-use-cross-reference t)) | |
4690 | virtual | |
4691 | ;; Only do cross-references on subscribed | |
4692 | ;; groups, if that is what is wanted. | |
4693 | (<= (gnus-info-level info) gnus-level-subscribed)) | |
4694 | (gnus-group-make-articles-read name idlist)))) | |
4695 | xref-hashtb))))) | |
4696 | ||
6748645f LMI |
4697 | (defun gnus-compute-read-articles (group articles) |
4698 | (let* ((entry (gnus-gethash group gnus-newsrc-hashtb)) | |
4699 | (info (nth 2 entry)) | |
4700 | (active (gnus-active group)) | |
4701 | ninfo) | |
4702 | (when entry | |
16409b0b | 4703 | ;; First peel off all invalid article numbers. |
6748645f LMI |
4704 | (when active |
4705 | (let ((ids articles) | |
4706 | id first) | |
4707 | (while (setq id (pop ids)) | |
4708 | (when (and first (> id (cdr active))) | |
4709 | ;; We'll end up in this situation in one particular | |
4710 | ;; obscure situation. If you re-scan a group and get | |
4711 | ;; a new article that is cross-posted to a different | |
4712 | ;; group that has not been re-scanned, you might get | |
4713 | ;; crossposted article that has a higher number than | |
4714 | ;; Gnus believes possible. So we re-activate this | |
4715 | ;; group as well. This might mean doing the | |
4716 | ;; crossposting thingy will *increase* the number | |
4717 | ;; of articles in some groups. Tsk, tsk. | |
4718 | (setq active (or (gnus-activate-group group) active))) | |
4719 | (when (or (> id (cdr active)) | |
4720 | (< id (car active))) | |
4721 | (setq articles (delq id articles)))))) | |
4722 | ;; If the read list is nil, we init it. | |
4723 | (if (and active | |
4724 | (null (gnus-info-read info)) | |
4725 | (> (car active) 1)) | |
4726 | (setq ninfo (cons 1 (1- (car active)))) | |
4727 | (setq ninfo (gnus-info-read info))) | |
4728 | ;; Then we add the read articles to the range. | |
4729 | (gnus-add-to-range | |
4730 | ninfo (setq articles (sort articles '<)))))) | |
4731 | ||
eec82323 LMI |
4732 | (defun gnus-group-make-articles-read (group articles) |
4733 | "Update the info of GROUP to say that ARTICLES are read." | |
4734 | (let* ((num 0) | |
4735 | (entry (gnus-gethash group gnus-newsrc-hashtb)) | |
4736 | (info (nth 2 entry)) | |
4737 | (active (gnus-active group)) | |
4738 | range) | |
6748645f LMI |
4739 | (when entry |
4740 | (setq range (gnus-compute-read-articles group articles)) | |
4741 | (save-excursion | |
4742 | (set-buffer gnus-group-buffer) | |
4743 | (gnus-undo-register | |
4744 | `(progn | |
4745 | (gnus-info-set-marks ',info ',(gnus-info-marks info) t) | |
4746 | (gnus-info-set-read ',info ',(gnus-info-read info)) | |
4747 | (gnus-get-unread-articles-in-group ',info (gnus-active ,group)) | |
4748 | (gnus-group-update-group ,group t)))) | |
4749 | ;; Add the read articles to the range. | |
4750 | (gnus-info-set-read info range) | |
4751 | ;; Then we have to re-compute how many unread | |
4752 | ;; articles there are in this group. | |
4753 | (when active | |
4754 | (cond | |
4755 | ((not range) | |
4756 | (setq num (- (1+ (cdr active)) (car active)))) | |
4757 | ((not (listp (cdr range))) | |
4758 | (setq num (- (cdr active) (- (1+ (cdr range)) | |
4759 | (car range))))) | |
4760 | (t | |
4761 | (while range | |
4762 | (if (numberp (car range)) | |
4763 | (setq num (1+ num)) | |
4764 | (setq num (+ num (- (1+ (cdar range)) (caar range))))) | |
4765 | (setq range (cdr range))) | |
4766 | (setq num (- (cdr active) num)))) | |
4767 | ;; Update the number of unread articles. | |
4768 | (setcar entry num) | |
4769 | ;; Update the group buffer. | |
4770 | (gnus-group-update-group group t))))) | |
eec82323 | 4771 | |
eec82323 LMI |
4772 | (defvar gnus-newsgroup-none-id 0) |
4773 | ||
4774 | (defun gnus-get-newsgroup-headers (&optional dependencies force-new) | |
4775 | (let ((cur nntp-server-buffer) | |
4776 | (dependencies | |
4777 | (or dependencies | |
4778 | (save-excursion (set-buffer gnus-summary-buffer) | |
4779 | gnus-newsgroup-dependencies))) | |
16409b0b GM |
4780 | headers id end ref |
4781 | (mail-parse-charset gnus-newsgroup-charset) | |
4782 | (mail-parse-ignored-charsets | |
4783 | (save-excursion (condition-case nil | |
4784 | (set-buffer gnus-summary-buffer) | |
4785 | (error)) | |
4786 | gnus-newsgroup-ignored-charsets))) | |
eec82323 LMI |
4787 | (save-excursion |
4788 | (set-buffer nntp-server-buffer) | |
4789 | ;; Translate all TAB characters into SPACE characters. | |
4790 | (subst-char-in-region (point-min) (point-max) ?\t ? t) | |
16409b0b | 4791 | (subst-char-in-region (point-min) (point-max) ?\r ? t) |
6748645f | 4792 | (gnus-run-hooks 'gnus-parse-headers-hook) |
eec82323 | 4793 | (let ((case-fold-search t) |
6748645f | 4794 | in-reply-to header p lines chars) |
eec82323 LMI |
4795 | (goto-char (point-min)) |
4796 | ;; Search to the beginning of the next header. Error messages | |
4797 | ;; do not begin with 2 or 3. | |
4798 | (while (re-search-forward "^[23][0-9]+ " nil t) | |
4799 | (setq id nil | |
4800 | ref nil) | |
4801 | ;; This implementation of this function, with nine | |
4802 | ;; search-forwards instead of the one re-search-forward and | |
4803 | ;; a case (which basically was the old function) is actually | |
4804 | ;; about twice as fast, even though it looks messier. You | |
4805 | ;; can't have everything, I guess. Speed and elegance | |
4806 | ;; doesn't always go hand in hand. | |
4807 | (setq | |
4808 | header | |
4809 | (vector | |
4810 | ;; Number. | |
4811 | (prog1 | |
4812 | (read cur) | |
4813 | (end-of-line) | |
4814 | (setq p (point)) | |
4815 | (narrow-to-region (point) | |
4816 | (or (and (search-forward "\n.\n" nil t) | |
4817 | (- (point) 2)) | |
4818 | (point)))) | |
4819 | ;; Subject. | |
4820 | (progn | |
4821 | (goto-char p) | |
4822 | (if (search-forward "\nsubject: " nil t) | |
16409b0b GM |
4823 | (funcall gnus-decode-encoded-word-function |
4824 | (nnheader-header-value)) | |
2bd3dcae | 4825 | "(none)")) |
eec82323 LMI |
4826 | ;; From. |
4827 | (progn | |
4828 | (goto-char p) | |
d4dfaa19 DL |
4829 | (if (or (search-forward "\nfrom: " nil t) |
4830 | (search-forward "\nfrom:" nil t)) | |
16409b0b GM |
4831 | (funcall gnus-decode-encoded-word-function |
4832 | (nnheader-header-value)) | |
2bd3dcae | 4833 | "(nobody)")) |
eec82323 LMI |
4834 | ;; Date. |
4835 | (progn | |
4836 | (goto-char p) | |
4837 | (if (search-forward "\ndate: " nil t) | |
4838 | (nnheader-header-value) "")) | |
4839 | ;; Message-ID. | |
4840 | (progn | |
4841 | (goto-char p) | |
6748645f LMI |
4842 | (setq id (if (re-search-forward |
4843 | "^message-id: *\\(<[^\n\t> ]+>\\)" nil t) | |
4844 | ;; We do it this way to make sure the Message-ID | |
4845 | ;; is (somewhat) syntactically valid. | |
4846 | (buffer-substring (match-beginning 1) | |
4847 | (match-end 1)) | |
eec82323 LMI |
4848 | ;; If there was no message-id, we just fake one |
4849 | ;; to make subsequent routines simpler. | |
4850 | (nnheader-generate-fake-message-id)))) | |
4851 | ;; References. | |
4852 | (progn | |
4853 | (goto-char p) | |
4854 | (if (search-forward "\nreferences: " nil t) | |
4855 | (progn | |
4856 | (setq end (point)) | |
4857 | (prog1 | |
4858 | (nnheader-header-value) | |
4859 | (setq ref | |
4860 | (buffer-substring | |
4861 | (progn | |
4862 | (end-of-line) | |
4863 | (search-backward ">" end t) | |
4864 | (1+ (point))) | |
4865 | (progn | |
4866 | (search-backward "<" end t) | |
4867 | (point)))))) | |
4868 | ;; Get the references from the in-reply-to header if there | |
4869 | ;; were no references and the in-reply-to header looks | |
4870 | ;; promising. | |
4871 | (if (and (search-forward "\nin-reply-to: " nil t) | |
4872 | (setq in-reply-to (nnheader-header-value)) | |
4873 | (string-match "<[^>]+>" in-reply-to)) | |
6748645f LMI |
4874 | (let (ref2) |
4875 | (setq ref (substring in-reply-to (match-beginning 0) | |
4876 | (match-end 0))) | |
4877 | (while (string-match "<[^>]+>" in-reply-to (match-end 0)) | |
4878 | (setq ref2 (substring in-reply-to (match-beginning 0) | |
4879 | (match-end 0))) | |
4880 | (when (> (length ref2) (length ref)) | |
4881 | (setq ref ref2))) | |
4882 | ref) | |
eec82323 LMI |
4883 | (setq ref nil)))) |
4884 | ;; Chars. | |
6748645f LMI |
4885 | (progn |
4886 | (goto-char p) | |
4887 | (if (search-forward "\nchars: " nil t) | |
4888 | (if (numberp (setq chars (ignore-errors (read cur)))) | |
4889 | chars 0) | |
4890 | 0)) | |
eec82323 LMI |
4891 | ;; Lines. |
4892 | (progn | |
4893 | (goto-char p) | |
4894 | (if (search-forward "\nlines: " nil t) | |
a8151ef7 | 4895 | (if (numberp (setq lines (ignore-errors (read cur)))) |
eec82323 LMI |
4896 | lines 0) |
4897 | 0)) | |
4898 | ;; Xref. | |
4899 | (progn | |
4900 | (goto-char p) | |
4901 | (and (search-forward "\nxref: " nil t) | |
16409b0b GM |
4902 | (nnheader-header-value))) |
4903 | ;; Extra. | |
4904 | (when gnus-extra-headers | |
4905 | (let ((extra gnus-extra-headers) | |
4906 | out) | |
4907 | (while extra | |
4908 | (goto-char p) | |
4909 | (when (search-forward | |
4910 | (concat "\n" (symbol-name (car extra)) ": ") nil t) | |
4911 | (push (cons (car extra) (nnheader-header-value)) | |
4912 | out)) | |
4913 | (pop extra)) | |
4914 | out)))) | |
eec82323 LMI |
4915 | (when (equal id ref) |
4916 | (setq ref nil)) | |
6748645f LMI |
4917 | |
4918 | (when gnus-alter-header-function | |
4919 | (funcall gnus-alter-header-function header) | |
4920 | (setq id (mail-header-id header) | |
4921 | ref (gnus-parent-id (mail-header-references header)))) | |
4922 | ||
4923 | (when (setq header | |
4924 | (gnus-dependencies-add-header | |
4925 | header dependencies force-new)) | |
eec82323 LMI |
4926 | (push header headers)) |
4927 | (goto-char (point-max)) | |
4928 | (widen)) | |
4929 | (nreverse headers))))) | |
4930 | ||
eec82323 LMI |
4931 | ;; Goes through the xover lines and returns a list of vectors |
4932 | (defun gnus-get-newsgroup-headers-xover (sequence &optional | |
4933 | force-new dependencies | |
4934 | group also-fetch-heads) | |
16409b0b GM |
4935 | "Parse the news overview data in the server buffer. |
4936 | Return a list of headers that match SEQUENCE (see | |
4937 | `nntp-retrieve-headers')." | |
eec82323 LMI |
4938 | ;; Get the Xref when the users reads the articles since most/some |
4939 | ;; NNTP servers do not include Xrefs when using XOVER. | |
4940 | (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs)) | |
16409b0b GM |
4941 | (let ((mail-parse-charset gnus-newsgroup-charset) |
4942 | (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets) | |
4943 | (cur nntp-server-buffer) | |
eec82323 LMI |
4944 | (dependencies (or dependencies gnus-newsgroup-dependencies)) |
4945 | number headers header) | |
4946 | (save-excursion | |
4947 | (set-buffer nntp-server-buffer) | |
16409b0b | 4948 | (subst-char-in-region (point-min) (point-max) ?\r ? t) |
eec82323 | 4949 | ;; Allow the user to mangle the headers before parsing them. |
6748645f | 4950 | (gnus-run-hooks 'gnus-parse-headers-hook) |
eec82323 LMI |
4951 | (goto-char (point-min)) |
4952 | (while (not (eobp)) | |
4953 | (condition-case () | |
4954 | (while (and sequence (not (eobp))) | |
4955 | (setq number (read cur)) | |
4956 | (while (and sequence | |
4957 | (< (car sequence) number)) | |
4958 | (setq sequence (cdr sequence))) | |
4959 | (and sequence | |
4960 | (eq number (car sequence)) | |
4961 | (progn | |
4962 | (setq sequence (cdr sequence)) | |
4963 | (setq header (inline | |
4964 | (gnus-nov-parse-line | |
4965 | number dependencies force-new)))) | |
4966 | (push header headers)) | |
4967 | (forward-line 1)) | |
4968 | (error | |
4969 | (gnus-error 4 "Strange nov line (%d)" | |
4970 | (count-lines (point-min) (point))))) | |
4971 | (forward-line 1)) | |
4972 | ;; A common bug in inn is that if you have posted an article and | |
4973 | ;; then retrieves the active file, it will answer correctly -- | |
4974 | ;; the new article is included. However, a NOV entry for the | |
4975 | ;; article may not have been generated yet, so this may fail. | |
4976 | ;; We work around this problem by retrieving the last few | |
4977 | ;; headers using HEAD. | |
4978 | (if (or (not also-fetch-heads) | |
4979 | (not sequence)) | |
4980 | ;; We (probably) got all the headers. | |
4981 | (nreverse headers) | |
4982 | (let ((gnus-nov-is-evil t)) | |
4983 | (nconc | |
4984 | (nreverse headers) | |
4985 | (when (gnus-retrieve-headers sequence group) | |
4986 | (gnus-get-newsgroup-headers)))))))) | |
4987 | ||
4988 | (defun gnus-article-get-xrefs () | |
4989 | "Fill in the Xref value in `gnus-current-headers', if necessary. | |
4990 | This is meant to be called in `gnus-article-internal-prepare-hook'." | |
4991 | (let ((headers (save-excursion (set-buffer gnus-summary-buffer) | |
4992 | gnus-current-headers))) | |
4993 | (or (not gnus-use-cross-reference) | |
4994 | (not headers) | |
4995 | (and (mail-header-xref headers) | |
4996 | (not (string= (mail-header-xref headers) ""))) | |
4997 | (let ((case-fold-search t) | |
4998 | xref) | |
4999 | (save-restriction | |
5000 | (nnheader-narrow-to-headers) | |
5001 | (goto-char (point-min)) | |
16409b0b GM |
5002 | (when (or (and (not (eobp)) |
5003 | (eq (downcase (char-after)) ?x) | |
eec82323 LMI |
5004 | (looking-at "Xref:")) |
5005 | (search-forward "\nXref:" nil t)) | |
5006 | (goto-char (1+ (match-end 0))) | |
5007 | (setq xref (buffer-substring (point) | |
5008 | (progn (end-of-line) (point)))) | |
5009 | (mail-header-set-xref headers xref))))))) | |
5010 | ||
5011 | (defun gnus-summary-insert-subject (id &optional old-header use-old-header) | |
6748645f LMI |
5012 | "Find article ID and insert the summary line for that article. |
5013 | OLD-HEADER can either be a header or a line number to insert | |
5014 | the subject line on." | |
5015 | (let* ((line (and (numberp old-header) old-header)) | |
5016 | (old-header (and (vectorp old-header) old-header)) | |
5017 | (header (cond ((and old-header use-old-header) | |
16409b0b GM |
5018 | old-header) |
5019 | ((and (numberp id) | |
5020 | (gnus-number-to-header id)) | |
5021 | (gnus-number-to-header id)) | |
5022 | (t | |
5023 | (gnus-read-header id)))) | |
5024 | (number (and (numberp id) id)) | |
5025 | d) | |
eec82323 LMI |
5026 | (when header |
5027 | ;; Rebuild the thread that this article is part of and go to the | |
5028 | ;; article we have fetched. | |
5029 | (when (and (not gnus-show-threads) | |
5030 | old-header) | |
6748645f LMI |
5031 | (when (and number |
5032 | (setq d (gnus-data-find (mail-header-number old-header)))) | |
eec82323 LMI |
5033 | (goto-char (gnus-data-pos d)) |
5034 | (gnus-data-remove | |
5035 | number | |
5036 | (- (gnus-point-at-bol) | |
5037 | (prog1 | |
5038 | (1+ (gnus-point-at-eol)) | |
5039 | (gnus-delete-line)))))) | |
5040 | (when old-header | |
5041 | (mail-header-set-number header (mail-header-number old-header))) | |
5042 | (setq gnus-newsgroup-sparse | |
5043 | (delq (setq number (mail-header-number header)) | |
5044 | gnus-newsgroup-sparse)) | |
5045 | (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient)) | |
6748645f LMI |
5046 | (push number gnus-newsgroup-limit) |
5047 | (gnus-rebuild-thread (mail-header-id header) line) | |
eec82323 LMI |
5048 | (gnus-summary-goto-subject number nil t)) |
5049 | (when (and (numberp number) | |
5050 | (> number 0)) | |
5051 | ;; We have to update the boundaries even if we can't fetch the | |
5052 | ;; article if ID is a number -- so that the next `P' or `N' | |
5053 | ;; command will fetch the previous (or next) article even | |
5054 | ;; if the one we tried to fetch this time has been canceled. | |
5055 | (when (> number gnus-newsgroup-end) | |
5056 | (setq gnus-newsgroup-end number)) | |
5057 | (when (< number gnus-newsgroup-begin) | |
5058 | (setq gnus-newsgroup-begin number)) | |
5059 | (setq gnus-newsgroup-unselected | |
5060 | (delq number gnus-newsgroup-unselected))) | |
5061 | ;; Report back a success? | |
5062 | (and header (mail-header-number header)))) | |
5063 | ||
5064 | ;;; Process/prefix in the summary buffer | |
5065 | ||
5066 | (defun gnus-summary-work-articles (n) | |
6748645f LMI |
5067 | "Return a list of articles to be worked upon. |
5068 | The prefix argument, the list of process marked articles, and the | |
5069 | current article will be taken into consideration." | |
5070 | (save-excursion | |
5071 | (set-buffer gnus-summary-buffer) | |
5072 | (cond | |
5073 | (n | |
5074 | ;; A numerical prefix has been given. | |
5075 | (setq n (prefix-numeric-value n)) | |
5076 | (let ((backward (< n 0)) | |
5077 | (n (abs (prefix-numeric-value n))) | |
5078 | articles article) | |
5079 | (save-excursion | |
5080 | (while | |
5081 | (and (> n 0) | |
5082 | (push (setq article (gnus-summary-article-number)) | |
5083 | articles) | |
5084 | (if backward | |
5085 | (gnus-summary-find-prev nil article) | |
5086 | (gnus-summary-find-next nil article))) | |
5087 | (decf n))) | |
5088 | (nreverse articles))) | |
5089 | ((and (gnus-region-active-p) (mark)) | |
5090 | (message "region active") | |
5091 | ;; Work on the region between point and mark. | |
5092 | (let ((max (max (point) (mark))) | |
5093 | articles article) | |
5094 | (save-excursion | |
5095 | (goto-char (min (min (point) (mark)))) | |
5096 | (while | |
5097 | (and | |
5098 | (push (setq article (gnus-summary-article-number)) articles) | |
5099 | (gnus-summary-find-next nil article) | |
5100 | (< (point) max))) | |
5101 | (nreverse articles)))) | |
5102 | (gnus-newsgroup-processable | |
5103 | ;; There are process-marked articles present. | |
5104 | ;; Save current state. | |
5105 | (gnus-summary-save-process-mark) | |
5106 | ;; Return the list. | |
5107 | (reverse gnus-newsgroup-processable)) | |
5108 | (t | |
5109 | ;; Just return the current article. | |
5110 | (list (gnus-summary-article-number)))))) | |
5111 | ||
5112 | (defmacro gnus-summary-iterate (arg &rest forms) | |
5113 | "Iterate over the process/prefixed articles and do FORMS. | |
5114 | ARG is the interactive prefix given to the command. FORMS will be | |
5115 | executed with point over the summary line of the articles." | |
5116 | (let ((articles (make-symbol "gnus-summary-iterate-articles"))) | |
5117 | `(let ((,articles (gnus-summary-work-articles ,arg))) | |
5118 | (while ,articles | |
5119 | (gnus-summary-goto-subject (car ,articles)) | |
16409b0b GM |
5120 | ,@forms |
5121 | (pop ,articles))))) | |
6748645f LMI |
5122 | |
5123 | (put 'gnus-summary-iterate 'lisp-indent-function 1) | |
5124 | (put 'gnus-summary-iterate 'edebug-form-spec '(form body)) | |
eec82323 LMI |
5125 | |
5126 | (defun gnus-summary-save-process-mark () | |
5127 | "Push the current set of process marked articles on the stack." | |
5128 | (interactive) | |
5129 | (push (copy-sequence gnus-newsgroup-processable) | |
5130 | gnus-newsgroup-process-stack)) | |
5131 | ||
5132 | (defun gnus-summary-kill-process-mark () | |
5133 | "Push the current set of process marked articles on the stack and unmark." | |
5134 | (interactive) | |
5135 | (gnus-summary-save-process-mark) | |
5136 | (gnus-summary-unmark-all-processable)) | |
5137 | ||
5138 | (defun gnus-summary-yank-process-mark () | |
5139 | "Pop the last process mark state off the stack and restore it." | |
5140 | (interactive) | |
5141 | (unless gnus-newsgroup-process-stack | |
5142 | (error "Empty mark stack")) | |
5143 | (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack))) | |
5144 | ||
5145 | (defun gnus-summary-process-mark-set (set) | |
5146 | "Make SET into the current process marked articles." | |
5147 | (gnus-summary-unmark-all-processable) | |
5148 | (while set | |
5149 | (gnus-summary-set-process-mark (pop set)))) | |
5150 | ||
5151 | ;;; Searching and stuff | |
5152 | ||
5153 | (defun gnus-summary-search-group (&optional backward use-level) | |
5154 | "Search for next unread newsgroup. | |
5155 | If optional argument BACKWARD is non-nil, search backward instead." | |
5156 | (save-excursion | |
5157 | (set-buffer gnus-group-buffer) | |
5158 | (when (gnus-group-search-forward | |
5159 | backward nil (if use-level (gnus-group-group-level) nil)) | |
5160 | (gnus-group-group-name)))) | |
5161 | ||
5162 | (defun gnus-summary-best-group (&optional exclude-group) | |
5163 | "Find the name of the best unread group. | |
5164 | If EXCLUDE-GROUP, do not go to this group." | |
5165 | (save-excursion | |
5166 | (set-buffer gnus-group-buffer) | |
5167 | (save-excursion | |
5168 | (gnus-group-best-unread-group exclude-group)))) | |
5169 | ||
6748645f | 5170 | (defun gnus-summary-find-next (&optional unread article backward undownloaded) |
eec82323 LMI |
5171 | (if backward (gnus-summary-find-prev) |
5172 | (let* ((dummy (gnus-summary-article-intangible-p)) | |
5173 | (article (or article (gnus-summary-article-number))) | |
5174 | (arts (gnus-data-find-list article)) | |
5175 | result) | |
5176 | (when (and (not dummy) | |
5177 | (or (not gnus-summary-check-current) | |
5178 | (not unread) | |
5179 | (not (gnus-data-unread-p (car arts))))) | |
5180 | (setq arts (cdr arts))) | |
5181 | (when (setq result | |
5182 | (if unread | |
5183 | (progn | |
5184 | (while arts | |
6748645f LMI |
5185 | (when (or (and undownloaded |
5186 | (eq gnus-undownloaded-mark | |
5187 | (gnus-data-mark (car arts)))) | |
5188 | (gnus-data-unread-p (car arts))) | |
eec82323 LMI |
5189 | (setq result (car arts) |
5190 | arts nil)) | |
5191 | (setq arts (cdr arts))) | |
5192 | result) | |
5193 | (car arts))) | |
5194 | (goto-char (gnus-data-pos result)) | |
5195 | (gnus-data-number result))))) | |
5196 | ||
5197 | (defun gnus-summary-find-prev (&optional unread article) | |
5198 | (let* ((eobp (eobp)) | |
5199 | (article (or article (gnus-summary-article-number))) | |
5200 | (arts (gnus-data-find-list article (gnus-data-list 'rev))) | |
5201 | result) | |
5202 | (when (and (not eobp) | |
5203 | (or (not gnus-summary-check-current) | |
5204 | (not unread) | |
5205 | (not (gnus-data-unread-p (car arts))))) | |
5206 | (setq arts (cdr arts))) | |
5207 | (when (setq result | |
5208 | (if unread | |
5209 | (progn | |
5210 | (while arts | |
5211 | (when (gnus-data-unread-p (car arts)) | |
5212 | (setq result (car arts) | |
5213 | arts nil)) | |
5214 | (setq arts (cdr arts))) | |
5215 | result) | |
5216 | (car arts))) | |
5217 | (goto-char (gnus-data-pos result)) | |
5218 | (gnus-data-number result)))) | |
5219 | ||
5220 | (defun gnus-summary-find-subject (subject &optional unread backward article) | |
5221 | (let* ((simp-subject (gnus-simplify-subject-fully subject)) | |
5222 | (article (or article (gnus-summary-article-number))) | |
5223 | (articles (gnus-data-list backward)) | |
5224 | (arts (gnus-data-find-list article articles)) | |
5225 | result) | |
5226 | (when (or (not gnus-summary-check-current) | |
5227 | (not unread) | |
5228 | (not (gnus-data-unread-p (car arts)))) | |
5229 | (setq arts (cdr arts))) | |
5230 | (while arts | |
5231 | (and (or (not unread) | |
5232 | (gnus-data-unread-p (car arts))) | |
5233 | (vectorp (gnus-data-header (car arts))) | |
5234 | (gnus-subject-equal | |
5235 | simp-subject (mail-header-subject (gnus-data-header (car arts))) t) | |
5236 | (setq result (car arts) | |
5237 | arts nil)) | |
5238 | (setq arts (cdr arts))) | |
5239 | (and result | |
5240 | (goto-char (gnus-data-pos result)) | |
5241 | (gnus-data-number result)))) | |
5242 | ||
5243 | (defun gnus-summary-search-forward (&optional unread subject backward) | |
5244 | "Search forward for an article. | |
5245 | If UNREAD, look for unread articles. If SUBJECT, look for | |
5246 | articles with that subject. If BACKWARD, search backward instead." | |
5247 | (cond (subject (gnus-summary-find-subject subject unread backward)) | |
5248 | (backward (gnus-summary-find-prev unread)) | |
5249 | (t (gnus-summary-find-next unread)))) | |
5250 | ||
5251 | (defun gnus-recenter (&optional n) | |
5252 | "Center point in window and redisplay frame. | |
5253 | Also do horizontal recentering." | |
5254 | (interactive "P") | |
5255 | (when (and gnus-auto-center-summary | |
5256 | (not (eq gnus-auto-center-summary 'vertical))) | |
5257 | (gnus-horizontal-recenter)) | |
5258 | (recenter n)) | |
5259 | ||
5260 | (defun gnus-summary-recenter () | |
5261 | "Center point in the summary window. | |
5262 | If `gnus-auto-center-summary' is nil, or the article buffer isn't | |
5263 | displayed, no centering will be performed." | |
5264 | ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle). | |
5265 | ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu. | |
16409b0b | 5266 | (interactive) |
eec82323 LMI |
5267 | (let* ((top (cond ((< (window-height) 4) 0) |
5268 | ((< (window-height) 7) 1) | |
16409b0b GM |
5269 | (t (if (numberp gnus-auto-center-summary) |
5270 | gnus-auto-center-summary | |
5271 | 2)))) | |
eec82323 LMI |
5272 | (height (1- (window-height))) |
5273 | (bottom (save-excursion (goto-char (point-max)) | |
5274 | (forward-line (- height)) | |
5275 | (point))) | |
5276 | (window (get-buffer-window (current-buffer)))) | |
5277 | ;; The user has to want it. | |
5278 | (when gnus-auto-center-summary | |
5279 | (when (get-buffer-window gnus-article-buffer) | |
5280 | ;; Only do recentering when the article buffer is displayed, | |
5281 | ;; Set the window start to either `bottom', which is the biggest | |
5282 | ;; possible valid number, or the second line from the top, | |
5283 | ;; whichever is the least. | |
db7ebd73 MB |
5284 | (let ((top-pos (save-excursion (forward-line (- top)) (point)))) |
5285 | (if (> bottom top-pos) | |
5286 | ;; Keep the second line from the top visible | |
5287 | (set-window-start window top-pos t) | |
5288 | ;; Try to keep the bottom line visible; if it's partially | |
5289 | ;; obscured, either scroll one more line to make it fully | |
5290 | ;; visible, or revert to using TOP-POS. | |
5291 | (save-excursion | |
5292 | (goto-char (point-max)) | |
5293 | (forward-line -1) | |
5294 | (let ((last-line-start (point))) | |
5295 | (goto-char bottom) | |
5296 | (set-window-start window (point) t) | |
5297 | (when (not (pos-visible-in-window-p last-line-start window)) | |
5298 | (forward-line 1) | |
5299 | (set-window-start window (min (point) top-pos) t))))))) | |
eec82323 LMI |
5300 | ;; Do horizontal recentering while we're at it. |
5301 | (when (and (get-buffer-window (current-buffer) t) | |
5302 | (not (eq gnus-auto-center-summary 'vertical))) | |
5303 | (let ((selected (selected-window))) | |
5304 | (select-window (get-buffer-window (current-buffer) t)) | |
5305 | (gnus-summary-position-point) | |
5306 | (gnus-horizontal-recenter) | |
5307 | (select-window selected)))))) | |
5308 | ||
5309 | (defun gnus-summary-jump-to-group (newsgroup) | |
5310 | "Move point to NEWSGROUP in group mode buffer." | |
5311 | ;; Keep update point of group mode buffer if visible. | |
5312 | (if (eq (current-buffer) (get-buffer gnus-group-buffer)) | |
5313 | (save-window-excursion | |
5314 | ;; Take care of tree window mode. | |
5315 | (when (get-buffer-window gnus-group-buffer) | |
5316 | (pop-to-buffer gnus-group-buffer)) | |
5317 | (gnus-group-jump-to-group newsgroup)) | |
5318 | (save-excursion | |
5319 | ;; Take care of tree window mode. | |
5320 | (if (get-buffer-window gnus-group-buffer) | |
5321 | (pop-to-buffer gnus-group-buffer) | |
5322 | (set-buffer gnus-group-buffer)) | |
5323 | (gnus-group-jump-to-group newsgroup)))) | |
5324 | ||
5325 | ;; This function returns a list of article numbers based on the | |
5326 | ;; difference between the ranges of read articles in this group and | |
5327 | ;; the range of active articles. | |
5328 | (defun gnus-list-of-unread-articles (group) | |
5329 | (let* ((read (gnus-info-read (gnus-get-info group))) | |
5330 | (active (or (gnus-active group) (gnus-activate-group group))) | |
5331 | (last (cdr active)) | |
5332 | first nlast unread) | |
5333 | ;; If none are read, then all are unread. | |
5334 | (if (not read) | |
5335 | (setq first (car active)) | |
5336 | ;; If the range of read articles is a single range, then the | |
5337 | ;; first unread article is the article after the last read | |
5338 | ;; article. Sounds logical, doesn't it? | |
16409b0b GM |
5339 | (if (and (not (listp (cdr read))) |
5340 | (or (< (car read) (car active)) | |
5341 | (progn (setq read (list read)) | |
5342 | nil))) | |
6748645f | 5343 | (setq first (max (car active) (1+ (cdr read)))) |
eec82323 LMI |
5344 | ;; `read' is a list of ranges. |
5345 | (when (/= (setq nlast (or (and (numberp (car read)) (car read)) | |
5346 | (caar read))) | |
5347 | 1) | |
6748645f | 5348 | (setq first (car active))) |
eec82323 LMI |
5349 | (while read |
5350 | (when first | |
5351 | (while (< first nlast) | |
5352 | (push first unread) | |
5353 | (setq first (1+ first)))) | |
5354 | (setq first (1+ (if (atom (car read)) (car read) (cdar read)))) | |
5355 | (setq nlast (if (atom (cadr read)) (cadr read) (caadr read))) | |
5356 | (setq read (cdr read))))) | |
5357 | ;; And add the last unread articles. | |
5358 | (while (<= first last) | |
5359 | (push first unread) | |
5360 | (setq first (1+ first))) | |
5361 | ;; Return the list of unread articles. | |
6748645f | 5362 | (delq 0 (nreverse unread)))) |
eec82323 LMI |
5363 | |
5364 | (defun gnus-list-of-read-articles (group) | |
5365 | "Return a list of unread, unticked and non-dormant articles." | |
5366 | (let* ((info (gnus-get-info group)) | |
5367 | (marked (gnus-info-marks info)) | |
5368 | (active (gnus-active group))) | |
5369 | (and info active | |
5370 | (gnus-set-difference | |
5371 | (gnus-sorted-complement | |
5372 | (gnus-uncompress-range active) | |
5373 | (gnus-list-of-unread-articles group)) | |
5374 | (append | |
5375 | (gnus-uncompress-range (cdr (assq 'dormant marked))) | |
5376 | (gnus-uncompress-range (cdr (assq 'tick marked)))))))) | |
5377 | ||
5378 | ;; Various summary commands | |
5379 | ||
6748645f LMI |
5380 | (defun gnus-summary-select-article-buffer () |
5381 | "Reconfigure windows to show article buffer." | |
5382 | (interactive) | |
5383 | (if (not (gnus-buffer-live-p gnus-article-buffer)) | |
5384 | (error "There is no article buffer for this summary buffer") | |
5385 | (gnus-configure-windows 'article) | |
5386 | (select-window (get-buffer-window gnus-article-buffer)))) | |
5387 | ||
eec82323 LMI |
5388 | (defun gnus-summary-universal-argument (arg) |
5389 | "Perform any operation on all articles that are process/prefixed." | |
5390 | (interactive "P") | |
eec82323 LMI |
5391 | (let ((articles (gnus-summary-work-articles arg)) |
5392 | func article) | |
5393 | (if (eq | |
5394 | (setq | |
5395 | func | |
5396 | (key-binding | |
5397 | (read-key-sequence | |
5398 | (substitute-command-keys | |
16409b0b | 5399 | "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]")))) |
eec82323 LMI |
5400 | 'undefined) |
5401 | (gnus-error 1 "Undefined key") | |
5402 | (save-excursion | |
5403 | (while articles | |
5404 | (gnus-summary-goto-subject (setq article (pop articles))) | |
5405 | (let (gnus-newsgroup-processable) | |
5406 | (command-execute func)) | |
5407 | (gnus-summary-remove-process-mark article))))) | |
5408 | (gnus-summary-position-point)) | |
5409 | ||
5410 | (defun gnus-summary-toggle-truncation (&optional arg) | |
5411 | "Toggle truncation of summary lines. | |
5412 | With arg, turn line truncation on iff arg is positive." | |
5413 | (interactive "P") | |
5414 | (setq truncate-lines | |
5415 | (if (null arg) (not truncate-lines) | |
5416 | (> (prefix-numeric-value arg) 0))) | |
5417 | (redraw-display)) | |
5418 | ||
5419 | (defun gnus-summary-reselect-current-group (&optional all rescan) | |
5420 | "Exit and then reselect the current newsgroup. | |
5421 | The prefix argument ALL means to select all articles." | |
5422 | (interactive "P") | |
eec82323 LMI |
5423 | (when (gnus-ephemeral-group-p gnus-newsgroup-name) |
5424 | (error "Ephemeral groups can't be reselected")) | |
5425 | (let ((current-subject (gnus-summary-article-number)) | |
5426 | (group gnus-newsgroup-name)) | |
5427 | (setq gnus-newsgroup-begin nil) | |
5428 | (gnus-summary-exit) | |
5429 | ;; We have to adjust the point of group mode buffer because | |
5430 | ;; point was moved to the next unread newsgroup by exiting. | |
5431 | (gnus-summary-jump-to-group group) | |
5432 | (when rescan | |
5433 | (save-excursion | |
5434 | (gnus-group-get-new-news-this-group 1))) | |
5435 | (gnus-group-read-group all t) | |
5436 | (gnus-summary-goto-subject current-subject nil t))) | |
5437 | ||
5438 | (defun gnus-summary-rescan-group (&optional all) | |
5439 | "Exit the newsgroup, ask for new articles, and select the newsgroup." | |
5440 | (interactive "P") | |
5441 | (gnus-summary-reselect-current-group all t)) | |
5442 | ||
5443 | (defun gnus-summary-update-info (&optional non-destructive) | |
5444 | (save-excursion | |
5445 | (let ((group gnus-newsgroup-name)) | |
6748645f LMI |
5446 | (when group |
5447 | (when gnus-newsgroup-kill-headers | |
5448 | (setq gnus-newsgroup-killed | |
5449 | (gnus-compress-sequence | |
5450 | (nconc | |
5451 | (gnus-set-sorted-intersection | |
5452 | (gnus-uncompress-range gnus-newsgroup-killed) | |
5453 | (setq gnus-newsgroup-unselected | |
5454 | (sort gnus-newsgroup-unselected '<))) | |
5455 | (setq gnus-newsgroup-unreads | |
5456 | (sort gnus-newsgroup-unreads '<))) | |
5457 | t))) | |
5458 | (unless (listp (cdr gnus-newsgroup-killed)) | |
5459 | (setq gnus-newsgroup-killed (list gnus-newsgroup-killed))) | |
5460 | (let ((headers gnus-newsgroup-headers)) | |
5461 | ;; Set the new ranges of read articles. | |
5462 | (save-excursion | |
5463 | (set-buffer gnus-group-buffer) | |
5464 | (gnus-undo-force-boundary)) | |
5465 | (gnus-update-read-articles | |
5466 | group (append gnus-newsgroup-unreads gnus-newsgroup-unselected)) | |
5467 | ;; Set the current article marks. | |
5468 | (let ((gnus-newsgroup-scored | |
5469 | (if (and (not gnus-save-score) | |
5470 | (not non-destructive)) | |
5471 | nil | |
5472 | gnus-newsgroup-scored))) | |
5473 | (save-excursion | |
5474 | (gnus-update-marks))) | |
5475 | ;; Do the cross-ref thing. | |
5476 | (when gnus-use-cross-reference | |
5477 | (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads)) | |
5478 | ;; Do not switch windows but change the buffer to work. | |
a8151ef7 | 5479 | (set-buffer gnus-group-buffer) |
6748645f LMI |
5480 | (unless (gnus-ephemeral-group-p group) |
5481 | (gnus-group-update-group group))))))) | |
eec82323 LMI |
5482 | |
5483 | (defun gnus-summary-save-newsrc (&optional force) | |
5484 | "Save the current number of read/marked articles in the dribble buffer. | |
5485 | The dribble buffer will then be saved. | |
5486 | If FORCE (the prefix), also save the .newsrc file(s)." | |
5487 | (interactive "P") | |
5488 | (gnus-summary-update-info t) | |
5489 | (if force | |
5490 | (gnus-save-newsrc-file) | |
5491 | (gnus-dribble-save))) | |
5492 | ||
5493 | (defun gnus-summary-exit (&optional temporary) | |
5494 | "Exit reading current newsgroup, and then return to group selection mode. | |
16409b0b | 5495 | `gnus-exit-group-hook' is called with no arguments if that value is non-nil." |
eec82323 LMI |
5496 | (interactive) |
5497 | (gnus-set-global-variables) | |
16409b0b GM |
5498 | (when (gnus-buffer-live-p gnus-article-buffer) |
5499 | (save-excursion | |
5500 | (set-buffer gnus-article-buffer) | |
5501 | (mm-destroy-parts gnus-article-mime-handles) | |
5502 | ;; Set it to nil for safety reason. | |
5503 | (setq gnus-article-mime-handle-alist nil) | |
5504 | (setq gnus-article-mime-handles nil))) | |
eec82323 | 5505 | (gnus-kill-save-kill-buffer) |
6748645f | 5506 | (gnus-async-halt-prefetch) |
eec82323 LMI |
5507 | (let* ((group gnus-newsgroup-name) |
5508 | (quit-config (gnus-group-quit-config gnus-newsgroup-name)) | |
5509 | (mode major-mode) | |
a8151ef7 | 5510 | (group-point nil) |
eec82323 | 5511 | (buf (current-buffer))) |
16409b0b GM |
5512 | (unless quit-config |
5513 | ;; Do adaptive scoring, and possibly save score files. | |
5514 | (when gnus-newsgroup-adaptive | |
5515 | (gnus-score-adaptive)) | |
5516 | (when gnus-use-scoring | |
5517 | (gnus-score-save))) | |
6748645f | 5518 | (gnus-run-hooks 'gnus-summary-prepare-exit-hook) |
eec82323 LMI |
5519 | ;; If we have several article buffers, we kill them at exit. |
5520 | (unless gnus-single-article-buffer | |
5521 | (gnus-kill-buffer gnus-original-article-buffer) | |
5522 | (setq gnus-article-current nil)) | |
5523 | (when gnus-use-cache | |
5524 | (gnus-cache-possibly-remove-articles) | |
5525 | (gnus-cache-save-buffers)) | |
5526 | (gnus-async-prefetch-remove-group group) | |
5527 | (when gnus-suppress-duplicates | |
5528 | (gnus-dup-enter-articles)) | |
5529 | (when gnus-use-trees | |
5530 | (gnus-tree-close group)) | |
16409b0b GM |
5531 | (when gnus-use-cache |
5532 | (gnus-cache-write-active)) | |
6748645f LMI |
5533 | ;; Remove entries for this group. |
5534 | (nnmail-purge-split-history (gnus-group-real-name group)) | |
eec82323 LMI |
5535 | ;; Make all changes in this group permanent. |
5536 | (unless quit-config | |
6748645f | 5537 | (gnus-run-hooks 'gnus-exit-group-hook) |
16409b0b | 5538 | (gnus-summary-update-info)) |
eec82323 LMI |
5539 | (gnus-close-group group) |
5540 | ;; Make sure where we were, and go to next newsgroup. | |
5541 | (set-buffer gnus-group-buffer) | |
5542 | (unless quit-config | |
5543 | (gnus-group-jump-to-group group)) | |
6748645f LMI |
5544 | (gnus-run-hooks 'gnus-summary-exit-hook) |
5545 | (unless (or quit-config | |
5546 | ;; If this group has disappeared from the summary | |
5547 | ;; buffer, don't skip forwards. | |
5548 | (not (string= group (gnus-group-group-name)))) | |
eec82323 | 5549 | (gnus-group-next-unread-group 1)) |
a8151ef7 | 5550 | (setq group-point (point)) |
eec82323 LMI |
5551 | (if temporary |
5552 | nil ;Nothing to do. | |
5553 | ;; If we have several article buffers, we kill them at exit. | |
5554 | (unless gnus-single-article-buffer | |
5555 | (gnus-kill-buffer gnus-article-buffer) | |
5556 | (gnus-kill-buffer gnus-original-article-buffer) | |
5557 | (setq gnus-article-current nil)) | |
5558 | (set-buffer buf) | |
5559 | (if (not gnus-kill-summary-on-exit) | |
5560 | (gnus-deaden-summary) | |
5561 | ;; We set all buffer-local variables to nil. It is unclear why | |
5562 | ;; this is needed, but if we don't, buffer-local variables are | |
5563 | ;; not garbage-collected, it seems. This would the lead to en | |
5564 | ;; ever-growing Emacs. | |
5565 | (gnus-summary-clear-local-variables) | |
5566 | (when (get-buffer gnus-article-buffer) | |
5567 | (bury-buffer gnus-article-buffer)) | |
5568 | ;; We clear the global counterparts of the buffer-local | |
5569 | ;; variables as well, just to be on the safe side. | |
5570 | (set-buffer gnus-group-buffer) | |
5571 | (gnus-summary-clear-local-variables) | |
5572 | ;; Return to group mode buffer. | |
5573 | (when (eq mode 'gnus-summary-mode) | |
5574 | (gnus-kill-buffer buf))) | |
5575 | (setq gnus-current-select-method gnus-select-method) | |
5576 | (pop-to-buffer gnus-group-buffer) | |
eec82323 LMI |
5577 | (if (not quit-config) |
5578 | (progn | |
a8151ef7 | 5579 | (goto-char group-point) |
eec82323 LMI |
5580 | (gnus-configure-windows 'group 'force)) |
5581 | (gnus-handle-ephemeral-exit quit-config)) | |
6748645f | 5582 | ;; Clear the current group name. |
eec82323 LMI |
5583 | (unless quit-config |
5584 | (setq gnus-newsgroup-name nil))))) | |
5585 | ||
5586 | (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update) | |
5587 | (defun gnus-summary-exit-no-update (&optional no-questions) | |
5588 | "Quit reading current newsgroup without updating read article info." | |
5589 | (interactive) | |
eec82323 LMI |
5590 | (let* ((group gnus-newsgroup-name) |
5591 | (quit-config (gnus-group-quit-config group))) | |
5592 | (when (or no-questions | |
5593 | gnus-expert-user | |
5594 | (gnus-y-or-n-p "Discard changes to this group and exit? ")) | |
6748645f | 5595 | (gnus-async-halt-prefetch) |
16409b0b GM |
5596 | (mapcar 'funcall |
5597 | (delq 'gnus-summary-expire-articles | |
5598 | (copy-sequence gnus-summary-prepare-exit-hook))) | |
5599 | (when (gnus-buffer-live-p gnus-article-buffer) | |
5600 | (save-excursion | |
5601 | (set-buffer gnus-article-buffer) | |
5602 | (mm-destroy-parts gnus-article-mime-handles) | |
5603 | ;; Set it to nil for safety reason. | |
5604 | (setq gnus-article-mime-handle-alist nil) | |
5605 | (setq gnus-article-mime-handles nil))) | |
eec82323 LMI |
5606 | ;; If we have several article buffers, we kill them at exit. |
5607 | (unless gnus-single-article-buffer | |
5608 | (gnus-kill-buffer gnus-article-buffer) | |
5609 | (gnus-kill-buffer gnus-original-article-buffer) | |
5610 | (setq gnus-article-current nil)) | |
5611 | (if (not gnus-kill-summary-on-exit) | |
5612 | (gnus-deaden-summary) | |
5613 | (gnus-close-group group) | |
5614 | (gnus-summary-clear-local-variables) | |
5615 | (set-buffer gnus-group-buffer) | |
5616 | (gnus-summary-clear-local-variables) | |
5617 | (when (get-buffer gnus-summary-buffer) | |
5618 | (kill-buffer gnus-summary-buffer))) | |
5619 | (unless gnus-single-article-buffer | |
5620 | (setq gnus-article-current nil)) | |
5621 | (when gnus-use-trees | |
5622 | (gnus-tree-close group)) | |
5623 | (gnus-async-prefetch-remove-group group) | |
5624 | (when (get-buffer gnus-article-buffer) | |
5625 | (bury-buffer gnus-article-buffer)) | |
5626 | ;; Return to the group buffer. | |
5627 | (gnus-configure-windows 'group 'force) | |
5628 | ;; Clear the current group name. | |
5629 | (setq gnus-newsgroup-name nil) | |
5630 | (when (equal (gnus-group-group-name) group) | |
5631 | (gnus-group-next-unread-group 1)) | |
5632 | (when quit-config | |
5633 | (gnus-handle-ephemeral-exit quit-config))))) | |
5634 | ||
5635 | (defun gnus-handle-ephemeral-exit (quit-config) | |
6748645f LMI |
5636 | "Handle movement when leaving an ephemeral group. |
5637 | The state which existed when entering the ephemeral is reset." | |
eec82323 LMI |
5638 | (if (not (buffer-name (car quit-config))) |
5639 | (gnus-configure-windows 'group 'force) | |
5640 | (set-buffer (car quit-config)) | |
5641 | (cond ((eq major-mode 'gnus-summary-mode) | |
5642 | (gnus-set-global-variables)) | |
5643 | ((eq major-mode 'gnus-article-mode) | |
5644 | (save-excursion | |
5645 | ;; The `gnus-summary-buffer' variable may point | |
5646 | ;; to the old summary buffer when using a single | |
5647 | ;; article buffer. | |
5648 | (unless (gnus-buffer-live-p gnus-summary-buffer) | |
5649 | (set-buffer gnus-group-buffer)) | |
5650 | (set-buffer gnus-summary-buffer) | |
5651 | (gnus-set-global-variables)))) | |
5652 | (if (or (eq (cdr quit-config) 'article) | |
5653 | (eq (cdr quit-config) 'pick)) | |
5654 | (progn | |
5655 | ;; The current article may be from the ephemeral group | |
5656 | ;; thus it is best that we reload this article | |
5657 | (gnus-summary-show-article) | |
5658 | (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode)) | |
5659 | (gnus-configure-windows 'pick 'force) | |
5660 | (gnus-configure-windows (cdr quit-config) 'force))) | |
5661 | (gnus-configure-windows (cdr quit-config) 'force)) | |
5662 | (when (eq major-mode 'gnus-summary-mode) | |
5663 | (gnus-summary-next-subject 1 nil t) | |
5664 | (gnus-summary-recenter) | |
5665 | (gnus-summary-position-point)))) | |
5666 | ||
5667 | ;;; Dead summaries. | |
5668 | ||
5669 | (defvar gnus-dead-summary-mode-map nil) | |
5670 | ||
5671 | (unless gnus-dead-summary-mode-map | |
5672 | (setq gnus-dead-summary-mode-map (make-keymap)) | |
5673 | (suppress-keymap gnus-dead-summary-mode-map) | |
5674 | (substitute-key-definition | |
5675 | 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map) | |
a8151ef7 | 5676 | (let ((keys '("\C-d" "\r" "\177" [delete]))) |
eec82323 LMI |
5677 | (while keys |
5678 | (define-key gnus-dead-summary-mode-map | |
5679 | (pop keys) 'gnus-summary-wake-up-the-dead)))) | |
5680 | ||
5681 | (defvar gnus-dead-summary-mode nil | |
5682 | "Minor mode for Gnus summary buffers.") | |
5683 | ||
5684 | (defun gnus-dead-summary-mode (&optional arg) | |
5685 | "Minor mode for Gnus summary buffers." | |
5686 | (interactive "P") | |
5687 | (when (eq major-mode 'gnus-summary-mode) | |
5688 | (make-local-variable 'gnus-dead-summary-mode) | |
5689 | (setq gnus-dead-summary-mode | |
5690 | (if (null arg) (not gnus-dead-summary-mode) | |
5691 | (> (prefix-numeric-value arg) 0))) | |
5692 | (when gnus-dead-summary-mode | |
a8151ef7 LMI |
5693 | (gnus-add-minor-mode |
5694 | 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map)))) | |
eec82323 LMI |
5695 | |
5696 | (defun gnus-deaden-summary () | |
5697 | "Make the current summary buffer into a dead summary buffer." | |
5698 | ;; Kill any previous dead summary buffer. | |
5699 | (when (and gnus-dead-summary | |
5700 | (buffer-name gnus-dead-summary)) | |
5701 | (save-excursion | |
5702 | (set-buffer gnus-dead-summary) | |
5703 | (when gnus-dead-summary-mode | |
5704 | (kill-buffer (current-buffer))))) | |
5705 | ;; Make this the current dead summary. | |
5706 | (setq gnus-dead-summary (current-buffer)) | |
5707 | (gnus-dead-summary-mode 1) | |
5708 | (let ((name (buffer-name))) | |
5709 | (when (string-match "Summary" name) | |
5710 | (rename-buffer | |
5711 | (concat (substring name 0 (match-beginning 0)) "Dead " | |
5712 | (substring name (match-beginning 0))) | |
16409b0b GM |
5713 | t) |
5714 | (bury-buffer)))) | |
eec82323 LMI |
5715 | |
5716 | (defun gnus-kill-or-deaden-summary (buffer) | |
5717 | "Kill or deaden the summary BUFFER." | |
6748645f LMI |
5718 | (save-excursion |
5719 | (when (and (buffer-name buffer) | |
5720 | (not gnus-single-article-buffer)) | |
5721 | (save-excursion | |
5722 | (set-buffer buffer) | |
5723 | (gnus-kill-buffer gnus-article-buffer) | |
5724 | (gnus-kill-buffer gnus-original-article-buffer))) | |
5725 | (cond (gnus-kill-summary-on-exit | |
5726 | (when (and gnus-use-trees | |
5727 | (gnus-buffer-exists-p buffer)) | |
5728 | (save-excursion | |
5729 | (set-buffer buffer) | |
5730 | (gnus-tree-close gnus-newsgroup-name))) | |
5731 | (gnus-kill-buffer buffer)) | |
5732 | ((gnus-buffer-exists-p buffer) | |
eec82323 | 5733 | (save-excursion |
6748645f LMI |
5734 | (set-buffer buffer) |
5735 | (gnus-deaden-summary)))))) | |
eec82323 LMI |
5736 | |
5737 | (defun gnus-summary-wake-up-the-dead (&rest args) | |
5738 | "Wake up the dead summary buffer." | |
5739 | (interactive) | |
5740 | (gnus-dead-summary-mode -1) | |
5741 | (let ((name (buffer-name))) | |
5742 | (when (string-match "Dead " name) | |
5743 | (rename-buffer | |
5744 | (concat (substring name 0 (match-beginning 0)) | |
5745 | (substring name (match-end 0))) | |
5746 | t))) | |
5747 | (gnus-message 3 "This dead summary is now alive again")) | |
5748 | ||
5749 | ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>. | |
5750 | (defun gnus-summary-fetch-faq (&optional faq-dir) | |
5751 | "Fetch the FAQ for the current group. | |
5752 | If FAQ-DIR (the prefix), prompt for a directory to search for the faq | |
5753 | in." | |
5754 | (interactive | |
5755 | (list | |
5756 | (when current-prefix-arg | |
5757 | (completing-read | |
5758 | "Faq dir: " (and (listp gnus-group-faq-directory) | |
a8151ef7 LMI |
5759 | (mapcar (lambda (file) (list file)) |
5760 | gnus-group-faq-directory)))))) | |
eec82323 LMI |
5761 | (let (gnus-faq-buffer) |
5762 | (when (setq gnus-faq-buffer | |
5763 | (gnus-group-fetch-faq gnus-newsgroup-name faq-dir)) | |
5764 | (gnus-configure-windows 'summary-faq)))) | |
5765 | ||
5766 | ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>. | |
5767 | (defun gnus-summary-describe-group (&optional force) | |
5768 | "Describe the current newsgroup." | |
5769 | (interactive "P") | |
5770 | (gnus-group-describe-group force gnus-newsgroup-name)) | |
5771 | ||
5772 | (defun gnus-summary-describe-briefly () | |
5773 | "Describe summary mode commands briefly." | |
5774 | (interactive) | |
16409b0b | 5775 | (gnus-message 6 (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"))) |
eec82323 LMI |
5776 | |
5777 | ;; Walking around group mode buffer from summary mode. | |
5778 | ||
5779 | (defun gnus-summary-next-group (&optional no-article target-group backward) | |
5780 | "Exit current newsgroup and then select next unread newsgroup. | |
5781 | If prefix argument NO-ARTICLE is non-nil, no article is selected | |
5782 | initially. If NEXT-GROUP, go to this group. If BACKWARD, go to | |
5783 | previous group instead." | |
5784 | (interactive "P") | |
eec82323 LMI |
5785 | ;; Stop pre-fetching. |
5786 | (gnus-async-halt-prefetch) | |
5787 | (let ((current-group gnus-newsgroup-name) | |
5788 | (current-buffer (current-buffer)) | |
5789 | entered) | |
5790 | ;; First we semi-exit this group to update Xrefs and all variables. | |
5791 | ;; We can't do a real exit, because the window conf must remain | |
5792 | ;; the same in case the user is prompted for info, and we don't | |
5793 | ;; want the window conf to change before that... | |
5794 | (gnus-summary-exit t) | |
5795 | (while (not entered) | |
5796 | ;; Then we find what group we are supposed to enter. | |
5797 | (set-buffer gnus-group-buffer) | |
5798 | (gnus-group-jump-to-group current-group) | |
5799 | (setq target-group | |
5800 | (or target-group | |
5801 | (if (eq gnus-keep-same-level 'best) | |
5802 | (gnus-summary-best-group gnus-newsgroup-name) | |
5803 | (gnus-summary-search-group backward gnus-keep-same-level)))) | |
5804 | (if (not target-group) | |
5805 | ;; There are no further groups, so we return to the group | |
5806 | ;; buffer. | |
5807 | (progn | |
5808 | (gnus-message 5 "Returning to the group buffer") | |
5809 | (setq entered t) | |
5810 | (when (gnus-buffer-live-p current-buffer) | |
5811 | (set-buffer current-buffer) | |
5812 | (gnus-summary-exit)) | |
6748645f | 5813 | (gnus-run-hooks 'gnus-group-no-more-groups-hook)) |
eec82323 LMI |
5814 | ;; We try to enter the target group. |
5815 | (gnus-group-jump-to-group target-group) | |
5816 | (let ((unreads (gnus-group-group-unread))) | |
5817 | (if (and (or (eq t unreads) | |
5818 | (and unreads (not (zerop unreads)))) | |
5819 | (gnus-summary-read-group | |
a8151ef7 | 5820 | target-group nil no-article |
6748645f LMI |
5821 | (and (buffer-name current-buffer) current-buffer) |
5822 | nil backward)) | |
eec82323 LMI |
5823 | (setq entered t) |
5824 | (setq current-group target-group | |
5825 | target-group nil))))))) | |
5826 | ||
5827 | (defun gnus-summary-prev-group (&optional no-article) | |
5828 | "Exit current newsgroup and then select previous unread newsgroup. | |
5829 | If prefix argument NO-ARTICLE is non-nil, no article is selected initially." | |
5830 | (interactive "P") | |
5831 | (gnus-summary-next-group no-article nil t)) | |
5832 | ||
5833 | ;; Walking around summary lines. | |
5834 | ||
6748645f | 5835 | (defun gnus-summary-first-subject (&optional unread undownloaded) |
eec82323 LMI |
5836 | "Go to the first unread subject. |
5837 | If UNREAD is non-nil, go to the first unread article. | |
5838 | Returns the article selected or nil if there are no unread articles." | |
5839 | (interactive "P") | |
5840 | (prog1 | |
5841 | (cond | |
5842 | ;; Empty summary. | |
5843 | ((null gnus-newsgroup-data) | |
5844 | (gnus-message 3 "No articles in the group") | |
5845 | nil) | |
5846 | ;; Pick the first article. | |
5847 | ((not unread) | |
5848 | (goto-char (gnus-data-pos (car gnus-newsgroup-data))) | |
5849 | (gnus-data-number (car gnus-newsgroup-data))) | |
5850 | ;; No unread articles. | |
5851 | ((null gnus-newsgroup-unreads) | |
5852 | (gnus-message 3 "No more unread articles") | |
5853 | nil) | |
5854 | ;; Find the first unread article. | |
5855 | (t | |
5856 | (let ((data gnus-newsgroup-data)) | |
5857 | (while (and data | |
6748645f LMI |
5858 | (and (not (and undownloaded |
5859 | (eq gnus-undownloaded-mark | |
5860 | (gnus-data-mark (car data))))) | |
5861 | (not (gnus-data-unread-p (car data))))) | |
eec82323 LMI |
5862 | (setq data (cdr data))) |
5863 | (when data | |
5864 | (goto-char (gnus-data-pos (car data))) | |
5865 | (gnus-data-number (car data)))))) | |
5866 | (gnus-summary-position-point))) | |
5867 | ||
5868 | (defun gnus-summary-next-subject (n &optional unread dont-display) | |
5869 | "Go to next N'th summary line. | |
5870 | If N is negative, go to the previous N'th subject line. | |
5871 | If UNREAD is non-nil, only unread articles are selected. | |
5872 | The difference between N and the actual number of steps taken is | |
5873 | returned." | |
5874 | (interactive "p") | |
5875 | (let ((backward (< n 0)) | |
5876 | (n (abs n))) | |
5877 | (while (and (> n 0) | |
5878 | (if backward | |
5879 | (gnus-summary-find-prev unread) | |
5880 | (gnus-summary-find-next unread))) | |
16409b0b GM |
5881 | (unless (zerop (setq n (1- n))) |
5882 | (gnus-summary-show-thread))) | |
eec82323 LMI |
5883 | (when (/= 0 n) |
5884 | (gnus-message 7 "No more%s articles" | |
5885 | (if unread " unread" ""))) | |
5886 | (unless dont-display | |
5887 | (gnus-summary-recenter) | |
5888 | (gnus-summary-position-point)) | |
5889 | n)) | |
5890 | ||
5891 | (defun gnus-summary-next-unread-subject (n) | |
5892 | "Go to next N'th unread summary line." | |
5893 | (interactive "p") | |
5894 | (gnus-summary-next-subject n t)) | |
5895 | ||
5896 | (defun gnus-summary-prev-subject (n &optional unread) | |
5897 | "Go to previous N'th summary line. | |
5898 | If optional argument UNREAD is non-nil, only unread article is selected." | |
5899 | (interactive "p") | |
5900 | (gnus-summary-next-subject (- n) unread)) | |
5901 | ||
5902 | (defun gnus-summary-prev-unread-subject (n) | |
5903 | "Go to previous N'th unread summary line." | |
5904 | (interactive "p") | |
5905 | (gnus-summary-next-subject (- n) t)) | |
5906 | ||
5907 | (defun gnus-summary-goto-subject (article &optional force silent) | |
5908 | "Go the subject line of ARTICLE. | |
5909 | If FORCE, also allow jumping to articles not currently shown." | |
5910 | (interactive "nArticle number: ") | |
5911 | (let ((b (point)) | |
5912 | (data (gnus-data-find article))) | |
5913 | ;; We read in the article if we have to. | |
5914 | (and (not data) | |
5915 | force | |
6748645f LMI |
5916 | (gnus-summary-insert-subject |
5917 | article | |
5918 | (if (or (numberp force) (vectorp force)) force) | |
5919 | t) | |
eec82323 LMI |
5920 | (setq data (gnus-data-find article))) |
5921 | (goto-char b) | |
5922 | (if (not data) | |
5923 | (progn | |
5924 | (unless silent | |
5925 | (gnus-message 3 "Can't find article %d" article)) | |
5926 | nil) | |
5927 | (goto-char (gnus-data-pos data)) | |
6748645f | 5928 | (gnus-summary-position-point) |
eec82323 LMI |
5929 | article))) |
5930 | ||
5931 | ;; Walking around summary lines with displaying articles. | |
5932 | ||
5933 | (defun gnus-summary-expand-window (&optional arg) | |
5934 | "Make the summary buffer take up the entire Emacs frame. | |
5935 | Given a prefix, will force an `article' buffer configuration." | |
5936 | (interactive "P") | |
eec82323 LMI |
5937 | (if arg |
5938 | (gnus-configure-windows 'article 'force) | |
5939 | (gnus-configure-windows 'summary 'force))) | |
5940 | ||
5941 | (defun gnus-summary-display-article (article &optional all-header) | |
5942 | "Display ARTICLE in article buffer." | |
d4dfaa19 DL |
5943 | (when (gnus-buffer-live-p gnus-article-buffer) |
5944 | (with-current-buffer gnus-article-buffer | |
5945 | (mm-enable-multibyte-mule4))) | |
eec82323 LMI |
5946 | (gnus-set-global-variables) |
5947 | (if (null article) | |
5948 | nil | |
5949 | (prog1 | |
5950 | (if gnus-summary-display-article-function | |
5951 | (funcall gnus-summary-display-article-function article all-header) | |
5952 | (gnus-article-prepare article all-header)) | |
6748645f | 5953 | (gnus-run-hooks 'gnus-select-article-hook) |
eec82323 LMI |
5954 | (when (and gnus-current-article |
5955 | (not (zerop gnus-current-article))) | |
5956 | (gnus-summary-goto-subject gnus-current-article)) | |
5957 | (gnus-summary-recenter) | |
5958 | (when (and gnus-use-trees gnus-show-threads) | |
5959 | (gnus-possibly-generate-tree article) | |
5960 | (gnus-highlight-selected-tree article)) | |
5961 | ;; Successfully display article. | |
5962 | (gnus-article-set-window-start | |
5963 | (cdr (assq article gnus-newsgroup-bookmarks)))))) | |
5964 | ||
5965 | (defun gnus-summary-select-article (&optional all-headers force pseudo article) | |
5966 | "Select the current article. | |
5967 | If ALL-HEADERS is non-nil, show all header fields. If FORCE is | |
5968 | non-nil, the article will be re-fetched even if it already present in | |
5969 | the article buffer. If PSEUDO is non-nil, pseudo-articles will also | |
5970 | be displayed." | |
5971 | ;; Make sure we are in the summary buffer to work around bbdb bug. | |
5972 | (unless (eq major-mode 'gnus-summary-mode) | |
5973 | (set-buffer gnus-summary-buffer)) | |
5974 | (let ((article (or article (gnus-summary-article-number))) | |
5975 | (all-headers (not (not all-headers))) ;Must be T or NIL. | |
16409b0b | 5976 | gnus-summary-display-article-function) |
eec82323 LMI |
5977 | (and (not pseudo) |
5978 | (gnus-summary-article-pseudo-p article) | |
a8151ef7 | 5979 | (error "This is a pseudo-article")) |
16409b0b GM |
5980 | (save-excursion |
5981 | (set-buffer gnus-summary-buffer) | |
5982 | (if (or (and gnus-single-article-buffer | |
5983 | (or (null gnus-current-article) | |
5984 | (null gnus-article-current) | |
5985 | (null (get-buffer gnus-article-buffer)) | |
5986 | (not (eq article (cdr gnus-article-current))) | |
5987 | (not (equal (car gnus-article-current) | |
5988 | gnus-newsgroup-name)))) | |
5989 | (and (not gnus-single-article-buffer) | |
5990 | (or (null gnus-current-article) | |
5991 | (not (eq gnus-current-article article)))) | |
5992 | force) | |
5993 | ;; The requested article is different from the current article. | |
5994 | (progn | |
16409b0b GM |
5995 | (gnus-summary-display-article article all-headers) |
5996 | (when (gnus-buffer-live-p gnus-article-buffer) | |
d4dfaa19 | 5997 | (with-current-buffer gnus-article-buffer |
16409b0b | 5998 | (if (not gnus-article-decoded-p) ;; a local variable |
d4dfaa19 | 5999 | (mm-disable-multibyte-mule4)))) |
eec82323 LMI |
6000 | (when (or all-headers gnus-show-all-headers) |
6001 | (gnus-article-show-all-headers)) | |
16409b0b GM |
6002 | (gnus-article-set-window-start |
6003 | (cdr (assq article gnus-newsgroup-bookmarks))) | |
6004 | article) | |
6005 | (when (or all-headers gnus-show-all-headers) | |
6006 | (gnus-article-show-all-headers)) | |
6007 | 'old)))) | |
eec82323 LMI |
6008 | |
6009 | (defun gnus-summary-set-current-mark (&optional current-mark) | |
6010 | "Obsolete function." | |
6011 | nil) | |
6012 | ||
6013 | (defun gnus-summary-next-article (&optional unread subject backward push) | |
6014 | "Select the next article. | |
6015 | If UNREAD, only unread articles are selected. | |
6016 | If SUBJECT, only articles with SUBJECT are selected. | |
6017 | If BACKWARD, the previous article is selected instead of the next." | |
6018 | (interactive "P") | |
eec82323 LMI |
6019 | (cond |
6020 | ;; Is there such an article? | |
6021 | ((and (gnus-summary-search-forward unread subject backward) | |
6022 | (or (gnus-summary-display-article (gnus-summary-article-number)) | |
6023 | (eq (gnus-summary-article-mark) gnus-canceled-mark))) | |
6024 | (gnus-summary-position-point)) | |
6025 | ;; If not, we try the first unread, if that is wanted. | |
6026 | ((and subject | |
6027 | gnus-auto-select-same | |
6028 | (gnus-summary-first-unread-article)) | |
6029 | (gnus-summary-position-point) | |
6030 | (gnus-message 6 "Wrapped")) | |
6031 | ;; Try to get next/previous article not displayed in this group. | |
6032 | ((and gnus-auto-extend-newsgroup | |
6033 | (not unread) (not subject)) | |
6034 | (gnus-summary-goto-article | |
6035 | (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end)) | |
6748645f | 6036 | nil (count-lines (point-min) (point)))) |
eec82323 LMI |
6037 | ;; Go to next/previous group. |
6038 | (t | |
6039 | (unless (gnus-ephemeral-group-p gnus-newsgroup-name) | |
6040 | (gnus-summary-jump-to-group gnus-newsgroup-name)) | |
6041 | (let ((cmd last-command-char) | |
6042 | (point | |
6043 | (save-excursion | |
6044 | (set-buffer gnus-group-buffer) | |
6045 | (point))) | |
6046 | (group | |
6047 | (if (eq gnus-keep-same-level 'best) | |
6048 | (gnus-summary-best-group gnus-newsgroup-name) | |
6049 | (gnus-summary-search-group backward gnus-keep-same-level)))) | |
6050 | ;; For some reason, the group window gets selected. We change | |
6051 | ;; it back. | |
6052 | (select-window (get-buffer-window (current-buffer))) | |
6053 | ;; Select next unread newsgroup automagically. | |
6054 | (cond | |
6055 | ((or (not gnus-auto-select-next) | |
6056 | (not cmd)) | |
6057 | (gnus-message 7 "No more%s articles" (if unread " unread" ""))) | |
6058 | ((or (eq gnus-auto-select-next 'quietly) | |
6059 | (and (eq gnus-auto-select-next 'slightly-quietly) | |
6060 | push) | |
6061 | (and (eq gnus-auto-select-next 'almost-quietly) | |
6062 | (gnus-summary-last-article-p))) | |
6063 | ;; Select quietly. | |
6064 | (if (gnus-ephemeral-group-p gnus-newsgroup-name) | |
6065 | (gnus-summary-exit) | |
6066 | (gnus-message 7 "No more%s articles (%s)..." | |
6067 | (if unread " unread" "") | |
6068 | (if group (concat "selecting " group) | |
6069 | "exiting")) | |
6070 | (gnus-summary-next-group nil group backward))) | |
6071 | (t | |
6072 | (when (gnus-key-press-event-p last-input-event) | |
6073 | (gnus-summary-walk-group-buffer | |
6074 | gnus-newsgroup-name cmd unread backward point)))))))) | |
6075 | ||
6076 | (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start) | |
6077 | (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1)) | |
6078 | (?\C-p (gnus-group-prev-unread-group 1)))) | |
6079 | (cursor-in-echo-area t) | |
6080 | keve key group ended) | |
6081 | (save-excursion | |
6082 | (set-buffer gnus-group-buffer) | |
6083 | (goto-char start) | |
6084 | (setq group | |
6085 | (if (eq gnus-keep-same-level 'best) | |
6086 | (gnus-summary-best-group gnus-newsgroup-name) | |
6087 | (gnus-summary-search-group backward gnus-keep-same-level)))) | |
6088 | (while (not ended) | |
6089 | (gnus-message | |
6090 | 5 "No more%s articles%s" (if unread " unread" "") | |
6091 | (if (and group | |
6092 | (not (gnus-ephemeral-group-p gnus-newsgroup-name))) | |
6093 | (format " (Type %s for %s [%s])" | |
6094 | (single-key-description cmd) group | |
6095 | (car (gnus-gethash group gnus-newsrc-hashtb))) | |
6096 | (format " (Type %s to exit %s)" | |
6097 | (single-key-description cmd) | |
6098 | gnus-newsgroup-name))) | |
6099 | ;; Confirm auto selection. | |
6100 | (setq key (car (setq keve (gnus-read-event-char)))) | |
6101 | (setq ended t) | |
6102 | (cond | |
6103 | ((assq key keystrokes) | |
6104 | (let ((obuf (current-buffer))) | |
6105 | (switch-to-buffer gnus-group-buffer) | |
6106 | (when group | |
6107 | (gnus-group-jump-to-group group)) | |
6108 | (eval (cadr (assq key keystrokes))) | |
6109 | (setq group (gnus-group-group-name)) | |
6110 | (switch-to-buffer obuf)) | |
6111 | (setq ended nil)) | |
6112 | ((equal key cmd) | |
6113 | (if (or (not group) | |
6114 | (gnus-ephemeral-group-p gnus-newsgroup-name)) | |
6115 | (gnus-summary-exit) | |
6116 | (gnus-summary-next-group nil group backward))) | |
6117 | (t | |
6118 | (push (cdr keve) unread-command-events)))))) | |
6119 | ||
6120 | (defun gnus-summary-next-unread-article () | |
6121 | "Select unread article after current one." | |
6122 | (interactive) | |
6123 | (gnus-summary-next-article | |
6124 | (or (not (eq gnus-summary-goto-unread 'never)) | |
6125 | (gnus-summary-last-article-p (gnus-summary-article-number))) | |
6126 | (and gnus-auto-select-same | |
6127 | (gnus-summary-article-subject)))) | |
6128 | ||
6129 | (defun gnus-summary-prev-article (&optional unread subject) | |
6130 | "Select the article after the current one. | |
6131 | If UNREAD is non-nil, only unread articles are selected." | |
6132 | (interactive "P") | |
6133 | (gnus-summary-next-article unread subject t)) | |
6134 | ||
6135 | (defun gnus-summary-prev-unread-article () | |
6136 | "Select unread article before current one." | |
6137 | (interactive) | |
6138 | (gnus-summary-prev-article | |
6139 | (or (not (eq gnus-summary-goto-unread 'never)) | |
6140 | (gnus-summary-first-article-p (gnus-summary-article-number))) | |
6141 | (and gnus-auto-select-same | |
6142 | (gnus-summary-article-subject)))) | |
6143 | ||
6144 | (defun gnus-summary-next-page (&optional lines circular) | |
6145 | "Show next page of the selected article. | |
6146 | If at the end of the current article, select the next article. | |
6147 | LINES says how many lines should be scrolled up. | |
6148 | ||
6149 | If CIRCULAR is non-nil, go to the start of the article instead of | |
6150 | selecting the next article when reaching the end of the current | |
6151 | article." | |
6152 | (interactive "P") | |
6153 | (setq gnus-summary-buffer (current-buffer)) | |
6154 | (gnus-set-global-variables) | |
6155 | (let ((article (gnus-summary-article-number)) | |
6156 | (article-window (get-buffer-window gnus-article-buffer t)) | |
6157 | endp) | |
6748645f LMI |
6158 | ;; If the buffer is empty, we have no article. |
6159 | (unless article | |
6160 | (error "No article to select")) | |
eec82323 LMI |
6161 | (gnus-configure-windows 'article) |
6162 | (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark) | |
6163 | (if (and (eq gnus-summary-goto-unread 'never) | |
6164 | (not (gnus-summary-last-article-p article))) | |
6165 | (gnus-summary-next-article) | |
6166 | (gnus-summary-next-unread-article)) | |
6167 | (if (or (null gnus-current-article) | |
6168 | (null gnus-article-current) | |
6169 | (/= article (cdr gnus-article-current)) | |
6170 | (not (equal (car gnus-article-current) gnus-newsgroup-name))) | |
6171 | ;; Selected subject is different from current article's. | |
6172 | (gnus-summary-display-article article) | |
6173 | (when article-window | |
6174 | (gnus-eval-in-buffer-window gnus-article-buffer | |
6175 | (setq endp (gnus-article-next-page lines))) | |
6176 | (when endp | |
6177 | (cond (circular | |
6178 | (gnus-summary-beginning-of-article)) | |
6179 | (lines | |
6180 | (gnus-message 3 "End of message")) | |
6181 | ((null lines) | |
6182 | (if (and (eq gnus-summary-goto-unread 'never) | |
6183 | (not (gnus-summary-last-article-p article))) | |
6184 | (gnus-summary-next-article) | |
6185 | (gnus-summary-next-unread-article)))))))) | |
6186 | (gnus-summary-recenter) | |
6187 | (gnus-summary-position-point))) | |
6188 | ||
6189 | (defun gnus-summary-prev-page (&optional lines move) | |
6190 | "Show previous page of selected article. | |
6191 | Argument LINES specifies lines to be scrolled down. | |
6192 | If MOVE, move to the previous unread article if point is at | |
6193 | the beginning of the buffer." | |
6194 | (interactive "P") | |
eec82323 LMI |
6195 | (let ((article (gnus-summary-article-number)) |
6196 | (article-window (get-buffer-window gnus-article-buffer t)) | |
6197 | endp) | |
6198 | (gnus-configure-windows 'article) | |
6199 | (if (or (null gnus-current-article) | |
6200 | (null gnus-article-current) | |
6201 | (/= article (cdr gnus-article-current)) | |
6202 | (not (equal (car gnus-article-current) gnus-newsgroup-name))) | |
6203 | ;; Selected subject is different from current article's. | |
6204 | (gnus-summary-display-article article) | |
6205 | (gnus-summary-recenter) | |
6206 | (when article-window | |
6207 | (gnus-eval-in-buffer-window gnus-article-buffer | |
6208 | (setq endp (gnus-article-prev-page lines))) | |
6209 | (when (and move endp) | |
6210 | (cond (lines | |
6211 | (gnus-message 3 "Beginning of message")) | |
6212 | ((null lines) | |
6213 | (if (and (eq gnus-summary-goto-unread 'never) | |
6214 | (not (gnus-summary-first-article-p article))) | |
6215 | (gnus-summary-prev-article) | |
6216 | (gnus-summary-prev-unread-article)))))))) | |
6217 | (gnus-summary-position-point)) | |
6218 | ||
6219 | (defun gnus-summary-prev-page-or-article (&optional lines) | |
6220 | "Show previous page of selected article. | |
6221 | Argument LINES specifies lines to be scrolled down. | |
6222 | If at the beginning of the article, go to the next article." | |
6223 | (interactive "P") | |
6224 | (gnus-summary-prev-page lines t)) | |
6225 | ||
6226 | (defun gnus-summary-scroll-up (lines) | |
6227 | "Scroll up (or down) one line current article. | |
6228 | Argument LINES specifies lines to be scrolled up (or down if negative)." | |
6229 | (interactive "p") | |
eec82323 LMI |
6230 | (gnus-configure-windows 'article) |
6231 | (gnus-summary-show-thread) | |
6232 | (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old) | |
6233 | (gnus-eval-in-buffer-window gnus-article-buffer | |
6234 | (cond ((> lines 0) | |
6235 | (when (gnus-article-next-page lines) | |
6236 | (gnus-message 3 "End of message"))) | |
6237 | ((< lines 0) | |
6238 | (gnus-article-prev-page (- lines)))))) | |
6239 | (gnus-summary-recenter) | |
6240 | (gnus-summary-position-point)) | |
6241 | ||
6748645f LMI |
6242 | (defun gnus-summary-scroll-down (lines) |
6243 | "Scroll down (or up) one line current article. | |
6244 | Argument LINES specifies lines to be scrolled down (or up if negative)." | |
6245 | (interactive "p") | |
6246 | (gnus-summary-scroll-up (- lines))) | |
6247 | ||
eec82323 LMI |
6248 | (defun gnus-summary-next-same-subject () |
6249 | "Select next article which has the same subject as current one." | |
6250 | (interactive) | |
eec82323 LMI |
6251 | (gnus-summary-next-article nil (gnus-summary-article-subject))) |
6252 | ||
6253 | (defun gnus-summary-prev-same-subject () | |
6254 | "Select previous article which has the same subject as current one." | |
6255 | (interactive) | |
eec82323 LMI |
6256 | (gnus-summary-prev-article nil (gnus-summary-article-subject))) |
6257 | ||
6258 | (defun gnus-summary-next-unread-same-subject () | |
6259 | "Select next unread article which has the same subject as current one." | |
6260 | (interactive) | |
eec82323 LMI |
6261 | (gnus-summary-next-article t (gnus-summary-article-subject))) |
6262 | ||
6263 | (defun gnus-summary-prev-unread-same-subject () | |
6264 | "Select previous unread article which has the same subject as current one." | |
6265 | (interactive) | |
eec82323 LMI |
6266 | (gnus-summary-prev-article t (gnus-summary-article-subject))) |
6267 | ||
6268 | (defun gnus-summary-first-unread-article () | |
6269 | "Select the first unread article. | |
6270 | Return nil if there are no unread articles." | |
6271 | (interactive) | |
eec82323 LMI |
6272 | (prog1 |
6273 | (when (gnus-summary-first-subject t) | |
6274 | (gnus-summary-show-thread) | |
6275 | (gnus-summary-first-subject t) | |
6276 | (gnus-summary-display-article (gnus-summary-article-number))) | |
6277 | (gnus-summary-position-point))) | |
6278 | ||
16409b0b GM |
6279 | (defun gnus-summary-first-unread-subject () |
6280 | "Place the point on the subject line of the first unread article. | |
6281 | Return nil if there are no unread articles." | |
6282 | (interactive) | |
6283 | (prog1 | |
6284 | (when (gnus-summary-first-subject t) | |
6285 | (gnus-summary-show-thread) | |
6286 | (gnus-summary-first-subject t)) | |
6287 | (gnus-summary-position-point))) | |
6288 | ||
eec82323 LMI |
6289 | (defun gnus-summary-first-article () |
6290 | "Select the first article. | |
6291 | Return nil if there are no articles." | |
6292 | (interactive) | |
eec82323 LMI |
6293 | (prog1 |
6294 | (when (gnus-summary-first-subject) | |
16409b0b GM |
6295 | (gnus-summary-show-thread) |
6296 | (gnus-summary-first-subject) | |
6297 | (gnus-summary-display-article (gnus-summary-article-number))) | |
eec82323 LMI |
6298 | (gnus-summary-position-point))) |
6299 | ||
6300 | (defun gnus-summary-best-unread-article () | |
6301 | "Select the unread article with the highest score." | |
6302 | (interactive) | |
eec82323 LMI |
6303 | (let ((best -1000000) |
6304 | (data gnus-newsgroup-data) | |
6305 | article score) | |
6306 | (while data | |
6307 | (and (gnus-data-unread-p (car data)) | |
6308 | (> (setq score | |
6309 | (gnus-summary-article-score (gnus-data-number (car data)))) | |
6310 | best) | |
6311 | (setq best score | |
6312 | article (gnus-data-number (car data)))) | |
6313 | (setq data (cdr data))) | |
6314 | (prog1 | |
6315 | (if article | |
6316 | (gnus-summary-goto-article article) | |
6317 | (error "No unread articles")) | |
6318 | (gnus-summary-position-point)))) | |
6319 | ||
6320 | (defun gnus-summary-last-subject () | |
6321 | "Go to the last displayed subject line in the group." | |
6322 | (let ((article (gnus-data-number (car (gnus-data-list t))))) | |
6323 | (when article | |
6324 | (gnus-summary-goto-subject article)))) | |
6325 | ||
6326 | (defun gnus-summary-goto-article (article &optional all-headers force) | |
6748645f LMI |
6327 | "Fetch ARTICLE (article number or Message-ID) and display it if it exists. |
6328 | If ALL-HEADERS is non-nil, no header lines are hidden. | |
6329 | If FORCE, go to the article even if it isn't displayed. If FORCE | |
6330 | is a number, it is the line the article is to be displayed on." | |
eec82323 LMI |
6331 | (interactive |
6332 | (list | |
6748645f LMI |
6333 | (completing-read |
6334 | "Article number or Message-ID: " | |
6335 | (mapcar (lambda (number) (list (int-to-string number))) | |
6336 | gnus-newsgroup-limit)) | |
eec82323 LMI |
6337 | current-prefix-arg |
6338 | t)) | |
6339 | (prog1 | |
6748645f LMI |
6340 | (if (and (stringp article) |
6341 | (string-match "@" article)) | |
6342 | (gnus-summary-refer-article article) | |
6343 | (when (stringp article) | |
6344 | (setq article (string-to-number article))) | |
6345 | (if (gnus-summary-goto-subject article force) | |
6346 | (gnus-summary-display-article article all-headers) | |
6347 | (gnus-message 4 "Couldn't go to article %s" article) nil)) | |
eec82323 LMI |
6348 | (gnus-summary-position-point))) |
6349 | ||
6350 | (defun gnus-summary-goto-last-article () | |
6351 | "Go to the previously read article." | |
6352 | (interactive) | |
6353 | (prog1 | |
6354 | (when gnus-last-article | |
6748645f | 6355 | (gnus-summary-goto-article gnus-last-article nil t)) |
eec82323 LMI |
6356 | (gnus-summary-position-point))) |
6357 | ||
6358 | (defun gnus-summary-pop-article (number) | |
6359 | "Pop one article off the history and go to the previous. | |
6360 | NUMBER articles will be popped off." | |
6361 | (interactive "p") | |
6362 | (let (to) | |
6363 | (setq gnus-newsgroup-history | |
6364 | (cdr (setq to (nthcdr number gnus-newsgroup-history)))) | |
6365 | (if to | |
6748645f | 6366 | (gnus-summary-goto-article (car to) nil t) |
eec82323 LMI |
6367 | (error "Article history empty"))) |
6368 | (gnus-summary-position-point)) | |
6369 | ||
6370 | ;; Summary commands and functions for limiting the summary buffer. | |
6371 | ||
6372 | (defun gnus-summary-limit-to-articles (n) | |
6373 | "Limit the summary buffer to the next N articles. | |
6374 | If not given a prefix, use the process marked articles instead." | |
6375 | (interactive "P") | |
eec82323 LMI |
6376 | (prog1 |
6377 | (let ((articles (gnus-summary-work-articles n))) | |
6378 | (setq gnus-newsgroup-processable nil) | |
6379 | (gnus-summary-limit articles)) | |
6380 | (gnus-summary-position-point))) | |
6381 | ||
6382 | (defun gnus-summary-pop-limit (&optional total) | |
6383 | "Restore the previous limit. | |
6384 | If given a prefix, remove all limits." | |
6385 | (interactive "P") | |
eec82323 LMI |
6386 | (when total |
6387 | (setq gnus-newsgroup-limits | |
6388 | (list (mapcar (lambda (h) (mail-header-number h)) | |
6389 | gnus-newsgroup-headers)))) | |
6390 | (unless gnus-newsgroup-limits | |
6391 | (error "No limit to pop")) | |
6392 | (prog1 | |
6393 | (gnus-summary-limit nil 'pop) | |
6394 | (gnus-summary-position-point))) | |
6395 | ||
6396 | (defun gnus-summary-limit-to-subject (subject &optional header) | |
6397 | "Limit the summary buffer to articles that have subjects that match a regexp." | |
6398 | (interactive "sLimit to subject (regexp): ") | |
6399 | (unless header | |
6400 | (setq header "subject")) | |
6401 | (when (not (equal "" subject)) | |
6402 | (prog1 | |
6403 | (let ((articles (gnus-summary-find-matching | |
6404 | (or header "subject") subject 'all))) | |
6405 | (unless articles | |
6406 | (error "Found no matches for \"%s\"" subject)) | |
6407 | (gnus-summary-limit articles)) | |
6408 | (gnus-summary-position-point)))) | |
6409 | ||
6410 | (defun gnus-summary-limit-to-author (from) | |
6411 | "Limit the summary buffer to articles that have authors that match a regexp." | |
6412 | (interactive "sLimit to author (regexp): ") | |
6413 | (gnus-summary-limit-to-subject from "from")) | |
6414 | ||
6415 | (defun gnus-summary-limit-to-age (age &optional younger-p) | |
6416 | "Limit the summary buffer to articles that are older than (or equal) AGE days. | |
6417 | If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to | |
6418 | articles that are younger than AGE days." | |
16409b0b GM |
6419 | (interactive |
6420 | (let ((younger current-prefix-arg) | |
6421 | (days-got nil) | |
6422 | days) | |
6423 | (while (not days-got) | |
6424 | (setq days (if younger | |
6425 | (read-string "Limit to articles within (in days): ") | |
6426 | (read-string "Limit to articles old than (in days): "))) | |
6427 | (when (> (length days) 0) | |
6428 | (setq days (read days))) | |
6429 | (if (numberp days) | |
6430 | (setq days-got t) | |
6431 | (message "Please enter a number.") | |
6432 | (sleep-for 1))) | |
6433 | (list days younger))) | |
eec82323 LMI |
6434 | (prog1 |
6435 | (let ((data gnus-newsgroup-data) | |
16409b0b | 6436 | (cutoff (days-to-time age)) |
eec82323 LMI |
6437 | articles d date is-younger) |
6438 | (while (setq d (pop data)) | |
6439 | (when (and (vectorp (gnus-data-header d)) | |
6440 | (setq date (mail-header-date (gnus-data-header d)))) | |
16409b0b GM |
6441 | (setq is-younger (time-less-p |
6442 | (time-since (condition-case () | |
6443 | (date-to-time date) | |
6444 | (error '(0 0)))) | |
eec82323 | 6445 | cutoff)) |
6748645f LMI |
6446 | (when (if younger-p |
6447 | is-younger | |
6448 | (not is-younger)) | |
eec82323 LMI |
6449 | (push (gnus-data-number d) articles)))) |
6450 | (gnus-summary-limit (nreverse articles))) | |
6451 | (gnus-summary-position-point))) | |
6452 | ||
16409b0b GM |
6453 | (defun gnus-summary-limit-to-extra (header regexp) |
6454 | "Limit the summary buffer to articles that match an 'extra' header." | |
6455 | (interactive | |
6456 | (let ((header | |
6457 | (intern | |
6458 | (gnus-completing-read | |
6459 | (symbol-name (car gnus-extra-headers)) | |
6460 | "Limit extra header:" | |
6461 | (mapcar (lambda (x) | |
6462 | (cons (symbol-name x) x)) | |
6463 | gnus-extra-headers) | |
6464 | nil | |
6465 | t)))) | |
6466 | (list header | |
6467 | (read-string (format "Limit to header %s (regexp): " header))))) | |
6468 | (when (not (equal "" regexp)) | |
6469 | (prog1 | |
6470 | (let ((articles (gnus-summary-find-matching | |
6471 | (cons 'extra header) regexp 'all))) | |
6472 | (unless articles | |
6473 | (error "Found no matches for \"%s\"" regexp)) | |
6474 | (gnus-summary-limit articles)) | |
6475 | (gnus-summary-position-point)))) | |
6476 | ||
eec82323 LMI |
6477 | (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread) |
6478 | (make-obsolete | |
6479 | 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread) | |
6480 | ||
6481 | (defun gnus-summary-limit-to-unread (&optional all) | |
6482 | "Limit the summary buffer to articles that are not marked as read. | |
6483 | If ALL is non-nil, limit strictly to unread articles." | |
6484 | (interactive "P") | |
6485 | (if all | |
6486 | (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark)) | |
6487 | (gnus-summary-limit-to-marks | |
6488 | ;; Concat all the marks that say that an article is read and have | |
6489 | ;; those removed. | |
6490 | (list gnus-del-mark gnus-read-mark gnus-ancient-mark | |
6491 | gnus-killed-mark gnus-kill-file-mark | |
6492 | gnus-low-score-mark gnus-expirable-mark | |
6493 | gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark | |
6494 | gnus-duplicate-mark gnus-souped-mark) | |
6495 | 'reverse))) | |
6496 | ||
6497 | (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks) | |
6498 | (make-obsolete 'gnus-summary-delete-marked-with | |
6499 | 'gnus-summary-limit-exlude-marks) | |
6500 | ||
6501 | (defun gnus-summary-limit-exclude-marks (marks &optional reverse) | |
6502 | "Exclude articles that are marked with MARKS (e.g. \"DK\"). | |
6503 | If REVERSE, limit the summary buffer to articles that are marked | |
6504 | with MARKS. MARKS can either be a string of marks or a list of marks. | |
6505 | Returns how many articles were removed." | |
6506 | (interactive "sMarks: ") | |
6507 | (gnus-summary-limit-to-marks marks t)) | |
6508 | ||
6509 | (defun gnus-summary-limit-to-marks (marks &optional reverse) | |
6510 | "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\"). | |
6511 | If REVERSE (the prefix), limit the summary buffer to articles that are | |
6512 | not marked with MARKS. MARKS can either be a string of marks or a | |
6513 | list of marks. | |
6514 | Returns how many articles were removed." | |
6748645f | 6515 | (interactive "sMarks: \nP") |
eec82323 LMI |
6516 | (prog1 |
6517 | (let ((data gnus-newsgroup-data) | |
6518 | (marks (if (listp marks) marks | |
6519 | (append marks nil))) ; Transform to list. | |
6520 | articles) | |
6521 | (while data | |
6522 | (when (if reverse (not (memq (gnus-data-mark (car data)) marks)) | |
6523 | (memq (gnus-data-mark (car data)) marks)) | |
6524 | (push (gnus-data-number (car data)) articles)) | |
6525 | (setq data (cdr data))) | |
6526 | (gnus-summary-limit articles)) | |
6527 | (gnus-summary-position-point))) | |
6528 | ||
6529 | (defun gnus-summary-limit-to-score (&optional score) | |
6530 | "Limit to articles with score at or above SCORE." | |
6531 | (interactive "P") | |
eec82323 LMI |
6532 | (setq score (if score |
6533 | (prefix-numeric-value score) | |
6534 | (or gnus-summary-default-score 0))) | |
6535 | (let ((data gnus-newsgroup-data) | |
6536 | articles) | |
6537 | (while data | |
6538 | (when (>= (gnus-summary-article-score (gnus-data-number (car data))) | |
6539 | score) | |
6540 | (push (gnus-data-number (car data)) articles)) | |
6541 | (setq data (cdr data))) | |
6542 | (prog1 | |
6543 | (gnus-summary-limit articles) | |
6544 | (gnus-summary-position-point)))) | |
6545 | ||
6748645f LMI |
6546 | (defun gnus-summary-limit-include-thread (id) |
6547 | "Display all the hidden articles that in the current thread." | |
6548 | (interactive (list (mail-header-id (gnus-summary-article-header)))) | |
6549 | (let ((articles (gnus-articles-in-thread | |
6550 | (gnus-id-to-thread (gnus-root-id id))))) | |
6551 | (prog1 | |
6552 | (gnus-summary-limit (nconc articles gnus-newsgroup-limit)) | |
6553 | (gnus-summary-position-point)))) | |
6554 | ||
eec82323 | 6555 | (defun gnus-summary-limit-include-dormant () |
6748645f LMI |
6556 | "Display all the hidden articles that are marked as dormant. |
6557 | Note that this command only works on a subset of the articles currently | |
6558 | fetched for this group." | |
eec82323 | 6559 | (interactive) |
eec82323 LMI |
6560 | (unless gnus-newsgroup-dormant |
6561 | (error "There are no dormant articles in this group")) | |
6562 | (prog1 | |
6563 | (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit)) | |
6564 | (gnus-summary-position-point))) | |
6565 | ||
6566 | (defun gnus-summary-limit-exclude-dormant () | |
6567 | "Hide all dormant articles." | |
6568 | (interactive) | |
eec82323 LMI |
6569 | (prog1 |
6570 | (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse) | |
6571 | (gnus-summary-position-point))) | |
6572 | ||
6573 | (defun gnus-summary-limit-exclude-childless-dormant () | |
6574 | "Hide all dormant articles that have no children." | |
6575 | (interactive) | |
eec82323 LMI |
6576 | (let ((data (gnus-data-list t)) |
6577 | articles d children) | |
6578 | ;; Find all articles that are either not dormant or have | |
6579 | ;; children. | |
6580 | (while (setq d (pop data)) | |
6581 | (when (or (not (= (gnus-data-mark d) gnus-dormant-mark)) | |
6582 | (and (setq children | |
6583 | (gnus-article-children (gnus-data-number d))) | |
6584 | (let (found) | |
6585 | (while children | |
6586 | (when (memq (car children) articles) | |
6587 | (setq children nil | |
6588 | found t)) | |
6589 | (pop children)) | |
6590 | found))) | |
6591 | (push (gnus-data-number d) articles))) | |
6592 | ;; Do the limiting. | |
6593 | (prog1 | |
6594 | (gnus-summary-limit articles) | |
6595 | (gnus-summary-position-point)))) | |
6596 | ||
6597 | (defun gnus-summary-limit-mark-excluded-as-read (&optional all) | |
6598 | "Mark all unread excluded articles as read. | |
6599 | If ALL, mark even excluded ticked and dormants as read." | |
6600 | (interactive "P") | |
6601 | (let ((articles (gnus-sorted-complement | |
6602 | (sort | |
6603 | (mapcar (lambda (h) (mail-header-number h)) | |
6604 | gnus-newsgroup-headers) | |
6605 | '<) | |
6606 | (sort gnus-newsgroup-limit '<))) | |
6607 | article) | |
6748645f LMI |
6608 | (setq gnus-newsgroup-unreads |
6609 | (gnus-intersection gnus-newsgroup-unreads gnus-newsgroup-limit)) | |
eec82323 LMI |
6610 | (if all |
6611 | (setq gnus-newsgroup-dormant nil | |
6612 | gnus-newsgroup-marked nil | |
6613 | gnus-newsgroup-reads | |
6614 | (nconc | |
6615 | (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles) | |
6616 | gnus-newsgroup-reads)) | |
6617 | (while (setq article (pop articles)) | |
6618 | (unless (or (memq article gnus-newsgroup-dormant) | |
6619 | (memq article gnus-newsgroup-marked)) | |
6620 | (push (cons article gnus-catchup-mark) gnus-newsgroup-reads)))))) | |
6621 | ||
6622 | (defun gnus-summary-limit (articles &optional pop) | |
6623 | (if pop | |
6624 | ;; We pop the previous limit off the stack and use that. | |
6625 | (setq articles (car gnus-newsgroup-limits) | |
6626 | gnus-newsgroup-limits (cdr gnus-newsgroup-limits)) | |
6627 | ;; We use the new limit, so we push the old limit on the stack. | |
6628 | (push gnus-newsgroup-limit gnus-newsgroup-limits)) | |
6629 | ;; Set the limit. | |
6630 | (setq gnus-newsgroup-limit articles) | |
6631 | (let ((total (length gnus-newsgroup-data)) | |
6632 | (data (gnus-data-find-list (gnus-summary-article-number))) | |
6633 | (gnus-summary-mark-below nil) ; Inhibit this. | |
6634 | found) | |
6635 | ;; This will do all the work of generating the new summary buffer | |
6636 | ;; according to the new limit. | |
6637 | (gnus-summary-prepare) | |
6638 | ;; Hide any threads, possibly. | |
6639 | (and gnus-show-threads | |
6640 | gnus-thread-hide-subtree | |
6641 | (gnus-summary-hide-all-threads)) | |
6642 | ;; Try to return to the article you were at, or one in the | |
6643 | ;; neighborhood. | |
6644 | (when data | |
6645 | ;; We try to find some article after the current one. | |
6646 | (while data | |
6647 | (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t) | |
6648 | (setq data nil | |
6649 | found t)) | |
6650 | (setq data (cdr data)))) | |
6651 | (unless found | |
6652 | ;; If there is no data, that means that we were after the last | |
6653 | ;; article. The same goes when we can't find any articles | |
6654 | ;; after the current one. | |
6655 | (goto-char (point-max)) | |
6656 | (gnus-summary-find-prev)) | |
6748645f | 6657 | (gnus-set-mode-line 'summary) |
eec82323 LMI |
6658 | ;; We return how many articles were removed from the summary |
6659 | ;; buffer as a result of the new limit. | |
6660 | (- total (length gnus-newsgroup-data)))) | |
6661 | ||
6662 | (defsubst gnus-invisible-cut-children (threads) | |
6663 | (let ((num 0)) | |
6664 | (while threads | |
6665 | (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit) | |
6666 | (incf num)) | |
6667 | (pop threads)) | |
6668 | (< num 2))) | |
6669 | ||
6670 | (defsubst gnus-cut-thread (thread) | |
6671 | "Go forwards in the thread until we find an article that we want to display." | |
6672 | (when (or (eq gnus-fetch-old-headers 'some) | |
6748645f | 6673 | (eq gnus-fetch-old-headers 'invisible) |
16409b0b | 6674 | (numberp gnus-fetch-old-headers) |
eec82323 LMI |
6675 | (eq gnus-build-sparse-threads 'some) |
6676 | (eq gnus-build-sparse-threads 'more)) | |
6677 | ;; Deal with old-fetched headers and sparse threads. | |
6678 | (while (and | |
6679 | thread | |
6680 | (or | |
6681 | (gnus-summary-article-sparse-p (mail-header-number (car thread))) | |
6682 | (gnus-summary-article-ancient-p | |
6683 | (mail-header-number (car thread)))) | |
6748645f LMI |
6684 | (if (or (<= (length (cdr thread)) 1) |
6685 | (eq gnus-fetch-old-headers 'invisible)) | |
6686 | (setq gnus-newsgroup-limit | |
6687 | (delq (mail-header-number (car thread)) | |
6688 | gnus-newsgroup-limit) | |
6689 | thread (cadr thread)) | |
6690 | (when (gnus-invisible-cut-children (cdr thread)) | |
6691 | (let ((th (cdr thread))) | |
6692 | (while th | |
6693 | (if (memq (mail-header-number (caar th)) | |
a8151ef7 | 6694 | gnus-newsgroup-limit) |
6748645f LMI |
6695 | (setq thread (car th) |
6696 | th nil) | |
6697 | (setq th (cdr th)))))))))) | |
eec82323 LMI |
6698 | thread) |
6699 | ||
6700 | (defun gnus-cut-threads (threads) | |
6701 | "Cut off all uninteresting articles from the beginning of threads." | |
6702 | (when (or (eq gnus-fetch-old-headers 'some) | |
6748645f | 6703 | (eq gnus-fetch-old-headers 'invisible) |
16409b0b | 6704 | (numberp gnus-fetch-old-headers) |
eec82323 LMI |
6705 | (eq gnus-build-sparse-threads 'some) |
6706 | (eq gnus-build-sparse-threads 'more)) | |
6707 | (let ((th threads)) | |
6708 | (while th | |
6709 | (setcar th (gnus-cut-thread (car th))) | |
6710 | (setq th (cdr th))))) | |
6711 | ;; Remove nixed out threads. | |
6712 | (delq nil threads)) | |
6713 | ||
6714 | (defun gnus-summary-initial-limit (&optional show-if-empty) | |
6715 | "Figure out what the initial limit is supposed to be on group entry. | |
6716 | This entails weeding out unwanted dormants, low-scored articles, | |
6717 | fetch-old-headers verbiage, and so on." | |
6718 | ;; Most groups have nothing to remove. | |
6719 | (if (or gnus-inhibit-limiting | |
6720 | (and (null gnus-newsgroup-dormant) | |
6721 | (not (eq gnus-fetch-old-headers 'some)) | |
16409b0b | 6722 | (not (numberp gnus-fetch-old-headers)) |
6748645f | 6723 | (not (eq gnus-fetch-old-headers 'invisible)) |
eec82323 LMI |
6724 | (null gnus-summary-expunge-below) |
6725 | (not (eq gnus-build-sparse-threads 'some)) | |
6726 | (not (eq gnus-build-sparse-threads 'more)) | |
6727 | (null gnus-thread-expunge-below) | |
6728 | (not gnus-use-nocem))) | |
6729 | () ; Do nothing. | |
6730 | (push gnus-newsgroup-limit gnus-newsgroup-limits) | |
6731 | (setq gnus-newsgroup-limit nil) | |
6732 | (mapatoms | |
6733 | (lambda (node) | |
6734 | (unless (car (symbol-value node)) | |
6735 | ;; These threads have no parents -- they are roots. | |
6736 | (let ((nodes (cdr (symbol-value node))) | |
6737 | thread) | |
6738 | (while nodes | |
6739 | (if (and gnus-thread-expunge-below | |
6740 | (< (gnus-thread-total-score (car nodes)) | |
6741 | gnus-thread-expunge-below)) | |
6742 | (gnus-expunge-thread (pop nodes)) | |
6743 | (setq thread (pop nodes)) | |
6744 | (gnus-summary-limit-children thread)))))) | |
6745 | gnus-newsgroup-dependencies) | |
6746 | ;; If this limitation resulted in an empty group, we might | |
6747 | ;; pop the previous limit and use it instead. | |
6748 | (when (and (not gnus-newsgroup-limit) | |
6749 | show-if-empty) | |
6750 | (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits))) | |
6751 | gnus-newsgroup-limit)) | |
6752 | ||
6753 | (defun gnus-summary-limit-children (thread) | |
6754 | "Return 1 if this subthread is visible and 0 if it is not." | |
6755 | ;; First we get the number of visible children to this thread. This | |
6756 | ;; is done by recursing down the thread using this function, so this | |
6757 | ;; will really go down to a leaf article first, before slowly | |
6758 | ;; working its way up towards the root. | |
6759 | (when thread | |
6760 | (let ((children | |
6761 | (if (cdr thread) | |
6762 | (apply '+ (mapcar 'gnus-summary-limit-children | |
6763 | (cdr thread))) | |
6764 | 0)) | |
6765 | (number (mail-header-number (car thread))) | |
6766 | score) | |
6767 | (if (and | |
6768 | (not (memq number gnus-newsgroup-marked)) | |
6769 | (or | |
6770 | ;; If this article is dormant and has absolutely no visible | |
6771 | ;; children, then this article isn't visible. | |
6772 | (and (memq number gnus-newsgroup-dormant) | |
6773 | (zerop children)) | |
6774 | ;; If this is "fetch-old-headered" and there is no | |
6775 | ;; visible children, then we don't want this article. | |
16409b0b GM |
6776 | (and (or (eq gnus-fetch-old-headers 'some) |
6777 | (numberp gnus-fetch-old-headers)) | |
eec82323 LMI |
6778 | (gnus-summary-article-ancient-p number) |
6779 | (zerop children)) | |
6748645f LMI |
6780 | ;; If this is "fetch-old-headered" and `invisible', then |
6781 | ;; we don't want this article. | |
6782 | (and (eq gnus-fetch-old-headers 'invisible) | |
6783 | (gnus-summary-article-ancient-p number)) | |
eec82323 LMI |
6784 | ;; If this is a sparsely inserted article with no children, |
6785 | ;; we don't want it. | |
6786 | (and (eq gnus-build-sparse-threads 'some) | |
6787 | (gnus-summary-article-sparse-p number) | |
6788 | (zerop children)) | |
6789 | ;; If we use expunging, and this article is really | |
6790 | ;; low-scored, then we don't want this article. | |
6791 | (when (and gnus-summary-expunge-below | |
6792 | (< (setq score | |
6793 | (or (cdr (assq number gnus-newsgroup-scored)) | |
6794 | gnus-summary-default-score)) | |
6795 | gnus-summary-expunge-below)) | |
6796 | ;; We increase the expunge-tally here, but that has | |
6797 | ;; nothing to do with the limits, really. | |
6798 | (incf gnus-newsgroup-expunged-tally) | |
6799 | ;; We also mark as read here, if that's wanted. | |
6800 | (when (and gnus-summary-mark-below | |
6801 | (< score gnus-summary-mark-below)) | |
6802 | (setq gnus-newsgroup-unreads | |
6803 | (delq number gnus-newsgroup-unreads)) | |
6804 | (if gnus-newsgroup-auto-expire | |
6805 | (push number gnus-newsgroup-expirable) | |
6806 | (push (cons number gnus-low-score-mark) | |
6807 | gnus-newsgroup-reads))) | |
6808 | t) | |
6809 | ;; Check NoCeM things. | |
6810 | (if (and gnus-use-nocem | |
6811 | (gnus-nocem-unwanted-article-p | |
6812 | (mail-header-id (car thread)))) | |
6813 | (progn | |
a8151ef7 | 6814 | (setq gnus-newsgroup-unreads |
eec82323 LMI |
6815 | (delq number gnus-newsgroup-unreads)) |
6816 | t)))) | |
6817 | ;; Nope, invisible article. | |
6818 | 0 | |
6819 | ;; Ok, this article is to be visible, so we add it to the limit | |
6820 | ;; and return 1. | |
6821 | (push number gnus-newsgroup-limit) | |
6822 | 1)))) | |
6823 | ||
6824 | (defun gnus-expunge-thread (thread) | |
6825 | "Mark all articles in THREAD as read." | |
6826 | (let* ((number (mail-header-number (car thread)))) | |
6827 | (incf gnus-newsgroup-expunged-tally) | |
6828 | ;; We also mark as read here, if that's wanted. | |
6829 | (setq gnus-newsgroup-unreads | |
6830 | (delq number gnus-newsgroup-unreads)) | |
6831 | (if gnus-newsgroup-auto-expire | |
6832 | (push number gnus-newsgroup-expirable) | |
6833 | (push (cons number gnus-low-score-mark) | |
6834 | gnus-newsgroup-reads))) | |
6835 | ;; Go recursively through all subthreads. | |
6836 | (mapcar 'gnus-expunge-thread (cdr thread))) | |
6837 | ||
6838 | ;; Summary article oriented commands | |
6839 | ||
6840 | (defun gnus-summary-refer-parent-article (n) | |
6841 | "Refer parent article N times. | |
6842 | If N is negative, go to ancestor -N instead. | |
6843 | The difference between N and the number of articles fetched is returned." | |
6844 | (interactive "p") | |
eec82323 LMI |
6845 | (let ((skip 1) |
6846 | error header ref) | |
6847 | (when (not (natnump n)) | |
6848 | (setq skip (abs n) | |
6849 | n 1)) | |
6850 | (while (and (> n 0) | |
6851 | (not error)) | |
6852 | (setq header (gnus-summary-article-header)) | |
6853 | (if (and (eq (mail-header-number header) | |
6854 | (cdr gnus-article-current)) | |
6855 | (equal gnus-newsgroup-name | |
6856 | (car gnus-article-current))) | |
6857 | ;; If we try to find the parent of the currently | |
6858 | ;; displayed article, then we take a look at the actual | |
6859 | ;; References header, since this is slightly more | |
6860 | ;; reliable than the References field we got from the | |
6861 | ;; server. | |
6862 | (save-excursion | |
6863 | (set-buffer gnus-original-article-buffer) | |
6864 | (nnheader-narrow-to-headers) | |
6865 | (unless (setq ref (message-fetch-field "references")) | |
6866 | (setq ref (message-fetch-field "in-reply-to"))) | |
6867 | (widen)) | |
6868 | (setq ref | |
6869 | ;; It's not the current article, so we take a bet on | |
6870 | ;; the value we got from the server. | |
6871 | (mail-header-references header))) | |
6872 | (if (and ref | |
6873 | (not (equal ref ""))) | |
6874 | (unless (gnus-summary-refer-article (gnus-parent-id ref skip)) | |
6875 | (gnus-message 1 "Couldn't find parent")) | |
6876 | (gnus-message 1 "No references in article %d" | |
6877 | (gnus-summary-article-number)) | |
6878 | (setq error t)) | |
6879 | (decf n)) | |
6880 | (gnus-summary-position-point) | |
6881 | n)) | |
6882 | ||
6883 | (defun gnus-summary-refer-references () | |
6884 | "Fetch all articles mentioned in the References header. | |
6748645f | 6885 | Return the number of articles fetched." |
eec82323 | 6886 | (interactive) |
eec82323 LMI |
6887 | (let ((ref (mail-header-references (gnus-summary-article-header))) |
6888 | (current (gnus-summary-article-number)) | |
6889 | (n 0)) | |
6890 | (if (or (not ref) | |
6891 | (equal ref "")) | |
6892 | (error "No References in the current article") | |
6893 | ;; For each Message-ID in the References header... | |
6894 | (while (string-match "<[^>]*>" ref) | |
6895 | (incf n) | |
6896 | ;; ... fetch that article. | |
6897 | (gnus-summary-refer-article | |
6898 | (prog1 (match-string 0 ref) | |
6899 | (setq ref (substring ref (match-end 0)))))) | |
6900 | (gnus-summary-goto-subject current) | |
6901 | (gnus-summary-position-point) | |
6902 | n))) | |
6903 | ||
6748645f LMI |
6904 | (defun gnus-summary-refer-thread (&optional limit) |
6905 | "Fetch all articles in the current thread. | |
6906 | If LIMIT (the numerical prefix), fetch that many old headers instead | |
6907 | of what's specified by the `gnus-refer-thread-limit' variable." | |
6908 | (interactive "P") | |
6909 | (let ((id (mail-header-id (gnus-summary-article-header))) | |
6910 | (limit (if limit (prefix-numeric-value limit) | |
6911 | gnus-refer-thread-limit))) | |
6912 | ;; We want to fetch LIMIT *old* headers, but we also have to | |
6913 | ;; re-fetch all the headers in the current buffer, because many of | |
6914 | ;; them may be undisplayed. So we adjust LIMIT. | |
6915 | (when (numberp limit) | |
6916 | (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin))) | |
6917 | (unless (eq gnus-fetch-old-headers 'invisible) | |
6918 | (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name) | |
6919 | ;; Retrieve the headers and read them in. | |
6920 | (if (eq (gnus-retrieve-headers | |
6921 | (list gnus-newsgroup-end) gnus-newsgroup-name limit) | |
6922 | 'nov) | |
6923 | (gnus-build-all-threads) | |
6924 | (error "Can't fetch thread from backends that don't support NOV")) | |
6925 | (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)) | |
6926 | (gnus-summary-limit-include-thread id))) | |
6927 | ||
16409b0b GM |
6928 | (defun gnus-summary-refer-article (message-id) |
6929 | "Fetch an article specified by MESSAGE-ID." | |
6930 | (interactive "sMessage-ID: ") | |
eec82323 LMI |
6931 | (when (and (stringp message-id) |
6932 | (not (zerop (length message-id)))) | |
6933 | ;; Construct the correct Message-ID if necessary. | |
6934 | ;; Suggested by tale@pawl.rpi.edu. | |
6935 | (unless (string-match "^<" message-id) | |
6936 | (setq message-id (concat "<" message-id))) | |
6937 | (unless (string-match ">$" message-id) | |
6938 | (setq message-id (concat message-id ">"))) | |
6939 | (let* ((header (gnus-id-to-header message-id)) | |
6940 | (sparse (and header | |
6941 | (gnus-summary-article-sparse-p | |
a8151ef7 LMI |
6942 | (mail-header-number header)) |
6943 | (memq (mail-header-number header) | |
16409b0b GM |
6944 | gnus-newsgroup-limit))) |
6945 | number) | |
6748645f LMI |
6946 | (cond |
6947 | ;; If the article is present in the buffer we just go to it. | |
6948 | ((and header | |
6949 | (or (not (gnus-summary-article-sparse-p | |
6950 | (mail-header-number header))) | |
6951 | sparse)) | |
6952 | (prog1 | |
6953 | (gnus-summary-goto-article | |
6954 | (mail-header-number header) nil t) | |
6955 | (when sparse | |
6956 | (gnus-summary-update-article (mail-header-number header))))) | |
6957 | (t | |
16409b0b GM |
6958 | ;; We fetch the article. |
6959 | (catch 'found | |
6960 | (dolist (gnus-override-method (gnus-refer-article-methods)) | |
6961 | (gnus-check-server gnus-override-method) | |
6962 | ;; Fetch the header, and display the article. | |
6963 | (when (setq number (gnus-summary-insert-subject message-id)) | |
eec82323 | 6964 | (gnus-summary-select-article nil nil nil number) |
16409b0b GM |
6965 | (throw 'found t))) |
6966 | (gnus-message 3 "Couldn't fetch article %s" message-id))))))) | |
6967 | ||
6968 | (defun gnus-refer-article-methods () | |
6969 | "Return a list of referrable methods." | |
6970 | (cond | |
6971 | ;; No method, so we default to current and native. | |
6972 | ((null gnus-refer-article-method) | |
6973 | (list gnus-current-select-method gnus-select-method)) | |
6974 | ;; Current. | |
6975 | ((eq 'current gnus-refer-article-method) | |
6976 | (list gnus-current-select-method)) | |
6977 | ;; List of select methods. | |
d4dfaa19 DL |
6978 | ((not (and (symbolp (car gnus-refer-article-method)) |
6979 | (assq (car gnus-refer-article-method) nnoo-definition-alist))) | |
16409b0b GM |
6980 | (let (out) |
6981 | (dolist (method gnus-refer-article-method) | |
6982 | (push (if (eq 'current method) | |
6983 | gnus-current-select-method | |
6984 | method) | |
6985 | out)) | |
6986 | (nreverse out))) | |
6987 | ;; One single select method. | |
6988 | (t | |
6989 | (list gnus-refer-article-method)))) | |
6748645f LMI |
6990 | |
6991 | (defun gnus-summary-edit-parameters () | |
6992 | "Edit the group parameters of the current group." | |
6993 | (interactive) | |
6994 | (gnus-group-edit-group gnus-newsgroup-name 'params)) | |
eec82323 | 6995 | |
16409b0b GM |
6996 | (defun gnus-summary-customize-parameters () |
6997 | "Customize the group parameters of the current group." | |
6998 | (interactive) | |
6999 | (gnus-group-customize gnus-newsgroup-name)) | |
7000 | ||
eec82323 LMI |
7001 | (defun gnus-summary-enter-digest-group (&optional force) |
7002 | "Enter an nndoc group based on the current article. | |
7003 | If FORCE, force a digest interpretation. If not, try | |
7004 | to guess what the document format is." | |
7005 | (interactive "P") | |
eec82323 LMI |
7006 | (let ((conf gnus-current-window-configuration)) |
7007 | (save-excursion | |
7008 | (gnus-summary-select-article)) | |
7009 | (setq gnus-current-window-configuration conf) | |
7010 | (let* ((name (format "%s-%d" | |
7011 | (gnus-group-prefixed-name | |
7012 | gnus-newsgroup-name (list 'nndoc "")) | |
7013 | (save-excursion | |
7014 | (set-buffer gnus-summary-buffer) | |
7015 | gnus-current-article))) | |
7016 | (ogroup gnus-newsgroup-name) | |
7017 | (params (append (gnus-info-params (gnus-get-info ogroup)) | |
7018 | (list (cons 'to-group ogroup)) | |
7019 | (list (cons 'save-article-group ogroup)))) | |
7020 | (case-fold-search t) | |
7021 | (buf (current-buffer)) | |
16409b0b | 7022 | dig to-address) |
eec82323 | 7023 | (save-excursion |
16409b0b GM |
7024 | (set-buffer gnus-original-article-buffer) |
7025 | ;; Have the digest group inherit the main mail address of | |
7026 | ;; the parent article. | |
7027 | (when (setq to-address (or (message-fetch-field "reply-to") | |
7028 | (message-fetch-field "from"))) | |
d4dfaa19 DL |
7029 | (setq params (append |
7030 | (list (cons 'to-address | |
7031 | (funcall gnus-decode-encoded-word-function | |
7032 | to-address)))))) | |
eec82323 LMI |
7033 | (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*")) |
7034 | (insert-buffer-substring gnus-original-article-buffer) | |
7035 | ;; Remove lines that may lead nndoc to misinterpret the | |
7036 | ;; document type. | |
7037 | (narrow-to-region | |
7038 | (goto-char (point-min)) | |
7039 | (or (search-forward "\n\n" nil t) (point))) | |
7040 | (goto-char (point-min)) | |
16409b0b | 7041 | (delete-matching-lines "^Path:\\|^From ") |
eec82323 LMI |
7042 | (widen)) |
7043 | (unwind-protect | |
16409b0b GM |
7044 | (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset) |
7045 | (gnus-newsgroup-ephemeral-ignored-charsets | |
7046 | gnus-newsgroup-ignored-charsets)) | |
7047 | (gnus-group-read-ephemeral-group | |
7048 | name `(nndoc ,name (nndoc-address ,(get-buffer dig)) | |
7049 | (nndoc-article-type | |
7050 | ,(if force 'mbox 'guess))) t)) | |
7051 | ;; Make all postings to this group go to the parent group. | |
eec82323 LMI |
7052 | (nconc (gnus-info-params (gnus-get-info name)) |
7053 | params) | |
7054 | ;; Couldn't select this doc group. | |
7055 | (switch-to-buffer buf) | |
7056 | (gnus-set-global-variables) | |
7057 | (gnus-configure-windows 'summary) | |
7058 | (gnus-message 3 "Article couldn't be entered?")) | |
7059 | (kill-buffer dig))))) | |
7060 | ||
7061 | (defun gnus-summary-read-document (n) | |
7062 | "Open a new group based on the current article(s). | |
7063 | This will allow you to read digests and other similar | |
7064 | documents as newsgroups. | |
7065 | Obeys the standard process/prefix convention." | |
7066 | (interactive "P") | |
7067 | (let* ((articles (gnus-summary-work-articles n)) | |
7068 | (ogroup gnus-newsgroup-name) | |
7069 | (params (append (gnus-info-params (gnus-get-info ogroup)) | |
7070 | (list (cons 'to-group ogroup)))) | |
7071 | article group egroup groups vgroup) | |
7072 | (while (setq article (pop articles)) | |
7073 | (setq group (format "%s-%d" gnus-newsgroup-name article)) | |
7074 | (gnus-summary-remove-process-mark article) | |
7075 | (when (gnus-summary-display-article article) | |
7076 | (save-excursion | |
16409b0b | 7077 | (with-temp-buffer |
eec82323 LMI |
7078 | (insert-buffer-substring gnus-original-article-buffer) |
7079 | ;; Remove some headers that may lead nndoc to make | |
7080 | ;; the wrong guess. | |
7081 | (message-narrow-to-head) | |
7082 | (goto-char (point-min)) | |
7083 | (delete-matching-lines "^\\(Path\\):\\|^From ") | |
7084 | (widen) | |
7085 | (if (setq egroup | |
7086 | (gnus-group-read-ephemeral-group | |
7087 | group `(nndoc ,group (nndoc-address ,(current-buffer)) | |
7088 | (nndoc-article-type guess)) | |
7089 | t nil t)) | |
7090 | (progn | |
7091 | ;; Make all postings to this group go to the parent group. | |
7092 | (nconc (gnus-info-params (gnus-get-info egroup)) | |
7093 | params) | |
7094 | (push egroup groups)) | |
7095 | ;; Couldn't select this doc group. | |
7096 | (gnus-error 3 "Article couldn't be entered")))))) | |
7097 | ;; Now we have selected all the documents. | |
7098 | (cond | |
7099 | ((not groups) | |
7100 | (error "None of the articles could be interpreted as documents")) | |
7101 | ((gnus-group-read-ephemeral-group | |
7102 | (setq vgroup (format | |
7103 | "nnvirtual:%s-%s" gnus-newsgroup-name | |
7104 | (format-time-string "%Y%m%dT%H%M%S" (current-time)))) | |
7105 | `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups)) | |
7106 | t | |
7107 | (cons (current-buffer) 'summary))) | |
7108 | (t | |
7109 | (error "Couldn't select virtual nndoc group"))))) | |
7110 | ||
7111 | (defun gnus-summary-isearch-article (&optional regexp-p) | |
7112 | "Do incremental search forward on the current article. | |
7113 | If REGEXP-P (the prefix) is non-nil, do regexp isearch." | |
7114 | (interactive "P") | |
eec82323 LMI |
7115 | (gnus-summary-select-article) |
7116 | (gnus-configure-windows 'article) | |
7117 | (gnus-eval-in-buffer-window gnus-article-buffer | |
6748645f LMI |
7118 | (save-restriction |
7119 | (widen) | |
7120 | (isearch-forward regexp-p)))) | |
eec82323 LMI |
7121 | |
7122 | (defun gnus-summary-search-article-forward (regexp &optional backward) | |
7123 | "Search for an article containing REGEXP forward. | |
7124 | If BACKWARD, search backward instead." | |
7125 | (interactive | |
7126 | (list (read-string | |
7127 | (format "Search article %s (regexp%s): " | |
7128 | (if current-prefix-arg "backward" "forward") | |
7129 | (if gnus-last-search-regexp | |
7130 | (concat ", default " gnus-last-search-regexp) | |
7131 | ""))) | |
7132 | current-prefix-arg)) | |
eec82323 LMI |
7133 | (if (string-equal regexp "") |
7134 | (setq regexp (or gnus-last-search-regexp "")) | |
7135 | (setq gnus-last-search-regexp regexp)) | |
7136 | (if (gnus-summary-search-article regexp backward) | |
7137 | (gnus-summary-show-thread) | |
7138 | (error "Search failed: \"%s\"" regexp))) | |
7139 | ||
7140 | (defun gnus-summary-search-article-backward (regexp) | |
7141 | "Search for an article containing REGEXP backward." | |
7142 | (interactive | |
7143 | (list (read-string | |
7144 | (format "Search article backward (regexp%s): " | |
7145 | (if gnus-last-search-regexp | |
7146 | (concat ", default " gnus-last-search-regexp) | |
7147 | ""))))) | |
7148 | (gnus-summary-search-article-forward regexp 'backward)) | |
7149 | ||
7150 | (defun gnus-summary-search-article (regexp &optional backward) | |
7151 | "Search for an article containing REGEXP. | |
7152 | Optional argument BACKWARD means do search for backward. | |
7153 | `gnus-select-article-hook' is not called during the search." | |
a8151ef7 LMI |
7154 | ;; We have to require this here to make sure that the following |
7155 | ;; dynamic binding isn't shadowed by autoloading. | |
7156 | (require 'gnus-async) | |
16409b0b | 7157 | (require 'gnus-art) |
eec82323 | 7158 | (let ((gnus-select-article-hook nil) ;Disable hook. |
16409b0b | 7159 | (gnus-article-prepare-hook nil) |
eec82323 LMI |
7160 | (gnus-mark-article-hook nil) ;Inhibit marking as read. |
7161 | (gnus-use-article-prefetch nil) | |
7162 | (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay. | |
a8151ef7 | 7163 | (gnus-use-trees nil) ;Inhibit updating tree buffer. |
eec82323 | 7164 | (sum (current-buffer)) |
16409b0b | 7165 | (gnus-display-mime-function nil) |
eec82323 LMI |
7166 | (found nil) |
7167 | point) | |
7168 | (gnus-save-hidden-threads | |
7169 | (gnus-summary-select-article) | |
7170 | (set-buffer gnus-article-buffer) | |
16409b0b | 7171 | (goto-char (window-point (get-buffer-window (current-buffer)))) |
eec82323 LMI |
7172 | (when backward |
7173 | (forward-line -1)) | |
7174 | (while (not found) | |
7175 | (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current)) | |
7176 | (if (if backward | |
7177 | (re-search-backward regexp nil t) | |
7178 | (re-search-forward regexp nil t)) | |
7179 | ;; We found the regexp. | |
7180 | (progn | |
7181 | (setq found 'found) | |
7182 | (beginning-of-line) | |
7183 | (set-window-start | |
7184 | (get-buffer-window (current-buffer)) | |
7185 | (point)) | |
7186 | (forward-line 1) | |
16409b0b GM |
7187 | (set-window-point |
7188 | (get-buffer-window (current-buffer)) | |
7189 | (point)) | |
eec82323 LMI |
7190 | (set-buffer sum) |
7191 | (setq point (point))) | |
7192 | ;; We didn't find it, so we go to the next article. | |
7193 | (set-buffer sum) | |
7194 | (setq found 'not) | |
7195 | (while (eq found 'not) | |
7196 | (if (not (if backward (gnus-summary-find-prev) | |
7197 | (gnus-summary-find-next))) | |
7198 | ;; No more articles. | |
7199 | (setq found t) | |
7200 | ;; Select the next article and adjust point. | |
7201 | (unless (gnus-summary-article-sparse-p | |
7202 | (gnus-summary-article-number)) | |
7203 | (setq found nil) | |
7204 | (gnus-summary-select-article) | |
7205 | (set-buffer gnus-article-buffer) | |
7206 | (widen) | |
7207 | (goto-char (if backward (point-max) (point-min)))))))) | |
7208 | (gnus-message 7 "")) | |
7209 | ;; Return whether we found the regexp. | |
7210 | (when (eq found 'found) | |
7211 | (goto-char point) | |
7212 | (gnus-summary-show-thread) | |
7213 | (gnus-summary-goto-subject gnus-current-article) | |
7214 | (gnus-summary-position-point) | |
7215 | t))) | |
7216 | ||
7217 | (defun gnus-summary-find-matching (header regexp &optional backward unread | |
7218 | not-case-fold) | |
7219 | "Return a list of all articles that match REGEXP on HEADER. | |
7220 | The search stars on the current article and goes forwards unless | |
7221 | BACKWARD is non-nil. If BACKWARD is `all', do all articles. | |
7222 | If UNREAD is non-nil, only unread articles will | |
7223 | be taken into consideration. If NOT-CASE-FOLD, case won't be folded | |
7224 | in the comparisons." | |
7225 | (let ((data (if (eq backward 'all) gnus-newsgroup-data | |
7226 | (gnus-data-find-list | |
7227 | (gnus-summary-article-number) (gnus-data-list backward)))) | |
eec82323 | 7228 | (case-fold-search (not not-case-fold)) |
16409b0b GM |
7229 | articles d func) |
7230 | (if (consp header) | |
7231 | (if (eq (car header) 'extra) | |
7232 | (setq func | |
7233 | `(lambda (h) | |
7234 | (or (cdr (assq ',(cdr header) (mail-header-extra h))) | |
7235 | ""))) | |
7236 | (error "%s is an invalid header" header)) | |
7237 | (unless (fboundp (intern (concat "mail-header-" header))) | |
7238 | (error "%s is not a valid header" header)) | |
7239 | (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))) | |
eec82323 LMI |
7240 | (while data |
7241 | (setq d (car data)) | |
7242 | (and (or (not unread) ; We want all articles... | |
7243 | (gnus-data-unread-p d)) ; Or just unreads. | |
7244 | (vectorp (gnus-data-header d)) ; It's not a pseudo. | |
7245 | (string-match regexp (funcall func (gnus-data-header d))) ; Match. | |
7246 | (push (gnus-data-number d) articles)) ; Success! | |
7247 | (setq data (cdr data))) | |
7248 | (nreverse articles))) | |
7249 | ||
7250 | (defun gnus-summary-execute-command (header regexp command &optional backward) | |
7251 | "Search forward for an article whose HEADER matches REGEXP and execute COMMAND. | |
7252 | If HEADER is an empty string (or nil), the match is done on the entire | |
7253 | article. If BACKWARD (the prefix) is non-nil, search backward instead." | |
7254 | (interactive | |
7255 | (list (let ((completion-ignore-case t)) | |
7256 | (completing-read | |
7257 | "Header name: " | |
7258 | (mapcar (lambda (string) (list string)) | |
7259 | '("Number" "Subject" "From" "Lines" "Date" | |
7260 | "Message-ID" "Xref" "References" "Body")) | |
7261 | nil 'require-match)) | |
7262 | (read-string "Regexp: ") | |
7263 | (read-key-sequence "Command: ") | |
7264 | current-prefix-arg)) | |
7265 | (when (equal header "Body") | |
7266 | (setq header "")) | |
eec82323 LMI |
7267 | ;; Hidden thread subtrees must be searched as well. |
7268 | (gnus-summary-show-all-threads) | |
7269 | ;; We don't want to change current point nor window configuration. | |
7270 | (save-excursion | |
7271 | (save-window-excursion | |
7272 | (gnus-message 6 "Executing %s..." (key-description command)) | |
7273 | ;; We'd like to execute COMMAND interactively so as to give arguments. | |
7274 | (gnus-execute header regexp | |
7275 | `(call-interactively ',(key-binding command)) | |
7276 | backward) | |
7277 | (gnus-message 6 "Executing %s...done" (key-description command))))) | |
7278 | ||
7279 | (defun gnus-summary-beginning-of-article () | |
7280 | "Scroll the article back to the beginning." | |
7281 | (interactive) | |
eec82323 LMI |
7282 | (gnus-summary-select-article) |
7283 | (gnus-configure-windows 'article) | |
7284 | (gnus-eval-in-buffer-window gnus-article-buffer | |
7285 | (widen) | |
7286 | (goto-char (point-min)) | |
7287 | (when gnus-page-broken | |
7288 | (gnus-narrow-to-page)))) | |
7289 | ||
7290 | (defun gnus-summary-end-of-article () | |
7291 | "Scroll to the end of the article." | |
7292 | (interactive) | |
eec82323 LMI |
7293 | (gnus-summary-select-article) |
7294 | (gnus-configure-windows 'article) | |
7295 | (gnus-eval-in-buffer-window gnus-article-buffer | |
7296 | (widen) | |
7297 | (goto-char (point-max)) | |
7298 | (recenter -3) | |
7299 | (when gnus-page-broken | |
7300 | (gnus-narrow-to-page)))) | |
7301 | ||
6748645f LMI |
7302 | (defun gnus-summary-print-article (&optional filename n) |
7303 | "Generate and print a PostScript image of the N next (mail) articles. | |
7304 | ||
7305 | If N is negative, print the N previous articles. If N is nil and articles | |
7306 | have been marked with the process mark, print these instead. | |
eec82323 | 7307 | |
16409b0b | 7308 | If the optional first argument FILENAME is nil, send the image to the |
6748645f LMI |
7309 | printer. If FILENAME is a string, save the PostScript image in a file with |
7310 | that name. If FILENAME is a number, prompt the user for the name of the file | |
eec82323 | 7311 | to save in." |
676a7cc9 | 7312 | (interactive (list (ps-print-preprint current-prefix-arg))) |
6748645f LMI |
7313 | (dolist (article (gnus-summary-work-articles n)) |
7314 | (gnus-summary-select-article nil nil 'pseudo article) | |
7315 | (gnus-eval-in-buffer-window gnus-article-buffer | |
7316 | (let ((buffer (generate-new-buffer " *print*"))) | |
7317 | (unwind-protect | |
7318 | (progn | |
7319 | (copy-to-buffer buffer (point-min) (point-max)) | |
7320 | (set-buffer buffer) | |
7321 | (gnus-article-delete-invisible-text) | |
7322 | (let ((ps-left-header | |
7323 | (list | |
7324 | (concat "(" | |
7325 | (mail-header-subject gnus-current-headers) ")") | |
7326 | (concat "(" | |
7327 | (mail-header-from gnus-current-headers) ")"))) | |
7328 | (ps-right-header | |
7329 | (list | |
7330 | "/pagenumberstring load" | |
7331 | (concat "(" | |
7332 | (mail-header-date gnus-current-headers) ")")))) | |
7333 | (gnus-run-hooks 'gnus-ps-print-hook) | |
7334 | (save-excursion | |
676a7cc9 SZ |
7335 | (ps-spool-buffer-with-faces)))) |
7336 | (kill-buffer buffer)))) | |
7337 | (gnus-summary-remove-process-mark article)) | |
7338 | (ps-despool filename)) | |
eec82323 LMI |
7339 | |
7340 | (defun gnus-summary-show-article (&optional arg) | |
7341 | "Force re-fetching of the current article. | |
16409b0b GM |
7342 | If ARG (the prefix) is a number, show the article with the charset |
7343 | defined in `gnus-summary-show-article-charset-alist', or the charset | |
7344 | inputed. | |
7345 | If ARG (the prefix) is non-nil and not a number, show the raw article | |
7346 | without any article massaging functions being run." | |
eec82323 | 7347 | (interactive "P") |
16409b0b GM |
7348 | (cond |
7349 | ((numberp arg) | |
7350 | (let ((gnus-newsgroup-charset | |
7351 | (or (cdr (assq arg gnus-summary-show-article-charset-alist)) | |
7352 | (read-coding-system "Charset: "))) | |
7353 | (gnus-newsgroup-ignored-charsets 'gnus-all)) | |
7354 | (gnus-summary-select-article nil 'force))) | |
7355 | ((not arg) | |
7356 | ;; Select the article the normal way. | |
7357 | (gnus-summary-select-article nil 'force)) | |
7358 | (t | |
7359 | ;; We have to require this here to make sure that the following | |
7360 | ;; dynamic binding isn't shadowed by autoloading. | |
7361 | (require 'gnus-async) | |
7362 | (require 'gnus-art) | |
eec82323 LMI |
7363 | ;; Bind the article treatment functions to nil. |
7364 | (let ((gnus-have-all-headers t) | |
eec82323 | 7365 | gnus-article-prepare-hook |
16409b0b GM |
7366 | gnus-article-decode-hook |
7367 | gnus-display-mime-function | |
7368 | gnus-break-pages) | |
7369 | ;; Destroy any MIME parts. | |
7370 | (when (gnus-buffer-live-p gnus-article-buffer) | |
7371 | (save-excursion | |
7372 | (set-buffer gnus-article-buffer) | |
7373 | (mm-destroy-parts gnus-article-mime-handles) | |
7374 | ;; Set it to nil for safety reason. | |
7375 | (setq gnus-article-mime-handle-alist nil) | |
7376 | (setq gnus-article-mime-handles nil))) | |
7377 | (gnus-summary-select-article nil 'force)))) | |
eec82323 LMI |
7378 | (gnus-summary-goto-subject gnus-current-article) |
7379 | (gnus-summary-position-point)) | |
7380 | ||
7381 | (defun gnus-summary-verbose-headers (&optional arg) | |
7382 | "Toggle permanent full header display. | |
7383 | If ARG is a positive number, turn header display on. | |
7384 | If ARG is a negative number, turn header display off." | |
7385 | (interactive "P") | |
eec82323 LMI |
7386 | (setq gnus-show-all-headers |
7387 | (cond ((or (not (numberp arg)) | |
7388 | (zerop arg)) | |
7389 | (not gnus-show-all-headers)) | |
7390 | ((natnump arg) | |
7391 | t))) | |
7392 | (gnus-summary-show-article)) | |
7393 | ||
7394 | (defun gnus-summary-toggle-header (&optional arg) | |
7395 | "Show the headers if they are hidden, or hide them if they are shown. | |
7396 | If ARG is a positive number, show the entire header. | |
7397 | If ARG is a negative number, hide the unwanted header lines." | |
7398 | (interactive "P") | |
eec82323 LMI |
7399 | (save-excursion |
7400 | (set-buffer gnus-article-buffer) | |
16409b0b GM |
7401 | (save-restriction |
7402 | (let* ((buffer-read-only nil) | |
7403 | (inhibit-point-motion-hooks t) | |
7404 | hidden e) | |
7405 | (setq hidden | |
7406 | (if (numberp arg) | |
7407 | (>= arg 0) | |
7408 | (save-restriction | |
7409 | (article-narrow-to-head) | |
7410 | (gnus-article-hidden-text-p 'headers)))) | |
7411 | (goto-char (point-min)) | |
7412 | (when (search-forward "\n\n" nil t) | |
7413 | (delete-region (point-min) (1- (point)))) | |
eec82323 | 7414 | (goto-char (point-min)) |
16409b0b GM |
7415 | (save-excursion |
7416 | (set-buffer gnus-original-article-buffer) | |
7417 | (goto-char (point-min)) | |
7418 | (setq e (1- (or (search-forward "\n\n" nil t) (point-max))))) | |
7419 | (insert-buffer-substring gnus-original-article-buffer 1 e) | |
7420 | (save-restriction | |
7421 | (narrow-to-region (point-min) (point)) | |
7422 | (article-decode-encoded-words) | |
7423 | (if hidden | |
7424 | (let ((gnus-treat-hide-headers nil) | |
7425 | (gnus-treat-hide-boring-headers nil)) | |
7426 | (setq gnus-article-wash-types | |
7427 | (delq 'headers gnus-article-wash-types)) | |
7428 | (gnus-treat-article 'head)) | |
7429 | (gnus-treat-article 'head))) | |
7430 | (gnus-set-mode-line 'article))))) | |
eec82323 LMI |
7431 | |
7432 | (defun gnus-summary-show-all-headers () | |
7433 | "Make all header lines visible." | |
7434 | (interactive) | |
eec82323 LMI |
7435 | (gnus-article-show-all-headers)) |
7436 | ||
eec82323 LMI |
7437 | (defun gnus-summary-caesar-message (&optional arg) |
7438 | "Caesar rotate the current article by 13. | |
7439 | The numerical prefix specifies how many places to rotate each letter | |
7440 | forward." | |
7441 | (interactive "P") | |
eec82323 LMI |
7442 | (gnus-summary-select-article) |
7443 | (let ((mail-header-separator "")) | |
7444 | (gnus-eval-in-buffer-window gnus-article-buffer | |
7445 | (save-restriction | |
7446 | (widen) | |
7447 | (let ((start (window-start)) | |
7448 | buffer-read-only) | |
7449 | (message-caesar-buffer-body arg) | |
7450 | (set-window-start (get-buffer-window (current-buffer)) start)))))) | |
7451 | ||
7452 | (defun gnus-summary-stop-page-breaking () | |
7453 | "Stop page breaking in the current article." | |
7454 | (interactive) | |
eec82323 LMI |
7455 | (gnus-summary-select-article) |
7456 | (gnus-eval-in-buffer-window gnus-article-buffer | |
7457 | (widen) | |
7458 | (when (gnus-visual-p 'page-marker) | |
7459 | (let ((buffer-read-only nil)) | |
7460 | (gnus-remove-text-with-property 'gnus-prev) | |
6748645f LMI |
7461 | (gnus-remove-text-with-property 'gnus-next)) |
7462 | (setq gnus-page-broken nil)))) | |
eec82323 LMI |
7463 | |
7464 | (defun gnus-summary-move-article (&optional n to-newsgroup | |
7465 | select-method action) | |
7466 | "Move the current article to a different newsgroup. | |
7467 | If N is a positive number, move the N next articles. | |
7468 | If N is a negative number, move the N previous articles. | |
7469 | If N is nil and any articles have been marked with the process mark, | |
7470 | move those articles instead. | |
7471 | If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to. | |
7472 | If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but | |
7473 | re-spool using this method. | |
7474 | ||
7475 | For this function to work, both the current newsgroup and the | |
7476 | newsgroup that you want to move to have to support the `request-move' | |
16409b0b GM |
7477 | and `request-accept' functions. |
7478 | ||
7479 | ACTION can be either `move' (the default), `crosspost' or `copy'." | |
eec82323 LMI |
7480 | (interactive "P") |
7481 | (unless action | |
7482 | (setq action 'move)) | |
eec82323 LMI |
7483 | ;; Disable marking as read. |
7484 | (let (gnus-mark-article-hook) | |
7485 | (save-window-excursion | |
7486 | (gnus-summary-select-article))) | |
7487 | ;; Check whether the source group supports the required functions. | |
7488 | (cond ((and (eq action 'move) | |
7489 | (not (gnus-check-backend-function | |
7490 | 'request-move-article gnus-newsgroup-name))) | |
7491 | (error "The current group does not support article moving")) | |
7492 | ((and (eq action 'crosspost) | |
7493 | (not (gnus-check-backend-function | |
7494 | 'request-replace-article gnus-newsgroup-name))) | |
7495 | (error "The current group does not support article editing"))) | |
7496 | (let ((articles (gnus-summary-work-articles n)) | |
16409b0b GM |
7497 | (prefix (if (gnus-check-backend-function |
7498 | 'request-move-article gnus-newsgroup-name) | |
7499 | (gnus-group-real-prefix gnus-newsgroup-name) | |
7500 | "")) | |
eec82323 LMI |
7501 | (names '((move "Move" "Moving") |
7502 | (copy "Copy" "Copying") | |
7503 | (crosspost "Crosspost" "Crossposting"))) | |
7504 | (copy-buf (save-excursion | |
7505 | (nnheader-set-temp-buffer " *copy article*"))) | |
7506 | art-group to-method new-xref article to-groups) | |
7507 | (unless (assq action names) | |
7508 | (error "Unknown action %s" action)) | |
7509 | ;; Read the newsgroup name. | |
7510 | (when (and (not to-newsgroup) | |
7511 | (not select-method)) | |
7512 | (setq to-newsgroup | |
7513 | (gnus-read-move-group-name | |
7514 | (cadr (assq action names)) | |
7515 | (symbol-value (intern (format "gnus-current-%s-group" action))) | |
7516 | articles prefix)) | |
7517 | (set (intern (format "gnus-current-%s-group" action)) to-newsgroup)) | |
7518 | (setq to-method (or select-method | |
16409b0b GM |
7519 | (gnus-server-to-method |
7520 | (gnus-group-method to-newsgroup)))) | |
eec82323 LMI |
7521 | ;; Check the method we are to move this article to... |
7522 | (unless (gnus-check-backend-function | |
7523 | 'request-accept-article (car to-method)) | |
7524 | (error "%s does not support article copying" (car to-method))) | |
7525 | (unless (gnus-check-server to-method) | |
7526 | (error "Can't open server %s" (car to-method))) | |
7527 | (gnus-message 6 "%s to %s: %s..." | |
7528 | (caddr (assq action names)) | |
7529 | (or (car select-method) to-newsgroup) articles) | |
7530 | (while articles | |
7531 | (setq article (pop articles)) | |
7532 | (setq | |
7533 | art-group | |
7534 | (cond | |
7535 | ;; Move the article. | |
7536 | ((eq action 'move) | |
a8151ef7 LMI |
7537 | ;; Remove this article from future suppression. |
7538 | (gnus-dup-unsuppress-article article) | |
eec82323 LMI |
7539 | (gnus-request-move-article |
7540 | article ; Article to move | |
7541 | gnus-newsgroup-name ; From newsgroup | |
7542 | (nth 1 (gnus-find-method-for-group | |
7543 | gnus-newsgroup-name)) ; Server | |
7544 | (list 'gnus-request-accept-article | |
7545 | to-newsgroup (list 'quote select-method) | |
16409b0b | 7546 | (not articles) t) ; Accept form |
eec82323 LMI |
7547 | (not articles))) ; Only save nov last time |
7548 | ;; Copy the article. | |
7549 | ((eq action 'copy) | |
7550 | (save-excursion | |
7551 | (set-buffer copy-buf) | |
6748645f LMI |
7552 | (when (gnus-request-article-this-buffer article gnus-newsgroup-name) |
7553 | (gnus-request-accept-article | |
16409b0b | 7554 | to-newsgroup select-method (not articles) t)))) |
eec82323 LMI |
7555 | ;; Crosspost the article. |
7556 | ((eq action 'crosspost) | |
7557 | (let ((xref (message-tokenize-header | |
7558 | (mail-header-xref (gnus-summary-article-header article)) | |
7559 | " "))) | |
7560 | (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name) | |
7561 | ":" article)) | |
7562 | (unless xref | |
7563 | (setq xref (list (system-name)))) | |
7564 | (setq new-xref | |
7565 | (concat | |
7566 | (mapconcat 'identity | |
7567 | (delete "Xref:" (delete new-xref xref)) | |
7568 | " ") | |
7569 | " " new-xref)) | |
7570 | (save-excursion | |
7571 | (set-buffer copy-buf) | |
7572 | ;; First put the article in the destination group. | |
7573 | (gnus-request-article-this-buffer article gnus-newsgroup-name) | |
7574 | (when (consp (setq art-group | |
7575 | (gnus-request-accept-article | |
7576 | to-newsgroup select-method (not articles)))) | |
7577 | (setq new-xref (concat new-xref " " (car art-group) | |
7578 | ":" (cdr art-group))) | |
7579 | ;; Now we have the new Xrefs header, so we insert | |
7580 | ;; it and replace the new article. | |
7581 | (nnheader-replace-header "Xref" new-xref) | |
7582 | (gnus-request-replace-article | |
7583 | (cdr art-group) to-newsgroup (current-buffer)) | |
7584 | art-group)))))) | |
7585 | (cond | |
7586 | ((not art-group) | |
16409b0b GM |
7587 | (gnus-message 1 "Couldn't %s article %s: %s" |
7588 | (cadr (assq action names)) article | |
7589 | (nnheader-get-report (car to-method)))) | |
7590 | ((eq art-group 'junk) | |
7591 | (when (eq action 'move) | |
7592 | (gnus-summary-mark-article article gnus-canceled-mark) | |
7593 | (gnus-message 4 "Deleted article %s" article))) | |
eec82323 | 7594 | (t |
6748645f LMI |
7595 | (let* ((pto-group (gnus-group-prefixed-name |
7596 | (car art-group) to-method)) | |
7597 | (entry | |
7598 | (gnus-gethash pto-group gnus-newsrc-hashtb)) | |
eec82323 | 7599 | (info (nth 2 entry)) |
16409b0b GM |
7600 | (to-group (gnus-info-group info)) |
7601 | to-marks) | |
eec82323 LMI |
7602 | ;; Update the group that has been moved to. |
7603 | (when (and info | |
7604 | (memq action '(move copy))) | |
7605 | (unless (member to-group to-groups) | |
7606 | (push to-group to-groups)) | |
7607 | ||
7608 | (unless (memq article gnus-newsgroup-unreads) | |
16409b0b | 7609 | (push 'read to-marks) |
eec82323 LMI |
7610 | (gnus-info-set-read |
7611 | info (gnus-add-to-range (gnus-info-read info) | |
7612 | (list (cdr art-group))))) | |
7613 | ||
16409b0b | 7614 | ;; See whether the article is to be put in the cache. |
eec82323 LMI |
7615 | (let ((marks gnus-article-mark-lists) |
7616 | (to-article (cdr art-group))) | |
7617 | ||
16409b0b GM |
7618 | ;; Enter the article into the cache in the new group, |
7619 | ;; if that is required. | |
eec82323 LMI |
7620 | (when gnus-use-cache |
7621 | (gnus-cache-possibly-enter-article | |
7622 | to-group to-article | |
eec82323 LMI |
7623 | (memq article gnus-newsgroup-marked) |
7624 | (memq article gnus-newsgroup-dormant) | |
7625 | (memq article gnus-newsgroup-unreads))) | |
7626 | ||
16409b0b GM |
7627 | (when gnus-preserve-marks |
7628 | ;; Copy any marks over to the new group. | |
7629 | (when (and (equal to-group gnus-newsgroup-name) | |
7630 | (not (memq article gnus-newsgroup-unreads))) | |
7631 | ;; Mark this article as read in this group. | |
7632 | (push (cons to-article gnus-read-mark) gnus-newsgroup-reads) | |
7633 | (setcdr (gnus-active to-group) to-article) | |
7634 | (setcdr gnus-newsgroup-active to-article)) | |
7635 | ||
7636 | (while marks | |
7637 | (when (memq article (symbol-value | |
7638 | (intern (format "gnus-newsgroup-%s" | |
7639 | (caar marks))))) | |
7640 | (push (cdar marks) to-marks) | |
7641 | ;; If the other group is the same as this group, | |
7642 | ;; then we have to add the mark to the list. | |
7643 | (when (equal to-group gnus-newsgroup-name) | |
7644 | (set (intern (format "gnus-newsgroup-%s" (caar marks))) | |
7645 | (cons to-article | |
7646 | (symbol-value | |
7647 | (intern (format "gnus-newsgroup-%s" | |
7648 | (caar marks))))))) | |
7649 | ;; Copy the marks to other group. | |
7650 | (gnus-add-marked-articles | |
7651 | to-group (cdar marks) (list to-article) info)) | |
7652 | (setq marks (cdr marks))) | |
7653 | ||
7654 | (gnus-request-set-mark to-group (list (list (list to-article) | |
7655 | 'set | |
7656 | to-marks)))) | |
eec82323 LMI |
7657 | |
7658 | (gnus-dribble-enter | |
7659 | (concat "(gnus-group-set-info '" | |
7660 | (gnus-prin1-to-string (gnus-get-info to-group)) | |
7661 | ")")))) | |
7662 | ||
7663 | ;; Update the Xref header in this article to point to | |
7664 | ;; the new crossposted article we have just created. | |
7665 | (when (eq action 'crosspost) | |
7666 | (save-excursion | |
7667 | (set-buffer copy-buf) | |
7668 | (gnus-request-article-this-buffer article gnus-newsgroup-name) | |
7669 | (nnheader-replace-header "Xref" new-xref) | |
7670 | (gnus-request-replace-article | |
7671 | article gnus-newsgroup-name (current-buffer))))) | |
7672 | ||
6748645f LMI |
7673 | ;;;!!!Why is this necessary? |
7674 | (set-buffer gnus-summary-buffer) | |
7675 | ||
eec82323 LMI |
7676 | (gnus-summary-goto-subject article) |
7677 | (when (eq action 'move) | |
7678 | (gnus-summary-mark-article article gnus-canceled-mark)))) | |
7679 | (gnus-summary-remove-process-mark article)) | |
7680 | ;; Re-activate all groups that have been moved to. | |
7681 | (while to-groups | |
7682 | (save-excursion | |
7683 | (set-buffer gnus-group-buffer) | |
7684 | (when (gnus-group-goto-group (car to-groups) t) | |
a8151ef7 | 7685 | (gnus-group-get-new-news-this-group 1 t)) |
eec82323 LMI |
7686 | (pop to-groups))) |
7687 | ||
7688 | (gnus-kill-buffer copy-buf) | |
7689 | (gnus-summary-position-point) | |
7690 | (gnus-set-mode-line 'summary))) | |
7691 | ||
7692 | (defun gnus-summary-copy-article (&optional n to-newsgroup select-method) | |
7693 | "Move the current article to a different newsgroup. | |
7694 | If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to. | |
7695 | If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but | |
7696 | re-spool using this method." | |
7697 | (interactive "P") | |
7698 | (gnus-summary-move-article n to-newsgroup select-method 'copy)) | |
7699 | ||
7700 | (defun gnus-summary-crosspost-article (&optional n) | |
7701 | "Crosspost the current article to some other group." | |
7702 | (interactive "P") | |
7703 | (gnus-summary-move-article n nil nil 'crosspost)) | |
7704 | ||
7705 | (defcustom gnus-summary-respool-default-method nil | |
7706 | "Default method for respooling an article. | |
7707 | If nil, use to the current newsgroup method." | |
04ad70ac KH |
7708 | :type '(choice (gnus-select-method :value (nnml "")) |
7709 | (const nil)) | |
eec82323 LMI |
7710 | :group 'gnus-summary-mail) |
7711 | ||
7712 | (defun gnus-summary-respool-article (&optional n method) | |
7713 | "Respool the current article. | |
7714 | The article will be squeezed through the mail spooling process again, | |
7715 | which means that it will be put in some mail newsgroup or other | |
7716 | depending on `nnmail-split-methods'. | |
7717 | If N is a positive number, respool the N next articles. | |
7718 | If N is a negative number, respool the N previous articles. | |
7719 | If N is nil and any articles have been marked with the process mark, | |
7720 | respool those articles instead. | |
7721 | ||
7722 | Respooling can be done both from mail groups and \"real\" newsgroups. | |
7723 | In the former case, the articles in question will be moved from the | |
7724 | current group into whatever groups they are destined to. In the | |
7725 | latter case, they will be copied into the relevant groups." | |
7726 | (interactive | |
7727 | (list current-prefix-arg | |
7728 | (let* ((methods (gnus-methods-using 'respool)) | |
7729 | (methname | |
7730 | (symbol-name (or gnus-summary-respool-default-method | |
7731 | (car (gnus-find-method-for-group | |
7732 | gnus-newsgroup-name))))) | |
7733 | (method | |
7734 | (gnus-completing-read | |
7735 | methname "What backend do you want to use when respooling?" | |
7736 | methods nil t nil 'gnus-mail-method-history)) | |
7737 | ms) | |
7738 | (cond | |
7739 | ((zerop (length (setq ms (gnus-servers-using-backend | |
7740 | (intern method))))) | |
7741 | (list (intern method) "")) | |
7742 | ((= 1 (length ms)) | |
7743 | (car ms)) | |
7744 | (t | |
7745 | (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms))) | |
7746 | (cdr (assoc (completing-read "Server name: " ms-alist nil t) | |
7747 | ms-alist)))))))) | |
eec82323 LMI |
7748 | (unless method |
7749 | (error "No method given for respooling")) | |
7750 | (if (assoc (symbol-name | |
7751 | (car (gnus-find-method-for-group gnus-newsgroup-name))) | |
7752 | (gnus-methods-using 'respool)) | |
7753 | (gnus-summary-move-article n nil method) | |
7754 | (gnus-summary-copy-article n nil method))) | |
7755 | ||
7756 | (defun gnus-summary-import-article (file) | |
6748645f | 7757 | "Import an arbitrary file into a mail newsgroup." |
eec82323 | 7758 | (interactive "fImport file: ") |
eec82323 LMI |
7759 | (let ((group gnus-newsgroup-name) |
7760 | (now (current-time)) | |
7761 | atts lines) | |
7762 | (unless (gnus-check-backend-function 'request-accept-article group) | |
7763 | (error "%s does not support article importing" group)) | |
7764 | (or (file-readable-p file) | |
7765 | (not (file-regular-p file)) | |
7766 | (error "Can't read %s" file)) | |
7767 | (save-excursion | |
6748645f | 7768 | (set-buffer (gnus-get-buffer-create " *import file*")) |
eec82323 | 7769 | (erase-buffer) |
16409b0b | 7770 | (nnheader-insert-file-contents file) |
eec82323 LMI |
7771 | (goto-char (point-min)) |
7772 | (unless (nnheader-article-p) | |
7773 | ;; This doesn't look like an article, so we fudge some headers. | |
7774 | (setq atts (file-attributes file) | |
7775 | lines (count-lines (point-min) (point-max))) | |
7776 | (insert "From: " (read-string "From: ") "\n" | |
7777 | "Subject: " (read-string "Subject: ") "\n" | |
16409b0b | 7778 | "Date: " (message-make-date (nth 5 atts)) |
eec82323 LMI |
7779 | "\n" |
7780 | "Message-ID: " (message-make-message-id) "\n" | |
7781 | "Lines: " (int-to-string lines) "\n" | |
7782 | "Chars: " (int-to-string (nth 7 atts)) "\n\n")) | |
7783 | (gnus-request-accept-article group nil t) | |
7784 | (kill-buffer (current-buffer))))) | |
7785 | ||
7786 | (defun gnus-summary-article-posted-p () | |
16409b0b | 7787 | "Say whether the current (mail) article is available from news as well. |
eec82323 LMI |
7788 | This will be the case if the article has both been mailed and posted." |
7789 | (interactive) | |
7790 | (let ((id (mail-header-references (gnus-summary-article-header))) | |
16409b0b | 7791 | (gnus-override-method (car (gnus-refer-article-methods)))) |
eec82323 LMI |
7792 | (if (gnus-request-head id "") |
7793 | (gnus-message 2 "The current message was found on %s" | |
7794 | gnus-override-method) | |
7795 | (gnus-message 2 "The current message couldn't be found on %s" | |
7796 | gnus-override-method) | |
7797 | nil))) | |
7798 | ||
7799 | (defun gnus-summary-expire-articles (&optional now) | |
7800 | "Expire all articles that are marked as expirable in the current group." | |
7801 | (interactive) | |
eec82323 LMI |
7802 | (when (gnus-check-backend-function |
7803 | 'request-expire-articles gnus-newsgroup-name) | |
7804 | ;; This backend supports expiry. | |
7805 | (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name)) | |
7806 | (expirable (if total | |
7807 | (progn | |
7808 | ;; We need to update the info for | |
7809 | ;; this group for `gnus-list-of-read-articles' | |
7810 | ;; to give us the right answer. | |
6748645f | 7811 | (gnus-run-hooks 'gnus-exit-group-hook) |
eec82323 LMI |
7812 | (gnus-summary-update-info) |
7813 | (gnus-list-of-read-articles gnus-newsgroup-name)) | |
7814 | (setq gnus-newsgroup-expirable | |
7815 | (sort gnus-newsgroup-expirable '<)))) | |
7816 | (expiry-wait (if now 'immediate | |
7817 | (gnus-group-find-parameter | |
7818 | gnus-newsgroup-name 'expiry-wait))) | |
16409b0b GM |
7819 | (nnmail-expiry-target |
7820 | (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target) | |
7821 | nnmail-expiry-target)) | |
eec82323 LMI |
7822 | es) |
7823 | (when expirable | |
7824 | ;; There are expirable articles in this group, so we run them | |
7825 | ;; through the expiry process. | |
7826 | (gnus-message 6 "Expiring articles...") | |
16409b0b GM |
7827 | (unless (gnus-check-group gnus-newsgroup-name) |
7828 | (error "Can't open server for %s" gnus-newsgroup-name)) | |
eec82323 | 7829 | ;; The list of articles that weren't expired is returned. |
6748645f LMI |
7830 | (save-excursion |
7831 | (if expiry-wait | |
7832 | (let ((nnmail-expiry-wait-function nil) | |
7833 | (nnmail-expiry-wait expiry-wait)) | |
7834 | (setq es (gnus-request-expire-articles | |
7835 | expirable gnus-newsgroup-name))) | |
7836 | (setq es (gnus-request-expire-articles | |
7837 | expirable gnus-newsgroup-name)))) | |
eec82323 LMI |
7838 | (unless total |
7839 | (setq gnus-newsgroup-expirable es)) | |
7840 | ;; We go through the old list of expirable, and mark all | |
7841 | ;; really expired articles as nonexistent. | |
7842 | (unless (eq es expirable) ;If nothing was expired, we don't mark. | |
7843 | (let ((gnus-use-cache nil)) | |
7844 | (while expirable | |
7845 | (unless (memq (car expirable) es) | |
7846 | (when (gnus-data-find (car expirable)) | |
7847 | (gnus-summary-mark-article | |
7848 | (car expirable) gnus-canceled-mark))) | |
7849 | (setq expirable (cdr expirable))))) | |
7850 | (gnus-message 6 "Expiring articles...done"))))) | |
7851 | ||
7852 | (defun gnus-summary-expire-articles-now () | |
7853 | "Expunge all expirable articles in the current group. | |
7854 | This means that *all* articles that are marked as expirable will be | |
7855 | deleted forever, right now." | |
7856 | (interactive) | |
eec82323 LMI |
7857 | (or gnus-expert-user |
7858 | (gnus-yes-or-no-p | |
7859 | "Are you really, really, really sure you want to delete all these messages? ") | |
7860 | (error "Phew!")) | |
7861 | (gnus-summary-expire-articles t)) | |
7862 | ||
7863 | ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. | |
7864 | (defun gnus-summary-delete-article (&optional n) | |
7865 | "Delete the N next (mail) articles. | |
7866 | This command actually deletes articles. This is not a marking | |
7867 | command. The article will disappear forever from your life, never to | |
7868 | return. | |
7869 | If N is negative, delete backwards. | |
7870 | If N is nil and articles have been marked with the process mark, | |
7871 | delete these instead." | |
7872 | (interactive "P") | |
eec82323 LMI |
7873 | (unless (gnus-check-backend-function 'request-expire-articles |
7874 | gnus-newsgroup-name) | |
a8151ef7 | 7875 | (error "The current newsgroup does not support article deletion")) |
16409b0b GM |
7876 | (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name)) |
7877 | (error "Couldn't open server")) | |
eec82323 | 7878 | ;; Compute the list of articles to delete. |
6748645f | 7879 | (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<)) |
eec82323 LMI |
7880 | not-deleted) |
7881 | (if (and gnus-novice-user | |
7882 | (not (gnus-yes-or-no-p | |
7883 | (format "Do you really want to delete %s forever? " | |
7884 | (if (> (length articles) 1) | |
7885 | (format "these %s articles" (length articles)) | |
7886 | "this article"))))) | |
7887 | () | |
7888 | ;; Delete the articles. | |
7889 | (setq not-deleted (gnus-request-expire-articles | |
7890 | articles gnus-newsgroup-name 'force)) | |
7891 | (while articles | |
7892 | (gnus-summary-remove-process-mark (car articles)) | |
7893 | ;; The backend might not have been able to delete the article | |
7894 | ;; after all. | |
7895 | (unless (memq (car articles) not-deleted) | |
7896 | (gnus-summary-mark-article (car articles) gnus-canceled-mark)) | |
7897 | (setq articles (cdr articles))) | |
7898 | (when not-deleted | |
7899 | (gnus-message 4 "Couldn't delete articles %s" not-deleted))) | |
7900 | (gnus-summary-position-point) | |
7901 | (gnus-set-mode-line 'summary) | |
7902 | not-deleted)) | |
7903 | ||
16409b0b | 7904 | (defun gnus-summary-edit-article (&optional arg) |
eec82323 LMI |
7905 | "Edit the current article. |
7906 | This will have permanent effect only in mail groups. | |
16409b0b GM |
7907 | If ARG is nil, edit the decoded articles. |
7908 | If ARG is 1, edit the raw articles. | |
7909 | If ARG is 2, edit the raw articles even in read-only groups. | |
7910 | Otherwise, allow editing of articles even in read-only | |
eec82323 LMI |
7911 | groups." |
7912 | (interactive "P") | |
16409b0b GM |
7913 | (let (force raw) |
7914 | (cond | |
7915 | ((null arg)) | |
7916 | ((eq arg 1) (setq raw t)) | |
7917 | ((eq arg 2) (setq raw t | |
7918 | force t)) | |
7919 | (t (setq force t))) | |
7920 | (if (and raw (not force) (equal gnus-newsgroup-name "nndraft:drafts")) | |
715a2ca2 | 7921 | (error "Can't edit the raw article in group nndraft:drafts")) |
16409b0b GM |
7922 | (save-excursion |
7923 | (set-buffer gnus-summary-buffer) | |
7924 | (let ((mail-parse-charset gnus-newsgroup-charset) | |
7925 | (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)) | |
7926 | (gnus-set-global-variables) | |
7927 | (when (and (not force) | |
7928 | (gnus-group-read-only-p)) | |
7929 | (error "The current newsgroup does not support article editing")) | |
7930 | (gnus-summary-show-article t) | |
7931 | (when (and (not raw) (gnus-buffer-live-p gnus-article-buffer)) | |
7932 | (with-current-buffer gnus-article-buffer | |
d4dfaa19 | 7933 | (mm-enable-multibyte-mule4))) |
16409b0b GM |
7934 | (if (equal gnus-newsgroup-name "nndraft:drafts") |
7935 | (setq raw t)) | |
7936 | (gnus-article-edit-article | |
7937 | (if raw 'ignore | |
7938 | #'(lambda () | |
7939 | (let ((mbl mml-buffer-list)) | |
7940 | (setq mml-buffer-list nil) | |
7941 | (mime-to-mml) | |
7942 | (make-local-hook 'kill-buffer-hook) | |
7943 | (let ((mml-buffer-list mml-buffer-list)) | |
7944 | (setq mml-buffer-list mbl) | |
7945 | (make-local-variable 'mml-buffer-list)) | |
7946 | (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))) | |
7947 | `(lambda (no-highlight) | |
7948 | (let ((mail-parse-charset ',gnus-newsgroup-charset) | |
7949 | (mail-parse-ignored-charsets | |
7950 | ',gnus-newsgroup-ignored-charsets)) | |
7951 | ,(if (not raw) '(progn | |
7952 | (mml-to-mime) | |
7953 | (mml-destroy-buffers) | |
7954 | (remove-hook 'kill-buffer-hook | |
7955 | 'mml-destroy-buffers t) | |
7956 | (kill-local-variable 'mml-buffer-list))) | |
7957 | (gnus-summary-edit-article-done | |
7958 | ,(or (mail-header-references gnus-current-headers) "") | |
7959 | ,(gnus-group-read-only-p) | |
7960 | ,gnus-summary-buffer no-highlight)))))))) | |
eec82323 LMI |
7961 | |
7962 | (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit) | |
7963 | ||
6748645f LMI |
7964 | (defun gnus-summary-edit-article-done (&optional references read-only buffer |
7965 | no-highlight) | |
eec82323 LMI |
7966 | "Make edits to the current article permanent." |
7967 | (interactive) | |
7968 | ;; Replace the article. | |
6748645f | 7969 | (let ((buf (current-buffer))) |
16409b0b GM |
7970 | (with-temp-buffer |
7971 | (insert-buffer-substring buf) | |
6748645f LMI |
7972 | (if (and (not read-only) |
7973 | (not (gnus-request-replace-article | |
7974 | (cdr gnus-article-current) (car gnus-article-current) | |
16409b0b | 7975 | (current-buffer) t))) |
6748645f LMI |
7976 | (error "Couldn't replace article") |
7977 | ;; Update the summary buffer. | |
7978 | (if (and references | |
7979 | (equal (message-tokenize-header references " ") | |
7980 | (message-tokenize-header | |
7981 | (or (message-fetch-field "references") "") " "))) | |
7982 | ;; We only have to update this line. | |
7983 | (save-excursion | |
7984 | (save-restriction | |
7985 | (message-narrow-to-head) | |
7986 | (let ((head (buffer-string)) | |
7987 | header) | |
16409b0b | 7988 | (with-temp-buffer |
6748645f LMI |
7989 | (insert (format "211 %d Article retrieved.\n" |
7990 | (cdr gnus-article-current))) | |
7991 | (insert head) | |
7992 | (insert ".\n") | |
7993 | (let ((nntp-server-buffer (current-buffer))) | |
7994 | (setq header (car (gnus-get-newsgroup-headers | |
7995 | (save-excursion | |
7996 | (set-buffer gnus-summary-buffer) | |
7997 | gnus-newsgroup-dependencies) | |
7998 | t)))) | |
7999 | (save-excursion | |
8000 | (set-buffer gnus-summary-buffer) | |
8001 | (gnus-data-set-header | |
8002 | (gnus-data-find (cdr gnus-article-current)) | |
8003 | header) | |
8004 | (gnus-summary-update-article-line | |
8005 | (cdr gnus-article-current) header)))))) | |
8006 | ;; Update threads. | |
8007 | (set-buffer (or buffer gnus-summary-buffer)) | |
8008 | (gnus-summary-update-article (cdr gnus-article-current))) | |
8009 | ;; Prettify the article buffer again. | |
8010 | (unless no-highlight | |
8011 | (save-excursion | |
8012 | (set-buffer gnus-article-buffer) | |
16409b0b GM |
8013 | ;;;!!! Fix this -- article should be rehighlighted. |
8014 | ;;;(gnus-run-hooks 'gnus-article-display-hook) | |
6748645f LMI |
8015 | (set-buffer gnus-original-article-buffer) |
8016 | (gnus-request-article | |
8017 | (cdr gnus-article-current) | |
8018 | (car gnus-article-current) (current-buffer)))) | |
8019 | ;; Prettify the summary buffer line. | |
8020 | (when (gnus-visual-p 'summary-highlight 'highlight) | |
8021 | (gnus-run-hooks 'gnus-visual-mark-article-hook)))))) | |
eec82323 LMI |
8022 | |
8023 | (defun gnus-summary-edit-wash (key) | |
6748645f | 8024 | "Perform editing command KEY in the article buffer." |
eec82323 LMI |
8025 | (interactive |
8026 | (list | |
8027 | (progn | |
8028 | (message "%s" (concat (this-command-keys) "- ")) | |
8029 | (read-char)))) | |
8030 | (message "") | |
8031 | (gnus-summary-edit-article) | |
8032 | (execute-kbd-macro (concat (this-command-keys) key)) | |
8033 | (gnus-article-edit-done)) | |
8034 | ||
8035 | ;;; Respooling | |
8036 | ||
6748645f | 8037 | (defun gnus-summary-respool-query (&optional silent trace) |
eec82323 LMI |
8038 | "Query where the respool algorithm would put this article." |
8039 | (interactive) | |
eec82323 LMI |
8040 | (let (gnus-mark-article-hook) |
8041 | (gnus-summary-select-article) | |
8042 | (save-excursion | |
8043 | (set-buffer gnus-original-article-buffer) | |
8044 | (save-restriction | |
8045 | (message-narrow-to-head) | |
6748645f | 8046 | (let ((groups (nnmail-article-group 'identity trace))) |
eec82323 LMI |
8047 | (unless silent |
8048 | (if groups | |
8049 | (message "This message would go to %s" | |
8050 | (mapconcat 'car groups ", ")) | |
8051 | (message "This message would go to no groups")) | |
8052 | groups)))))) | |
8053 | ||
6748645f LMI |
8054 | (defun gnus-summary-respool-trace () |
8055 | "Trace where the respool algorithm would put this article. | |
8056 | Display a buffer showing all fancy splitting patterns which matched." | |
8057 | (interactive) | |
8058 | (gnus-summary-respool-query nil t)) | |
8059 | ||
eec82323 LMI |
8060 | ;; Summary marking commands. |
8061 | ||
8062 | (defun gnus-summary-kill-same-subject-and-select (&optional unmark) | |
8063 | "Mark articles which has the same subject as read, and then select the next. | |
8064 | If UNMARK is positive, remove any kind of mark. | |
8065 | If UNMARK is negative, tick articles." | |
8066 | (interactive "P") | |
eec82323 LMI |
8067 | (when unmark |
8068 | (setq unmark (prefix-numeric-value unmark))) | |
8069 | (let ((count | |
8070 | (gnus-summary-mark-same-subject | |
8071 | (gnus-summary-article-subject) unmark))) | |
8072 | ;; Select next unread article. If auto-select-same mode, should | |
8073 | ;; select the first unread article. | |
8074 | (gnus-summary-next-article t (and gnus-auto-select-same | |
8075 | (gnus-summary-article-subject))) | |
8076 | (gnus-message 7 "%d article%s marked as %s" | |
8077 | count (if (= count 1) " is" "s are") | |
8078 | (if unmark "unread" "read")))) | |
8079 | ||
8080 | (defun gnus-summary-kill-same-subject (&optional unmark) | |
8081 | "Mark articles which has the same subject as read. | |
8082 | If UNMARK is positive, remove any kind of mark. | |
8083 | If UNMARK is negative, tick articles." | |
8084 | (interactive "P") | |
eec82323 LMI |
8085 | (when unmark |
8086 | (setq unmark (prefix-numeric-value unmark))) | |
8087 | (let ((count | |
8088 | (gnus-summary-mark-same-subject | |
8089 | (gnus-summary-article-subject) unmark))) | |
8090 | ;; If marked as read, go to next unread subject. | |
8091 | (when (null unmark) | |
8092 | ;; Go to next unread subject. | |
8093 | (gnus-summary-next-subject 1 t)) | |
8094 | (gnus-message 7 "%d articles are marked as %s" | |
8095 | count (if unmark "unread" "read")))) | |
8096 | ||
8097 | (defun gnus-summary-mark-same-subject (subject &optional unmark) | |
8098 | "Mark articles with same SUBJECT as read, and return marked number. | |
8099 | If optional argument UNMARK is positive, remove any kinds of marks. | |
8100 | If optional argument UNMARK is negative, mark articles as unread instead." | |
8101 | (let ((count 1)) | |
8102 | (save-excursion | |
8103 | (cond | |
8104 | ((null unmark) ; Mark as read. | |
8105 | (while (and | |
8106 | (progn | |
8107 | (gnus-summary-mark-article-as-read gnus-killed-mark) | |
8108 | (gnus-summary-show-thread) t) | |
8109 | (gnus-summary-find-subject subject)) | |
8110 | (setq count (1+ count)))) | |
8111 | ((> unmark 0) ; Tick. | |
8112 | (while (and | |
8113 | (progn | |
8114 | (gnus-summary-mark-article-as-unread gnus-ticked-mark) | |
8115 | (gnus-summary-show-thread) t) | |
8116 | (gnus-summary-find-subject subject)) | |
8117 | (setq count (1+ count)))) | |
8118 | (t ; Mark as unread. | |
8119 | (while (and | |
8120 | (progn | |
8121 | (gnus-summary-mark-article-as-unread gnus-unread-mark) | |
8122 | (gnus-summary-show-thread) t) | |
8123 | (gnus-summary-find-subject subject)) | |
8124 | (setq count (1+ count))))) | |
8125 | (gnus-set-mode-line 'summary) | |
8126 | ;; Return the number of marked articles. | |
8127 | count))) | |
8128 | ||
8129 | (defun gnus-summary-mark-as-processable (n &optional unmark) | |
8130 | "Set the process mark on the next N articles. | |
8131 | If N is negative, mark backward instead. If UNMARK is non-nil, remove | |
8132 | the process mark instead. The difference between N and the actual | |
8133 | number of articles marked is returned." | |
8134 | (interactive "p") | |
eec82323 LMI |
8135 | (let ((backward (< n 0)) |
8136 | (n (abs n))) | |
8137 | (while (and | |
8138 | (> n 0) | |
8139 | (if unmark | |
8140 | (gnus-summary-remove-process-mark | |
8141 | (gnus-summary-article-number)) | |
8142 | (gnus-summary-set-process-mark (gnus-summary-article-number))) | |
8143 | (zerop (gnus-summary-next-subject (if backward -1 1) nil t))) | |
8144 | (setq n (1- n))) | |
8145 | (when (/= 0 n) | |
8146 | (gnus-message 7 "No more articles")) | |
8147 | (gnus-summary-recenter) | |
8148 | (gnus-summary-position-point) | |
8149 | n)) | |
8150 | ||
8151 | (defun gnus-summary-unmark-as-processable (n) | |
8152 | "Remove the process mark from the next N articles. | |
6748645f LMI |
8153 | If N is negative, unmark backward instead. The difference between N and |
8154 | the actual number of articles unmarked is returned." | |
eec82323 | 8155 | (interactive "p") |
eec82323 LMI |
8156 | (gnus-summary-mark-as-processable n t)) |
8157 | ||
8158 | (defun gnus-summary-unmark-all-processable () | |
8159 | "Remove the process mark from all articles." | |
8160 | (interactive) | |
eec82323 LMI |
8161 | (save-excursion |
8162 | (while gnus-newsgroup-processable | |
8163 | (gnus-summary-remove-process-mark (car gnus-newsgroup-processable)))) | |
8164 | (gnus-summary-position-point)) | |
8165 | ||
8166 | (defun gnus-summary-mark-as-expirable (n) | |
8167 | "Mark N articles forward as expirable. | |
8168 | If N is negative, mark backward instead. The difference between N and | |
8169 | the actual number of articles marked is returned." | |
8170 | (interactive "p") | |
eec82323 LMI |
8171 | (gnus-summary-mark-forward n gnus-expirable-mark)) |
8172 | ||
8173 | (defun gnus-summary-mark-article-as-replied (article) | |
8174 | "Mark ARTICLE replied and update the summary line." | |
8175 | (push article gnus-newsgroup-replied) | |
8176 | (let ((buffer-read-only nil)) | |
16409b0b | 8177 | (when (gnus-summary-goto-subject article nil t) |
eec82323 LMI |
8178 | (gnus-summary-update-secondary-mark article)))) |
8179 | ||
8180 | (defun gnus-summary-set-bookmark (article) | |
8181 | "Set a bookmark in current article." | |
8182 | (interactive (list (gnus-summary-article-number))) | |
eec82323 LMI |
8183 | (when (or (not (get-buffer gnus-article-buffer)) |
8184 | (not gnus-current-article) | |
8185 | (not gnus-article-current) | |
8186 | (not (equal gnus-newsgroup-name (car gnus-article-current)))) | |
8187 | (error "No current article selected")) | |
8188 | ;; Remove old bookmark, if one exists. | |
8189 | (let ((old (assq article gnus-newsgroup-bookmarks))) | |
8190 | (when old | |
8191 | (setq gnus-newsgroup-bookmarks | |
8192 | (delq old gnus-newsgroup-bookmarks)))) | |
8193 | ;; Set the new bookmark, which is on the form | |
8194 | ;; (article-number . line-number-in-body). | |
8195 | (push | |
8196 | (cons article | |
8197 | (save-excursion | |
8198 | (set-buffer gnus-article-buffer) | |
8199 | (count-lines | |
8200 | (min (point) | |
8201 | (save-excursion | |
8202 | (goto-char (point-min)) | |
8203 | (search-forward "\n\n" nil t) | |
8204 | (point))) | |
8205 | (point)))) | |
8206 | gnus-newsgroup-bookmarks) | |
8207 | (gnus-message 6 "A bookmark has been added to the current article.")) | |
8208 | ||
8209 | (defun gnus-summary-remove-bookmark (article) | |
8210 | "Remove the bookmark from the current article." | |
8211 | (interactive (list (gnus-summary-article-number))) | |
eec82323 LMI |
8212 | ;; Remove old bookmark, if one exists. |
8213 | (let ((old (assq article gnus-newsgroup-bookmarks))) | |
8214 | (if old | |
8215 | (progn | |
8216 | (setq gnus-newsgroup-bookmarks | |
8217 | (delq old gnus-newsgroup-bookmarks)) | |
8218 | (gnus-message 6 "Removed bookmark.")) | |
8219 | (gnus-message 6 "No bookmark in current article.")))) | |
8220 | ||
8221 | ;; Suggested by Daniel Quinlan <quinlan@best.com>. | |
8222 | (defun gnus-summary-mark-as-dormant (n) | |
8223 | "Mark N articles forward as dormant. | |
8224 | If N is negative, mark backward instead. The difference between N and | |
8225 | the actual number of articles marked is returned." | |
8226 | (interactive "p") | |
eec82323 LMI |
8227 | (gnus-summary-mark-forward n gnus-dormant-mark)) |
8228 | ||
8229 | (defun gnus-summary-set-process-mark (article) | |
8230 | "Set the process mark on ARTICLE and update the summary line." | |
8231 | (setq gnus-newsgroup-processable | |
8232 | (cons article | |
8233 | (delq article gnus-newsgroup-processable))) | |
8234 | (when (gnus-summary-goto-subject article) | |
8235 | (gnus-summary-show-thread) | |
6748645f | 8236 | (gnus-summary-goto-subject article) |
eec82323 LMI |
8237 | (gnus-summary-update-secondary-mark article))) |
8238 | ||
8239 | (defun gnus-summary-remove-process-mark (article) | |
8240 | "Remove the process mark from ARTICLE and update the summary line." | |
8241 | (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable)) | |
8242 | (when (gnus-summary-goto-subject article) | |
8243 | (gnus-summary-show-thread) | |
6748645f | 8244 | (gnus-summary-goto-subject article) |
eec82323 LMI |
8245 | (gnus-summary-update-secondary-mark article))) |
8246 | ||
8247 | (defun gnus-summary-set-saved-mark (article) | |
8248 | "Set the process mark on ARTICLE and update the summary line." | |
8249 | (push article gnus-newsgroup-saved) | |
8250 | (when (gnus-summary-goto-subject article) | |
8251 | (gnus-summary-update-secondary-mark article))) | |
8252 | ||
8253 | (defun gnus-summary-mark-forward (n &optional mark no-expire) | |
8254 | "Mark N articles as read forwards. | |
8255 | If N is negative, mark backwards instead. Mark with MARK, ?r by default. | |
8256 | The difference between N and the actual number of articles marked is | |
16409b0b GM |
8257 | returned. |
8258 | Iff NO-EXPIRE, auto-expiry will be inhibited." | |
eec82323 | 8259 | (interactive "p") |
16409b0b | 8260 | (gnus-summary-show-thread) |
eec82323 LMI |
8261 | (let ((backward (< n 0)) |
8262 | (gnus-summary-goto-unread | |
8263 | (and gnus-summary-goto-unread | |
8264 | (not (eq gnus-summary-goto-unread 'never)) | |
8265 | (not (memq mark (list gnus-unread-mark | |
8266 | gnus-ticked-mark gnus-dormant-mark))))) | |
8267 | (n (abs n)) | |
8268 | (mark (or mark gnus-del-mark))) | |
8269 | (while (and (> n 0) | |
8270 | (gnus-summary-mark-article nil mark no-expire) | |
8271 | (zerop (gnus-summary-next-subject | |
8272 | (if backward -1 1) | |
8273 | (and gnus-summary-goto-unread | |
8274 | (not (eq gnus-summary-goto-unread 'never))) | |
8275 | t))) | |
8276 | (setq n (1- n))) | |
8277 | (when (/= 0 n) | |
8278 | (gnus-message 7 "No more %sarticles" (if mark "" "unread "))) | |
8279 | (gnus-summary-recenter) | |
8280 | (gnus-summary-position-point) | |
8281 | (gnus-set-mode-line 'summary) | |
8282 | n)) | |
8283 | ||
8284 | (defun gnus-summary-mark-article-as-read (mark) | |
8285 | "Mark the current article quickly as read with MARK." | |
8286 | (let ((article (gnus-summary-article-number))) | |
8287 | (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads)) | |
8288 | (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)) | |
8289 | (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)) | |
8290 | (push (cons article mark) gnus-newsgroup-reads) | |
8291 | ;; Possibly remove from cache, if that is used. | |
8292 | (when gnus-use-cache | |
8293 | (gnus-cache-enter-remove-article article)) | |
8294 | ;; Allow the backend to change the mark. | |
8295 | (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark)) | |
8296 | ;; Check for auto-expiry. | |
8297 | (when (and gnus-newsgroup-auto-expire | |
16409b0b | 8298 | (memq mark gnus-auto-expirable-marks)) |
eec82323 | 8299 | (setq mark gnus-expirable-mark) |
6748645f LMI |
8300 | ;; Let the backend know about the mark change. |
8301 | (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark)) | |
eec82323 LMI |
8302 | (push article gnus-newsgroup-expirable)) |
8303 | ;; Set the mark in the buffer. | |
8304 | (gnus-summary-update-mark mark 'unread) | |
8305 | t)) | |
8306 | ||
8307 | (defun gnus-summary-mark-article-as-unread (mark) | |
8308 | "Mark the current article quickly as unread with MARK." | |
6748645f LMI |
8309 | (let* ((article (gnus-summary-article-number)) |
8310 | (old-mark (gnus-summary-article-mark article))) | |
8311 | ;; Allow the backend to change the mark. | |
8312 | (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark)) | |
8313 | (if (eq mark old-mark) | |
8314 | t | |
8315 | (if (<= article 0) | |
8316 | (progn | |
8317 | (gnus-error 1 "Can't mark negative article numbers") | |
8318 | nil) | |
8319 | (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)) | |
8320 | (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)) | |
8321 | (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)) | |
8322 | (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads)) | |
8323 | (cond ((= mark gnus-ticked-mark) | |
8324 | (push article gnus-newsgroup-marked)) | |
8325 | ((= mark gnus-dormant-mark) | |
8326 | (push article gnus-newsgroup-dormant)) | |
8327 | (t | |
8328 | (push article gnus-newsgroup-unreads))) | |
8329 | (gnus-pull article gnus-newsgroup-reads) | |
eec82323 | 8330 | |
6748645f LMI |
8331 | ;; See whether the article is to be put in the cache. |
8332 | (and gnus-use-cache | |
8333 | (vectorp (gnus-summary-article-header article)) | |
8334 | (save-excursion | |
8335 | (gnus-cache-possibly-enter-article | |
8336 | gnus-newsgroup-name article | |
6748645f LMI |
8337 | (= mark gnus-ticked-mark) |
8338 | (= mark gnus-dormant-mark) (= mark gnus-unread-mark)))) | |
8339 | ||
8340 | ;; Fix the mark. | |
8341 | (gnus-summary-update-mark mark 'unread) | |
8342 | t)))) | |
eec82323 LMI |
8343 | |
8344 | (defun gnus-summary-mark-article (&optional article mark no-expire) | |
8345 | "Mark ARTICLE with MARK. MARK can be any character. | |
8346 | Four MARK strings are reserved: `? ' (unread), `?!' (ticked), | |
8347 | `??' (dormant) and `?E' (expirable). | |
16409b0b | 8348 | If MARK is nil, then the default character `?r' is used. |
eec82323 | 8349 | If ARTICLE is nil, then the article on the current line will be |
16409b0b GM |
8350 | marked. |
8351 | Iff NO-EXPIRE, auto-expiry will be inhibited." | |
eec82323 LMI |
8352 | ;; The mark might be a string. |
8353 | (when (stringp mark) | |
8354 | (setq mark (aref mark 0))) | |
8355 | ;; If no mark is given, then we check auto-expiring. | |
16409b0b GM |
8356 | (when (null mark) |
8357 | (setq mark gnus-del-mark)) | |
8358 | (when (and (not no-expire) | |
8359 | gnus-newsgroup-auto-expire | |
8360 | (memq mark gnus-auto-expirable-marks)) | |
8361 | (setq mark gnus-expirable-mark)) | |
8362 | (let ((article (or article (gnus-summary-article-number))) | |
8363 | (old-mark (gnus-summary-article-mark article))) | |
6748645f LMI |
8364 | ;; Allow the backend to change the mark. |
8365 | (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark)) | |
8366 | (if (eq mark old-mark) | |
8367 | t | |
8368 | (unless article | |
8369 | (error "No article on current line")) | |
8370 | (if (not (if (or (= mark gnus-unread-mark) | |
8371 | (= mark gnus-ticked-mark) | |
8372 | (= mark gnus-dormant-mark)) | |
8373 | (gnus-mark-article-as-unread article mark) | |
8374 | (gnus-mark-article-as-read article mark))) | |
8375 | t | |
8376 | ;; See whether the article is to be put in the cache. | |
8377 | (and gnus-use-cache | |
8378 | (not (= mark gnus-canceled-mark)) | |
8379 | (vectorp (gnus-summary-article-header article)) | |
8380 | (save-excursion | |
8381 | (gnus-cache-possibly-enter-article | |
8382 | gnus-newsgroup-name article | |
6748645f LMI |
8383 | (= mark gnus-ticked-mark) |
8384 | (= mark gnus-dormant-mark) (= mark gnus-unread-mark)))) | |
8385 | ||
8386 | (when (gnus-summary-goto-subject article nil t) | |
8387 | (let ((buffer-read-only nil)) | |
8388 | (gnus-summary-show-thread) | |
8389 | ;; Fix the mark. | |
8390 | (gnus-summary-update-mark mark 'unread) | |
8391 | t)))))) | |
eec82323 LMI |
8392 | |
8393 | (defun gnus-summary-update-secondary-mark (article) | |
8394 | "Update the secondary (read, process, cache) mark." | |
8395 | (gnus-summary-update-mark | |
8396 | (cond ((memq article gnus-newsgroup-processable) | |
8397 | gnus-process-mark) | |
8398 | ((memq article gnus-newsgroup-cached) | |
8399 | gnus-cached-mark) | |
8400 | ((memq article gnus-newsgroup-replied) | |
8401 | gnus-replied-mark) | |
8402 | ((memq article gnus-newsgroup-saved) | |
8403 | gnus-saved-mark) | |
8404 | (t gnus-unread-mark)) | |
8405 | 'replied) | |
8406 | (when (gnus-visual-p 'summary-highlight 'highlight) | |
6748645f | 8407 | (gnus-run-hooks 'gnus-summary-update-hook)) |
eec82323 LMI |
8408 | t) |
8409 | ||
8410 | (defun gnus-summary-update-mark (mark type) | |
8411 | (let ((forward (cdr (assq type gnus-summary-mark-positions))) | |
8412 | (buffer-read-only nil)) | |
8413 | (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit) | |
16409b0b GM |
8414 | (when forward |
8415 | (when (looking-at "\r") | |
8416 | (incf forward)) | |
8417 | (when (<= (+ forward (point)) (point-max)) | |
8418 | ;; Go to the right position on the line. | |
8419 | (goto-char (+ forward (point))) | |
8420 | ;; Replace the old mark with the new mark. | |
8421 | (subst-char-in-region (point) (1+ (point)) (char-after) mark) | |
8422 | ;; Optionally update the marks by some user rule. | |
8423 | (when (eq type 'unread) | |
8424 | (gnus-data-set-mark | |
8425 | (gnus-data-find (gnus-summary-article-number)) mark) | |
8426 | (gnus-summary-update-line (eq mark gnus-unread-mark))))))) | |
eec82323 LMI |
8427 | |
8428 | (defun gnus-mark-article-as-read (article &optional mark) | |
8429 | "Enter ARTICLE in the pertinent lists and remove it from others." | |
8430 | ;; Make the article expirable. | |
8431 | (let ((mark (or mark gnus-del-mark))) | |
8432 | (if (= mark gnus-expirable-mark) | |
8433 | (push article gnus-newsgroup-expirable) | |
8434 | (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))) | |
8435 | ;; Remove from unread and marked lists. | |
8436 | (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads)) | |
8437 | (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)) | |
8438 | (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)) | |
8439 | (push (cons article mark) gnus-newsgroup-reads) | |
8440 | ;; Possibly remove from cache, if that is used. | |
8441 | (when gnus-use-cache | |
6748645f LMI |
8442 | (gnus-cache-enter-remove-article article)) |
8443 | t)) | |
eec82323 LMI |
8444 | |
8445 | (defun gnus-mark-article-as-unread (article &optional mark) | |
8446 | "Enter ARTICLE in the pertinent lists and remove it from others." | |
8447 | (let ((mark (or mark gnus-ticked-mark))) | |
6748645f LMI |
8448 | (if (<= article 0) |
8449 | (progn | |
8450 | (gnus-error 1 "Can't mark negative article numbers") | |
8451 | nil) | |
8452 | (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked) | |
8453 | gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant) | |
8454 | gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable) | |
8455 | gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads)) | |
eec82323 | 8456 | |
6748645f LMI |
8457 | ;; Unsuppress duplicates? |
8458 | (when gnus-suppress-duplicates | |
8459 | (gnus-dup-unsuppress-article article)) | |
8460 | ||
8461 | (cond ((= mark gnus-ticked-mark) | |
8462 | (push article gnus-newsgroup-marked)) | |
8463 | ((= mark gnus-dormant-mark) | |
8464 | (push article gnus-newsgroup-dormant)) | |
8465 | (t | |
8466 | (push article gnus-newsgroup-unreads))) | |
8467 | (gnus-pull article gnus-newsgroup-reads) | |
8468 | t))) | |
eec82323 LMI |
8469 | |
8470 | (defalias 'gnus-summary-mark-as-unread-forward | |
8471 | 'gnus-summary-tick-article-forward) | |
8472 | (make-obsolete 'gnus-summary-mark-as-unread-forward | |
8473 | 'gnus-summary-tick-article-forward) | |
8474 | (defun gnus-summary-tick-article-forward (n) | |
8475 | "Tick N articles forwards. | |
8476 | If N is negative, tick backwards instead. | |
8477 | The difference between N and the number of articles ticked is returned." | |
8478 | (interactive "p") | |
8479 | (gnus-summary-mark-forward n gnus-ticked-mark)) | |
8480 | ||
8481 | (defalias 'gnus-summary-mark-as-unread-backward | |
8482 | 'gnus-summary-tick-article-backward) | |
8483 | (make-obsolete 'gnus-summary-mark-as-unread-backward | |
8484 | 'gnus-summary-tick-article-backward) | |
8485 | (defun gnus-summary-tick-article-backward (n) | |
8486 | "Tick N articles backwards. | |
8487 | The difference between N and the number of articles ticked is returned." | |
8488 | (interactive "p") | |
8489 | (gnus-summary-mark-forward (- n) gnus-ticked-mark)) | |
8490 | ||
8491 | (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article) | |
8492 | (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article) | |
8493 | (defun gnus-summary-tick-article (&optional article clear-mark) | |
8494 | "Mark current article as unread. | |
8495 | Optional 1st argument ARTICLE specifies article number to be marked as unread. | |
8496 | Optional 2nd argument CLEAR-MARK remove any kinds of mark." | |
8497 | (interactive) | |
8498 | (gnus-summary-mark-article article (if clear-mark gnus-unread-mark | |
8499 | gnus-ticked-mark))) | |
8500 | ||
8501 | (defun gnus-summary-mark-as-read-forward (n) | |
8502 | "Mark N articles as read forwards. | |
8503 | If N is negative, mark backwards instead. | |
8504 | The difference between N and the actual number of articles marked is | |
8505 | returned." | |
8506 | (interactive "p") | |
16409b0b | 8507 | (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire)) |
eec82323 LMI |
8508 | |
8509 | (defun gnus-summary-mark-as-read-backward (n) | |
8510 | "Mark the N articles as read backwards. | |
8511 | The difference between N and the actual number of articles marked is | |
8512 | returned." | |
8513 | (interactive "p") | |
16409b0b GM |
8514 | (gnus-summary-mark-forward |
8515 | (- n) gnus-del-mark gnus-inhibit-user-auto-expire)) | |
eec82323 LMI |
8516 | |
8517 | (defun gnus-summary-mark-as-read (&optional article mark) | |
8518 | "Mark current article as read. | |
8519 | ARTICLE specifies the article to be marked as read. | |
8520 | MARK specifies a string to be inserted at the beginning of the line." | |
8521 | (gnus-summary-mark-article article mark)) | |
8522 | ||
8523 | (defun gnus-summary-clear-mark-forward (n) | |
8524 | "Clear marks from N articles forward. | |
8525 | If N is negative, clear backward instead. | |
8526 | The difference between N and the number of marks cleared is returned." | |
8527 | (interactive "p") | |
8528 | (gnus-summary-mark-forward n gnus-unread-mark)) | |
8529 | ||
8530 | (defun gnus-summary-clear-mark-backward (n) | |
8531 | "Clear marks from N articles backward. | |
8532 | The difference between N and the number of marks cleared is returned." | |
8533 | (interactive "p") | |
8534 | (gnus-summary-mark-forward (- n) gnus-unread-mark)) | |
8535 | ||
8536 | (defun gnus-summary-mark-unread-as-read () | |
8537 | "Intended to be used by `gnus-summary-mark-article-hook'." | |
8538 | (when (memq gnus-current-article gnus-newsgroup-unreads) | |
8539 | (gnus-summary-mark-article gnus-current-article gnus-read-mark))) | |
8540 | ||
8541 | (defun gnus-summary-mark-read-and-unread-as-read () | |
8542 | "Intended to be used by `gnus-summary-mark-article-hook'." | |
8543 | (let ((mark (gnus-summary-article-mark))) | |
8544 | (when (or (gnus-unread-mark-p mark) | |
8545 | (gnus-read-mark-p mark)) | |
8546 | (gnus-summary-mark-article gnus-current-article gnus-read-mark)))) | |
8547 | ||
8548 | (defun gnus-summary-mark-region-as-read (point mark all) | |
8549 | "Mark all unread articles between point and mark as read. | |
8550 | If given a prefix, mark all articles between point and mark as read, | |
8551 | even ticked and dormant ones." | |
8552 | (interactive "r\nP") | |
8553 | (save-excursion | |
8554 | (let (article) | |
8555 | (goto-char point) | |
8556 | (beginning-of-line) | |
8557 | (while (and | |
8558 | (< (point) mark) | |
8559 | (progn | |
8560 | (when (or all | |
8561 | (memq (setq article (gnus-summary-article-number)) | |
8562 | gnus-newsgroup-unreads)) | |
8563 | (gnus-summary-mark-article article gnus-del-mark)) | |
8564 | t) | |
8565 | (gnus-summary-find-next)))))) | |
8566 | ||
8567 | (defun gnus-summary-mark-below (score mark) | |
8568 | "Mark articles with score less than SCORE with MARK." | |
8569 | (interactive "P\ncMark: ") | |
eec82323 LMI |
8570 | (setq score (if score |
8571 | (prefix-numeric-value score) | |
8572 | (or gnus-summary-default-score 0))) | |
8573 | (save-excursion | |
8574 | (set-buffer gnus-summary-buffer) | |
8575 | (goto-char (point-min)) | |
8576 | (while | |
8577 | (progn | |
8578 | (and (< (gnus-summary-article-score) score) | |
8579 | (gnus-summary-mark-article nil mark)) | |
8580 | (gnus-summary-find-next))))) | |
8581 | ||
8582 | (defun gnus-summary-kill-below (&optional score) | |
8583 | "Mark articles with score below SCORE as read." | |
8584 | (interactive "P") | |
eec82323 LMI |
8585 | (gnus-summary-mark-below score gnus-killed-mark)) |
8586 | ||
8587 | (defun gnus-summary-clear-above (&optional score) | |
8588 | "Clear all marks from articles with score above SCORE." | |
8589 | (interactive "P") | |
eec82323 LMI |
8590 | (gnus-summary-mark-above score gnus-unread-mark)) |
8591 | ||
8592 | (defun gnus-summary-tick-above (&optional score) | |
8593 | "Tick all articles with score above SCORE." | |
8594 | (interactive "P") | |
eec82323 LMI |
8595 | (gnus-summary-mark-above score gnus-ticked-mark)) |
8596 | ||
8597 | (defun gnus-summary-mark-above (score mark) | |
8598 | "Mark articles with score over SCORE with MARK." | |
8599 | (interactive "P\ncMark: ") | |
eec82323 LMI |
8600 | (setq score (if score |
8601 | (prefix-numeric-value score) | |
8602 | (or gnus-summary-default-score 0))) | |
8603 | (save-excursion | |
8604 | (set-buffer gnus-summary-buffer) | |
8605 | (goto-char (point-min)) | |
8606 | (while (and (progn | |
8607 | (when (> (gnus-summary-article-score) score) | |
8608 | (gnus-summary-mark-article nil mark)) | |
8609 | t) | |
8610 | (gnus-summary-find-next))))) | |
8611 | ||
8612 | ;; Suggested by Daniel Quinlan <quinlan@best.com>. | |
8613 | (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged) | |
8614 | (defun gnus-summary-limit-include-expunged (&optional no-error) | |
8615 | "Display all the hidden articles that were expunged for low scores." | |
8616 | (interactive) | |
eec82323 LMI |
8617 | (let ((buffer-read-only nil)) |
8618 | (let ((scored gnus-newsgroup-scored) | |
8619 | headers h) | |
8620 | (while scored | |
8621 | (unless (gnus-summary-goto-subject (caar scored)) | |
8622 | (and (setq h (gnus-summary-article-header (caar scored))) | |
8623 | (< (cdar scored) gnus-summary-expunge-below) | |
8624 | (push h headers))) | |
8625 | (setq scored (cdr scored))) | |
8626 | (if (not headers) | |
8627 | (when (not no-error) | |
a8151ef7 | 8628 | (error "No expunged articles hidden")) |
eec82323 LMI |
8629 | (goto-char (point-min)) |
8630 | (gnus-summary-prepare-unthreaded (nreverse headers)) | |
8631 | (goto-char (point-min)) | |
8632 | (gnus-summary-position-point) | |
8633 | t)))) | |
8634 | ||
8635 | (defun gnus-summary-catchup (&optional all quietly to-here not-mark) | |
8636 | "Mark all unread articles in this newsgroup as read. | |
8637 | If prefix argument ALL is non-nil, ticked and dormant articles will | |
8638 | also be marked as read. | |
8639 | If QUIETLY is non-nil, no questions will be asked. | |
8640 | If TO-HERE is non-nil, it should be a point in the buffer. All | |
8641 | articles before this point will be marked as read. | |
8642 | Note that this function will only catch up the unread article | |
8643 | in the current summary buffer limitation. | |
8644 | The number of articles marked as read is returned." | |
8645 | (interactive "P") | |
eec82323 LMI |
8646 | (prog1 |
8647 | (save-excursion | |
8648 | (when (or quietly | |
8649 | (not gnus-interactive-catchup) ;Without confirmation? | |
8650 | gnus-expert-user | |
8651 | (gnus-y-or-n-p | |
8652 | (if all | |
8653 | "Mark absolutely all articles as read? " | |
8654 | "Mark all unread articles as read? "))) | |
8655 | (if (and not-mark | |
8656 | (not gnus-newsgroup-adaptive) | |
8657 | (not gnus-newsgroup-auto-expire) | |
a8151ef7 LMI |
8658 | (not gnus-suppress-duplicates) |
8659 | (or (not gnus-use-cache) | |
6748645f | 8660 | (eq gnus-use-cache 'passive))) |
eec82323 LMI |
8661 | (progn |
8662 | (when all | |
8663 | (setq gnus-newsgroup-marked nil | |
8664 | gnus-newsgroup-dormant nil)) | |
6748645f | 8665 | (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable)) |
eec82323 LMI |
8666 | ;; We actually mark all articles as canceled, which we |
8667 | ;; have to do when using auto-expiry or adaptive scoring. | |
8668 | (gnus-summary-show-all-threads) | |
6748645f | 8669 | (when (gnus-summary-first-subject (not all) t) |
eec82323 LMI |
8670 | (while (and |
8671 | (if to-here (< (point) to-here) t) | |
8672 | (gnus-summary-mark-article-as-read gnus-catchup-mark) | |
6748645f | 8673 | (gnus-summary-find-next (not all) nil nil t)))) |
eec82323 LMI |
8674 | (gnus-set-mode-line 'summary)) |
8675 | t)) | |
8676 | (gnus-summary-position-point))) | |
8677 | ||
8678 | (defun gnus-summary-catchup-to-here (&optional all) | |
8679 | "Mark all unticked articles before the current one as read. | |
8680 | If ALL is non-nil, also mark ticked and dormant articles as read." | |
8681 | (interactive "P") | |
eec82323 LMI |
8682 | (save-excursion |
8683 | (gnus-save-hidden-threads | |
8684 | (let ((beg (point))) | |
8685 | ;; We check that there are unread articles. | |
8686 | (when (or all (gnus-summary-find-prev)) | |
8687 | (gnus-summary-catchup all t beg))))) | |
8688 | (gnus-summary-position-point)) | |
8689 | ||
8690 | (defun gnus-summary-catchup-all (&optional quietly) | |
8691 | "Mark all articles in this newsgroup as read." | |
8692 | (interactive "P") | |
eec82323 LMI |
8693 | (gnus-summary-catchup t quietly)) |
8694 | ||
8695 | (defun gnus-summary-catchup-and-exit (&optional all quietly) | |
16409b0b | 8696 | "Mark all unread articles in this group as read, then exit. |
eec82323 LMI |
8697 | If prefix argument ALL is non-nil, all articles are marked as read." |
8698 | (interactive "P") | |
eec82323 LMI |
8699 | (when (gnus-summary-catchup all quietly nil 'fast) |
8700 | ;; Select next newsgroup or exit. | |
6748645f LMI |
8701 | (if (and (not (gnus-group-quit-config gnus-newsgroup-name)) |
8702 | (eq gnus-auto-select-next 'quietly)) | |
eec82323 LMI |
8703 | (gnus-summary-next-group nil) |
8704 | (gnus-summary-exit)))) | |
8705 | ||
8706 | (defun gnus-summary-catchup-all-and-exit (&optional quietly) | |
8707 | "Mark all articles in this newsgroup as read, and then exit." | |
8708 | (interactive "P") | |
eec82323 LMI |
8709 | (gnus-summary-catchup-and-exit t quietly)) |
8710 | ||
eec82323 LMI |
8711 | (defun gnus-summary-catchup-and-goto-next-group (&optional all) |
8712 | "Mark all articles in this group as read and select the next group. | |
8713 | If given a prefix, mark all articles, unread as well as ticked, as | |
8714 | read." | |
8715 | (interactive "P") | |
eec82323 LMI |
8716 | (save-excursion |
8717 | (gnus-summary-catchup all)) | |
16409b0b GM |
8718 | (gnus-summary-next-group)) |
8719 | ||
8720 | ;;; | |
8721 | ;;; with article | |
8722 | ;;; | |
8723 | ||
8724 | (defmacro gnus-with-article (article &rest forms) | |
8725 | "Select ARTICLE and perform FORMS in the original article buffer. | |
8726 | Then replace the article with the result." | |
8727 | `(progn | |
8728 | ;; We don't want the article to be marked as read. | |
8729 | (let (gnus-mark-article-hook) | |
8730 | (gnus-summary-select-article t t nil ,article)) | |
8731 | (set-buffer gnus-original-article-buffer) | |
8732 | ,@forms | |
8733 | (if (not (gnus-check-backend-function | |
8734 | 'request-replace-article (car gnus-article-current))) | |
8735 | (gnus-message 5 "Read-only group; not replacing") | |
8736 | (unless (gnus-request-replace-article | |
8737 | ,article (car gnus-article-current) | |
8738 | (current-buffer) t) | |
8739 | (error "Couldn't replace article"))) | |
8740 | ;; The cache and backlog have to be flushed somewhat. | |
8741 | (when gnus-keep-backlog | |
8742 | (gnus-backlog-remove-article | |
8743 | (car gnus-article-current) (cdr gnus-article-current))) | |
8744 | (when gnus-use-cache | |
8745 | (gnus-cache-update-article | |
8746 | (car gnus-article-current) (cdr gnus-article-current))))) | |
8747 | ||
8748 | (put 'gnus-with-article 'lisp-indent-function 1) | |
8749 | (put 'gnus-with-article 'edebug-form-spec '(form body)) | |
eec82323 LMI |
8750 | |
8751 | ;; Thread-based commands. | |
8752 | ||
8753 | (defun gnus-summary-articles-in-thread (&optional article) | |
8754 | "Return a list of all articles in the current thread. | |
8755 | If ARTICLE is non-nil, return all articles in the thread that starts | |
8756 | with that article." | |
8757 | (let* ((article (or article (gnus-summary-article-number))) | |
8758 | (data (gnus-data-find-list article)) | |
8759 | (top-level (gnus-data-level (car data))) | |
8760 | (top-subject | |
8761 | (cond ((null gnus-thread-operation-ignore-subject) | |
8762 | (gnus-simplify-subject-re | |
8763 | (mail-header-subject (gnus-data-header (car data))))) | |
8764 | ((eq gnus-thread-operation-ignore-subject 'fuzzy) | |
8765 | (gnus-simplify-subject-fuzzy | |
8766 | (mail-header-subject (gnus-data-header (car data))))) | |
8767 | (t nil))) | |
8768 | (end-point (save-excursion | |
8769 | (if (gnus-summary-go-to-next-thread) | |
8770 | (point) (point-max)))) | |
8771 | articles) | |
8772 | (while (and data | |
8773 | (< (gnus-data-pos (car data)) end-point)) | |
8774 | (when (or (not top-subject) | |
8775 | (string= top-subject | |
8776 | (if (eq gnus-thread-operation-ignore-subject 'fuzzy) | |
8777 | (gnus-simplify-subject-fuzzy | |
8778 | (mail-header-subject | |
8779 | (gnus-data-header (car data)))) | |
8780 | (gnus-simplify-subject-re | |
8781 | (mail-header-subject | |
8782 | (gnus-data-header (car data))))))) | |
8783 | (push (gnus-data-number (car data)) articles)) | |
8784 | (unless (and (setq data (cdr data)) | |
8785 | (> (gnus-data-level (car data)) top-level)) | |
8786 | (setq data nil))) | |
8787 | ;; Return the list of articles. | |
8788 | (nreverse articles))) | |
8789 | ||
8790 | (defun gnus-summary-rethread-current () | |
8791 | "Rethread the thread the current article is part of." | |
8792 | (interactive) | |
eec82323 LMI |
8793 | (let* ((gnus-show-threads t) |
8794 | (article (gnus-summary-article-number)) | |
8795 | (id (mail-header-id (gnus-summary-article-header))) | |
8796 | (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id))))) | |
8797 | (unless id | |
8798 | (error "No article on the current line")) | |
8799 | (gnus-rebuild-thread id) | |
8800 | (gnus-summary-goto-subject article))) | |
8801 | ||
8802 | (defun gnus-summary-reparent-thread () | |
8803 | "Make the current article child of the marked (or previous) article. | |
8804 | ||
8805 | Note that the re-threading will only work if `gnus-thread-ignore-subject' | |
8806 | is non-nil or the Subject: of both articles are the same." | |
8807 | (interactive) | |
8808 | (unless (not (gnus-group-read-only-p)) | |
a8151ef7 | 8809 | (error "The current newsgroup does not support article editing")) |
eec82323 | 8810 | (unless (<= (length gnus-newsgroup-processable) 1) |
a8151ef7 | 8811 | (error "No more than one article may be marked")) |
eec82323 LMI |
8812 | (save-window-excursion |
8813 | (let ((gnus-article-buffer " *reparent*") | |
8814 | (current-article (gnus-summary-article-number)) | |
8815 | ;; First grab the marked article, otherwise one line up. | |
8816 | (parent-article (if (not (null gnus-newsgroup-processable)) | |
8817 | (car gnus-newsgroup-processable) | |
8818 | (save-excursion | |
8819 | (if (eq (forward-line -1) 0) | |
8820 | (gnus-summary-article-number) | |
a8151ef7 | 8821 | (error "Beginning of summary buffer")))))) |
eec82323 | 8822 | (unless (not (eq current-article parent-article)) |
a8151ef7 | 8823 | (error "An article may not be self-referential")) |
eec82323 LMI |
8824 | (let ((message-id (mail-header-id |
8825 | (gnus-summary-article-header parent-article)))) | |
8826 | (unless (and message-id (not (equal message-id ""))) | |
a8151ef7 | 8827 | (error "No message-id in desired parent")) |
16409b0b GM |
8828 | (gnus-with-article current-article |
8829 | (save-restriction | |
eec82323 | 8830 | (goto-char (point-min)) |
16409b0b | 8831 | (message-narrow-to-head) |
6748645f LMI |
8832 | (if (re-search-forward "^References: " nil t) |
8833 | (progn | |
8834 | (re-search-forward "^[^ \t]" nil t) | |
8835 | (forward-line -1) | |
8836 | (end-of-line) | |
8837 | (insert " " message-id)) | |
16409b0b | 8838 | (insert "References: " message-id "\n")))) |
eec82323 LMI |
8839 | (set-buffer gnus-summary-buffer) |
8840 | (gnus-summary-unmark-all-processable) | |
6748645f | 8841 | (gnus-summary-update-article current-article) |
eec82323 | 8842 | (gnus-summary-rethread-current) |
a8151ef7 | 8843 | (gnus-message 3 "Article %d is now the child of article %d" |
eec82323 LMI |
8844 | current-article parent-article))))) |
8845 | ||
8846 | (defun gnus-summary-toggle-threads (&optional arg) | |
8847 | "Toggle showing conversation threads. | |
8848 | If ARG is positive number, turn showing conversation threads on." | |
8849 | (interactive "P") | |
eec82323 LMI |
8850 | (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end))) |
8851 | (setq gnus-show-threads | |
8852 | (if (null arg) (not gnus-show-threads) | |
8853 | (> (prefix-numeric-value arg) 0))) | |
8854 | (gnus-summary-prepare) | |
8855 | (gnus-summary-goto-subject current) | |
8856 | (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off")) | |
8857 | (gnus-summary-position-point))) | |
8858 | ||
8859 | (defun gnus-summary-show-all-threads () | |
8860 | "Show all threads." | |
8861 | (interactive) | |
eec82323 LMI |
8862 | (save-excursion |
8863 | (let ((buffer-read-only nil)) | |
8864 | (subst-char-in-region (point-min) (point-max) ?\^M ?\n t))) | |
8865 | (gnus-summary-position-point)) | |
8866 | ||
8867 | (defun gnus-summary-show-thread () | |
8868 | "Show thread subtrees. | |
8869 | Returns nil if no thread was there to be shown." | |
8870 | (interactive) | |
eec82323 LMI |
8871 | (let ((buffer-read-only nil) |
8872 | (orig (point)) | |
8873 | ;; first goto end then to beg, to have point at beg after let | |
8874 | (end (progn (end-of-line) (point))) | |
8875 | (beg (progn (beginning-of-line) (point)))) | |
8876 | (prog1 | |
8877 | ;; Any hidden lines here? | |
8878 | (search-forward "\r" end t) | |
8879 | (subst-char-in-region beg end ?\^M ?\n t) | |
8880 | (goto-char orig) | |
8881 | (gnus-summary-position-point)))) | |
8882 | ||
8883 | (defun gnus-summary-hide-all-threads () | |
8884 | "Hide all thread subtrees." | |
8885 | (interactive) | |
eec82323 LMI |
8886 | (save-excursion |
8887 | (goto-char (point-min)) | |
8888 | (gnus-summary-hide-thread) | |
8889 | (while (zerop (gnus-summary-next-thread 1 t)) | |
8890 | (gnus-summary-hide-thread))) | |
8891 | (gnus-summary-position-point)) | |
8892 | ||
8893 | (defun gnus-summary-hide-thread () | |
8894 | "Hide thread subtrees. | |
8895 | Returns nil if no threads were there to be hidden." | |
8896 | (interactive) | |
eec82323 LMI |
8897 | (let ((buffer-read-only nil) |
8898 | (start (point)) | |
8899 | (article (gnus-summary-article-number))) | |
8900 | (goto-char start) | |
8901 | ;; Go forward until either the buffer ends or the subthread | |
8902 | ;; ends. | |
8903 | (when (and (not (eobp)) | |
8904 | (or (zerop (gnus-summary-next-thread 1 t)) | |
8905 | (goto-char (point-max)))) | |
8906 | (prog1 | |
8907 | (if (and (> (point) start) | |
8908 | (search-backward "\n" start t)) | |
8909 | (progn | |
8910 | (subst-char-in-region start (point) ?\n ?\^M) | |
8911 | (gnus-summary-goto-subject article)) | |
8912 | (goto-char start) | |
16409b0b | 8913 | nil))))) |
eec82323 LMI |
8914 | |
8915 | (defun gnus-summary-go-to-next-thread (&optional previous) | |
8916 | "Go to the same level (or less) next thread. | |
8917 | If PREVIOUS is non-nil, go to previous thread instead. | |
8918 | Return the article number moved to, or nil if moving was impossible." | |
8919 | (let ((level (gnus-summary-thread-level)) | |
8920 | (way (if previous -1 1)) | |
8921 | (beg (point))) | |
8922 | (forward-line way) | |
8923 | (while (and (not (eobp)) | |
8924 | (< level (gnus-summary-thread-level))) | |
8925 | (forward-line way)) | |
8926 | (if (eobp) | |
8927 | (progn | |
8928 | (goto-char beg) | |
8929 | nil) | |
8930 | (setq beg (point)) | |
8931 | (prog1 | |
8932 | (gnus-summary-article-number) | |
8933 | (goto-char beg))))) | |
8934 | ||
8935 | (defun gnus-summary-next-thread (n &optional silent) | |
8936 | "Go to the same level next N'th thread. | |
8937 | If N is negative, search backward instead. | |
8938 | Returns the difference between N and the number of skips actually | |
8939 | done. | |
8940 | ||
8941 | If SILENT, don't output messages." | |
8942 | (interactive "p") | |
eec82323 LMI |
8943 | (let ((backward (< n 0)) |
8944 | (n (abs n))) | |
8945 | (while (and (> n 0) | |
8946 | (gnus-summary-go-to-next-thread backward)) | |
8947 | (decf n)) | |
8948 | (unless silent | |
8949 | (gnus-summary-position-point)) | |
8950 | (when (and (not silent) (/= 0 n)) | |
8951 | (gnus-message 7 "No more threads")) | |
8952 | n)) | |
8953 | ||
8954 | (defun gnus-summary-prev-thread (n) | |
8955 | "Go to the same level previous N'th thread. | |
8956 | Returns the difference between N and the number of skips actually | |
8957 | done." | |
8958 | (interactive "p") | |
eec82323 LMI |
8959 | (gnus-summary-next-thread (- n))) |
8960 | ||
8961 | (defun gnus-summary-go-down-thread () | |
8962 | "Go down one level in the current thread." | |
8963 | (let ((children (gnus-summary-article-children))) | |
8964 | (when children | |
8965 | (gnus-summary-goto-subject (car children))))) | |
8966 | ||
8967 | (defun gnus-summary-go-up-thread () | |
8968 | "Go up one level in the current thread." | |
8969 | (let ((parent (gnus-summary-article-parent))) | |
8970 | (when parent | |
8971 | (gnus-summary-goto-subject parent)))) | |
8972 | ||
8973 | (defun gnus-summary-down-thread (n) | |
8974 | "Go down thread N steps. | |
8975 | If N is negative, go up instead. | |
8976 | Returns the difference between N and how many steps down that were | |
8977 | taken." | |
8978 | (interactive "p") | |
eec82323 LMI |
8979 | (let ((up (< n 0)) |
8980 | (n (abs n))) | |
8981 | (while (and (> n 0) | |
8982 | (if up (gnus-summary-go-up-thread) | |
8983 | (gnus-summary-go-down-thread))) | |
8984 | (setq n (1- n))) | |
8985 | (gnus-summary-position-point) | |
8986 | (when (/= 0 n) | |
8987 | (gnus-message 7 "Can't go further")) | |
8988 | n)) | |
8989 | ||
8990 | (defun gnus-summary-up-thread (n) | |
8991 | "Go up thread N steps. | |
8992 | If N is negative, go up instead. | |
8993 | Returns the difference between N and how many steps down that were | |
8994 | taken." | |
8995 | (interactive "p") | |
eec82323 LMI |
8996 | (gnus-summary-down-thread (- n))) |
8997 | ||
8998 | (defun gnus-summary-top-thread () | |
8999 | "Go to the top of the thread." | |
9000 | (interactive) | |
eec82323 LMI |
9001 | (while (gnus-summary-go-up-thread)) |
9002 | (gnus-summary-article-number)) | |
9003 | ||
9004 | (defun gnus-summary-kill-thread (&optional unmark) | |
9005 | "Mark articles under current thread as read. | |
9006 | If the prefix argument is positive, remove any kinds of marks. | |
9007 | If the prefix argument is negative, tick articles instead." | |
9008 | (interactive "P") | |
eec82323 LMI |
9009 | (when unmark |
9010 | (setq unmark (prefix-numeric-value unmark))) | |
9011 | (let ((articles (gnus-summary-articles-in-thread))) | |
9012 | (save-excursion | |
9013 | ;; Expand the thread. | |
9014 | (gnus-summary-show-thread) | |
9015 | ;; Mark all the articles. | |
9016 | (while articles | |
9017 | (gnus-summary-goto-subject (car articles)) | |
9018 | (cond ((null unmark) | |
9019 | (gnus-summary-mark-article-as-read gnus-killed-mark)) | |
9020 | ((> unmark 0) | |
9021 | (gnus-summary-mark-article-as-unread gnus-unread-mark)) | |
9022 | (t | |
9023 | (gnus-summary-mark-article-as-unread gnus-ticked-mark))) | |
9024 | (setq articles (cdr articles)))) | |
9025 | ;; Hide killed subtrees. | |
9026 | (and (null unmark) | |
9027 | gnus-thread-hide-killed | |
9028 | (gnus-summary-hide-thread)) | |
9029 | ;; If marked as read, go to next unread subject. | |
9030 | (when (null unmark) | |
9031 | ;; Go to next unread subject. | |
9032 | (gnus-summary-next-subject 1 t))) | |
9033 | (gnus-set-mode-line 'summary)) | |
9034 | ||
9035 | ;; Summary sorting commands | |
9036 | ||
9037 | (defun gnus-summary-sort-by-number (&optional reverse) | |
9038 | "Sort the summary buffer by article number. | |
9039 | Argument REVERSE means reverse order." | |
9040 | (interactive "P") | |
9041 | (gnus-summary-sort 'number reverse)) | |
9042 | ||
9043 | (defun gnus-summary-sort-by-author (&optional reverse) | |
9044 | "Sort the summary buffer by author name alphabetically. | |
16409b0b | 9045 | If `case-fold-search' is non-nil, case of letters is ignored. |
eec82323 LMI |
9046 | Argument REVERSE means reverse order." |
9047 | (interactive "P") | |
9048 | (gnus-summary-sort 'author reverse)) | |
9049 | ||
9050 | (defun gnus-summary-sort-by-subject (&optional reverse) | |
9051 | "Sort the summary buffer by subject alphabetically. `Re:'s are ignored. | |
16409b0b | 9052 | If `case-fold-search' is non-nil, case of letters is ignored. |
eec82323 LMI |
9053 | Argument REVERSE means reverse order." |
9054 | (interactive "P") | |
9055 | (gnus-summary-sort 'subject reverse)) | |
9056 | ||
9057 | (defun gnus-summary-sort-by-date (&optional reverse) | |
9058 | "Sort the summary buffer by date. | |
9059 | Argument REVERSE means reverse order." | |
9060 | (interactive "P") | |
9061 | (gnus-summary-sort 'date reverse)) | |
9062 | ||
9063 | (defun gnus-summary-sort-by-score (&optional reverse) | |
9064 | "Sort the summary buffer by score. | |
9065 | Argument REVERSE means reverse order." | |
9066 | (interactive "P") | |
9067 | (gnus-summary-sort 'score reverse)) | |
9068 | ||
9069 | (defun gnus-summary-sort-by-lines (&optional reverse) | |
16409b0b | 9070 | "Sort the summary buffer by the number of lines. |
eec82323 LMI |
9071 | Argument REVERSE means reverse order." |
9072 | (interactive "P") | |
9073 | (gnus-summary-sort 'lines reverse)) | |
9074 | ||
16409b0b GM |
9075 | (defun gnus-summary-sort-by-chars (&optional reverse) |
9076 | "Sort the summary buffer by article length. | |
9077 | Argument REVERSE means reverse order." | |
9078 | (interactive "P") | |
9079 | (gnus-summary-sort 'chars reverse)) | |
9080 | ||
eec82323 LMI |
9081 | (defun gnus-summary-sort (predicate reverse) |
9082 | "Sort summary buffer by PREDICATE. REVERSE means reverse order." | |
eec82323 LMI |
9083 | (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate))) |
9084 | (article (intern (format "gnus-article-sort-by-%s" predicate))) | |
9085 | (gnus-thread-sort-functions | |
16409b0b GM |
9086 | (if (not reverse) |
9087 | thread | |
9088 | `(lambda (t1 t2) | |
9089 | (,thread t2 t1)))) | |
9090 | (gnus-sort-gathered-threads-function | |
9091 | gnus-thread-sort-functions) | |
eec82323 | 9092 | (gnus-article-sort-functions |
16409b0b GM |
9093 | (if (not reverse) |
9094 | article | |
9095 | `(lambda (t1 t2) | |
9096 | (,article t2 t1)))) | |
eec82323 LMI |
9097 | (buffer-read-only) |
9098 | (gnus-summary-prepare-hook nil)) | |
9099 | ;; We do the sorting by regenerating the threads. | |
9100 | (gnus-summary-prepare) | |
9101 | ;; Hide subthreads if needed. | |
9102 | (when (and gnus-show-threads gnus-thread-hide-subtree) | |
9103 | (gnus-summary-hide-all-threads)))) | |
9104 | ||
9105 | ;; Summary saving commands. | |
9106 | ||
9107 | (defun gnus-summary-save-article (&optional n not-saved) | |
9108 | "Save the current article using the default saver function. | |
9109 | If N is a positive number, save the N next articles. | |
9110 | If N is a negative number, save the N previous articles. | |
9111 | If N is nil and any articles have been marked with the process mark, | |
9112 | save those articles instead. | |
9113 | The variable `gnus-default-article-saver' specifies the saver function." | |
9114 | (interactive "P") | |
eec82323 LMI |
9115 | (let* ((articles (gnus-summary-work-articles n)) |
9116 | (save-buffer (save-excursion | |
9117 | (nnheader-set-temp-buffer " *Gnus Save*"))) | |
9118 | (num (length articles)) | |
16409b0b GM |
9119 | header file) |
9120 | (dolist (article articles) | |
9121 | (setq header (gnus-summary-article-header article)) | |
eec82323 LMI |
9122 | (if (not (vectorp header)) |
9123 | ;; This is a pseudo-article. | |
9124 | (if (assq 'name header) | |
9125 | (gnus-copy-file (cdr (assq 'name header))) | |
9126 | (gnus-message 1 "Article %d is unsaveable" article)) | |
9127 | ;; This is a real article. | |
9128 | (save-window-excursion | |
9129 | (gnus-summary-select-article t nil nil article)) | |
9130 | (save-excursion | |
9131 | (set-buffer save-buffer) | |
9132 | (erase-buffer) | |
9133 | (insert-buffer-substring gnus-original-article-buffer)) | |
9134 | (setq file (gnus-article-save save-buffer file num)) | |
9135 | (gnus-summary-remove-process-mark article) | |
9136 | (unless not-saved | |
9137 | (gnus-summary-set-saved-mark article)))) | |
9138 | (gnus-kill-buffer save-buffer) | |
9139 | (gnus-summary-position-point) | |
9140 | (gnus-set-mode-line 'summary) | |
9141 | n)) | |
9142 | ||
9143 | (defun gnus-summary-pipe-output (&optional arg) | |
9144 | "Pipe the current article to a subprocess. | |
9145 | If N is a positive number, pipe the N next articles. | |
9146 | If N is a negative number, pipe the N previous articles. | |
9147 | If N is nil and any articles have been marked with the process mark, | |
9148 | pipe those articles instead." | |
9149 | (interactive "P") | |
84169620 | 9150 | (require 'gnus-art) |
eec82323 LMI |
9151 | (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe)) |
9152 | (gnus-summary-save-article arg t)) | |
9153 | (gnus-configure-windows 'pipe)) | |
9154 | ||
9155 | (defun gnus-summary-save-article-mail (&optional arg) | |
9156 | "Append the current article to an mail file. | |
9157 | If N is a positive number, save the N next articles. | |
9158 | If N is a negative number, save the N previous articles. | |
9159 | If N is nil and any articles have been marked with the process mark, | |
9160 | save those articles instead." | |
9161 | (interactive "P") | |
84169620 | 9162 | (require 'gnus-art) |
eec82323 LMI |
9163 | (let ((gnus-default-article-saver 'gnus-summary-save-in-mail)) |
9164 | (gnus-summary-save-article arg))) | |
9165 | ||
9166 | (defun gnus-summary-save-article-rmail (&optional arg) | |
9167 | "Append the current article to an rmail file. | |
9168 | If N is a positive number, save the N next articles. | |
9169 | If N is a negative number, save the N previous articles. | |
9170 | If N is nil and any articles have been marked with the process mark, | |
9171 | save those articles instead." | |
9172 | (interactive "P") | |
84169620 | 9173 | (require 'gnus-art) |
eec82323 LMI |
9174 | (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail)) |
9175 | (gnus-summary-save-article arg))) | |
9176 | ||
9177 | (defun gnus-summary-save-article-file (&optional arg) | |
9178 | "Append the current article to a file. | |
9179 | If N is a positive number, save the N next articles. | |
9180 | If N is a negative number, save the N previous articles. | |
9181 | If N is nil and any articles have been marked with the process mark, | |
9182 | save those articles instead." | |
9183 | (interactive "P") | |
84169620 | 9184 | (require 'gnus-art) |
eec82323 LMI |
9185 | (let ((gnus-default-article-saver 'gnus-summary-save-in-file)) |
9186 | (gnus-summary-save-article arg))) | |
9187 | ||
9188 | (defun gnus-summary-write-article-file (&optional arg) | |
9189 | "Write the current article to a file, deleting the previous file. | |
9190 | If N is a positive number, save the N next articles. | |
9191 | If N is a negative number, save the N previous articles. | |
9192 | If N is nil and any articles have been marked with the process mark, | |
9193 | save those articles instead." | |
9194 | (interactive "P") | |
84169620 | 9195 | (require 'gnus-art) |
eec82323 LMI |
9196 | (let ((gnus-default-article-saver 'gnus-summary-write-to-file)) |
9197 | (gnus-summary-save-article arg))) | |
9198 | ||
9199 | (defun gnus-summary-save-article-body-file (&optional arg) | |
9200 | "Append the current article body to a file. | |
9201 | If N is a positive number, save the N next articles. | |
9202 | If N is a negative number, save the N previous articles. | |
9203 | If N is nil and any articles have been marked with the process mark, | |
9204 | save those articles instead." | |
9205 | (interactive "P") | |
84169620 | 9206 | (require 'gnus-art) |
eec82323 LMI |
9207 | (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file)) |
9208 | (gnus-summary-save-article arg))) | |
9209 | ||
9210 | (defun gnus-summary-pipe-message (program) | |
9211 | "Pipe the current article through PROGRAM." | |
9212 | (interactive "sProgram: ") | |
eec82323 | 9213 | (gnus-summary-select-article) |
6748645f | 9214 | (let ((mail-header-separator "")) |
eec82323 LMI |
9215 | (gnus-eval-in-buffer-window gnus-article-buffer |
9216 | (save-restriction | |
9217 | (widen) | |
9218 | (let ((start (window-start)) | |
9219 | buffer-read-only) | |
9220 | (message-pipe-buffer-body program) | |
9221 | (set-window-start (get-buffer-window (current-buffer)) start)))))) | |
9222 | ||
9223 | (defun gnus-get-split-value (methods) | |
9224 | "Return a value based on the split METHODS." | |
9225 | (let (split-name method result match) | |
9226 | (when methods | |
9227 | (save-excursion | |
9228 | (set-buffer gnus-original-article-buffer) | |
9229 | (save-restriction | |
9230 | (nnheader-narrow-to-headers) | |
d4dfaa19 | 9231 | (while (and methods (not split-name)) |
eec82323 LMI |
9232 | (goto-char (point-min)) |
9233 | (setq method (pop methods)) | |
9234 | (setq match (car method)) | |
9235 | (when (cond | |
9236 | ((stringp match) | |
9237 | ;; Regular expression. | |
9238 | (ignore-errors | |
9239 | (re-search-forward match nil t))) | |
9240 | ((gnus-functionp match) | |
9241 | ;; Function. | |
9242 | (save-restriction | |
9243 | (widen) | |
9244 | (setq result (funcall match gnus-newsgroup-name)))) | |
9245 | ((consp match) | |
9246 | ;; Form. | |
9247 | (save-restriction | |
9248 | (widen) | |
9249 | (setq result (eval match))))) | |
d4dfaa19 | 9250 | (setq split-name (cdr method)) |
eec82323 LMI |
9251 | (cond ((stringp result) |
9252 | (push (expand-file-name | |
9253 | result gnus-article-save-directory) | |
9254 | split-name)) | |
9255 | ((consp result) | |
9256 | (setq split-name (append result split-name))))))))) | |
16409b0b | 9257 | (nreverse split-name))) |
eec82323 LMI |
9258 | |
9259 | (defun gnus-valid-move-group-p (group) | |
9260 | (and (boundp group) | |
9261 | (symbol-name group) | |
16409b0b GM |
9262 | (symbol-value group) |
9263 | (gnus-get-function (gnus-find-method-for-group | |
9264 | (symbol-name group)) 'request-accept-article t))) | |
eec82323 LMI |
9265 | |
9266 | (defun gnus-read-move-group-name (prompt default articles prefix) | |
9267 | "Read a group name." | |
9268 | (let* ((split-name (gnus-get-split-value gnus-move-split-methods)) | |
9269 | (minibuffer-confirm-incomplete nil) ; XEmacs | |
9270 | (prom | |
9271 | (format "%s %s to:" | |
9272 | prompt | |
9273 | (if (> (length articles) 1) | |
9274 | (format "these %d articles" (length articles)) | |
9275 | "this article"))) | |
9276 | (to-newsgroup | |
9277 | (cond | |
9278 | ((null split-name) | |
9279 | (gnus-completing-read default prom | |
9280 | gnus-active-hashtb | |
9281 | 'gnus-valid-move-group-p | |
9282 | nil prefix | |
9283 | 'gnus-group-history)) | |
9284 | ((= 1 (length split-name)) | |
9285 | (gnus-completing-read (car split-name) prom | |
9286 | gnus-active-hashtb | |
9287 | 'gnus-valid-move-group-p | |
9288 | nil nil | |
9289 | 'gnus-group-history)) | |
9290 | (t | |
9291 | (gnus-completing-read nil prom | |
9292 | (mapcar (lambda (el) (list el)) | |
9293 | (nreverse split-name)) | |
9294 | nil nil nil | |
16409b0b GM |
9295 | 'gnus-group-history)))) |
9296 | (to-method (gnus-server-to-method (gnus-group-method to-newsgroup)))) | |
eec82323 LMI |
9297 | (when to-newsgroup |
9298 | (if (or (string= to-newsgroup "") | |
9299 | (string= to-newsgroup prefix)) | |
9300 | (setq to-newsgroup default)) | |
9301 | (unless to-newsgroup | |
9302 | (error "No group name entered")) | |
9303 | (or (gnus-active to-newsgroup) | |
16409b0b | 9304 | (gnus-activate-group to-newsgroup nil nil to-method) |
eec82323 LMI |
9305 | (if (gnus-y-or-n-p (format "No such group: %s. Create it? " |
9306 | to-newsgroup)) | |
16409b0b GM |
9307 | (or (and (gnus-request-create-group to-newsgroup to-method) |
9308 | (gnus-activate-group | |
9309 | to-newsgroup nil nil to-method) | |
9310 | (gnus-subscribe-group to-newsgroup)) | |
eec82323 LMI |
9311 | (error "Couldn't create group %s" to-newsgroup))) |
9312 | (error "No such group: %s" to-newsgroup))) | |
9313 | to-newsgroup)) | |
9314 | ||
16409b0b GM |
9315 | (defun gnus-summary-save-parts (type dir n &optional reverse) |
9316 | "Save parts matching TYPE to DIR. | |
9317 | If REVERSE, save parts that do not match TYPE." | |
9318 | (interactive | |
8b93df01 DL |
9319 | (list (read-string "Save parts of type: " |
9320 | (or (car gnus-summary-save-parts-type-history) | |
9321 | gnus-summary-save-parts-default-mime) | |
9322 | 'gnus-summary-save-parts-type-history) | |
9323 | (setq gnus-summary-save-parts-last-directory | |
9324 | (read-file-name "Save to directory: " | |
9325 | gnus-summary-save-parts-last-directory | |
9326 | nil t)) | |
16409b0b GM |
9327 | current-prefix-arg)) |
9328 | (gnus-summary-iterate n | |
9329 | (let ((gnus-display-mime-function nil) | |
9330 | (gnus-inhibit-treatment t)) | |
9331 | (gnus-summary-select-article)) | |
9332 | (save-excursion | |
9333 | (set-buffer gnus-article-buffer) | |
9334 | (let ((handles (or gnus-article-mime-handles | |
9335 | (mm-dissect-buffer) (mm-uu-dissect)))) | |
9336 | (when handles | |
9337 | (gnus-summary-save-parts-1 type dir handles reverse) | |
9338 | (unless gnus-article-mime-handles ;; Don't destroy this case. | |
9339 | (mm-destroy-parts handles))))))) | |
9340 | ||
9341 | (defun gnus-summary-save-parts-1 (type dir handle reverse) | |
9342 | (if (stringp (car handle)) | |
9343 | (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse)) | |
9344 | (cdr handle)) | |
9345 | (when (if reverse | |
9346 | (not (string-match type (mm-handle-media-type handle))) | |
9347 | (string-match type (mm-handle-media-type handle))) | |
9348 | (let ((file (expand-file-name | |
9349 | (file-name-nondirectory | |
9350 | (or | |
9351 | (mail-content-type-get | |
9352 | (mm-handle-disposition handle) 'filename) | |
9353 | (concat gnus-newsgroup-name | |
9354 | "." (number-to-string | |
9355 | (cdr gnus-article-current))))) | |
9356 | dir))) | |
9357 | (unless (file-exists-p file) | |
9358 | (mm-save-part-to-file handle file)))))) | |
9359 | ||
eec82323 LMI |
9360 | ;; Summary extract commands |
9361 | ||
9362 | (defun gnus-summary-insert-pseudos (pslist &optional not-view) | |
9363 | (let ((buffer-read-only nil) | |
9364 | (article (gnus-summary-article-number)) | |
9365 | after-article b e) | |
9366 | (unless (gnus-summary-goto-subject article) | |
9367 | (error "No such article: %d" article)) | |
9368 | (gnus-summary-position-point) | |
9369 | ;; If all commands are to be bunched up on one line, we collect | |
9370 | ;; them here. | |
9371 | (unless gnus-view-pseudos-separately | |
9372 | (let ((ps (setq pslist (sort pslist 'gnus-pseudos<))) | |
9373 | files action) | |
9374 | (while ps | |
9375 | (setq action (cdr (assq 'action (car ps)))) | |
9376 | (setq files (list (cdr (assq 'name (car ps))))) | |
9377 | (while (and ps (cdr ps) | |
9378 | (string= (or action "1") | |
9379 | (or (cdr (assq 'action (cadr ps))) "2"))) | |
9380 | (push (cdr (assq 'name (cadr ps))) files) | |
9381 | (setcdr ps (cddr ps))) | |
9382 | (when files | |
9383 | (when (not (string-match "%s" action)) | |
9384 | (push " " files)) | |
9385 | (push " " files) | |
9386 | (when (assq 'execute (car ps)) | |
9387 | (setcdr (assq 'execute (car ps)) | |
9388 | (funcall (if (string-match "%s" action) | |
9389 | 'format 'concat) | |
9390 | action | |
9391 | (mapconcat | |
9392 | (lambda (f) | |
9393 | (if (equal f " ") | |
9394 | f | |
16409b0b | 9395 | (mm-quote-arg f))) |
eec82323 LMI |
9396 | files " "))))) |
9397 | (setq ps (cdr ps))))) | |
9398 | (if (and gnus-view-pseudos (not not-view)) | |
9399 | (while pslist | |
9400 | (when (assq 'execute (car pslist)) | |
9401 | (gnus-execute-command (cdr (assq 'execute (car pslist))) | |
9402 | (eq gnus-view-pseudos 'not-confirm))) | |
9403 | (setq pslist (cdr pslist))) | |
9404 | (save-excursion | |
9405 | (while pslist | |
9406 | (setq after-article (or (cdr (assq 'article (car pslist))) | |
9407 | (gnus-summary-article-number))) | |
9408 | (gnus-summary-goto-subject after-article) | |
9409 | (forward-line 1) | |
9410 | (setq b (point)) | |
9411 | (insert " " (file-name-nondirectory | |
9412 | (cdr (assq 'name (car pslist)))) | |
9413 | ": " (or (cdr (assq 'execute (car pslist))) "") "\n") | |
9414 | (setq e (point)) | |
9415 | (forward-line -1) ; back to `b' | |
9416 | (gnus-add-text-properties | |
9417 | b (1- e) (list 'gnus-number gnus-reffed-article-number | |
9418 | gnus-mouse-face-prop gnus-mouse-face)) | |
9419 | (gnus-data-enter | |
9420 | after-article gnus-reffed-article-number | |
9421 | gnus-unread-mark b (car pslist) 0 (- e b)) | |
9422 | (push gnus-reffed-article-number gnus-newsgroup-unreads) | |
9423 | (setq gnus-reffed-article-number (1- gnus-reffed-article-number)) | |
9424 | (setq pslist (cdr pslist))))))) | |
9425 | ||
9426 | (defun gnus-pseudos< (p1 p2) | |
9427 | (let ((c1 (cdr (assq 'action p1))) | |
9428 | (c2 (cdr (assq 'action p2)))) | |
9429 | (and c1 c2 (string< c1 c2)))) | |
9430 | ||
9431 | (defun gnus-request-pseudo-article (props) | |
9432 | (cond ((assq 'execute props) | |
9433 | (gnus-execute-command (cdr (assq 'execute props))))) | |
9434 | (let ((gnus-current-article (gnus-summary-article-number))) | |
6748645f | 9435 | (gnus-run-hooks 'gnus-mark-article-hook))) |
eec82323 LMI |
9436 | |
9437 | (defun gnus-execute-command (command &optional automatic) | |
9438 | (save-excursion | |
9439 | (gnus-article-setup-buffer) | |
9440 | (set-buffer gnus-article-buffer) | |
9441 | (setq buffer-read-only nil) | |
a8151ef7 LMI |
9442 | (let ((command (if automatic command |
9443 | (read-string "Command: " (cons command 0))))) | |
eec82323 LMI |
9444 | (erase-buffer) |
9445 | (insert "$ " command "\n\n") | |
9446 | (if gnus-view-pseudo-asynchronously | |
9447 | (start-process "gnus-execute" (current-buffer) shell-file-name | |
9448 | shell-command-switch command) | |
9449 | (call-process shell-file-name nil t nil | |
9450 | shell-command-switch command))))) | |
9451 | ||
9452 | ;; Summary kill commands. | |
9453 | ||
9454 | (defun gnus-summary-edit-global-kill (article) | |
9455 | "Edit the \"global\" kill file." | |
9456 | (interactive (list (gnus-summary-article-number))) | |
eec82323 LMI |
9457 | (gnus-group-edit-global-kill article)) |
9458 | ||
9459 | (defun gnus-summary-edit-local-kill () | |
9460 | "Edit a local kill file applied to the current newsgroup." | |
9461 | (interactive) | |
eec82323 | 9462 | (setq gnus-current-headers (gnus-summary-article-header)) |
eec82323 LMI |
9463 | (gnus-group-edit-local-kill |
9464 | (gnus-summary-article-number) gnus-newsgroup-name)) | |
9465 | ||
9466 | ;;; Header reading. | |
9467 | ||
9468 | (defun gnus-read-header (id &optional header) | |
9469 | "Read the headers of article ID and enter them into the Gnus system." | |
9470 | (let ((group gnus-newsgroup-name) | |
9471 | (gnus-override-method | |
16409b0b GM |
9472 | (or |
9473 | gnus-override-method | |
9474 | (and (gnus-news-group-p gnus-newsgroup-name) | |
9475 | (car (gnus-refer-article-methods))))) | |
eec82323 LMI |
9476 | where) |
9477 | ;; First we check to see whether the header in question is already | |
9478 | ;; fetched. | |
9479 | (if (stringp id) | |
9480 | ;; This is a Message-ID. | |
9481 | (setq header (or header (gnus-id-to-header id))) | |
9482 | ;; This is an article number. | |
9483 | (setq header (or header (gnus-summary-article-header id)))) | |
9484 | (if (and header | |
9485 | (not (gnus-summary-article-sparse-p (mail-header-number header)))) | |
9486 | ;; We have found the header. | |
9487 | header | |
6748645f LMI |
9488 | ;; If this is a sparse article, we have to nix out its |
9489 | ;; previous entry in the thread hashtb. | |
9490 | (when (and header | |
9491 | (gnus-summary-article-sparse-p (mail-header-number header))) | |
9492 | (let* ((parent (gnus-parent-id (mail-header-references header))) | |
9493 | (thread (and parent (gnus-id-to-thread parent)))) | |
9494 | (when thread | |
9495 | (delq (assq header thread) thread)))) | |
eec82323 LMI |
9496 | ;; We have to really fetch the header to this article. |
9497 | (save-excursion | |
9498 | (set-buffer nntp-server-buffer) | |
9499 | (when (setq where (gnus-request-head id group)) | |
9500 | (nnheader-fold-continuation-lines) | |
9501 | (goto-char (point-max)) | |
9502 | (insert ".\n") | |
9503 | (goto-char (point-min)) | |
9504 | (insert "211 ") | |
9505 | (princ (cond | |
9506 | ((numberp id) id) | |
9507 | ((cdr where) (cdr where)) | |
9508 | (header (mail-header-number header)) | |
9509 | (t gnus-reffed-article-number)) | |
9510 | (current-buffer)) | |
9511 | (insert " Article retrieved.\n")) | |
9512 | (if (or (not where) | |
9513 | (not (setq header (car (gnus-get-newsgroup-headers nil t))))) | |
9514 | () ; Malformed head. | |
9515 | (unless (gnus-summary-article-sparse-p (mail-header-number header)) | |
9516 | (when (and (stringp id) | |
9517 | (not (string= (gnus-group-real-name group) | |
9518 | (car where)))) | |
9519 | ;; If we fetched by Message-ID and the article came | |
9520 | ;; from a different group, we fudge some bogus article | |
9521 | ;; numbers for this article. | |
9522 | (mail-header-set-number header gnus-reffed-article-number)) | |
9523 | (save-excursion | |
9524 | (set-buffer gnus-summary-buffer) | |
9525 | (decf gnus-reffed-article-number) | |
9526 | (gnus-remove-header (mail-header-number header)) | |
9527 | (push header gnus-newsgroup-headers) | |
9528 | (setq gnus-current-headers header) | |
9529 | (push (mail-header-number header) gnus-newsgroup-limit))) | |
9530 | header))))) | |
9531 | ||
9532 | (defun gnus-remove-header (number) | |
9533 | "Remove header NUMBER from `gnus-newsgroup-headers'." | |
9534 | (if (and gnus-newsgroup-headers | |
9535 | (= number (mail-header-number (car gnus-newsgroup-headers)))) | |
9536 | (pop gnus-newsgroup-headers) | |
9537 | (let ((headers gnus-newsgroup-headers)) | |
9538 | (while (and (cdr headers) | |
9539 | (not (= number (mail-header-number (cadr headers))))) | |
9540 | (pop headers)) | |
9541 | (when (cdr headers) | |
9542 | (setcdr headers (cddr headers)))))) | |
9543 | ||
9544 | ;;; | |
9545 | ;;; summary highlights | |
9546 | ;;; | |
9547 | ||
9548 | (defun gnus-highlight-selected-summary () | |
16409b0b | 9549 | "Highlight selected article in summary buffer." |
eec82323 | 9550 | ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>. |
eec82323 LMI |
9551 | (when gnus-summary-selected-face |
9552 | (save-excursion | |
9553 | (let* ((beg (progn (beginning-of-line) (point))) | |
9554 | (end (progn (end-of-line) (point))) | |
9555 | ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>. | |
9556 | (from (if (get-text-property beg gnus-mouse-face-prop) | |
9557 | beg | |
9558 | (or (next-single-property-change | |
9559 | beg gnus-mouse-face-prop nil end) | |
9560 | beg))) | |
9561 | (to | |
9562 | (if (= from end) | |
9563 | (- from 2) | |
9564 | (or (next-single-property-change | |
9565 | from gnus-mouse-face-prop nil end) | |
9566 | end)))) | |
9567 | ;; If no mouse-face prop on line we will have to = from = end, | |
9568 | ;; so we highlight the entire line instead. | |
9569 | (when (= (+ to 2) from) | |
9570 | (setq from beg) | |
9571 | (setq to end)) | |
9572 | (if gnus-newsgroup-selected-overlay | |
9573 | ;; Move old overlay. | |
9574 | (gnus-move-overlay | |
9575 | gnus-newsgroup-selected-overlay from to (current-buffer)) | |
9576 | ;; Create new overlay. | |
9577 | (gnus-overlay-put | |
9578 | (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to)) | |
9579 | 'face gnus-summary-selected-face)))))) | |
9580 | ||
9581 | ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>. | |
9582 | (defun gnus-summary-highlight-line () | |
9583 | "Highlight current line according to `gnus-summary-highlight'." | |
9584 | (let* ((list gnus-summary-highlight) | |
9585 | (p (point)) | |
9586 | (end (progn (end-of-line) (point))) | |
9587 | ;; now find out where the line starts and leave point there. | |
9588 | (beg (progn (beginning-of-line) (point))) | |
9589 | (article (gnus-summary-article-number)) | |
9590 | (score (or (cdr (assq (or article gnus-current-article) | |
9591 | gnus-newsgroup-scored)) | |
9592 | gnus-summary-default-score 0)) | |
9593 | (mark (or (gnus-summary-article-mark) gnus-unread-mark)) | |
9594 | (inhibit-read-only t)) | |
9595 | ;; Eval the cars of the lists until we find a match. | |
9596 | (let ((default gnus-summary-default-score)) | |
9597 | (while (and list | |
9598 | (not (eval (caar list)))) | |
9599 | (setq list (cdr list)))) | |
9600 | (let ((face (cdar list))) | |
9601 | (unless (eq face (get-text-property beg 'face)) | |
6748645f | 9602 | (gnus-put-text-property-excluding-characters-with-faces |
eec82323 LMI |
9603 | beg end 'face |
9604 | (setq face (if (boundp face) (symbol-value face) face))) | |
9605 | (when gnus-summary-highlight-line-function | |
9606 | (funcall gnus-summary-highlight-line-function article face)))) | |
9607 | (goto-char p))) | |
9608 | ||
6748645f | 9609 | (defun gnus-update-read-articles (group unread &optional compute) |
eec82323 LMI |
9610 | "Update the list of read articles in GROUP." |
9611 | (let* ((active (or gnus-newsgroup-active (gnus-active group))) | |
9612 | (entry (gnus-gethash group gnus-newsrc-hashtb)) | |
9613 | (info (nth 2 entry)) | |
9614 | (prev 1) | |
9615 | (unread (sort (copy-sequence unread) '<)) | |
9616 | read) | |
9617 | (if (or (not info) (not active)) | |
9618 | ;; There is no info on this group if it was, in fact, | |
9619 | ;; killed. Gnus stores no information on killed groups, so | |
9620 | ;; there's nothing to be done. | |
9621 | ;; One could store the information somewhere temporarily, | |
9622 | ;; perhaps... Hmmm... | |
9623 | () | |
9624 | ;; Remove any negative articles numbers. | |
9625 | (while (and unread (< (car unread) 0)) | |
9626 | (setq unread (cdr unread))) | |
9627 | ;; Remove any expired article numbers | |
9628 | (while (and unread (< (car unread) (car active))) | |
9629 | (setq unread (cdr unread))) | |
9630 | ;; Compute the ranges of read articles by looking at the list of | |
9631 | ;; unread articles. | |
9632 | (while unread | |
9633 | (when (/= (car unread) prev) | |
9634 | (push (if (= prev (1- (car unread))) prev | |
9635 | (cons prev (1- (car unread)))) | |
9636 | read)) | |
9637 | (setq prev (1+ (car unread))) | |
9638 | (setq unread (cdr unread))) | |
9639 | (when (<= prev (cdr active)) | |
9640 | (push (cons prev (cdr active)) read)) | |
16409b0b | 9641 | (setq read (if (> (length read) 1) (nreverse read) read)) |
6748645f | 9642 | (if compute |
16409b0b | 9643 | read |
6748645f | 9644 | (save-excursion |
16409b0b GM |
9645 | (let (setmarkundo) |
9646 | ;; Propagate the read marks to the backend. | |
9647 | (when (gnus-check-backend-function 'request-set-mark group) | |
9648 | (let ((del (gnus-remove-from-range (gnus-info-read info) read)) | |
9649 | (add (gnus-remove-from-range read (gnus-info-read info)))) | |
9650 | (when (or add del) | |
9651 | (unless (gnus-check-group group) | |
9652 | (error "Can't open server for %s" group)) | |
9653 | (gnus-request-set-mark | |
9654 | group (delq nil (list (if add (list add 'add '(read))) | |
9655 | (if del (list del 'del '(read)))))) | |
9656 | (setq setmarkundo | |
9657 | `(gnus-request-set-mark | |
9658 | ,group | |
9659 | ',(delq nil (list | |
9660 | (if del (list del 'add '(read))) | |
9661 | (if add (list add 'del '(read)))))))))) | |
9662 | (set-buffer gnus-group-buffer) | |
9663 | (gnus-undo-register | |
9664 | `(progn | |
9665 | (gnus-info-set-marks ',info ',(gnus-info-marks info) t) | |
9666 | (gnus-info-set-read ',info ',(gnus-info-read info)) | |
9667 | (gnus-get-unread-articles-in-group ',info | |
9668 | (gnus-active ,group)) | |
9669 | (gnus-group-update-group ,group t) | |
9670 | ,setmarkundo)))) | |
6748645f | 9671 | ;; Enter this list into the group info. |
16409b0b | 9672 | (gnus-info-set-read info read) |
6748645f LMI |
9673 | ;; Set the number of unread articles in gnus-newsrc-hashtb. |
9674 | (gnus-get-unread-articles-in-group info (gnus-active group)) | |
9675 | t)))) | |
eec82323 LMI |
9676 | |
9677 | (defun gnus-offer-save-summaries () | |
9678 | "Offer to save all active summary buffers." | |
9679 | (save-excursion | |
9680 | (let ((buflist (buffer-list)) | |
9681 | buffers bufname) | |
9682 | ;; Go through all buffers and find all summaries. | |
9683 | (while buflist | |
9684 | (and (setq bufname (buffer-name (car buflist))) | |
9685 | (string-match "Summary" bufname) | |
9686 | (save-excursion | |
9687 | (set-buffer bufname) | |
9688 | ;; We check that this is, indeed, a summary buffer. | |
9689 | (and (eq major-mode 'gnus-summary-mode) | |
9690 | ;; Also make sure this isn't bogus. | |
9691 | gnus-newsgroup-prepared | |
9692 | ;; Also make sure that this isn't a dead summary buffer. | |
9693 | (not gnus-dead-summary-mode))) | |
9694 | (push bufname buffers)) | |
9695 | (setq buflist (cdr buflist))) | |
9696 | ;; Go through all these summary buffers and offer to save them. | |
9697 | (when buffers | |
9698 | (map-y-or-n-p | |
9699 | "Update summary buffer %s? " | |
6748645f LMI |
9700 | (lambda (buf) |
9701 | (switch-to-buffer buf) | |
9702 | (gnus-summary-exit)) | |
eec82323 LMI |
9703 | buffers))))) |
9704 | ||
16409b0b GM |
9705 | (defun gnus-summary-setup-default-charset () |
9706 | "Setup newsgroup default charset." | |
9707 | (if (equal gnus-newsgroup-name "nndraft:drafts") | |
9708 | (setq gnus-newsgroup-charset nil) | |
9709 | (let* ((name (and gnus-newsgroup-name | |
9710 | (gnus-group-real-name gnus-newsgroup-name))) | |
9711 | (ignored-charsets | |
9712 | (or gnus-newsgroup-ephemeral-ignored-charsets | |
9713 | (append | |
9714 | (and gnus-newsgroup-name | |
9715 | (or (gnus-group-find-parameter gnus-newsgroup-name | |
9716 | 'ignored-charsets t) | |
9717 | (let ((alist gnus-group-ignored-charsets-alist) | |
9718 | elem (charsets nil)) | |
9719 | (while (setq elem (pop alist)) | |
9720 | (when (and name | |
9721 | (string-match (car elem) name)) | |
9722 | (setq alist nil | |
9723 | charsets (cdr elem)))) | |
9724 | charsets))) | |
9725 | gnus-newsgroup-ignored-charsets)))) | |
9726 | (setq gnus-newsgroup-charset | |
9727 | (or gnus-newsgroup-ephemeral-charset | |
9728 | (and gnus-newsgroup-name | |
9729 | (or (gnus-group-find-parameter gnus-newsgroup-name 'charset) | |
9730 | (let ((alist gnus-group-charset-alist) | |
9731 | elem charset) | |
9732 | (while (setq elem (pop alist)) | |
9733 | (when (and name | |
9734 | (string-match (car elem) name)) | |
9735 | (setq alist nil | |
9736 | charset (cadr elem)))) | |
9737 | charset))) | |
9738 | gnus-default-charset)) | |
9739 | (set (make-local-variable 'gnus-newsgroup-ignored-charsets) | |
9740 | ignored-charsets)))) | |
9741 | ||
9742 | ;;; | |
9743 | ;;; Mime Commands | |
9744 | ;;; | |
9745 | ||
9746 | (defun gnus-summary-display-buttonized (&optional show-all-parts) | |
9747 | "Display the current article buffer fully MIME-buttonized. | |
9748 | If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are | |
9749 | treated as multipart/mixed." | |
9750 | (interactive "P") | |
9751 | (require 'gnus-art) | |
9752 | (let ((gnus-unbuttonized-mime-types nil) | |
9753 | (gnus-mime-display-multipart-as-mixed show-all-parts)) | |
9754 | (gnus-summary-show-article))) | |
9755 | ||
9756 | (defun gnus-summary-repair-multipart (article) | |
9757 | "Add a Content-Type header to a multipart article without one." | |
9758 | (interactive (list (gnus-summary-article-number))) | |
9759 | (gnus-with-article article | |
9760 | (message-narrow-to-head) | |
9761 | (goto-char (point-max)) | |
9762 | (widen) | |
9763 | (when (search-forward "\n--" nil t) | |
9764 | (let ((separator (buffer-substring (point) (gnus-point-at-eol)))) | |
9765 | (message-narrow-to-head) | |
9766 | (message-remove-header "Mime-Version") | |
9767 | (message-remove-header "Content-Type") | |
9768 | (goto-char (point-max)) | |
9769 | (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n" | |
9770 | separator)) | |
9771 | (insert "Mime-Version: 1.0\n") | |
9772 | (widen)))) | |
9773 | (let (gnus-mark-article-hook) | |
9774 | (gnus-summary-select-article t t nil article))) | |
9775 | ||
9776 | (defun gnus-summary-toggle-display-buttonized () | |
9777 | "Toggle the buttonizing of the article buffer." | |
9778 | (interactive) | |
9779 | (require 'gnus-art) | |
9780 | (if (setq gnus-inhibit-mime-unbuttonizing | |
9781 | (not gnus-inhibit-mime-unbuttonizing)) | |
9782 | (let ((gnus-unbuttonized-mime-types nil)) | |
9783 | (gnus-summary-show-article)) | |
9784 | (gnus-summary-show-article))) | |
9785 | ||
9786 | ;;; | |
9787 | ;;; Generic summary marking commands | |
9788 | ;;; | |
9789 | ||
9790 | (defvar gnus-summary-marking-alist | |
9791 | '((read gnus-del-mark "d") | |
9792 | (unread gnus-unread-mark "u") | |
9793 | (ticked gnus-ticked-mark "!") | |
9794 | (dormant gnus-dormant-mark "?") | |
9795 | (expirable gnus-expirable-mark "e")) | |
9796 | "An alist of names/marks/keystrokes.") | |
9797 | ||
9798 | (defvar gnus-summary-generic-mark-map (make-sparse-keymap)) | |
9799 | (defvar gnus-summary-mark-map) | |
9800 | ||
9801 | (defun gnus-summary-make-all-marking-commands () | |
9802 | (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map) | |
9803 | (dolist (elem gnus-summary-marking-alist) | |
9804 | (apply 'gnus-summary-make-marking-command elem))) | |
9805 | ||
9806 | (defun gnus-summary-make-marking-command (name mark keystroke) | |
9807 | (let ((map (make-sparse-keymap))) | |
9808 | (define-key gnus-summary-generic-mark-map keystroke map) | |
9809 | (dolist (lway `((next "next" next nil "n") | |
9810 | (next-unread "next unread" next t "N") | |
9811 | (prev "previous" prev nil "p") | |
9812 | (prev-unread "previous unread" prev t "P") | |
9813 | (nomove "" nil nil ,keystroke))) | |
9814 | (let ((func (gnus-summary-make-marking-command-1 | |
9815 | mark (car lway) lway name))) | |
9816 | (setq func (eval func)) | |
9817 | (define-key map (nth 4 lway) func))))) | |
9818 | ||
9819 | (defun gnus-summary-make-marking-command-1 (mark way lway name) | |
9820 | `(defun ,(intern | |
9821 | (format "gnus-summary-put-mark-as-%s%s" | |
9822 | name (if (eq way 'nomove) | |
9823 | "" | |
9824 | (concat "-" (symbol-name way))))) | |
9825 | (n) | |
9826 | ,(format | |
9827 | "Mark the current article as %s%s. | |
9828 | If N, the prefix, then repeat N times. | |
9829 | If N is negative, move in reverse order. | |
9830 | The difference between N and the actual number of articles marked is | |
9831 | returned." | |
9832 | name (cadr lway)) | |
9833 | (interactive "p") | |
9834 | (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway)))) | |
9835 | ||
9836 | (defun gnus-summary-generic-mark (n mark move unread) | |
9837 | "Mark N articles with MARK." | |
9838 | (unless (eq major-mode 'gnus-summary-mode) | |
9839 | (error "This command can only be used in the summary buffer")) | |
9840 | (gnus-summary-show-thread) | |
9841 | (let ((nummove | |
9842 | (cond | |
9843 | ((eq move 'next) 1) | |
9844 | ((eq move 'prev) -1) | |
9845 | (t 0)))) | |
9846 | (if (zerop nummove) | |
9847 | (setq n 1) | |
9848 | (when (< n 0) | |
9849 | (setq n (abs n) | |
9850 | nummove (* -1 nummove)))) | |
9851 | (while (and (> n 0) | |
9852 | (gnus-summary-mark-article nil mark) | |
9853 | (zerop (gnus-summary-next-subject nummove unread t))) | |
9854 | (setq n (1- n))) | |
9855 | (when (/= 0 n) | |
9856 | (gnus-message 7 "No more %sarticles" (if mark "" "unread "))) | |
9857 | (gnus-summary-recenter) | |
9858 | (gnus-summary-position-point) | |
9859 | (gnus-set-mode-line 'summary) | |
9860 | n)) | |
9861 | ||
9862 | (gnus-summary-make-all-marking-commands) | |
9863 | ||
a8151ef7 LMI |
9864 | (gnus-ems-redefine) |
9865 | ||
eec82323 LMI |
9866 | (provide 'gnus-sum) |
9867 | ||
9868 | (run-hooks 'gnus-sum-load-hook) | |
9869 | ||
9870 | ;;; gnus-sum.el ends here |