1 ;;; gnus.el --- a newsreader for GNU Emacs
3 ;; Copyright (C) 1987,88,89,90,93,94,95 Free Software Foundation, Inc.
5 ;; Author: Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
6 ;; Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
28 ;; Although Gnus looks suspiciously like GNUS, it isn't quite the same
29 ;; beast. Most internal structures have been changed. If you have
30 ;; written packages that depend on any of the hash tables,
31 ;; `gnus-newsrc-alist', `gnus-killed-assoc', marked lists, the .newsrc
32 ;; buffer, or internal knowledge of the `nntp-header-' macros, or
33 ;; dependence on the buffers having a certain format, your code will
38 (eval '(run-hooks 'gnus-load-hook
))
44 ;; Site dependent variables. These variables should be defined in
47 (defvar gnus-default-nntp-server nil
48 "Specify a default NNTP server.
49 This variable should be defined in paths.el, and should never be set
51 If you want to change servers, you should use `gnus-select-method'.
52 See the documentation to that variable.")
54 (defconst gnus-backup-default-subscribed-newsgroups
55 '("news.announce.newusers" "news.groups.questions" "gnu.emacs.gnus")
56 "Default default new newsgroups the first time Gnus is run.
57 Should be set in paths.el, and shouldn't be touched by the user.")
59 (defvar gnus-local-domain nil
60 "Local domain name without a host name.
61 The DOMAINNAME environment variable is used instead if it is defined.
62 If the `system-name' function returns the full Internet name, there is
63 no need to set this variable.")
65 (defvar gnus-local-organization nil
66 "String with a description of what organization (if any) the user belongs to.
67 The ORGANIZATION environment variable is used instead if it is defined.
68 If this variable contains a function, this function will be called
69 with the current newsgroup name as the argument. The function should
72 In any case, if the string (either in the variable, in the environment
73 variable, or returned by the function) is a file name, the contents of
74 this file will be used as the organization.")
76 (defvar gnus-use-generic-from nil
77 "If nil, the full host name will be the system name prepended to the domain name.
78 If this is a string, the full host name will be this string.
79 If this is non-nil, non-string, the domain name will be used as the
82 (defvar gnus-use-generic-path nil
83 "If nil, use the NNTP server name in the Path header.
84 If stringp, use this; if non-nil, use no host name (user name only).")
87 ;; Customization variables
89 ;; Don't touch this variable.
90 (defvar gnus-nntp-service
"nntp"
91 "*NNTP service name (\"nntp\" or 119).
92 This is an obsolete variable, which is scarcely used. If you use an
93 nntp server for your newsgroup and want to change the port number
94 used to 899, you would say something along these lines:
96 (setq gnus-select-method '(nntp \"my.nntp.server\" (nntp-port-number 899)))")
98 (defvar gnus-select-method
100 (list 'nntp
(or (getenv "NNTPSERVER")
101 (if (and gnus-default-nntp-server
102 (not (string= gnus-default-nntp-server
"")))
103 gnus-default-nntp-server
)
105 (if (or (null gnus-nntp-service
)
106 (equal gnus-nntp-service
"nntp"))
108 (list gnus-nntp-service
)))
109 "*Default method for selecting a newsgroup.
110 This variable should be a list, where the first element is how the
111 news is to be fetched, the second is the address.
113 For instance, if you want to get your news via NNTP from
114 \"flab.flab.edu\", you could say:
116 (setq gnus-select-method '(nntp \"flab.flab.edu\"))
118 If you want to use your local spool, say:
120 (setq gnus-select-method (list 'nnspool (system-name)))
122 If you use this variable, you must set `gnus-nntp-server' to nil.
124 There is a lot more to know about select methods and virtual servers -
125 see the manual for details.")
127 ;; Added by Sudish Joseph <joseph@cis.ohio-state.edu>.
128 (defvar gnus-post-method nil
129 "*Preferred method for posting USENET news.
130 If this variable is nil, Gnus will use the current method to decide
131 which method to use when posting. If it is non-nil, it will override
132 the current method. This method will not be used in mail groups and
133 the like, only in \"real\" newsgroups.
135 The value must be a valid method as discussed in the documentation of
136 `gnus-select-method'.")
138 (defvar gnus-refer-article-method nil
139 "*Preferred method for fetching an article by Message-ID.
140 If you are reading news from the local spool (with nnspool), fetching
141 articles by Message-ID is painfully slow. By setting this method to an
142 nntp method, you might get acceptable results.
144 The value of this variable must be a valid select method as discussed
145 in the documentation of `gnus-select-method'")
147 (defvar gnus-secondary-select-methods nil
148 "*A list of secondary methods that will be used for reading news.
149 This is a list where each element is a complete select method (see
150 `gnus-select-method').
152 If, for instance, you want to read your mail with the nnml backend,
153 you could set this variable:
155 (setq gnus-secondary-select-methods '((nnml \"\")))")
157 (defvar gnus-secondary-servers nil
158 "*List of NNTP servers that the user can choose between interactively.
159 To make Gnus query you for a server, you have to give `gnus' a
160 non-numeric prefix - `C-u M-x gnus', in short.")
162 (defvar gnus-nntp-server nil
163 "*The name of the host running the NNTP server.
164 This variable is semi-obsolete. Use the `gnus-select-method'
167 (defvar gnus-startup-file
"~/.newsrc"
168 "*Your `.newsrc' file.
169 `.newsrc-SERVER' will be used instead if that exists.")
171 (defvar gnus-init-file
"~/.gnus"
172 "*Your Gnus elisp startup file.
173 If a file with the .el or .elc suffixes exist, it will be read
176 (defvar gnus-group-faq-directory
177 "/ftp@mirrors.aol.com:/pub/rtfm/usenet/"
178 "*Directory where the group FAQs are stored.
179 This will most commonly be on a remote machine, and the file will be
182 Note that Gnus uses an aol machine as the default directory. If this
183 feels fundamentally unclean, just think of it as a way to finally get
184 something of value back from them.
186 If the default site is too slow, try one of these:
188 North America: ftp.uu.net /usenet/news.answers
189 mirrors.aol.com /pub/rtfm/usenet
190 ftp.seas.gwu.edu /pub/rtfm
191 rtfm.mit.edu /pub/usenet/news.answers
192 Europe: ftp.uni-paderborn.de /pub/FAQ
193 ftp.Germany.EU.net /pub/newsarchive/news.answers
194 ftp.sunet.se /pub/usenet
195 Asia: nctuccca.edu.tw /USENET/FAQ
196 hwarang.postech.ac.kr /pub/usenet/news.answers
197 ftp.hk.super.net /mirror/faqs")
199 (defvar gnus-group-archive-directory
200 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/"
201 "*The address of the (ding) archives.")
203 (defvar gnus-group-recent-archive-directory
204 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/"
205 "*The address of the most recent (ding) articles.")
207 (defvar gnus-default-subscribed-newsgroups nil
208 "*This variable lists what newsgroups should be subscribed the first time Gnus is used.
209 It should be a list of strings.
210 If it is `t', Gnus will not do anything special the first time it is
211 started; it'll just use the normal newsgroups subscription methods.")
213 (defvar gnus-use-cross-reference t
214 "*Non-nil means that cross referenced articles will be marked as read.
215 If nil, ignore cross references. If t, mark articles as read in
216 subscribed newsgroups. If neither t nor nil, mark as read in all
219 (defvar gnus-use-dribble-file t
220 "*Non-nil means that Gnus will use a dribble file to store user updates.
221 If Emacs should crash without saving the .newsrc files, complete
222 information can be restored from the dribble file.")
224 (defvar gnus-asynchronous nil
225 "*If non-nil, Gnus will supply backends with data needed for async article fetching.")
227 (defvar gnus-asynchronous-article-function nil
228 "*Function for picking articles to pre-fetch, possibly.")
230 (defvar gnus-score-file-single-match-alist nil
231 "*Alist mapping regexps to lists of score files.
232 Each element of this alist should be of the form
233 (\"REGEXP\" [ \"SCORE-FILE-1\" ] [ \"SCORE-FILE-2\" ] ... )
235 If the name of a group is matched by REGEXP, the corresponding scorefiles
236 will be used for that group.
237 The first match found is used, subsequent matching entries are ignored (to
238 use multiple matches, see gnus-score-file-multiple-match-alist).
240 These score files are loaded in addition to any files returned by
241 gnus-score-find-score-files-function (which see).")
243 (defvar gnus-score-file-multiple-match-alist nil
244 "*Alist mapping regexps to lists of score files.
245 Each element of this alist should be of the form
246 (\"REGEXP\" [ \"SCORE-FILE-1\" ] [ \"SCORE-FILE-2\" ] ... )
248 If the name of a group is matched by REGEXP, the corresponding scorefiles
249 will be used for that group.
250 If multiple REGEXPs match a group, the score files corresponding to each
251 match will be used (for only one match to be used, see
252 gnus-score-file-single-match-alist).
254 These score files are loaded in addition to any files returned by
255 gnus-score-find-score-files-function (which see).")
258 (defvar gnus-score-file-suffix
"SCORE"
259 "*Suffix of the score files.")
261 (defvar gnus-adaptive-file-suffix
"ADAPT"
262 "*Suffix of the adaptive score files.")
264 (defvar gnus-score-find-score-files-function
'gnus-score-find-bnews
265 "*Function used to find score files.
266 The function will be called with the group name as the argument, and
267 should return a list of score files to apply to that group. The score
268 files do not actually have to exist.
270 Predefined values are:
272 gnus-score-find-single: Only apply the group's own score file.
273 gnus-score-find-hierarchical: Also apply score files from parent groups.
274 gnus-score-find-bnews: Apply score files whose names matches.
276 See the documentation to these functions for more information.
278 This variable can also be a list of functions to be called. Each
279 function should either return a list of score files, or a list of
282 (defvar gnus-score-interactive-default-score
1000
283 "*Scoring commands will raise/lower the score with this number as the default.")
285 (defvar gnus-large-newsgroup
200
286 "*The number of articles which indicates a large newsgroup.
287 If the number of articles in a newsgroup is greater than this value,
288 confirmation is required for selecting the newsgroup.")
290 ;; Suggested by Andrew Eskilsson <pi92ae@lelle.pt.hk-r.se>.
291 (defvar gnus-no-groups-message
"No news is horrible news"
292 "*Message displayed by Gnus when no groups are available.")
294 (defvar gnus-use-long-file-name
(not (memq system-type
'(usg-unix-v xenix
)))
295 "*Non-nil means that the default name of a file to save articles in is the group name.
296 If it's nil, the directory form of the group name is used instead.
298 If this variable is a list, and the list contains the element
299 `not-score', long file names will not be used for score files; if it
300 contains the element `not-save', long file names will not be used for
301 saving; and if it contains the element `not-kill', long file names
302 will not be used for kill files.")
304 (defvar gnus-article-save-directory
(or (getenv "SAVEDIR") "~/News/")
305 "*Name of the directory articles will be saved in (default \"~/News\").
306 Initialized from the SAVEDIR environment variable.")
308 (defvar gnus-kill-files-directory
(or (getenv "SAVEDIR") "~/News/")
309 "*Name of the directory where kill files will be stored (default \"~/News\").
310 Initialized from the SAVEDIR environment variable.")
312 (defvar gnus-default-article-saver
'gnus-summary-save-in-rmail
313 "*A function to save articles in your favorite format.
314 The function must be interactively callable (in other words, it must
315 be an Emacs command).
317 Gnus provides the following functions:
319 * gnus-summary-save-in-rmail (Rmail format)
320 * gnus-summary-save-in-mail (Unix mail format)
321 * gnus-summary-save-in-folder (MH folder)
322 * gnus-summary-save-in-file (article format).
323 * gnus-summary-save-in-vm (use VM's folder format).")
325 (defvar gnus-rmail-save-name
(function gnus-plain-save-name
)
326 "*A function generating a file name to save articles in Rmail format.
327 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
329 (defvar gnus-mail-save-name
(function gnus-plain-save-name
)
330 "*A function generating a file name to save articles in Unix mail format.
331 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
333 (defvar gnus-folder-save-name
(function gnus-folder-save-name
)
334 "*A function generating a file name to save articles in MH folder.
335 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER.")
337 (defvar gnus-file-save-name
(function gnus-numeric-save-name
)
338 "*A function generating a file name to save articles in article format.
339 The function is called with NEWSGROUP, HEADERS, and optional
342 (defvar gnus-split-methods nil
343 "*Variable used to suggest where articles are to be saved.
344 The syntax of this variable is the same as `nnmail-split-methods'.
346 For instance, if you would like to save articles related to Gnus in
347 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
348 you could set this variable to something like:
350 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
351 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))")
353 (defvar gnus-save-score nil
354 "*If non-nil, save group scoring info.")
356 (defvar gnus-use-adaptive-scoring nil
357 "*If non-nil, use some adaptive scoring scheme.")
359 (defvar gnus-use-cache nil
360 "*If non-nil, Gnus will cache (some) articles locally.")
362 (defvar gnus-use-scoring t
363 "*If non-nil, enable scoring.")
365 (defvar gnus-fetch-old-headers nil
366 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
367 If an unread article in the group refers to an older, already read (or
368 just marked as read) article, the old article will not normally be
369 displayed in the Summary buffer. If this variable is non-nil, Gnus
370 will attempt to grab the headers to the old articles, and thereby
371 build complete threads. If it has the value `some', only enough
372 headers to connect otherwise loose threads will be displayed.
374 The server has to support XOVER for any of this to work.")
377 ;(defvar gnus-visual t
378 ; "*If non-nil, will do various highlighting.
379 ;If nil, no mouse highlights (or any other highlights) will be
380 ;performed. This might speed up Gnus some when generating large group
381 ;and summary buffers.")
383 (defvar gnus-novice-user t
384 "*Non-nil means that you are a usenet novice.
385 If non-nil, verbose messages may be displayed and confirmations may be
388 (defvar gnus-expert-user nil
389 "*Non-nil means that you will never be asked for confirmation about anything.
390 And that means *anything*.")
392 (defvar gnus-verbose
7
393 "*Integer that says how verbose Gnus should be.
394 The higher the number, the more messages Gnus will flash to say what
395 it's doing. At zero, Gnus will be totally mute; at five, Gnus will
396 display most important messages; and at ten, Gnus will keep on
397 jabbering all the time.")
399 (defvar gnus-keep-same-level nil
400 "*Non-nil means that the next newsgroup after the current will be on the same level.
401 When you type, for instance, `n' after reading the last article in the
402 current newsgroup, you will go to the next newsgroup. If this variable
403 is nil, the next newsgroup will be the next from the group
405 If this variable is non-nil, Gnus will either put you in the
406 next newsgroup with the same level, or, if no such newsgroup is
407 available, the next newsgroup with the lowest possible level higher
408 than the current level.
409 If this variable is `best', Gnus will make the next newsgroup the one
410 with the best level.")
412 (defvar gnus-summary-make-false-root
'adopt
413 "*nil means that Gnus won't gather loose threads.
414 If the root of a thread has expired or been read in a previous
415 session, the information necessary to build a complete thread has been
416 lost. Instead of having many small sub-threads from this original thread
417 scattered all over the summary buffer, Gnus can gather them.
419 If non-nil, Gnus will try to gather all loose sub-threads from an
420 original thread into one large thread.
422 If this variable is non-nil, it should be one of `none', `adopt',
425 If this variable is `none', Gnus will not make a false root, but just
426 present the sub-threads after another.
427 If this variable is `dummy', Gnus will create a dummy root that will
428 have all the sub-threads as children.
429 If this variable is `adopt', Gnus will make one of the \"children\"
430 the parent and mark all the step-children as such.
431 If this variable is `empty', the \"children\" are printed with empty
432 subject fields. (Or rather, they will be printed with a string
433 given by the `gnus-summary-same-subject' variable.)")
435 (defvar gnus-summary-gather-subject-limit nil
436 "*Maximum length of subject comparisons when gathering loose threads.
437 Use nil to compare full subjects. Setting this variable to a low
438 number will help gather threads that have been corrupted by
439 newsreaders chopping off subject lines, but it might also mean that
440 unrelated articles that have subject that happen to begin with the
441 same few characters will be incorrectly gathered.
443 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
444 comparing subjects.")
446 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
447 (defvar gnus-summary-same-subject
""
448 "*String indicating that the current article has the same subject as the previous.
449 This variable will only be used if the value of
450 `gnus-summary-make-false-root' is `empty'.")
452 (defvar gnus-summary-goto-unread t
453 "*If non-nil, marking commands will go to the next unread article.")
455 (defvar gnus-group-goto-unread t
456 "*If non-nil, movement commands will go to the next unread and subscribed group.")
458 (defvar gnus-check-new-newsgroups t
459 "*Non-nil means that Gnus will add new newsgroups at startup.
460 If this variable is `ask-server', Gnus will ask the server for new
461 groups since the last time it checked. This means that the killed list
462 is no longer necessary, so you could set `gnus-save-killed-list' to
465 A variant is to have this variable be a list of select methods. Gnus
466 will then use the `ask-server' method on all these select methods to
467 query for new groups from all those servers.
470 (setq gnus-check-new-newsgroups
471 '((nntp \"some.server\") (nntp \"other.server\")))
473 If this variable is nil, then you have to tell Gnus explicitly to
474 check for new newsgroups with \\<gnus-group-mode-map>\\[gnus-find-new-newsgroups].")
476 (defvar gnus-check-bogus-newsgroups nil
477 "*Non-nil means that Gnus will check and remove bogus newsgroup at startup.
478 If this variable is nil, then you have to tell Gnus explicitly to
479 check for bogus newsgroups with \\<gnus-group-mode-map>\\[gnus-group-check-bogus-groups].")
481 (defvar gnus-read-active-file t
482 "*Non-nil means that Gnus will read the entire active file at startup.
483 If this variable is nil, Gnus will only know about the groups in your
486 If this variable is `some', Gnus will try to only read the relevant
487 parts of the active file from the server. Not all servers support
488 this, and it might be quite slow with other servers, but this should
489 generally be faster than both the t and nil value.
491 If you set this variable to nil or `some', you probably still want to
492 be told about new newsgroups that arrive. To do that, set
493 `gnus-check-new-newsgroups' to `ask-server'. This may not work
494 properly with all servers.")
496 (defvar gnus-level-subscribed
5
497 "*Groups with levels less than or equal to this variable are subscribed.")
499 (defvar gnus-level-unsubscribed
7
500 "*Groups with levels less than or equal to this variable are unsubscribed.
501 Groups with levels less than `gnus-level-subscribed', which should be
502 less than this variable, are subscribed.")
504 (defvar gnus-level-zombie
8
505 "*Groups with this level are zombie groups.")
507 (defvar gnus-level-killed
9
508 "*Groups with this level are killed.")
510 (defvar gnus-level-default-subscribed
3
511 "*New subscribed groups will be subscribed at this level.")
513 (defvar gnus-level-default-unsubscribed
6
514 "*New unsubscribed groups will be unsubscribed at this level.")
516 (defvar gnus-activate-foreign-newsgroups
4
517 "*If nil, Gnus will not check foreign newsgroups at startup.
518 If it is non-nil, it should be a number between one and nine. Foreign
519 newsgroups that have a level lower or equal to this number will be
520 activated on startup. For instance, if you want to active all
521 subscribed newsgroups, but not the rest, you'd set this variable to
522 `gnus-level-subscribed'.
524 If you subscribe to lots of newsgroups from different servers, startup
525 might take a while. By setting this variable to nil, you'll save time,
526 but you won't be told how many unread articles there are in the
529 (defvar gnus-save-newsrc-file t
530 "*Non-nil means that Gnus will save the `.newsrc' file.
531 Gnus always saves its own startup file, which is called
532 \".newsrc.eld\". The file called \".newsrc\" is in a format that can
533 be readily understood by other newsreaders. If you don't plan on
534 using other newsreaders, set this variable to nil to save some time on
537 (defvar gnus-save-killed-list t
538 "*If non-nil, save the list of killed groups to the startup file.
539 This will save both time (when starting and quitting) and space (both
540 memory and disk), but it will also mean that Gnus has no record of
541 which groups are new and which are old, so the automatic new
542 newsgroups subscription methods become meaningless. You should always
543 set `gnus-check-new-newsgroups' to `ask-server' or nil if you set this
546 (defvar gnus-interactive-catchup t
547 "*If non-nil, require your confirmation when catching up a group.")
549 (defvar gnus-interactive-post t
550 "*If non-nil, group name will be asked for when posting.")
552 (defvar gnus-interactive-exit t
553 "*If non-nil, require your confirmation when exiting Gnus.")
555 (defvar gnus-kill-killed t
556 "*If non-nil, Gnus will apply kill files to already killed articles.
557 If it is nil, Gnus will never apply kill files to articles that have
558 already been through the scoring process, which might very well save lots
561 (defvar gnus-extract-address-components
'gnus-extract-address-components
562 "*Function for extracting address components from a From header.
563 Two pre-defined function exist: `gnus-extract-address-components',
564 which is the default, quite fast, and too simplistic solution, and
565 `mail-extract-address-components', which works much better, but is
568 (defvar gnus-summary-default-score
0
569 "*Default article score level.
570 If this variable is nil, scoring will be disabled.")
572 (defvar gnus-summary-zcore-fuzz
0
573 "*Fuzziness factor for the zcore in the summary buffer.
574 Articles with scores closer than this to `gnus-summary-default-score'
575 will not be marked.")
577 (defvar gnus-simplify-subject-fuzzy-regexp nil
578 "*Regular expression that will be removed from subject strings if
579 fuzzy subject simplification is selected.")
581 (defvar gnus-group-default-list-level gnus-level-subscribed
582 "*Default listing level.
583 Ignored if `gnus-group-use-permanent-levels' is non-nil.")
585 (defvar gnus-group-use-permanent-levels nil
586 "*If non-nil, once you set a level, Gnus will use this level.")
588 (defvar gnus-show-mime nil
589 "*If non-nil, do mime processing of articles.
590 The articles will simply be fed to the function given by
591 `gnus-show-mime-method'.")
593 (defvar gnus-strict-mime t
594 "*If nil, decode MIME header even if there is not Mime-Version field.")
596 (defvar gnus-show-mime-method
(function metamail-buffer
)
597 "*Function to process a MIME message.
598 The function is called from the article buffer.")
600 (defvar gnus-show-threads t
601 "*If non-nil, display threads in summary mode.")
603 (defvar gnus-thread-hide-subtree nil
604 "*If non-nil, hide all threads initially.
605 If threads are hidden, you have to run the command
606 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
607 to expose hidden threads.")
609 (defvar gnus-thread-hide-killed t
610 "*If non-nil, hide killed threads automatically.")
612 (defvar gnus-thread-ignore-subject nil
613 "*If non-nil, ignore subjects and do all threading based on the Reference header.
614 If nil, which is the default, articles that have different subjects
615 from their parents will start separate threads.")
617 (defvar gnus-thread-indent-level
4
618 "*Number that says how much each sub-thread should be indented.")
620 (defvar gnus-ignored-newsgroups
621 (purecopy (mapconcat 'identity
622 '("^to\\." ; not "real" groups
623 "^[0-9. \t]+ " ; all digits in name
624 "[][\"#'()]" ; bogus characters
627 "*A regexp to match uninteresting newsgroups in the active file.
628 Any lines in the active file matching this regular expression are
629 removed from the newsgroup list before anything else is done to it,
630 thus making them effectively non-existent.")
632 (defvar gnus-ignored-headers
633 "^Path:\\|^Posting-Version:\\|^Article-I.D.:\\|^Expires:\\|^Date-Received:\\|^References:\\|^Control:\\|^Xref:\\|^Lines:\\|^Posted:\\|^Relay-Version:\\|^Message-ID:\\|^Nf-ID:\\|^Nf-From:\\|^Approved:\\|^Sender:\\|^Received:\\|^Mail-from:"
634 "*All headers that match this regexp will be hidden.
635 If `gnus-visible-headers' is non-nil, this variable will be ignored.")
637 (defvar gnus-visible-headers
"^From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^Cc:"
638 "*All headers that do not match this regexp will be hidden.
639 If this variable is non-nil, `gnus-ignored-headers' will be ignored.")
641 (defvar gnus-sorted-header-list
642 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:" "^To:"
643 "^Cc:" "^Date:" "^Organization:")
644 "*This variable is a list of regular expressions.
645 If it is non-nil, headers that match the regular expressions will
646 be placed first in the article buffer in the sequence specified by
649 (defvar gnus-show-all-headers nil
650 "*If non-nil, don't hide any headers.")
652 (defvar gnus-save-all-headers t
653 "*If non-nil, don't remove any headers before saving.")
655 (defvar gnus-inhibit-startup-message nil
656 "*If non-nil, the startup message will not be displayed.")
658 (defvar gnus-signature-separator
"^-- *$"
659 "Regexp matching signature separator.")
661 (defvar gnus-auto-extend-newsgroup t
662 "*If non-nil, extend newsgroup forward and backward when requested.")
664 (defvar gnus-auto-select-first t
665 "*If non-nil, select the first unread article when entering a group.
666 If you want to prevent automatic selection of the first unread article
667 in some newsgroups, set the variable to nil in
668 `gnus-select-group-hook'.")
670 (defvar gnus-auto-select-next t
671 "*If non-nil, offer to go to the next group from the end of the previous.
672 If the value is t and the next newsgroup is empty, Gnus will exit
673 summary mode and go back to group mode. If the value is neither nil
674 nor t, Gnus will select the following unread newsgroup. In
675 particular, if the value is the symbol `quietly', the next unread
676 newsgroup will be selected without any confirmations.")
678 (defvar gnus-auto-select-same nil
679 "*If non-nil, select the next article with the same subject.")
681 (defvar gnus-summary-check-current nil
682 "*If non-nil, consider the current article when moving.
683 The \"unread\" movement commands will stay on the same line if the
684 current article is unread.")
686 (defvar gnus-auto-center-summary t
687 "*If non-nil, always center the current summary buffer.")
689 (defvar gnus-break-pages t
690 "*If non-nil, do page breaking on articles.
691 The page delimiter is specified by the `gnus-page-delimiter'
694 (defvar gnus-page-delimiter
"^\^L"
695 "*Regexp describing what to use as article page delimiters.
696 The default value is \"^\^L\", which is a form linefeed at the
697 beginning of a line.")
699 (defvar gnus-use-full-window t
700 "*If non-nil, use the entire Emacs screen.")
702 (defvar gnus-window-configuration nil
703 "Obsolete variable. See `gnus-buffer-configuration'.")
705 (defvar gnus-buffer-configuration
706 '((group ([group
1.0 point
]
707 (if gnus-carpal
[group-carpal
4])))
708 (summary ([summary
1.0 point
]
709 (if gnus-carpal
[summary-carpal
4])))
710 (article ([summary
0.25 point
]
711 (if gnus-carpal
[summary-carpal
4])
713 (server ([server
1.0 point
]
714 (if gnus-carpal
[server-carpal
2])))
715 (browse ([browse
1.0 point
]
716 (if gnus-carpal
[browse-carpal
2])))
717 (group-mail ([mail
1.0 point
]))
718 (summary-mail ([mail
1.0 point
]))
719 (summary-reply ([article
0.5]
721 (info ([nil
1.0 point
]))
722 (summary-faq ([summary
0.25]
724 (edit-group ([group
0.5]
725 [edit-group
1.0 point
]))
726 (edit-server ([server
0.5]
727 [edit-server
1.0 point
]))
728 (edit-score ([summary
0.25]
729 [edit-score
1.0 point
]))
730 (post ([post
1.0 point
]))
731 (reply ([article
0.5]
733 (mail-forward ([mail
1.0 point
]))
734 (post-forward ([post
1.0 point
]))
735 (reply-yank ([mail
1.0 point
]))
736 (followup ([article
0.5]
738 (followup-yank ([post
1.0 point
])))
739 "Window configuration for all possible Gnus buffers.
740 This variable is a list of lists. Each of these lists has a NAME and
741 a RULE. The NAMEs are common-sense names like `group', which names a
742 rule used when displaying the group buffer; `summary', which names a
743 rule for what happens when you enter a group and do not display an
744 article buffer; and so on. See the value of this variable for a
745 complete list of NAMEs.
747 Each RULE is a list of vectors. The first element in this vector is
748 the name of the buffer to be displayed; the second element is the
749 percentage of the screen this buffer is to occupy (a number in the
750 0.0-0.99 range); the optional third element is `point', which should
751 be present to denote which buffer point is to go to after making this
752 buffer configuration.")
754 (defvar gnus-window-to-buffer
755 '((group . gnus-group-buffer
)
756 (summary . gnus-summary-buffer
)
757 (article . gnus-article-buffer
)
758 (server . gnus-server-buffer
)
759 (browse .
"*Gnus Browse Server*")
760 (edit-group . gnus-group-edit-buffer
)
761 (edit-server . gnus-server-edit-buffer
)
762 (group-carpal . gnus-carpal-group-buffer
)
763 (summary-carpal . gnus-carpal-summary-buffer
)
764 (server-carpal . gnus-carpal-server-buffer
)
765 (browse-carpal . gnus-carpal-browse-buffer
)
766 (edit-score . gnus-score-edit-buffer
)
767 (mail . gnus-mail-buffer
)
768 (post . gnus-post-news-buffer
)
769 (faq . gnus-faq-buffer
))
770 "Mapping from short symbols to buffer names or buffer variables.")
772 (defvar gnus-carpal nil
773 "*If non-nil, display clickable icons.")
775 (defvar gnus-subscribe-newsgroup-method
'gnus-subscribe-zombies
776 "*Function called with a group name when new group is detected.
777 A few pre-made functions are supplied: `gnus-subscribe-randomly'
778 inserts new groups at the beginning of the list of groups;
779 `gnus-subscribe-alphabetically' inserts new groups in strict
780 alphabetic order; `gnus-subscribe-hierarchically' inserts new groups
781 in hierarchical newsgroup order; `gnus-subscribe-interactively' asks
784 ;; Suggested by a bug report by Hallvard B Furuseth.
785 ;; <h.b.furuseth@usit.uio.no>.
786 (defvar gnus-subscribe-options-newsgroup-method
787 (function gnus-subscribe-alphabetically
)
788 "*This function is called to subscribe newsgroups mentioned on \"options -n\" lines.
789 If, for instance, you want to subscribe to all newsgroups in the
790 \"no\" and \"alt\" hierarchies, you'd put the following in your
793 options -n no.all alt.all
795 Gnus will the subscribe all new newsgroups in these hierarchies with
796 the subscription method in this variable.")
798 (defvar gnus-subscribe-hierarchical-interactive nil
799 "*If non-nil, Gnus will offer to subscribe hierarchically.
800 When a new hierarchy appears, Gnus will ask the user:
802 'alt.binaries': Do you want to subscribe to this hierarchy? ([d]ys):
804 If the user pressed `d', Gnus will descend the hierarchy, `y' will
805 subscribe to all newsgroups in the hierarchy and `s' will skip this
806 hierarchy in its entirety.")
808 (defvar gnus-group-sort-function
'gnus-group-sort-by-alphabet
809 "*Function used for sorting the group buffer.
810 This function will be called with group info entries as the arguments
811 for the groups to be sorted. Pre-made functions include
812 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-unread' and
813 `gnus-group-sort-by-level'")
815 ;; Mark variables suggested by Thomas Michanek
816 ;; <Thomas.Michanek@telelogic.se>.
817 (defvar gnus-unread-mark ?
818 "*Mark used for unread articles.")
819 (defvar gnus-ticked-mark ?
!
820 "*Mark used for ticked articles.")
821 (defvar gnus-dormant-mark ??
822 "*Mark used for dormant articles.")
823 (defvar gnus-del-mark ?r
824 "*Mark used for del'd articles.")
825 (defvar gnus-read-mark ?R
826 "*Mark used for read articles.")
827 (defvar gnus-expirable-mark ?E
828 "*Mark used for expirable articles.")
829 (defvar gnus-killed-mark ?K
830 "*Mark used for killed articles.")
831 (defvar gnus-kill-file-mark ?X
832 "*Mark used for articles killed by kill files.")
833 (defvar gnus-low-score-mark ?Y
834 "*Mark used for articles with a low score.")
835 (defvar gnus-catchup-mark ?C
836 "*Mark used for articles that are caught up.")
837 (defvar gnus-replied-mark ?A
838 "*Mark used for articles that have been replied to.")
839 (defvar gnus-process-mark ?
#
841 (defvar gnus-ancient-mark ?O
842 "*Mark used for ancient articles.")
843 (defvar gnus-canceled-mark ?G
844 "*Mark used for canceled articles.")
845 (defvar gnus-score-over-mark ?
+
846 "*Score mark used for articles with high scores.")
847 (defvar gnus-score-below-mark ?-
848 "*Score mark used for articles with low scores.")
849 (defvar gnus-empty-thread-mark ?
850 "*There is no thread under the article.")
851 (defvar gnus-not-empty-thread-mark ?
=
852 "*There is a thread under the article.")
853 (defvar gnus-dummy-mark ?Z
854 "*This is a dummy article.")
856 (defvar gnus-view-pseudo-asynchronously nil
857 "*If non-nil, Gnus will view pseudo-articles asynchronously.")
859 (defvar gnus-view-pseudos nil
860 "*If `automatic', pseudo-articles will be viewed automatically.
861 If `not-confirm', pseudos will be viewed automatically, and the user
862 will not be asked to confirm the command.")
864 (defvar gnus-view-pseudos-separately t
865 "*If non-nil, one pseudo-article will be created for each file to be viewed.
866 If nil, all files that use the same viewing command will be given as a
867 list of parameters to that command.")
869 (defvar gnus-group-line-format
"%M%S%p%5y: %(%g%)\n"
870 "*Format of group lines.
871 It works along the same lines as a normal formatting string,
872 with some simple extensions.
874 %M Only marked articles (character, \"*\" or \" \")
875 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
876 %L Level of subscribedness (integer)
877 %N Number of unread articles (integer)
878 %I Number of dormant articles (integer)
879 %i Number of ticked and dormant (integer)
880 %T Number of ticked articles (integer)
881 %R Number of read articles (integer)
882 %t Total number of articles (integer)
883 %y Number of unread, unticked articles (integer)
884 %G Group name (string)
885 %g Qualified group name (string)
886 %D Group description (string)
887 %s Select method (string)
888 %o Moderated group (char, \"m\")
889 %p Process mark (char)
890 %O Moderated group (string, \"(m)\" or \"\")
891 %n Select from where (string)
892 %z A string that look like `<%s:%n>' if a foreign select method is used
893 %u User defined specifier. The next character in the format string should
894 be a letter. Gnus will call the function gnus-user-format-function-X,
895 where X is the letter following %u. The function will be passed the
896 current header as argument. The function should return a string, which
897 will be inserted into the buffer just like information from any other
900 Text between %( and %) will be highlighted with `gnus-mouse-face' when
901 the mouse point move inside the area. There can only be one such area.
903 Note that this format specification is not always respected. For
904 reasons of efficiency, when listing killed groups, this specification
905 is ignored altogether. If the spec is changed considerably, your
906 output may end up looking strange when listing both alive and killed
909 If you use %o or %O, reading the active file will be slower and quite
910 a bit of extra memory will be used. %D will also worsen performance.
911 Also note that if you change the format specification to include any
912 of these specs, you must probably re-start Gnus to see them go into
915 (defvar gnus-summary-line-format
"%U%R%z%I%(%[%4L: %-20,20n%]%) %s\n"
916 "*The format specification of the lines in the summary buffer.
918 It works along the same lines as a normal formatting string,
919 with some simple extensions.
921 %N Article number, left padded with spaces (string)
923 %s Subject if it is at the root of a thread, and \"\" otherwise (string)
924 %n Name of the poster (string)
925 %a Extracted name of the poster (string)
926 %A Extracted address of the poster (string)
927 %F Contents of the From: header (string)
928 %x Contents of the Xref: header (string)
929 %D Date of the article (string)
930 %d Date of the article (string) in DD-MMM format
931 %M Message-id of the article (string)
932 %r References of the article (string)
933 %c Number of characters in the article (integer)
934 %L Number of lines in the article (integer)
935 %I Indentation based on thread level (a string of spaces)
936 %T A string with two possible values: 80 spaces if the article
937 is on thread level two or larger and 0 spaces on level one
938 %R \"A\" if this article has been replied to, \" \" otherwise (character)
939 %U Status of this article (character, \"R\", \"K\", \"-\" or \" \")
940 %[ Opening bracket (character, \"[\" or \"<\")
941 %] Closing bracket (character, \"]\" or \">\")
942 %> Spaces of length thread-level (string)
943 %< Spaces of length (- 20 thread-level) (string)
944 %i Article score (number)
945 %z Article zcore (character)
946 %t Number of articles under the current thread (number).
947 %e Whether the thread is empty or not (character).
948 %u User defined specifier. The next character in the format string should
949 be a letter. Gnus will call the function gnus-user-format-function-X,
950 where X is the letter following %u. The function will be passed the
951 current header as argument. The function should return a string, which
952 will be inserted into the summary just like information from any other
955 Text between %( and %) will be highlighted with `gnus-mouse-face'
956 when the mouse point is placed inside the area. There can only be one
959 The %U (status), %R (replied) and %z (zcore) specs have to be handled
960 with care. For reasons of efficiency, Gnus will compute what column
961 these characters will end up in, and \"hard-code\" that. This means that
962 it is illegal to have these specs after a variable-length spec. Well,
963 you might not be arrested, but your summary buffer will look strange,
966 The smart choice is to have these specs as for to the left as
969 This restriction may disappear in later versions of Gnus.")
971 (defvar gnus-summary-dummy-line-format
"* : : %S\n"
972 "*The format specification for the dummy roots in the summary buffer.
973 It works along the same lines as a normal formatting string,
974 with some simple extensions.
978 (defvar gnus-summary-mode-line-format
"Gnus: %b [%A] %Z"
979 "*The format specification for the summary mode line.")
981 (defvar gnus-article-mode-line-format
"Gnus: %b %S"
982 "*The format specification for the article mode line.")
984 (defvar gnus-group-mode-line-format
"Gnus: %b {%M:%S} "
985 "*The format specification for the group mode line.")
987 (defvar gnus-valid-select-methods
988 '(("nntp" post address prompt-address
)
990 ("nnvirtual" none virtual prompt-address
)
991 ("nnmbox" mail respool
)
992 ("nnml" mail respool
)
993 ("nnmh" mail respool
)
994 ("nndir" none prompt-address address
)
995 ("nneething" none prompt-address
)
997 ("nndoc" none prompt-address
)
998 ("nnbabyl" mail respool
)
999 ("nnkiboze" post virtual
)
1001 ("nnfolder" mail respool
))
1002 "An alist of valid select methods.
1003 The first element of each list lists should be a string with the name
1004 of the select method. The other elements may be be the category of
1005 this method (ie. `post', `mail', `none' or whatever) or other
1006 properties that this method has (like being respoolable).
1007 If you implement a new select method, all you should have to change is
1008 this variable. I think.")
1010 (defvar gnus-updated-mode-lines
'(group article summary
)
1011 "*List of buffers that should update their mode lines.
1012 The list may contain the symbols `group', `article' and `summary'. If
1013 the corresponding symbol is present, Gnus will keep that mode line
1014 updated with information that may be pertinent.
1015 If this variable is nil, screen refresh may be quicker.")
1017 ;; Added by Keinonen Kari <kk85613@cs.tut.fi>.
1018 (defvar gnus-mode-non-string-length nil
1019 "*Max length of mode-line non-string contents.
1020 If this is nil, Gnus will take space as is needed, leaving the rest
1021 of the modeline intact.")
1024 ;(defvar gnus-mouse-face 'highlight
1025 ; "*Face used for mouse highlighting in Gnus.
1026 ;No mouse highlights will be done if `gnus-visual' is nil.")
1028 (defvar gnus-summary-mark-below nil
1029 "*Mark all articles with a score below this variable as read.
1030 This variable is local to each summary buffer and usually set by the
1033 (defvar gnus-thread-sort-functions
'(gnus-thread-sort-by-number)
1034 "*List of functions used for sorting threads in the summary buffer.
1035 By default, threads are sorted by article number.
1037 Each function takes two threads and return non-nil if the first thread
1038 should be sorted before the other. If you use more than one function,
1039 the primary sort function should be the last.
1041 Ready-mady functions include `gnus-thread-sort-by-number',
1042 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
1043 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
1044 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').")
1046 (defvar gnus-thread-score-function
'+
1047 "*Function used for calculating the total score of a thread.
1049 The function is called with the scores of the article and each
1050 subthread and should then return the score of the thread.
1052 Some functions you can use are `+', `max', or `min'.")
1054 (defvar gnus-options-subscribe nil
1055 "*All new groups matching this regexp will be subscribed unconditionally.
1056 Note that this variable deals only with new newsgroups. This variable
1057 does not affect old newsgroups.")
1059 (defvar gnus-options-not-subscribe nil
1060 "*All new groups matching this regexp will be ignored.
1061 Note that this variable deals only with new newsgroups. This variable
1062 does not affect old (already subscribed) newsgroups.")
1064 (defvar gnus-auto-expirable-newsgroups nil
1065 "*Groups in which to automatically mark read articles as expirable.
1066 If non-nil, this should be a regexp that should match all groups in
1067 which to perform auto-expiry. This only makes sense for mail groups.")
1069 (defvar gnus-hidden-properties
'(invisible t intangible t
)
1070 "Property list to use for hiding text.")
1072 (defvar gnus-modtime-botch nil
1073 "*Non-nil means .newsrc should be deleted prior to save. Its use is
1074 due to the bogus appearance that .newsrc was modified on disc.")
1078 (defvar gnus-group-mode-hook nil
1079 "*A hook for Gnus group mode.")
1081 (defvar gnus-summary-mode-hook nil
1082 "*A hook for Gnus summary mode.
1083 This hook is run before any variables are set in the summary buffer.")
1085 (defvar gnus-article-mode-hook nil
1086 "*A hook for Gnus article mode.")
1088 (defun gnus-summary-prepare-exit-hook nil
1089 "*A hook called when preparing to exit from the summary buffer.
1090 It calls `gnus-summary-expire-articles' by default.")
1091 (add-hook 'gnus-summary-prepare-exit-hook
'gnus-summary-expire-articles
)
1093 (defun gnus-summary-exit-hook nil
1094 "*A hook called on exit from the summary buffer.")
1096 (defvar gnus-open-server-hook nil
1097 "*A hook called just before opening connection to the news server.")
1099 (defvar gnus-load-hook nil
1100 "*A hook run while Gnus is loaded.")
1102 (defvar gnus-startup-hook nil
1103 "*A hook called at startup.
1104 This hook is called after Gnus is connected to the NNTP server.")
1106 (defvar gnus-get-new-news-hook nil
1107 "*A hook run just before Gnus checks for new news.")
1109 (defvar gnus-group-prepare-function
'gnus-group-prepare-flat
1110 "*A function that is called to generate the group buffer.
1111 The function is called with three arguments: The first is a number;
1112 all group with a level less or equal to that number should be listed,
1113 if the second is non-nil, empty groups should also be displayed. If
1114 the third is non-nil, it is a number. No groups with a level lower
1115 than this number should be displayed.
1117 The only current function implemented is `gnus-group-prepare-flat'.")
1119 (defvar gnus-group-prepare-hook nil
1120 "*A hook called after the group buffer has been generated.
1121 If you want to modify the group buffer, you can use this hook.")
1123 (defvar gnus-summary-prepare-hook nil
1124 "*A hook called after the summary buffer has been generated.
1125 If you want to modify the summary buffer, you can use this hook.")
1127 (defvar gnus-article-prepare-hook nil
1128 "*A hook called after an article has been prepared in the article buffer.
1129 If you want to run a special decoding program like nkf, use this hook.")
1131 ;(defvar gnus-article-display-hook nil
1132 ; "*A hook called after the article is displayed in the article buffer.
1133 ;The hook is designed to change the contents of the article
1134 ;buffer. Typical functions that this hook may contain are
1135 ;`gnus-article-hide-headers' (hide selected headers),
1136 ;`gnus-article-maybe-highlight' (perform fancy article highlighting),
1137 ;`gnus-article-hide-signature' (hide signature) and
1138 ;`gnus-article-treat-overstrike' (turn \"^H_\" into bold characters).")
1139 ;(add-hook 'gnus-article-display-hook 'gnus-article-hide-headers-if-wanted)
1140 ;(add-hook 'gnus-article-display-hook 'gnus-article-treat-overstrike)
1141 ;(add-hook 'gnus-article-display-hook 'gnus-article-maybe-highlight)
1143 (defvar gnus-article-x-face-command
1144 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | xv -quit -"
1145 "String or function to be executed to display an X-Face header.
1146 If it is a string, the command will be executed in a sub-shell
1147 asynchronously. The compressed face will be piped to this command.")
1149 (defvar gnus-article-x-face-too-ugly nil
1150 "Regexp matching posters whose face shouldn't be shown automatically.")
1152 (defvar gnus-select-group-hook nil
1153 "*A hook called when a newsgroup is selected.
1155 If you'd like to simplify subjects like the
1156 `gnus-summary-next-same-subject' command does, you can use the
1159 (setq gnus-select-group-hook
1162 (mapcar (lambda (header)
1163 (mail-header-set-subject
1165 (gnus-simplify-subject
1166 (mail-header-subject header) 're-only)))
1167 gnus-newsgroup-headers))))")
1169 (defvar gnus-select-article-hook
1170 '(gnus-summary-show-thread)
1171 "*A hook called when an article is selected.
1172 The default hook shows conversation thread subtrees of the selected
1173 article automatically using `gnus-summary-show-thread'.")
1175 (defvar gnus-apply-kill-hook
'(gnus-apply-kill-file)
1176 "*A hook called to apply kill files to a group.
1177 This hook is intended to apply a kill file to the selected newsgroup.
1178 The function `gnus-apply-kill-file' is called by default.
1180 Since a general kill file is too heavy to use only for a few
1181 newsgroups, I recommend you to use a lighter hook function. For
1182 example, if you'd like to apply a kill file to articles which contains
1183 a string `rmgroup' in subject in newsgroup `control', you can use the
1186 (setq gnus-apply-kill-hook
1189 (cond ((string-match \"control\" gnus-newsgroup-name)
1190 (gnus-kill \"Subject\" \"rmgroup\")
1191 (gnus-expunge \"X\"))))))")
1193 (defvar gnus-visual-mark-article-hook
1194 (list 'gnus-highlight-selected-summary
)
1195 "*Hook run after selecting an article in the summary buffer.
1196 It is meant to be used for highlighting the article in some way. It
1197 is not run if `gnus-visual' is nil.")
1199 (defun gnus-parse-headers-hook nil
1200 "*A hook called before parsing the headers.")
1202 (defvar gnus-exit-group-hook nil
1203 "*A hook called when exiting (not quitting) summary mode.")
1205 (defvar gnus-suspend-gnus-hook nil
1206 "*A hook called when suspending (not exiting) Gnus.")
1208 (defvar gnus-exit-gnus-hook nil
1209 "*A hook called when exiting Gnus.")
1211 (defvar gnus-save-newsrc-hook nil
1212 "*A hook called when saving the newsrc file.")
1214 (defvar gnus-summary-update-hook
1215 (list 'gnus-summary-highlight-line
)
1216 "*A hook called when a summary line is changed.
1217 The hook will not be called if `gnus-visual' is nil.
1219 The default function `gnus-summary-highlight-line' will
1220 highlight the line according to the `gnus-summary-highlight'
1223 (defvar gnus-mark-article-hook
(list 'gnus-summary-mark-unread-as-read
)
1224 "*A hook called when an article is selected for the first time.
1225 The hook is intended to mark an article as read (or unread)
1226 automatically when it is selected.")
1228 ;; Remove any hilit infestation.
1229 (add-hook 'gnus-startup-hook
1231 (remove-hook 'gnus-summary-prepare-hook
1232 'hilit-rehighlight-buffer-quietly
)
1233 (remove-hook 'gnus-summary-prepare-hook
'hilit-install-line-hooks
)
1234 (setq gnus-mark-article-hook
'(gnus-summary-mark-unread-as-read))
1235 (remove-hook 'gnus-article-prepare-hook
1236 'hilit-rehighlight-buffer-quietly
)))
1240 ;; Internal variables
1242 ;; Avoid highlighting in kill files.
1243 (defvar gnus-summary-inhibit-highlight nil
)
1244 (defvar gnus-newsgroup-selected-overlay nil
)
1246 (defvar gnus-article-mode-map nil
)
1247 (defvar gnus-dribble-buffer nil
)
1248 (defvar gnus-headers-retrieved-by nil
)
1249 (defvar gnus-article-reply nil
)
1250 (defvar gnus-override-method nil
)
1251 (defvar gnus-article-check-size nil
)
1253 (defvar gnus-current-score-file nil
)
1254 (defvar gnus-internal-global-score-files nil
)
1255 (defvar gnus-score-file-list nil
)
1256 (defvar gnus-scores-exclude-files nil
)
1258 (defvar gnus-current-move-group nil
)
1260 (defvar gnus-newsgroup-dependencies nil
)
1261 (defvar gnus-newsgroup-threads nil
)
1262 (defvar gnus-newsgroup-async nil
)
1263 (defconst gnus-group-edit-buffer
"*Gnus edit newsgroup*")
1265 (defvar gnus-newsgroup-adaptive nil
)
1267 (defvar gnus-summary-display-table nil
)
1269 (defconst gnus-group-line-format-alist
1270 (list (list ?M
'marked ?c
)
1271 (list ?S
'subscribed ?c
)
1273 (list ?N
'number ?s
)
1274 (list ?I
'number-of-dormant ?d
)
1275 (list ?T
'number-of-ticked ?d
)
1276 (list ?R
'number-of-read ?s
)
1277 (list ?t
'number-total ?d
)
1278 (list ?y
'number-of-unread-unticked ?s
)
1279 (list ?i
'number-of-ticked-and-dormant ?d
)
1281 (list ?G
'qualified-group ?s
)
1282 (list ?D
'newsgroup-description ?s
)
1283 (list ?o
'moderated ?c
)
1284 (list ?O
'moderated-string ?s
)
1285 (list ?p
'process-marked ?c
)
1286 (list ?s
'news-server ?s
)
1287 (list ?n
'news-method ?s
)
1288 (list ?z
'news-method-string ?s
)
1289 (list ?u
'user-defined ?s
)))
1291 (defconst gnus-summary-line-format-alist
1292 (list (list ?N
'number ?d
)
1293 (list ?S
'subject ?s
)
1294 (list ?s
'subject-or-nil ?s
)
1296 (list ?A
'(car (cdr (funcall gnus-extract-address-components from
)))
1298 (list ?a
'(or (car (funcall gnus-extract-address-components from
))
1301 (list ?x
(macroexpand '(mail-header-xref header
)) ?s
)
1302 (list ?D
(macroexpand '(mail-header-date header
)) ?s
)
1303 (list ?d
'(gnus-dd-mmm (mail-header-date header
)) ?s
)
1304 (list ?M
(macroexpand '(mail-header-id header
)) ?s
)
1305 (list ?r
(macroexpand '(mail-header-references header
)) ?s
)
1306 (list ?c
'(or (mail-header-chars header
) 0) ?d
)
1308 (list ?I
'indentation ?s
)
1309 (list ?T
'(if (= level
0) "" (make-string (frame-width) ?
)) ?s
)
1310 (list ?R
'replied ?c
)
1311 (list ?\
[ 'opening-bracket ?c
)
1312 (list ?\
] 'closing-bracket ?c
)
1313 (list ?\
> '(make-string level ?
) ?s
)
1314 (list ?\
< '(make-string (max 0 (- 20 level
)) ?
) ?s
)
1316 (list ?z
'score-char ?c
)
1317 (list ?U
'unread ?c
)
1318 (list ?t
'(gnus-summary-number-of-articles-in-thread
1319 (and (boundp 'thread
) (car thread
)))
1321 (list ?e
'(gnus-summary-number-of-articles-in-thread
1322 (and (boundp 'thread
) (car thread
)) t
)
1324 (list ?u
'user-defined ?s
))
1325 "An alist of format specifications that can appear in summary lines,
1326 and what variables they correspond with, along with the type of the
1327 variable (string, integer, character, etc).")
1329 (defconst gnus-summary-dummy-line-format-alist
1330 (list (list ?S
'subject ?s
)
1331 (list ?N
'number ?d
)
1332 (list ?u
'user-defined ?s
)))
1334 (defconst gnus-summary-mode-line-format-alist
1335 (list (list ?G
'group-name ?s
)
1336 (list ?g
'(gnus-short-group-name group-name
) ?s
)
1337 (list ?A
'article-number ?d
)
1338 (list ?Z
'unread-and-unselected ?s
)
1339 (list ?V
'gnus-version ?s
)
1340 (list ?U
'unread ?d
)
1341 (list ?S
'subject ?s
)
1342 (list ?e
'unselected ?d
)
1343 (list ?u
'user-defined ?s
)
1344 (list ?b
'buffer-name ?s
)
1345 (list ?s
'(gnus-current-score-file-nondirectory) ?s
)))
1347 (defconst gnus-group-mode-line-format-alist
1348 (list (list ?S
'news-server ?s
)
1349 (list ?M
'news-method ?s
)
1350 (list ?b
'(buffer-name) ?s
)
1351 (list ?u
'user-defined ?s
)))
1353 (defvar gnus-have-read-active-file nil
)
1355 (defconst gnus-maintainer
1356 "gnus-bug@ifi.uio.no (The Gnus Bugfixing Girls + Boys)"
1357 "The mail address of the Gnus maintainers.")
1359 (defconst gnus-version
"Gnus v5.1"
1360 "Version number for this version of Gnus.")
1362 (defvar gnus-info-nodes
1363 '((gnus-group-mode "(gnus)The Group Buffer")
1364 (gnus-summary-mode "(gnus)The Summary Buffer")
1365 (gnus-article-mode "(gnus)The Article Buffer"))
1366 "Assoc list of major modes and related Info nodes.")
1368 (defvar gnus-group-buffer
"*Group*")
1369 (defvar gnus-summary-buffer
"*Summary*")
1370 (defvar gnus-article-buffer
"*Article*")
1371 (defvar gnus-server-buffer
"*Server*")
1373 (defvar gnus-work-buffer
" *gnus work*")
1375 (defvar gnus-buffer-list nil
1376 "Gnus buffers that should be killed on exit.")
1378 (defvar gnus-server-alist nil
1379 "List of available servers.")
1381 (defvar gnus-variable-list
1382 '(gnus-newsrc-options gnus-newsrc-options-n
1383 gnus-newsrc-last-checked-date
1384 gnus-newsrc-alist gnus-server-alist
1385 gnus-killed-list gnus-zombie-list
)
1386 "Gnus variables saved in the quick startup file.")
1388 (defvar gnus-overload-functions
1389 '((news-inews gnus-inews-news
"rnewspost"))
1390 "Functions overloaded by gnus.
1391 It is a list of `(original overload &optional file)'.")
1393 (defvar gnus-newsrc-options nil
1394 "Options line in the .newsrc file.")
1396 (defvar gnus-newsrc-options-n nil
1397 "List of regexps representing groups to be subscribed/ignored unconditionally.")
1399 (defvar gnus-newsrc-last-checked-date nil
1400 "Date Gnus last asked server for new newsgroups.")
1402 (defvar gnus-newsrc-alist nil
1403 "Assoc list of read articles.
1404 gnus-newsrc-hashtb should be kept so that both hold the same information.")
1406 (defvar gnus-newsrc-hashtb nil
1407 "Hashtable of gnus-newsrc-alist.")
1409 (defvar gnus-killed-list nil
1410 "List of killed newsgroups.")
1412 (defvar gnus-killed-hashtb nil
1413 "Hash table equivalent of gnus-killed-list.")
1415 (defvar gnus-zombie-list nil
1416 "List of almost dead newsgroups.")
1418 (defvar gnus-description-hashtb nil
1419 "Descriptions of newsgroups.")
1421 (defvar gnus-list-of-killed-groups nil
1422 "List of newsgroups that have recently been killed by the user.")
1424 (defvar gnus-active-hashtb nil
1425 "Hashtable of active articles.")
1427 (defvar gnus-moderated-list nil
1428 "List of moderated newsgroups.")
1430 (defvar gnus-group-marked nil
)
1432 (defvar gnus-current-startup-file nil
1433 "Startup file for the current host.")
1435 (defvar gnus-last-search-regexp nil
1436 "Default regexp for article search command.")
1438 (defvar gnus-last-shell-command nil
1439 "Default shell command on article.")
1441 (defvar gnus-current-select-method nil
1442 "The current method for selecting a newsgroup.")
1444 (defvar gnus-group-list-mode nil
)
1446 (defvar gnus-article-internal-prepare-hook nil
)
1448 (defvar gnus-newsgroup-name nil
)
1449 (defvar gnus-newsgroup-begin nil
)
1450 (defvar gnus-newsgroup-end nil
)
1451 (defvar gnus-newsgroup-last-rmail nil
)
1452 (defvar gnus-newsgroup-last-mail nil
)
1453 (defvar gnus-newsgroup-last-folder nil
)
1454 (defvar gnus-newsgroup-last-file nil
)
1455 (defvar gnus-newsgroup-auto-expire nil
)
1456 (defvar gnus-newsgroup-active nil
)
1458 (defvar gnus-newsgroup-unreads nil
1459 "List of unread articles in the current newsgroup.")
1461 (defvar gnus-newsgroup-unselected nil
1462 "List of unselected unread articles in the current newsgroup.")
1464 (defvar gnus-newsgroup-reads nil
1465 "Alist of read articles and article marks in the current newsgroup.")
1467 (defvar gnus-newsgroup-marked nil
1468 "List of ticked articles in the current newsgroup (a subset of unread art).")
1470 (defvar gnus-newsgroup-killed nil
1471 "List of ranges of articles that have been through the scoring process.")
1473 (defvar gnus-newsgroup-kill-headers nil
)
1475 (defvar gnus-newsgroup-replied nil
1476 "List of articles that have been replied to in the current newsgroup.")
1478 (defvar gnus-newsgroup-expirable nil
1479 "List of articles in the current newsgroup that can be expired.")
1481 (defvar gnus-newsgroup-processable nil
1482 "List of articles in the current newsgroup that can be processed.")
1484 (defvar gnus-newsgroup-bookmarks nil
1485 "List of articles in the current newsgroup that have bookmarks.")
1487 (defvar gnus-newsgroup-dormant nil
1488 "List of dormant articles in the current newsgroup.")
1490 (defvar gnus-newsgroup-scored nil
1491 "List of scored articles in the current newsgroup.")
1493 (defvar gnus-newsgroup-headers nil
1494 "List of article headers in the current newsgroup.")
1495 (defvar gnus-newsgroup-headers-hashtb-by-number nil
)
1497 (defvar gnus-newsgroup-ancient nil
1498 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1500 (defvar gnus-current-article nil
)
1501 (defvar gnus-article-current nil
)
1502 (defvar gnus-current-headers nil
)
1503 (defvar gnus-have-all-headers nil
)
1504 (defvar gnus-last-article nil
)
1505 (defvar gnus-newsgroup-history nil
)
1506 (defvar gnus-current-kill-article nil
)
1508 ;; Save window configuration.
1509 (defvar gnus-prev-winconf nil
)
1512 (defvar gnus-summary-line-format-spec nil
)
1513 (defvar gnus-summary-dummy-line-format-spec nil
)
1514 (defvar gnus-group-line-format-spec nil
)
1515 (defvar gnus-summary-mode-line-format-spec nil
)
1516 (defvar gnus-article-mode-line-format-spec nil
)
1517 (defvar gnus-group-mode-line-format-spec nil
)
1518 (defvar gnus-summary-mark-positions nil
)
1519 (defvar gnus-group-mark-positions nil
)
1521 (defvar gnus-summary-expunge-below nil
)
1522 (defvar gnus-reffed-article-number nil
)
1524 ; Let the byte-compiler know that we know about this variable.
1525 (defvar rmail-default-rmail-file
)
1527 (defvar gnus-cache-removable-articles nil
)
1529 (defconst gnus-summary-local-variables
1530 '(gnus-newsgroup-name
1531 gnus-newsgroup-begin gnus-newsgroup-end
1532 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1533 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1534 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1535 gnus-newsgroup-unselected gnus-newsgroup-marked
1536 gnus-newsgroup-reads
1537 gnus-newsgroup-replied gnus-newsgroup-expirable
1538 gnus-newsgroup-processable gnus-newsgroup-killed
1539 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1540 gnus-newsgroup-headers gnus-newsgroup-headers-hashtb-by-number
1541 gnus-current-article gnus-current-headers gnus-have-all-headers
1542 gnus-last-article gnus-article-internal-prepare-hook
1543 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1544 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1545 gnus-newsgroup-threads gnus-newsgroup-async
1546 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
1547 gnus-summary-mark-below gnus-newsgroup-active gnus-scores-exclude-files
1548 gnus-newsgroup-history gnus-newsgroup-ancient
1549 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring
)
1550 gnus-cache-removable-articles
)
1551 "Variables that are buffer-local to the summary buffers.")
1553 (defconst gnus-bug-message
1554 "Sending a bug report to the Gnus Towers.
1555 ========================================
1557 The buffer below is a mail buffer. When you press `C-c C-c', it will
1558 be sent to the Gnus Bug Exterminators.
1560 At the bottom of the buffer you'll see lots of variable settings.
1561 Please do not delete those. They will tell the Bug People what your
1562 environment is, so that it will be easier to locate the bugs.
1564 If you have found a bug that makes Emacs go \"beep\", set
1565 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
1566 and include the backtrace in your bug report.
1568 Please describe the bug in annoying, painstaking detail.
1570 Thank you for your help in stamping out bugs.
1573 ;;; End of variables.
1575 ;; Define some autoload functions Gnus might use.
1579 (autoload 'metamail-buffer
"metamail")
1580 (autoload 'Info-goto-node
"info")
1581 (autoload 'hexl-hex-string-to-integer
"hexl")
1583 (autoload 'pp-to-string
"pp")
1584 (autoload 'pp-eval-expression
"pp")
1585 (autoload 'mail-extract-address-components
"mail-extr")
1587 (autoload 'nnmail-split-fancy
"nnmail")
1588 (autoload 'nnvirtual-catchup-group
"nnvirtual")
1591 (autoload 'timezone-make-date-arpa-standard
"timezone")
1592 (autoload 'timezone-fix-time
"timezone")
1593 (autoload 'timezone-make-sortable-date
"timezone")
1594 (autoload 'timezone-make-time-string
"timezone")
1597 (autoload 'mail-position-on-field
"sendmail")
1598 (autoload 'mail-setup
"sendmail")
1599 (autoload 'rmail-output
"rmailout")
1600 (autoload 'news-mail-other-window
"rnewspost")
1601 (autoload 'news-reply-yank-original
"rnewspost")
1602 (autoload 'news-caesar-buffer-body
"rnewspost")
1603 (autoload 'rmail-insert-rmail-file-header
"rmail")
1604 (autoload 'rmail-count-new-messages
"rmail")
1605 (autoload 'rmail-show-message
"rmail")
1608 ;;(autoload 'gnus-group-brew-soup "gnus-soup" nil t)
1609 ;;(autoload 'gnus-brew-soup "gnus-soup" nil t)
1610 ;;(autoload 'gnus-soup-add-article "gnus-soup" nil t)
1611 ;;(autoload 'gnus-soup-send-replies "gnus-soup" nil t)
1612 ;;(autoload 'gnus-soup-save-areas "gnus-soup" nil t)
1613 ;;(autoload 'gnus-soup-pack-packet "gnus-soup" nil t)
1614 ;;(autoload 'nnsoup-pack-replies "nnsoup" nil t)
1617 (autoload 'gnus-mail-reply-using-mhe
"gnus-mh")
1618 (autoload 'gnus-mail-forward-using-mhe
"gnus-mh")
1619 (autoload 'gnus-mail-other-window-using-mhe
"gnus-mh")
1620 (autoload 'gnus-summary-save-in-folder
"gnus-mh" nil t
)
1621 (autoload 'gnus-summary-save-article-folder
"gnus-mh")
1622 (autoload 'gnus-Folder-save-name
"gnus-mh")
1623 (autoload 'gnus-folder-save-name
"gnus-mh")
1626 (autoload 'gnus-group-make-menu-bar
"gnus-vis")
1627 (autoload 'gnus-summary-make-menu-bar
"gnus-vis")
1628 (autoload 'gnus-server-make-menu-bar
"gnus-vis")
1629 (autoload 'gnus-article-make-menu-bar
"gnus-vis")
1630 (autoload 'gnus-browse-make-menu-bar
"gnus-vis")
1631 (autoload 'gnus-highlight-selected-summary
"gnus-vis")
1632 (autoload 'gnus-summary-highlight-line
"gnus-vis")
1633 (autoload 'gnus-carpal-setup-buffer
"gnus-vis")
1636 (autoload 'gnus-article-push-button
"gnus-vis" nil t
)
1637 (autoload 'gnus-article-press-button
"gnus-vis" nil t
)
1638 (autoload 'gnus-article-highlight
"gnus-vis" nil t
)
1639 (autoload 'gnus-article-highlight-some
"gnus-vis" nil t
)
1640 (autoload 'gnus-article-hide
"gnus-vis" nil t
)
1641 (autoload 'gnus-article-hide-signature
"gnus-vis" nil t
)
1642 (autoload 'gnus-article-highlight-headers
"gnus-vis" nil t
)
1643 (autoload 'gnus-article-highlight-signature
"gnus-vis" nil t
)
1644 (autoload 'gnus-article-add-buttons
"gnus-vis" nil t
)
1645 (autoload 'gnus-article-next-button
"gnus-vis" nil t
)
1646 (autoload 'gnus-article-add-button
"gnus-vis")
1649 (autoload 'gnus-article-highlight-citation
"gnus-cite" nil t
)
1650 (autoload 'gnus-article-hide-citation-maybe
"gnus-cite" nil t
)
1651 (autoload 'gnus-article-hide-citation
"gnus-cite" nil t
)
1654 (autoload 'gnus-kill
"gnus-kill")
1655 (autoload 'gnus-apply-kill-file-internal
"gnus-kill")
1656 (autoload 'gnus-kill-file-edit-file
"gnus-kill")
1657 (autoload 'gnus-kill-file-raise-followups-to-author
"gnus-kill")
1658 (autoload 'gnus-execute
"gnus-kill")
1659 (autoload 'gnus-expunge
"gnus-kill")
1662 (autoload 'gnus-cache-possibly-enter-article
"gnus-cache")
1663 (autoload 'gnus-cache-save-buffers
"gnus-cache")
1664 (autoload 'gnus-cache-possibly-remove-articles
"gnus-cache")
1665 (autoload 'gnus-cache-request-article
"gnus-cache")
1666 (autoload 'gnus-cache-retrieve-headers
"gnus-cache")
1667 (autoload 'gnus-cache-possibly-alter-active
"gnus-cache")
1668 (autoload 'gnus-jog-cache
"gnus-cache" nil t
)
1669 (autoload 'gnus-cache-enter-remove-article
"gnus-cache")
1672 (autoload 'gnus-summary-increase-score
"gnus-score" nil t
)
1673 (autoload 'gnus-summary-lower-score
"gnus-score" nil t
)
1674 (autoload 'gnus-summary-score-map
"gnus-score" nil nil
'keymap
)
1675 (autoload 'gnus-score-save
"gnus-score")
1676 (autoload 'gnus-score-headers
"gnus-score")
1677 (autoload 'gnus-current-score-file-nondirectory
"gnus-score")
1678 (autoload 'gnus-score-adaptive
"gnus-score")
1679 (autoload 'gnus-score-remove-lines-adaptive
"gnus-score")
1680 (autoload 'gnus-score-find-trace
"gnus-score")
1683 (autoload 'gnus-score-customize
"gnus-edit" nil t
)
1686 (autoload 'gnus-uu-extract-map
"gnus-uu" nil nil
'keymap
)
1687 (autoload 'gnus-uu-mark-map
"gnus-uu" nil nil
'keymap
)
1688 (autoload 'gnus-uu-digest-mail-forward
"gnus-uu" nil t
)
1689 (autoload 'gnus-uu-digest-post-forward
"gnus-uu" nil t
)
1690 (autoload 'gnus-uu-mark-series
"gnus-uu" nil t
)
1691 (autoload 'gnus-uu-mark-region
"gnus-uu" nil t
)
1692 (autoload 'gnus-uu-mark-by-regexp
"gnus-uu" nil t
)
1693 (autoload 'gnus-uu-mark-all
"gnus-uu" nil t
)
1694 (autoload 'gnus-uu-mark-sparse
"gnus-uu" nil t
)
1695 (autoload 'gnus-uu-mark-thread
"gnus-uu" nil t
)
1696 (autoload 'gnus-uu-decode-uu
"gnus-uu" nil t
)
1697 (autoload 'gnus-uu-decode-uu-and-save
"gnus-uu" nil t
)
1698 (autoload 'gnus-uu-decode-unshar
"gnus-uu" nil t
)
1699 (autoload 'gnus-uu-decode-unshar-and-save
"gnus-uu" nil t
)
1700 (autoload 'gnus-uu-decode-save
"gnus-uu" nil t
)
1701 (autoload 'gnus-uu-decode-binhex
"gnus-uu" nil t
)
1702 (autoload 'gnus-uu-decode-uu-view
"gnus-uu" nil t
)
1703 (autoload 'gnus-uu-decode-uu-and-save-view
"gnus-uu" nil t
)
1704 (autoload 'gnus-uu-decode-unshar-view
"gnus-uu" nil t
)
1705 (autoload 'gnus-uu-decode-unshar-and-save-view
"gnus-uu" nil t
)
1706 (autoload 'gnus-uu-decode-save-view
"gnus-uu" nil t
)
1707 (autoload 'gnus-uu-decode-binhex-view
"gnus-uu" nil t
)
1710 (autoload 'gnus-summary-send-map
"gnus-msg" nil nil
'keymap
)
1711 (autoload 'gnus-group-post-news
"gnus-msg" nil t
)
1712 (autoload 'gnus-group-mail
"gnus-msg" nil t
)
1713 (autoload 'gnus-summary-post-news
"gnus-msg" nil t
)
1714 (autoload 'gnus-summary-followup
"gnus-msg" nil t
)
1715 (autoload 'gnus-summary-followup-with-original
"gnus-msg" nil t
)
1716 (autoload 'gnus-summary-followup-and-reply
"gnus-msg" nil t
)
1717 (autoload 'gnus-summary-followup-and-reply-with-original
"gnus-msg" nil t
)
1718 (autoload 'gnus-summary-cancel-article
"gnus-msg" nil t
)
1719 (autoload 'gnus-summary-supersede-article
"gnus-msg" nil t
)
1720 (autoload 'gnus-post-news
"gnus-msg" nil t
)
1721 (autoload 'gnus-inews-news
"gnus-msg" nil t
)
1722 (autoload 'gnus-cancel-news
"gnus-msg" nil t
)
1723 (autoload 'gnus-summary-reply
"gnus-msg" nil t
)
1724 (autoload 'gnus-summary-reply-with-original
"gnus-msg" nil t
)
1725 (autoload 'gnus-summary-mail-forward
"gnus-msg" nil t
)
1726 (autoload 'gnus-summary-mail-other-window
"gnus-msg" nil t
)
1727 (autoload 'gnus-mail-reply-using-mail
"gnus-msg")
1728 (autoload 'gnus-mail-yank-original
"gnus-msg")
1729 (autoload 'gnus-mail-send-and-exit
"gnus-msg")
1730 (autoload 'gnus-mail-forward-using-mail
"gnus-msg")
1731 (autoload 'gnus-mail-other-window-using-mail
"gnus-msg")
1732 (autoload 'gnus-article-mail
"gnus-msg")
1733 (autoload 'gnus-bug
"gnus-msg" nil t
)
1736 (autoload 'gnus-summary-save-in-vm
"gnus-vm" nil t
)
1737 (autoload 'gnus-summary-save-article-vm
"gnus-vm" nil t
)
1738 (autoload 'gnus-mail-forward-using-vm
"gnus-vm")
1739 (autoload 'gnus-mail-reply-using-vm
"gnus-vm")
1740 (autoload 'gnus-mail-other-window-using-vm
"gnus-vm" nil t
)
1741 (autoload 'gnus-yank-article
"gnus-vm" nil t
)
1747 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
1748 ;; If you want the cursor to go somewhere else, set these two
1749 ;; functions in some startup hook to whatever you want.
1750 (defalias 'gnus-summary-position-cursor
'gnus-goto-colon
)
1751 (defalias 'gnus-group-position-cursor
'gnus-goto-colon
)
1753 ;;; Various macros and substs.
1755 (defmacro gnus-eval-in-buffer-window
(buffer &rest forms
)
1756 "Pop to BUFFER, evaluate FORMS, and then returns to original window."
1757 (` (let ((GnusStartBufferWindow (selected-window)))
1760 (pop-to-buffer (, buffer
))
1762 (select-window GnusStartBufferWindow
)))))
1764 (defmacro gnus-gethash
(string hashtable
)
1765 "Get hash value of STRING in HASHTABLE."
1766 ;;(` (symbol-value (abbrev-symbol (, string) (, hashtable))))
1767 ;;(` (abbrev-expansion (, string) (, hashtable)))
1768 (` (symbol-value (intern-soft (, string
) (, hashtable
)))))
1770 (defmacro gnus-sethash
(string value hashtable
)
1771 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
1772 ;; We cannot use define-abbrev since it only accepts string as value.
1773 ;; (set (intern string hashtable) value))
1774 (` (set (intern (, string
) (, hashtable
)) (, value
))))
1776 (defsubst gnus-buffer-substring
(beg end
)
1777 (buffer-substring (match-beginning beg
) (match-end end
)))
1779 ;; modified by MORIOKA Tomohiko <morioka@jaist.ac.jp>
1780 ;; function `substring' might cut on a middle of multi-octet
1782 (defun gnus-truncate-string (str width
)
1783 (substring str
0 width
))
1785 ;; Added by Geoffrey T. Dairiki <dairiki@u.washington.edu>. A safe way
1786 ;; to limit the length of a string. This function is necessary since
1787 ;; `(substr "abc" 0 30)' pukes with "Args out of range".
1788 (defsubst gnus-limit-string
(str width
)
1789 (if (> (length str
) width
)
1790 (substring str
0 width
)
1793 (defsubst gnus-simplify-subject-re
(subject)
1794 "Remove \"Re:\" from subject lines."
1795 (let ((case-fold-search t
))
1796 (if (string-match "^re: *" subject
)
1797 (substring subject
(match-end 0))
1800 (defsubst gnus-goto-char
(point)
1801 (and point
(goto-char point
)))
1803 (defmacro gnus-buffer-exists-p
(buffer)
1805 (funcall (if (stringp (, buffer
)) 'get-buffer
'buffer-name
)
1808 (defmacro gnus-kill-buffer
(buffer)
1809 (` (if (gnus-buffer-exists-p (, buffer
))
1810 (kill-buffer (, buffer
)))))
1812 (defsubst gnus-point-at-bol
()
1813 "Return point at the beginning of line."
1820 (defsubst gnus-point-at-eol
()
1821 "Return point at the beginning of line."
1828 ;; Delete the current line (and the next N lines.);
1829 (defmacro gnus-delete-line
(&optional n
)
1830 (` (delete-region (progn (beginning-of-line) (point))
1831 (progn (forward-line (, (or n
1))) (point)))))
1833 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
1834 (defvar gnus-init-inhibit nil
)
1835 (defun gnus-read-init-file (&optional inhibit-next
)
1836 (if gnus-init-inhibit
1837 (setq gnus-init-inhibit nil
)
1838 (setq gnus-init-inhibit inhibit-next
)
1840 (or (and (file-exists-p gnus-init-file
)
1841 ;; Don't try to load a directory.
1842 (not (file-directory-p gnus-init-file
)))
1843 (file-exists-p (concat gnus-init-file
".el"))
1844 (file-exists-p (concat gnus-init-file
".elc")))
1845 (load gnus-init-file nil t
))))
1847 ;;; Load the user startup file.
1848 ;; (eval '(gnus-read-init-file 'inhibit))
1850 ;;; Load the compatibility functions.
1857 ;;; Gnus Utility Functions
1860 (defun gnus-extract-address-components (from)
1862 ;; First find the address - the thing with the @ in it. This may
1863 ;; not be accurate in mail addresses, but does the trick most of
1864 ;; the time in news messages.
1865 (if (string-match "\\b[^@ \t<>]+[!@][^@ \t<>]+\\b" from
)
1866 (setq address
(substring from
(match-beginning 0) (match-end 0))))
1867 ;; Then we check whether the "name <address>" format is used.
1869 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>
1870 ;; Linear white space is not required.
1871 (string-match (concat "[ \t]*<" (regexp-quote address
) ">") from
)
1872 (and (setq name
(substring from
0 (match-beginning 0)))
1873 ;; Strip any quotes from the name.
1874 (string-match "\".*\"" name
)
1875 (setq name
(substring name
1 (1- (match-end 0))))))
1876 ;; If not, then "address (name)" is used.
1878 (and (string-match "(.+)" from
)
1879 (setq name
(substring from
(1+ (match-beginning 0))
1880 (1- (match-end 0)))))
1881 (and (string-match "()" from
)
1882 (setq name address
))
1883 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>.
1884 ;; XOVER might not support folded From headers.
1885 (and (string-match "(.*" from
)
1886 (setq name
(substring from
(1+ (match-beginning 0))
1888 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
1889 (list (or name from
) (or address from
))))
1891 (defun gnus-fetch-field (field)
1892 "Return the value of the header FIELD of current article."
1895 (let ((case-fold-search t
))
1896 (gnus-narrow-to-headers)
1897 (mail-fetch-field field
)))))
1899 (defun gnus-goto-colon ()
1901 (search-forward ":" (gnus-point-at-eol) t
))
1903 (defun gnus-narrow-to-headers ()
1907 (goto-char (point-min))
1908 (if (search-forward "\n\n" nil t
)
1912 (defvar gnus-old-specs nil
)
1914 (defun gnus-update-format-specifications ()
1915 (gnus-make-thread-indent-array)
1917 (let ((formats '(summary summary-dummy group
1918 summary-mode group-mode article-mode
))
1919 old-format new-format
)
1921 (setq new-format
(symbol-value
1922 (intern (format "gnus-%s-line-format" (car formats
)))))
1923 (or (and (setq old-format
(cdr (assq (car formats
) gnus-old-specs
)))
1924 (equal old-format new-format
))
1925 (set (intern (format "gnus-%s-line-format-spec" (car formats
)))
1929 (intern (format "gnus-%s-line-format-alist"
1930 (if (eq (car formats
) 'article-mode
)
1931 'summary-mode
(car formats
))))))))
1932 (setq gnus-old-specs
(cons (cons (car formats
) new-format
)
1933 (delq (car formats
) gnus-old-specs
)))
1934 (setq formats
(cdr formats
))))
1936 (gnus-update-group-mark-positions)
1937 (gnus-update-summary-mark-positions)
1939 (if (and (string-match "%D" gnus-group-line-format
)
1940 (not gnus-description-hashtb
)
1941 gnus-read-active-file
)
1942 (gnus-read-all-descriptions-files)))
1944 (defun gnus-update-summary-mark-positions ()
1946 (let ((gnus-replied-mark 129)
1947 (gnus-score-below-mark 130)
1948 (gnus-score-over-mark 130)
1951 (gnus-set-work-buffer)
1952 (gnus-summary-insert-line
1953 nil
[0 "" "" "" "" "" 0 0 ""] 0 nil
128 t nil
"" nil
1)
1954 (goto-char (point-min))
1955 (setq pos
(list (cons 'unread
(and (search-forward "\200" nil t
)
1957 (goto-char (point-min))
1958 (setq pos
(cons (cons 'replied
(and (search-forward "\201" nil t
)
1959 (- (point) 2))) pos
))
1960 (goto-char (point-min))
1961 (setq pos
(cons (cons 'score
(and (search-forward "\202" nil t
)
1962 (- (point) 2))) pos
))
1963 (setq gnus-summary-mark-positions pos
))))
1965 (defun gnus-update-group-mark-positions ()
1967 (let ((gnus-process-mark 128)
1968 (gnus-group-marked '("dummy.group")))
1969 (gnus-sethash "dummy.group" '(0 .
0) gnus-active-hashtb
)
1970 (gnus-set-work-buffer)
1971 (gnus-group-insert-group-line nil
"dummy.group" 0 nil
0 nil
)
1972 (goto-char (point-min))
1973 (setq gnus-group-mark-positions
1974 (list (cons 'process
(and (search-forward "\200" nil t
)
1975 (- (point) 2))))))))
1977 (defun gnus-mouse-face-function (form)
1978 (` (let ((string (, form
)))
1979 (put-text-property 0 (length string
) 'mouse-face gnus-mouse-face string
)
1982 (defun gnus-max-width-function (el max-width
)
1983 (or (numberp max-width
) (signal 'wrong-type-argument
'(numberp max-width
)))
1984 (` (let* ((val (eval (, el
)))
1985 (valstr (if (numberp val
)
1986 (int-to-string val
) val
)))
1987 (if (> (length valstr
) (, max-width
))
1988 (substring valstr
0 (, max-width
))
1991 (defun gnus-parse-format (format spec-alist
)
1992 ;; This function parses the FORMAT string with the help of the
1993 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
1994 ;; string. If the FORMAT string contains the specifiers %( and %)
1995 ;; the text between them will have the mouse-face text property.
1996 (if (string-match "\\`\\(.*\\)%(\\(.*\\)%)\\(.*\n?\\)\\'" format
)
1997 (if (and gnus-visual gnus-mouse-face
)
1998 (let ((pre (substring format
(match-beginning 1) (match-end 1)))
1999 (button (substring format
(match-beginning 2) (match-end 2)))
2000 (post (substring format
(match-beginning 3) (match-end 3))))
2002 (gnus-parse-simple-format pre spec-alist
)
2003 (gnus-mouse-face-function
2004 (gnus-parse-simple-format button spec-alist
))
2005 (gnus-parse-simple-format post spec-alist
)))
2006 (gnus-parse-simple-format
2007 (concat (substring format
(match-beginning 1) (match-end 1))
2008 (substring format
(match-beginning 2) (match-end 2))
2009 (substring format
(match-beginning 3) (match-end 3)))
2011 (gnus-parse-simple-format format spec-alist
)))
2013 (defun gnus-parse-simple-format (format spec-alist
)
2014 ;; This function parses the FORMAT string with the help of the
2015 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
2016 ;; string. The list will consist of the symbol `format', a format
2017 ;; specification string, and a list of forms depending on the
2020 spec flist fstring newspec elem beg
)
2022 (gnus-set-work-buffer)
2024 (goto-char (point-min))
2025 (while (re-search-forward "%[-0-9]*\\(,[0-9]+\\)?\\([^0-9]\\)\\(.\\)?" nil t
)
2026 (setq spec
(string-to-char (buffer-substring (match-beginning 2)
2028 ;; First check if there are any specs that look anything like
2029 ;; "%12,12A", ie. with a "max width specification". These have
2030 ;; to be treated specially.
2031 (if (setq beg
(match-beginning 1))
2034 (buffer-substring (1+ (match-beginning 1)) (match-end 1))))
2036 (setq beg
(match-beginning 2)))
2037 ;; Find the specification from `spec-alist'.
2038 (if (not (setq elem
(cdr (assq spec spec-alist
))))
2039 (setq elem
'("*" ?s
)))
2040 ;; Treat user defined format specifiers specially
2041 (and (eq (car elem
) 'user-defined
)
2044 (list (intern (concat "gnus-user-format-function-"
2050 (delete-region (match-beginning 3) (match-end 3)))
2051 (if (not (zerop max-width
))
2052 (let ((el (car elem
)))
2053 (cond ((= (car (cdr elem
)) ?c
)
2054 (setq el
(list 'char-to-string el
)))
2055 ((= (car (cdr elem
)) ?d
)
2056 (numberp el
) (setq el
(list 'int-to-string el
))))
2057 (setq flist
(cons (gnus-max-width-function el max-width
)
2060 (setq flist
(cons (car elem
) flist
))
2061 (setq newspec
(car (cdr elem
))))
2062 ;; Remove the old specification (and possibly a ",12" string).
2063 (delete-region beg
(match-end 2))
2064 ;; Insert the new specification.
2067 (setq fstring
(buffer-substring 1 (point-max))))
2068 (cons 'format
(cons fstring
(nreverse flist
)))))
2070 (defun gnus-set-work-buffer ()
2071 (if (get-buffer gnus-work-buffer
)
2073 (set-buffer gnus-work-buffer
)
2075 (set-buffer (get-buffer-create gnus-work-buffer
))
2076 (kill-all-local-variables)
2077 (buffer-disable-undo (current-buffer))
2078 (gnus-add-current-to-buffer-list)))
2080 ;; Article file names when saving.
2082 (defun gnus-Numeric-save-name (newsgroup headers
&optional last-file
)
2083 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2084 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group/num.
2085 Otherwise, it is like ~/News/news/group/num."
2088 (concat (if (gnus-use-long-file-name 'not-save
)
2089 (gnus-capitalize-newsgroup newsgroup
)
2090 (gnus-newsgroup-directory-form newsgroup
))
2091 "/" (int-to-string (mail-header-number headers
)))
2092 (or gnus-article-save-directory
"~/News"))))
2094 (string-equal (file-name-directory default
)
2095 (file-name-directory last-file
))
2096 (string-match "^[0-9]+$" (file-name-nondirectory last-file
)))
2098 (or last-file default
))))
2100 (defun gnus-numeric-save-name (newsgroup headers
&optional last-file
)
2101 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2102 If variable `gnus-use-long-file-name' is non-nil, it is
2103 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
2106 (concat (if (gnus-use-long-file-name 'not-save
)
2108 (gnus-newsgroup-directory-form newsgroup
))
2109 "/" (int-to-string (mail-header-number headers
)))
2110 (or gnus-article-save-directory
"~/News"))))
2112 (string-equal (file-name-directory default
)
2113 (file-name-directory last-file
))
2114 (string-match "^[0-9]+$" (file-name-nondirectory last-file
)))
2116 (or last-file default
))))
2118 (defun gnus-Plain-save-name (newsgroup headers
&optional last-file
)
2119 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2120 If variable `gnus-use-long-file-name' is non-nil, it is
2121 ~/News/News.group. Otherwise, it is like ~/News/news/group/news."
2124 (if (gnus-use-long-file-name 'not-save
)
2125 (gnus-capitalize-newsgroup newsgroup
)
2126 (concat (gnus-newsgroup-directory-form newsgroup
) "/news"))
2127 (or gnus-article-save-directory
"~/News"))))
2129 (defun gnus-plain-save-name (newsgroup headers
&optional last-file
)
2130 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2131 If variable `gnus-use-long-file-name' is non-nil, it is
2132 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
2135 (if (gnus-use-long-file-name 'not-save
)
2137 (concat (gnus-newsgroup-directory-form newsgroup
) "/news"))
2138 (or gnus-article-save-directory
"~/News"))))
2140 ;; For subscribing new newsgroup
2142 (defun gnus-subscribe-hierarchical-interactive (groups)
2143 (let ((groups (sort groups
'string
<))
2144 prefixes prefix start ans group starts
)
2146 (setq prefixes
(list "^"))
2147 (while (and groups prefixes
)
2148 (while (not (string-match (car prefixes
) (car groups
)))
2149 (setq prefixes
(cdr prefixes
)))
2150 (setq prefix
(car prefixes
))
2151 (setq start
(1- (length prefix
)))
2152 (if (and (string-match "[^\\.]\\." (car groups
) start
)
2155 (concat "^" (substring (car groups
) 0 (match-end 0))))
2156 (string-match prefix
(car (cdr groups
))))
2158 (setq prefixes
(cons prefix prefixes
))
2159 (message "Descend hierarchy %s? ([y]nsq): "
2160 (substring prefix
1 (1- (length prefix
))))
2161 (setq ans
(read-char))
2164 (string-match prefix
2165 (setq group
(car groups
))))
2166 (setq gnus-killed-list
2167 (cons group gnus-killed-list
))
2168 (gnus-sethash group group gnus-killed-hashtb
)
2169 (setq groups
(cdr groups
)))
2170 (setq starts
(cdr starts
)))
2173 (string-match prefix
2174 (setq group
(car groups
))))
2175 (gnus-sethash group group gnus-killed-hashtb
)
2176 (gnus-subscribe-alphabetically (car groups
))
2177 (setq groups
(cdr groups
)))
2178 (setq starts
(cdr starts
)))
2181 (setq group
(car groups
))
2182 (setq gnus-killed-list
(cons group gnus-killed-list
))
2183 (gnus-sethash group group gnus-killed-hashtb
)
2184 (setq groups
(cdr groups
))))
2186 (message "Subscribe %s? ([n]yq)" (car groups
))
2187 (setq ans
(read-char))
2188 (setq group
(car groups
))
2190 (gnus-subscribe-alphabetically (car groups
))
2191 (gnus-sethash group group gnus-killed-hashtb
))
2194 (setq group
(car groups
))
2195 (setq gnus-killed-list
(cons group gnus-killed-list
))
2196 (gnus-sethash group group gnus-killed-hashtb
)
2197 (setq groups
(cdr groups
))))
2199 (setq gnus-killed-list
(cons group gnus-killed-list
))
2200 (gnus-sethash group group gnus-killed-hashtb
)))
2201 (setq groups
(cdr groups
)))))))
2203 (defun gnus-subscribe-randomly (newsgroup)
2204 "Subscribe new NEWSGROUP by making it the first newsgroup."
2205 (gnus-subscribe-newsgroup newsgroup
))
2207 (defun gnus-subscribe-alphabetically (newgroup)
2208 "Subscribe new NEWSGROUP and insert it in alphabetical order."
2209 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
2210 (let ((groups (cdr gnus-newsrc-alist
))
2212 (while (and (not before
) groups
)
2213 (if (string< newgroup
(car (car groups
)))
2214 (setq before
(car (car groups
)))
2215 (setq groups
(cdr groups
))))
2216 (gnus-subscribe-newsgroup newgroup before
)))
2218 (defun gnus-subscribe-hierarchically (newgroup)
2219 "Subscribe new NEWSGROUP and insert it in hierarchical newsgroup order."
2220 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
2222 (set-buffer (find-file-noselect gnus-current-startup-file
))
2223 (let ((groupkey newgroup
)
2225 (while (and (not before
) groupkey
)
2226 (goto-char (point-min))
2228 (concat "^\\(" (regexp-quote groupkey
) ".*\\)[!:]")))
2229 (while (and (re-search-forward groupkey-re nil t
)
2231 (setq before
(buffer-substring
2232 (match-beginning 1) (match-end 1)))
2233 (string< before newgroup
)))))
2234 ;; Remove tail of newsgroup name (eg. a.b.c -> a.b)
2236 (if (string-match "^\\(.*\\)\\.[^.]+$" groupkey
)
2237 (substring groupkey
(match-beginning 1) (match-end 1)))))
2238 (gnus-subscribe-newsgroup newgroup before
))))
2240 (defun gnus-subscribe-interactively (newsgroup)
2241 "Subscribe new NEWSGROUP interactively.
2242 It is inserted in hierarchical newsgroup order if subscribed. If not,
2244 (if (gnus-y-or-n-p (format "Subscribe new newsgroup: %s " newsgroup
))
2245 (gnus-subscribe-hierarchically newsgroup
)
2246 (setq gnus-killed-list
(cons newsgroup gnus-killed-list
))))
2248 (defun gnus-subscribe-zombies (newsgroup)
2249 "Make new NEWSGROUP a zombie group."
2250 (setq gnus-zombie-list
(cons newsgroup gnus-zombie-list
)))
2252 (defun gnus-subscribe-newsgroup (newsgroup &optional next
)
2253 "Subscribe new NEWSGROUP.
2254 If NEXT is non-nil, it is inserted before NEXT. Otherwise it is made
2255 the first newsgroup."
2256 ;; We subscribe the group by changing its level to `subscribed'.
2257 (gnus-group-change-level
2258 newsgroup gnus-level-default-subscribed
2259 gnus-level-killed
(gnus-gethash (or next
"dummy.group") gnus-newsrc-hashtb
))
2260 (gnus-message 5 "Subscribe newsgroup: %s" newsgroup
))
2264 (defun gnus-newsgroup-directory-form (newsgroup)
2265 "Make hierarchical directory name from NEWSGROUP name."
2266 (let ((newsgroup (gnus-newsgroup-savable-name newsgroup
))
2267 (len (length newsgroup
))
2269 ;; If this is a foreign group, we don't want to translate the
2271 (if (setq idx
(string-match ":" newsgroup
))
2272 (aset newsgroup idx ?
/)
2274 ;; Replace all occurrences of `.' with `/'.
2276 (if (= (aref newsgroup idx
) ?.
)
2277 (aset newsgroup idx ?
/))
2278 (setq idx
(1+ idx
)))
2281 (defun gnus-newsgroup-savable-name (group)
2282 ;; Replace any slashes in a group name (eg. an ange-ftp nndoc group)
2284 (gnus-replace-chars-in-string group ?
/ ?.
))
2286 (defun gnus-make-directory (dir)
2287 "Make DIRECTORY recursively."
2288 ;; Why don't we use `(make-directory dir 'parents)'? That's just one
2289 ;; of the many mysteries of the universe.
2290 (let* ((dir (expand-file-name dir default-directory
))
2292 (if (string-match "/$" dir
)
2293 (setq dir
(substring dir
0 (match-beginning 0))))
2294 ;; First go down the path until we find a directory that exists.
2295 (while (not (file-exists-p dir
))
2296 (setq dirs
(cons dir dirs
))
2297 (string-match "/[^/]+$" dir
)
2298 (setq dir
(substring dir
0 (match-beginning 0))))
2299 ;; Then create all the subdirs.
2300 (while (and dirs
(not err
))
2302 (make-directory (car dirs
))
2303 (error (setq err t
)))
2304 (setq dirs
(cdr dirs
)))
2305 ;; We return whether we were successful or not.
2308 (defun gnus-capitalize-newsgroup (newsgroup)
2309 "Capitalize NEWSGROUP name."
2310 (and (not (zerop (length newsgroup
)))
2311 (concat (char-to-string (upcase (aref newsgroup
0)))
2312 (substring newsgroup
1))))
2316 (defun gnus-simplify-subject (subject &optional re-only
)
2317 "Remove `Re:' and words in parentheses.
2318 If optional argument RE-ONLY is non-nil, strip `Re:' only."
2319 (let ((case-fold-search t
)) ;Ignore case.
2320 ;; Remove `Re:' and `Re^N:'.
2321 (if (string-match "^re:[ \t]*" subject
)
2322 (setq subject
(substring subject
(match-end 0))))
2323 ;; Remove words in parentheses from end.
2325 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject
)
2326 (setq subject
(substring subject
0 (match-beginning 0)))))
2327 ;; Return subject string.
2330 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
2332 (defun gnus-simplify-subject-fuzzy (subject)
2333 (let ((case-fold-search t
))
2335 (gnus-set-work-buffer)
2337 (inline (gnus-simplify-buffer-fuzzy))
2340 (defun gnus-simplify-buffer-fuzzy ()
2341 (goto-char (point-min))
2342 ;; Fix by Stainless Steel Rat <ratinox@ccs.neu.edu>.
2343 (while (re-search-forward "^[ \t]*\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;][ \t]*"
2345 (replace-match "" t t
))
2346 (goto-char (point-min))
2347 (while (re-search-forward "[ \t\n]*([^()]*)[ \t\n]*$" nil t
)
2348 (replace-match "" t t
))
2349 (goto-char (point-min))
2350 (while (re-search-forward "[ \t]+" nil t
)
2351 (replace-match " " t t
))
2352 (goto-char (point-min))
2353 (while (re-search-forward "[ \t]+$" nil t
)
2354 (replace-match "" t t
))
2355 (goto-char (point-min))
2356 (while (re-search-forward "^[ \t]+" nil t
)
2357 (replace-match "" t t
))
2358 (if gnus-simplify-subject-fuzzy-regexp
2359 (while (re-search-forward gnus-simplify-subject-fuzzy-regexp nil t
)
2360 (replace-match "" t t
))))
2362 ;; Add the current buffer to the list of buffers to be killed on exit.
2363 (defun gnus-add-current-to-buffer-list ()
2364 (or (memq (current-buffer) gnus-buffer-list
)
2365 (setq gnus-buffer-list
(cons (current-buffer) gnus-buffer-list
))))
2367 (defun gnus-string> (s1 s2
)
2368 (not (or (string< s1 s2
)
2371 ;; Functions accessing headers.
2372 ;; Functions are more convenient than macros in some cases.
2374 (defun gnus-header-number (header)
2375 (mail-header-number header
))
2377 (defun gnus-header-subject (header)
2378 (mail-header-subject header
))
2380 (defun gnus-header-from (header)
2381 (mail-header-from header
))
2383 (defun gnus-header-xref (header)
2384 (mail-header-xref header
))
2386 (defun gnus-header-lines (header)
2387 (mail-header-lines header
))
2389 (defun gnus-header-date (header)
2390 (mail-header-date header
))
2392 (defun gnus-header-id (header)
2393 (mail-header-id header
))
2395 (defun gnus-header-message-id (header)
2396 (mail-header-id header
))
2398 (defun gnus-header-chars (header)
2399 (mail-header-chars header
))
2401 (defun gnus-header-references (header)
2402 (mail-header-references header
))
2404 ;;; General various misc type functions.
2406 (defun gnus-clear-system ()
2407 "Clear all variables and buffers."
2408 ;; Clear Gnus variables.
2409 (let ((variables gnus-variable-list
))
2411 (set (car variables
) nil
)
2412 (setq variables
(cdr variables
))))
2413 ;; Clear other internal variables.
2414 (setq gnus-list-of-killed-groups nil
2415 gnus-have-read-active-file nil
2416 gnus-newsrc-alist nil
2417 gnus-newsrc-hashtb nil
2418 gnus-killed-list nil
2419 gnus-zombie-list nil
2420 gnus-killed-hashtb nil
2421 gnus-active-hashtb nil
2422 gnus-moderated-list nil
2423 gnus-description-hashtb nil
2424 gnus-newsgroup-headers nil
2425 gnus-newsgroup-headers-hashtb-by-number nil
2426 gnus-newsgroup-name nil
2427 gnus-server-alist nil
2428 gnus-current-select-method nil
)
2429 ;; Reset any score variables.
2430 (and (boundp 'gnus-score-cache
)
2431 (set 'gnus-score-cache nil
))
2432 (and (boundp 'gnus-internal-global-score-files
)
2433 (set 'gnus-internal-global-score-files nil
))
2434 ;; Kill the startup file.
2435 (and gnus-current-startup-file
2436 (get-file-buffer gnus-current-startup-file
)
2437 (kill-buffer (get-file-buffer gnus-current-startup-file
)))
2438 ;; Save any cache buffers.
2439 (and gnus-use-cache
(gnus-cache-save-buffers))
2440 ;; Clear the dribble buffer.
2441 (gnus-dribble-clear)
2442 ;; Kill global KILL file buffer.
2443 (if (get-file-buffer (gnus-newsgroup-kill-file nil
))
2444 (kill-buffer (get-file-buffer (gnus-newsgroup-kill-file nil
))))
2445 (gnus-kill-buffer nntp-server-buffer
)
2446 ;; Kill Gnus buffers.
2447 (while gnus-buffer-list
2448 (gnus-kill-buffer (car gnus-buffer-list
))
2449 (setq gnus-buffer-list
(cdr gnus-buffer-list
))))
2451 (defun gnus-windows-old-to-new (setting)
2452 ;; First we take care of the really, really old Gnus 3 actions.
2453 (if (symbolp setting
)
2455 (cond ((memq setting
'(SelectArticle))
2457 ((memq setting
'(SelectSubject ExpandSubject
))
2459 ((memq setting
'(SelectNewsgroup ExitNewsgroup
))
2462 (if (or (listp setting
)
2463 (not (and gnus-window-configuration
2464 (memq setting
'(group summary article
)))))
2466 (let* ((setting (if (eq setting
'group
)
2467 (if (assq 'newsgroup gnus-window-configuration
)
2469 'newsgroups
) setting
))
2470 (elem (car (cdr (assq setting gnus-window-configuration
))))
2471 (total (apply '+ elem
))
2472 (types '(group summary article
))
2473 (pbuf (if (eq setting
'newsgroups
) 'group
'summary
))
2478 (or (not (numberp (nth i elem
)))
2479 (zerop (nth i elem
))
2481 (setq perc
(/ (* 1.0 (nth 0 elem
)) total
))
2482 (setq out
(cons (if (eq pbuf
(nth i types
))
2483 (vector (nth i types
) perc
'point
)
2484 (vector (nth i types
) perc
))
2487 (list (nreverse out
)))))
2489 (defun gnus-add-configuration (conf)
2490 (setq gnus-buffer-configuration
2491 (cons conf
(delq (assq (car conf
) gnus-buffer-configuration
)
2492 gnus-buffer-configuration
))))
2494 (defun gnus-configure-windows (setting &optional force
)
2495 (setq setting
(gnus-windows-old-to-new setting
))
2496 (let ((r (if (symbolp setting
)
2497 (cdr (assq setting gnus-buffer-configuration
))
2499 (in-buf (current-buffer))
2500 rule val w height hor ohor heights sub jump-buffer
2501 rel total to-buf all-visible
)
2502 (or r
(error "No such setting: %s" setting
))
2504 (if (and (not force
) (setq all-visible
(gnus-all-windows-visible-p r
)))
2505 ;; All the windows mentioned are already visible, so we just
2506 ;; put point in the assigned buffer, and do not touch the
2508 (select-window (get-buffer-window all-visible t
))
2511 ;; Either remove all windows or just remove all Gnus windows.
2512 (if gnus-use-full-window
2513 (delete-other-windows)
2514 (gnus-remove-some-windows)
2515 (switch-to-buffer nntp-server-buffer
))
2521 ;; We have to do the (possible) horizontal splitting before the
2523 (if (and (listp (car hor
))
2524 (eq (car (car hor
)) 'horizontal
))
2528 (if (integerp (nth 1 (car hor
)))
2530 (- (frame-width) (floor (* (frame-width) (nth 1 (car hor
))))))
2532 (setq hor
(cdr hor
))))
2534 ;; Go through the rules and eval the elements that are to be
2537 (if (setq val
(if (vectorp (car hor
)) (car hor
) (eval (car hor
))))
2539 ;; Expand short buffer name.
2540 (setq w
(aref val
0))
2541 (and (setq w
(cdr (assq w gnus-window-to-buffer
)))
2543 (setq val
(apply 'vector
(mapcar 'identity val
)))
2545 (setq ohor
(cons val ohor
))))
2546 (setq hor
(cdr hor
)))
2547 (setq rule
(cons (nreverse ohor
) rule
))
2549 (setq rule
(nreverse rule
))
2551 ;; We tally the window sizes.
2552 (setq total
(window-height))
2554 (setq hor
(car rule
))
2555 (if (and (listp (car hor
)) (eq (car (car hor
)) 'horizontal
))
2556 (setq hor
(cdr hor
)))
2559 (setq rel
(aref (car hor
) 1)
2561 (cond ((and (floatp rel
) (= 1.0 rel
))
2566 (max (floor (* total rel
)) 4)))
2568 sub
(+ sub
(if (numberp (car heights
)) (car heights
) 0))
2570 (setq heights
(nreverse heights
)
2573 ;; We then go through these heights and create windows for them.
2575 (setq height
(car heights
)
2576 heights
(cdr heights
))
2578 (setq height
(- total sub
)))
2580 (split-window nil height
))
2581 (setq to-buf
(aref (car hor
) 0))
2586 (symbol-value (aref (car hor
) 0)))
2588 (aref (car hor
) 0))))
2589 (and (> (length (car hor
)) 2)
2590 (eq (aref (car hor
) 2) 'point
)
2591 (setq jump-buffer
(current-buffer)))
2593 (setq hor
(cdr hor
)))
2595 (setq rule
(cdr rule
)))
2597 ;; Finally, we pop to the buffer that's supposed to have point.
2598 (or jump-buffer
(error "Missing `point' in spec for %s" setting
))
2600 (select-window (get-buffer-window jump-buffer t
))
2601 (set-buffer jump-buffer
))))
2603 (defun gnus-all-windows-visible-p (rule)
2604 (let (invisible hor jump-buffer val buffer
)
2605 ;; Go through the rules and eval the elements that are to be
2607 (while (and rule
(not invisible
))
2608 (setq hor
(car rule
)
2610 (while (and hor
(not invisible
))
2611 (if (setq val
(if (vectorp (car hor
))
2613 (if (not (eq (car (car hor
)) 'horizontal
))
2616 ;; Expand short buffer name.
2617 (setq buffer
(or (cdr (assq (aref val
0) gnus-window-to-buffer
))
2619 (setq buffer
(if (symbolp buffer
) (symbol-value buffer
)
2621 (and (> (length val
) 2) (eq 'point
(aref val
2))
2622 (setq jump-buffer buffer
))
2623 (setq invisible
(not (and buffer
(get-buffer-window buffer
))))))
2624 (setq hor
(cdr hor
))))
2625 (and (not invisible
) jump-buffer
)))
2627 (defun gnus-window-top-edge (&optional window
)
2628 (nth 1 (window-edges window
)))
2630 (defun gnus-remove-some-windows ()
2631 (let ((buffers gnus-window-to-buffer
)
2632 buf bufs lowest-buf lowest
)
2634 ;; Remove windows on all known Gnus buffers.
2636 (setq buf
(cdr (car buffers
)))
2638 (setq buf
(and (boundp buf
) (symbol-value buf
))))
2640 (get-buffer-window buf
)
2642 (setq bufs
(cons buf bufs
))
2644 (if (or (not lowest
)
2645 (< (gnus-window-top-edge) lowest
))
2647 (setq lowest
(gnus-window-top-edge))
2648 (setq lowest-buf buf
)))))
2649 (setq buffers
(cdr buffers
)))
2650 ;; Remove windows on *all* summary buffers.
2654 (let ((buf (window-buffer win
)))
2655 (if (string-match "^\\*Summary" (buffer-name buf
))
2657 (setq bufs
(cons buf bufs
))
2659 (if (or (not lowest
)
2660 (< (gnus-window-top-edge) lowest
))
2662 (setq lowest-buf buf
)
2663 (setq lowest
(gnus-window-top-edge))))))))))
2666 (pop-to-buffer lowest-buf
)
2667 (switch-to-buffer nntp-server-buffer
)))
2669 (and (not (eq (car bufs
) lowest-buf
))
2670 (delete-windows-on (car bufs
)))
2671 (setq bufs
(cdr bufs
))))))
2673 (defun gnus-version ()
2674 "Version numbers of this version of Gnus."
2676 (let ((methods gnus-valid-select-methods
)
2679 ;; Go through all the legal select methods and add their version
2680 ;; numbers to the total version string. Only the backends that are
2681 ;; currently in use will have their message numbers taken into
2684 (setq meth
(intern (concat (car (car methods
)) "-version")))
2686 (stringp (symbol-value meth
))
2687 (setq mess
(concat mess
"; " (symbol-value meth
))))
2688 (setq methods
(cdr methods
)))
2689 (gnus-message 2 mess
)))
2691 (defun gnus-info-find-node ()
2692 "Find Info documentation of Gnus."
2694 ;; Enlarge info window if needed.
2695 (let ((mode major-mode
))
2696 (gnus-configure-windows 'info
)
2697 (Info-goto-node (car (cdr (assq mode gnus-info-nodes
))))))
2699 (defun gnus-overload-functions (&optional overloads
)
2700 "Overload functions specified by optional argument OVERLOADS.
2701 If nothing is specified, use the variable gnus-overload-functions."
2703 (overloads (or overloads gnus-overload-functions
)))
2705 (setq defs
(car overloads
))
2706 (setq overloads
(cdr overloads
))
2707 ;; Load file before overloading function if necessary. Make
2708 ;; sure we cannot use `require' always.
2709 (and (not (fboundp (car defs
)))
2710 (car (cdr (cdr defs
)))
2711 (load (car (cdr (cdr defs
))) nil
'nomessage
))
2712 (fset (car defs
) (car (cdr defs
))))))
2714 (defun gnus-replace-chars-in-string (string &rest pairs
)
2715 "Replace characters in STRING from FROM to TO."
2716 (let ((string (substring string
0)) ;Copy string.
2717 (len (length string
))
2720 (or (zerop (%
(length pairs
) 2))
2721 (error "Odd number of translation pairs"))
2722 (setplist 'sym pairs
)
2723 ;; Replace all occurrences of FROM with TO.
2725 (if (setq to
(get 'sym
(aref string idx
)))
2726 (aset string idx to
))
2727 (setq idx
(1+ idx
)))
2730 (defun gnus-days-between (date1 date2
)
2731 ;; Return the number of days between date1 and date2.
2732 (- (gnus-day-number date1
) (gnus-day-number date2
)))
2734 (defun gnus-day-number (date)
2735 (let ((dat (mapcar (lambda (s) (and s
(string-to-int s
)) )
2736 (timezone-parse-date date
))))
2737 (timezone-absolute-from-gregorian
2738 (nth 1 dat
) (nth 2 dat
) (car dat
))))
2740 ;; Returns a floating point number that says how many seconds have
2741 ;; lapsed between Jan 1 12:00:00 1970 and DATE.
2742 (defun gnus-seconds-since-epoch (date)
2743 (let* ((tdate (mapcar (lambda (ti) (and ti
(string-to-int ti
)))
2744 (timezone-parse-date date
)))
2745 (ttime (mapcar (lambda (ti) (and ti
(string-to-int ti
)))
2746 (timezone-parse-time
2747 (aref (timezone-parse-date date
) 3))))
2748 (edate (mapcar (lambda (ti) (and ti
(string-to-int ti
)))
2749 (timezone-parse-date "Jan 1 12:00:00 1970")))
2750 (tday (- (timezone-absolute-from-gregorian
2751 (nth 1 tdate
) (nth 2 tdate
) (nth 0 tdate
))
2752 (timezone-absolute-from-gregorian
2753 (nth 1 edate
) (nth 2 edate
) (nth 0 edate
)))))
2755 (* (nth 1 ttime
) 60)
2756 (* 1.0 (nth 0 ttime
) 60 60)
2757 (* 1.0 tday
60 60 24))))
2759 (defun gnus-file-newer-than (file date
)
2760 (let ((fdate (nth 5 (file-attributes file
))))
2761 (or (> (car fdate
) (car date
))
2762 (and (= (car fdate
) (car date
))
2763 (> (nth 1 fdate
) (nth 1 date
))))))
2765 (defun gnus-group-read-only-p (&optional group
)
2766 "Check whether GROUP supports editing or not.
2767 If GROUP is nil, `gnus-newsgroup-name' will be checked instead. Note
2768 that that variable is buffer-local to the summary buffers."
2769 (let ((group (or group gnus-newsgroup-name
)))
2770 (not (gnus-check-backend-function 'request-replace-article group
))))
2772 ;; Two silly functions to ensure that all `y-or-n-p' questions clear
2774 (defun gnus-y-or-n-p (prompt)
2779 (defun gnus-yes-or-no-p (prompt)
2781 (yes-or-no-p prompt
)
2784 ;; Check whether to use long file names.
2785 (defun gnus-use-long-file-name (symbol)
2786 ;; The variable has to be set...
2787 (and gnus-use-long-file-name
2788 ;; If it isn't a list, then we return t.
2789 (or (not (listp gnus-use-long-file-name
))
2790 ;; If it is a list, and the list contains `symbol', we
2792 (not (memq symbol gnus-use-long-file-name
)))))
2794 ;; I suspect there's a better way, but I haven't taken the time to do
2795 ;; it yet. -erik selberg@cs.washington.edu
2796 (defun gnus-dd-mmm (messy-date)
2797 "Return a string like DD-MMM from a big messy string"
2798 (let ((datevec (timezone-parse-date messy-date
)))
2800 (or (aref datevec
2) "??")
2803 (nth (1- (string-to-number (aref datevec
1)))
2804 timezone-months-assoc
))
2807 ;; Make a hash table (default and minimum size is 255).
2808 ;; Optional argument HASHSIZE specifies the table size.
2809 (defun gnus-make-hashtable (&optional hashsize
)
2810 (make-vector (if hashsize
(max (gnus-create-hash-size hashsize
) 255) 255) 0))
2812 ;; Make a number that is suitable for hashing; bigger than MIN and one
2814 (defun gnus-create-hash-size (min)
2820 ;; Show message if message has a lower level than `gnus-verbose'.
2821 ;; Guide-line for numbers:
2822 ;; 1 - error messages, 3 - non-serious error messages, 5 - messages
2823 ;; for things that take a long time, 7 - not very important messages
2824 ;; on stuff, 9 - messages inside loops.
2825 (defun gnus-message (level &rest args
)
2826 (if (<= level gnus-verbose
)
2827 (apply 'message args
)
2828 ;; We have to do this format thingy here even if the result isn't
2829 ;; shown - the return value has to be the same as the return value
2831 (apply 'format args
)))
2833 ;; Generate a unique new group name.
2834 (defun gnus-generate-new-group-name (leaf)
2837 (while (gnus-gethash name gnus-newsrc-hashtb
)
2838 (setq name
(concat leaf
"<" (int-to-string (setq num
(1+ num
))) ">")))
2841 (defun gnus-ephemeral-group-p (group)
2842 "Say whether GROUP is ephemeral or not."
2843 (assoc 'quit-config
(gnus-find-method-for-group group
)))
2845 (defun gnus-group-quit-config (group)
2846 "Return the quit-config of GROUP."
2847 (nth 1 (assoc 'quit-config
(gnus-find-method-for-group group
))))
2849 (defun gnus-simplify-mode-line ()
2850 "Make mode lines a bit simpler."
2851 (setq mode-line-modified
"-- ")
2852 (if (listp mode-line-format
)
2854 (make-local-variable 'mode-line-format
)
2855 (setq mode-line-format
(copy-sequence mode-line-format
))
2856 (and (equal (nth 3 mode-line-format
) " ")
2857 (setcar (nthcdr 3 mode-line-format
) "")))))
2859 ;;; List and range functions
2861 (defun gnus-last-element (list)
2862 "Return last element of LIST."
2864 (setq list
(cdr list
)))
2867 (defun gnus-copy-sequence (list)
2868 "Do a complete, total copy of a list."
2869 (if (and (consp list
) (not (consp (cdr list
))))
2870 (cons (car list
) (cdr list
))
2871 (mapcar (lambda (elem) (if (consp elem
)
2872 (if (consp (cdr elem
))
2873 (gnus-copy-sequence elem
)
2874 (cons (car elem
) (cdr elem
)))
2878 (defun gnus-set-difference (list1 list2
)
2879 "Return a list of elements of LIST1 that do not appear in LIST2."
2880 (let ((list1 (copy-sequence list1
)))
2882 (setq list1
(delq (car list2
) list1
))
2883 (setq list2
(cdr list2
)))
2886 (defun gnus-sorted-complement (list1 list2
)
2887 "Return a list of elements of LIST1 that do not appear in LIST2.
2888 Both lists have to be sorted over <."
2890 (if (or (null list1
) (null list2
))
2892 (while (and list1 list2
)
2893 (cond ((= (car list1
) (car list2
))
2894 (setq list1
(cdr list1
)
2896 ((< (car list1
) (car list2
))
2897 (setq out
(cons (car list1
) out
))
2898 (setq list1
(cdr list1
)))
2900 (setq out
(cons (car list2
) out
))
2901 (setq list2
(cdr list2
)))))
2902 (nconc (nreverse out
) (or list1 list2
)))))
2904 (defun gnus-intersection (list1 list2
)
2907 (if (memq (car list2
) list1
)
2908 (setq result
(cons (car list2
) result
)))
2909 (setq list2
(cdr list2
)))
2912 (defun gnus-sorted-intersection (list1 list2
)
2913 ;; LIST1 and LIST2 have to be sorted over <.
2915 (while (and list1 list2
)
2916 (cond ((= (car list1
) (car list2
))
2917 (setq out
(cons (car list1
) out
)
2920 ((< (car list1
) (car list2
))
2921 (setq list1
(cdr list1
)))
2923 (setq list2
(cdr list2
)))))
2926 (defun gnus-set-sorted-intersection (list1 list2
)
2927 ;; LIST1 and LIST2 have to be sorted over <.
2928 ;; This function modifies LIST1.
2929 (let* ((top (cons nil list1
))
2931 (while (and list1 list2
)
2932 (cond ((= (car list1
) (car list2
))
2936 ((< (car list1
) (car list2
))
2937 (setcdr prev
(cdr list1
))
2938 (setq list1
(cdr list1
)))
2940 (setq list2
(cdr list2
)))))
2944 (defun gnus-compress-sequence (numbers &optional always-list
)
2945 "Convert list of numbers to a list of ranges or a single range.
2946 If ALWAYS-LIST is non-nil, this function will always release a list of
2948 (let* ((first (car numbers
))
2949 (last (car numbers
))
2953 (if (not (listp (cdr numbers
)))
2956 (cond ((= last
(car numbers
)) nil
) ;Omit duplicated number
2957 ((= (1+ last
) (car numbers
)) ;Still in sequence
2958 (setq last
(car numbers
)))
2959 (t ;End of one sequence
2961 (cons (if (= first last
) first
2962 (cons first last
)) result
))
2963 (setq first
(car numbers
))
2964 (setq last
(car numbers
))))
2965 (setq numbers
(cdr numbers
)))
2966 (if (and (not always-list
) (null result
))
2967 (if (= first last
) (list first
) (cons first last
))
2968 (nreverse (cons (if (= first last
) first
(cons first last
))
2971 (defalias 'gnus-uncompress-sequence
'gnus-uncompress-range
)
2972 (defun gnus-uncompress-range (ranges)
2973 "Expand a list of ranges into a list of numbers.
2974 RANGES is either a single range on the form `(num . num)' or a list of
2976 (let (first last result
)
2980 ((not (listp (cdr ranges
)))
2981 (setq first
(car ranges
))
2982 (setq last
(cdr ranges
))
2983 (while (<= first last
)
2984 (setq result
(cons first result
))
2985 (setq first
(1+ first
)))
2989 (if (atom (car ranges
))
2990 (if (numberp (car ranges
))
2991 (setq result
(cons (car ranges
) result
)))
2992 (setq first
(car (car ranges
)))
2993 (setq last
(cdr (car ranges
)))
2994 (while (<= first last
)
2995 (setq result
(cons first result
))
2996 (setq first
(1+ first
))))
2997 (setq ranges
(cdr ranges
)))
2998 (nreverse result
)))))
3000 (defun gnus-add-to-range (ranges list
)
3001 "Return a list of ranges that has all articles from both RANGES and LIST.
3002 Note: LIST has to be sorted over `<'."
3004 (gnus-compress-sequence list t
)
3005 (setq list
(copy-sequence list
))
3006 (or (listp (cdr ranges
))
3007 (setq ranges
(list ranges
)))
3009 ilist lowest highest temp
)
3010 (while (and ranges list
)
3012 (setq lowest
(or (and (atom (car ranges
)) (car ranges
))
3013 (car (car ranges
))))
3014 (while (and list
(cdr list
) (< (car (cdr list
)) lowest
))
3015 (setq list
(cdr list
)))
3016 (if (< (car ilist
) lowest
)
3019 (setq list
(cdr list
))
3021 (setq out
(nconc (gnus-compress-sequence ilist t
) out
))))
3022 (setq highest
(or (and (atom (car ranges
)) (car ranges
))
3023 (cdr (car ranges
))))
3024 (while (and list
(<= (car list
) highest
))
3025 (setq list
(cdr list
)))
3026 (setq ranges
(cdr ranges
)))
3028 (setq out
(nconc (gnus-compress-sequence list t
) out
)))
3029 (setq out
(sort out
(lambda (r1 r2
)
3030 (< (or (and (atom r1
) r1
) (car r1
))
3031 (or (and (atom r2
) r2
) (car r2
))))))
3034 (if (atom (car ranges
))
3036 (if (atom (car (cdr ranges
)))
3037 (if (= (1+ (car ranges
)) (car (cdr ranges
)))
3039 (setcar ranges
(cons (car ranges
)
3040 (car (cdr ranges
))))
3041 (setcdr ranges
(cdr (cdr ranges
)))))
3042 (if (= (1+ (car ranges
)) (car (car (cdr ranges
))))
3044 (setcar (car (cdr ranges
)) (car ranges
))
3045 (setcar ranges
(car (cdr ranges
)))
3046 (setcdr ranges
(cdr (cdr ranges
)))))))
3048 (if (atom (car (cdr ranges
)))
3049 (if (= (1+ (cdr (car ranges
))) (car (cdr ranges
)))
3051 (setcdr (car ranges
) (car (cdr ranges
)))
3052 (setcdr ranges
(cdr (cdr ranges
)))))
3053 (if (= (1+ (cdr (car ranges
))) (car (car (cdr ranges
))))
3055 (setcdr (car ranges
) (cdr (car (cdr ranges
))))
3056 (setcdr ranges
(cdr (cdr ranges
))))))))
3057 (setq ranges
(cdr ranges
)))
3060 (defun gnus-remove-from-range (ranges list
)
3061 "Return a list of ranges that has all articles from LIST removed from RANGES.
3062 Note: LIST has to be sorted over `<'."
3063 ;; !!! This function shouldn't look like this, but I've got a headache.
3064 (gnus-compress-sequence
3065 (gnus-sorted-complement
3066 (gnus-uncompress-range ranges
) list
)))
3068 (defun gnus-member-of-range (number ranges
)
3069 (if (not (listp (cdr ranges
)))
3070 (and (>= number
(car ranges
))
3071 (<= number
(cdr ranges
)))
3074 (if (numberp (car ranges
))
3075 (>= number
(car ranges
))
3076 (>= number
(car (car ranges
))))
3078 (if (if (numberp (car ranges
))
3079 (= number
(car ranges
))
3080 (and (>= number
(car (car ranges
)))
3081 (<= number
(cdr (car ranges
)))))
3082 (setq not-stop nil
))
3083 (setq ranges
(cdr ranges
)))
3091 (defvar gnus-group-mode-map nil
)
3092 (defvar gnus-group-group-map nil
)
3093 (defvar gnus-group-mark-map nil
)
3094 (defvar gnus-group-list-map nil
)
3095 (defvar gnus-group-help-map nil
)
3096 (defvar gnus-group-sub-map nil
)
3097 (put 'gnus-group-mode
'mode-class
'special
)
3099 (if gnus-group-mode-map
3101 (setq gnus-group-mode-map
(make-keymap))
3102 (suppress-keymap gnus-group-mode-map
)
3103 (define-key gnus-group-mode-map
" " 'gnus-group-read-group
)
3104 (define-key gnus-group-mode-map
"=" 'gnus-group-select-group
)
3105 (define-key gnus-group-mode-map
"\r" 'gnus-group-select-group
)
3106 (define-key gnus-group-mode-map
"j" 'gnus-group-jump-to-group
)
3107 (define-key gnus-group-mode-map
"n" 'gnus-group-next-unread-group
)
3108 (define-key gnus-group-mode-map
"p" 'gnus-group-prev-unread-group
)
3109 (define-key gnus-group-mode-map
"\177" 'gnus-group-prev-unread-group
)
3110 (define-key gnus-group-mode-map
"N" 'gnus-group-next-group
)
3111 (define-key gnus-group-mode-map
"P" 'gnus-group-prev-group
)
3112 (define-key gnus-group-mode-map
3113 "\M-n" 'gnus-group-next-unread-group-same-level
)
3114 (define-key gnus-group-mode-map
3115 "\M-p" 'gnus-group-prev-unread-group-same-level
)
3116 (define-key gnus-group-mode-map
"," 'gnus-group-best-unread-group
)
3117 (define-key gnus-group-mode-map
"." 'gnus-group-first-unread-group
)
3118 (define-key gnus-group-mode-map
"u" 'gnus-group-unsubscribe-current-group
)
3119 (define-key gnus-group-mode-map
"U" 'gnus-group-unsubscribe-group
)
3120 (define-key gnus-group-mode-map
"c" 'gnus-group-catchup-current
)
3121 (define-key gnus-group-mode-map
"C" 'gnus-group-catchup-current-all
)
3122 (define-key gnus-group-mode-map
"l" 'gnus-group-list-groups
)
3123 (define-key gnus-group-mode-map
"L" 'gnus-group-list-all-groups
)
3124 (define-key gnus-group-mode-map
"m" 'gnus-group-mail
)
3125 (define-key gnus-group-mode-map
"g" 'gnus-group-get-new-news
)
3126 (define-key gnus-group-mode-map
"\M-g" 'gnus-group-get-new-news-this-group
)
3127 (define-key gnus-group-mode-map
"R" 'gnus-group-restart
)
3128 (define-key gnus-group-mode-map
"r" 'gnus-group-read-init-file
)
3129 (define-key gnus-group-mode-map
"B" 'gnus-group-browse-foreign-server
)
3130 (define-key gnus-group-mode-map
"b" 'gnus-group-check-bogus-groups
)
3131 (define-key gnus-group-mode-map
"F" 'gnus-find-new-newsgroups
)
3132 (define-key gnus-group-mode-map
"\C-c\C-d" 'gnus-group-describe-group
)
3133 (define-key gnus-group-mode-map
"\M-d" 'gnus-group-describe-all-groups
)
3134 (define-key gnus-group-mode-map
"\C-c\C-a" 'gnus-group-apropos
)
3135 (define-key gnus-group-mode-map
"\C-c\M-\C-a" 'gnus-group-description-apropos
)
3136 (define-key gnus-group-mode-map
"a" 'gnus-group-post-news
)
3137 (define-key gnus-group-mode-map
"\ek" 'gnus-group-edit-local-kill
)
3138 (define-key gnus-group-mode-map
"\eK" 'gnus-group-edit-global-kill
)
3139 (define-key gnus-group-mode-map
"\C-k" 'gnus-group-kill-group
)
3140 (define-key gnus-group-mode-map
"\C-y" 'gnus-group-yank-group
)
3141 (define-key gnus-group-mode-map
"\C-w" 'gnus-group-kill-region
)
3142 (define-key gnus-group-mode-map
"\C-x\C-t" 'gnus-group-transpose-groups
)
3143 (define-key gnus-group-mode-map
"\C-c\C-l" 'gnus-group-list-killed
)
3144 (define-key gnus-group-mode-map
"\C-c\C-x" 'gnus-group-expire-articles
)
3145 (define-key gnus-group-mode-map
"\C-c\M-\C-x" 'gnus-group-expire-all-groups
)
3146 (define-key gnus-group-mode-map
"V" 'gnus-version
)
3147 (define-key gnus-group-mode-map
"s" 'gnus-group-save-newsrc
)
3148 (define-key gnus-group-mode-map
"z" 'gnus-group-suspend
)
3149 (define-key gnus-group-mode-map
"Z" 'gnus-group-clear-dribble
)
3150 (define-key gnus-group-mode-map
"q" 'gnus-group-exit
)
3151 (define-key gnus-group-mode-map
"Q" 'gnus-group-quit
)
3152 (define-key gnus-group-mode-map
"?" 'gnus-group-describe-briefly
)
3153 (define-key gnus-group-mode-map
"\C-c\C-i" 'gnus-info-find-node
)
3154 (define-key gnus-group-mode-map
"\M-e" 'gnus-group-edit-group-method
)
3155 (define-key gnus-group-mode-map
"^" 'gnus-group-enter-server-mode
)
3156 (define-key gnus-group-mode-map gnus-mouse-2
'gnus-mouse-pick-group
)
3157 (define-key gnus-group-mode-map
"<" 'beginning-of-buffer
)
3158 (define-key gnus-group-mode-map
">" 'end-of-buffer
)
3159 (define-key gnus-group-mode-map
"\C-c\C-b" 'gnus-bug
)
3160 (define-key gnus-group-mode-map
"\C-c\C-s" 'gnus-group-sort-groups
)
3162 (define-key gnus-group-mode-map
"#" 'gnus-group-mark-group
)
3163 (define-key gnus-group-mode-map
"\M-#" 'gnus-group-unmark-group
)
3164 (define-prefix-command 'gnus-group-mark-map
)
3165 (define-key gnus-group-mode-map
"M" 'gnus-group-mark-map
)
3166 (define-key gnus-group-mark-map
"m" 'gnus-group-mark-group
)
3167 (define-key gnus-group-mark-map
"u" 'gnus-group-unmark-group
)
3168 (define-key gnus-group-mark-map
"w" 'gnus-group-mark-region
)
3170 (define-prefix-command 'gnus-group-group-map
)
3171 (define-key gnus-group-mode-map
"G" 'gnus-group-group-map
)
3172 (define-key gnus-group-group-map
"d" 'gnus-group-make-directory-group
)
3173 (define-key gnus-group-group-map
"h" 'gnus-group-make-help-group
)
3174 (define-key gnus-group-group-map
"a" 'gnus-group-make-archive-group
)
3175 (define-key gnus-group-group-map
"k" 'gnus-group-make-kiboze-group
)
3176 (define-key gnus-group-group-map
"m" 'gnus-group-make-group
)
3177 (define-key gnus-group-group-map
"E" 'gnus-group-edit-group
)
3178 (define-key gnus-group-group-map
"e" 'gnus-group-edit-group-method
)
3179 (define-key gnus-group-group-map
"p" 'gnus-group-edit-group-parameters
)
3180 (define-key gnus-group-group-map
"v" 'gnus-group-add-to-virtual
)
3181 (define-key gnus-group-group-map
"V" 'gnus-group-make-empty-virtual
)
3182 (define-key gnus-group-group-map
"D" 'gnus-group-enter-directory
)
3183 (define-key gnus-group-group-map
"f" 'gnus-group-make-doc-group
)
3184 ;;(define-key gnus-group-group-map "sb" 'gnus-group-brew-soup)
3185 ;;(define-key gnus-group-group-map "sw" 'gnus-soup-save-areas)
3186 ;;(define-key gnus-group-group-map "ss" 'gnus-soup-send-replies)
3187 ;;(define-key gnus-group-group-map "sp" 'gnus-soup-pack-packet)
3188 ;;(define-key gnus-group-group-map "sr" 'nnsoup-pack-replies)
3190 (define-prefix-command 'gnus-group-list-map
)
3191 (define-key gnus-group-mode-map
"A" 'gnus-group-list-map
)
3192 (define-key gnus-group-list-map
"k" 'gnus-group-list-killed
)
3193 (define-key gnus-group-list-map
"z" 'gnus-group-list-zombies
)
3194 (define-key gnus-group-list-map
"s" 'gnus-group-list-groups
)
3195 (define-key gnus-group-list-map
"u" 'gnus-group-list-all-groups
)
3196 (define-key gnus-group-list-map
"a" 'gnus-group-apropos
)
3197 (define-key gnus-group-list-map
"d" 'gnus-group-description-apropos
)
3198 (define-key gnus-group-list-map
"m" 'gnus-group-list-matching
)
3199 (define-key gnus-group-list-map
"M" 'gnus-group-list-all-matching
)
3201 (define-prefix-command 'gnus-group-help-map
)
3202 (define-key gnus-group-mode-map
"H" 'gnus-group-help-map
)
3203 (define-key gnus-group-help-map
"f" 'gnus-group-fetch-faq
)
3205 (define-prefix-command 'gnus-group-sub-map
)
3206 (define-key gnus-group-mode-map
"S" 'gnus-group-sub-map
)
3207 (define-key gnus-group-sub-map
"l" 'gnus-group-set-current-level
)
3208 (define-key gnus-group-sub-map
"t" 'gnus-group-unsubscribe-current-group
)
3209 (define-key gnus-group-sub-map
"s" 'gnus-group-unsubscribe-group
)
3210 (define-key gnus-group-sub-map
"k" 'gnus-group-kill-group
)
3211 (define-key gnus-group-sub-map
"y" 'gnus-group-yank-group
)
3212 (define-key gnus-group-sub-map
"w" 'gnus-group-kill-region
)
3213 (define-key gnus-group-sub-map
"z" 'gnus-group-kill-all-zombies
))
3215 (defun gnus-group-mode ()
3216 "Major mode for reading news.
3218 All normal editing commands are switched off.
3219 \\<gnus-group-mode-map>
3220 The group buffer lists (some of) the groups available. For instance,
3221 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
3222 lists all zombie groups.
3224 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
3225 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
3227 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
3229 The following commands are available:
3231 \\{gnus-group-mode-map}"
3233 (if gnus-visual
(gnus-group-make-menu-bar))
3234 (kill-all-local-variables)
3235 (gnus-simplify-mode-line)
3236 (setq major-mode
'gnus-group-mode
)
3237 (setq mode-name
"Group")
3238 (gnus-group-set-mode-line)
3239 (setq mode-line-process nil
)
3240 (use-local-map gnus-group-mode-map
)
3241 (buffer-disable-undo (current-buffer))
3242 (setq truncate-lines t
)
3243 (setq buffer-read-only t
)
3244 (run-hooks 'gnus-group-mode-hook
))
3246 (defun gnus-mouse-pick-group (e)
3249 (gnus-group-read-group nil
))
3251 ;; Look at LEVEL and find out what the level is really supposed to be.
3252 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
3253 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
3254 (defun gnus-group-default-level (&optional level number-or-nil
)
3256 (gnus-group-use-permanent-levels
3257 (setq gnus-group-default-list-level
3258 (or level gnus-group-default-list-level
))
3259 (or gnus-group-default-list-level gnus-level-subscribed
))
3263 (or level gnus-group-default-list-level gnus-level-subscribed
))))
3266 (defvar gnus-tmp-prev-perm nil
)
3269 (defun gnus-no-server (&optional arg
)
3271 If ARG is a positive number, Gnus will use that as the
3272 startup level. If ARG is nil, Gnus will be started at level 2.
3273 If ARG is non-nil and not a positive number, Gnus will
3274 prompt the user for the name of an NNTP server to use.
3275 As opposed to `gnus', this command will not connect to the local server."
3278 (cons gnus-group-use-permanent-levels gnus-group-default-list-level
)))
3279 (setq gnus-tmp-prev-perm nil
)
3280 (setq gnus-group-use-permanent-levels t
)
3281 (gnus (or arg
(1- gnus-level-default-subscribed
)) t
)
3282 (setq gnus-tmp-prev-perm perm
)))
3285 (defun gnus (&optional arg dont-connect
)
3287 If ARG is non-nil and a positive number, Gnus will use that as the
3288 startup level. If ARG is non-nil and not a positive number, Gnus will
3289 prompt the user for the name of an NNTP server to use."
3291 (if (get-buffer gnus-group-buffer
)
3293 (switch-to-buffer gnus-group-buffer
)
3294 (gnus-group-get-new-news))
3298 (nnheader-init-server-buffer)
3299 ;; We do this if `gnus-no-server' has been run.
3300 (if gnus-tmp-prev-perm
3301 (setq gnus-group-use-permanent-levels
(car gnus-tmp-prev-perm
)
3302 gnus-group-default-list-level
(cdr gnus-tmp-prev-perm
)
3303 gnus-tmp-prev-perm nil
))
3304 (gnus-read-init-file)
3306 (gnus-group-setup-buffer)
3307 (let ((buffer-read-only nil
))
3309 (if (not gnus-inhibit-startup-message
)
3311 (gnus-group-startup-message)
3314 (let ((level (and arg
(numberp arg
) (> arg
0) arg
))
3320 (gnus-start-news-server (and arg
(not level
))))))
3321 (if (and (not dont-connect
)
3324 (run-hooks 'gnus-startup-hook
)
3325 ;; NNTP server is successfully open.
3327 ;; Find the current startup file name.
3328 (setq gnus-current-startup-file
3329 (gnus-make-newsrc-file gnus-startup-file
))
3331 ;; Read the dribble file.
3332 (and gnus-use-dribble-file
(gnus-dribble-read-file))
3334 (gnus-summary-make-display-table)
3335 (gnus-setup-news nil level
)
3336 (gnus-group-list-groups level
)
3337 (gnus-configure-windows 'group
))))))
3339 (defun gnus-unload ()
3340 "Unload all Gnus features."
3342 (or (boundp 'load-history
)
3343 (error "Sorry, `gnus-unload' is not implemented in this Emacs version."))
3344 (let ((history load-history
)
3347 (and (string-match "^gnus" (car (car history
)))
3348 (setq feature
(cdr (assq 'provide
(car history
))))
3349 (unload-feature feature
'force
))
3350 (setq history
(cdr history
)))))
3352 (defun gnus-group-startup-message (&optional x y
)
3353 "Insert startup message in current buffer."
3354 ;; Insert the message.
3359 _ ___ __ ___ __ _ ___
3377 Gnus * A newsreader for Emacsen
3378 A Praxis release * larsi@ifi.uio.no
3381 ;; And then hack it.
3382 ;; 18 is the longest line.
3383 (indent-rigidly (point-min) (point-max)
3384 (/ (max (- (window-width) (or x
46)) 0) 2))
3385 (goto-char (point-min))
3386 (let* ((pheight (count-lines (point-min) (point-max)))
3387 (wheight (window-height))
3388 (rest (- wheight pheight
)))
3389 (insert (make-string (max 0 (* 2 (/ rest
3))) ?
\n)))
3394 (goto-char (point-min))
3395 (search-forward "Praxis")
3396 (put-text-property (match-beginning 0) (match-end 0) 'face
'bold
)
3397 (goto-char (point-min)))
3399 (defun gnus-group-startup-message-old (&optional x y
)
3400 "Insert startup message in current buffer."
3401 ;; Insert the message.
3417 ;; And then hack it.
3418 ;; 18 is the longest line.
3419 (indent-rigidly (point-min) (point-max)
3420 (/ (max (- (window-width) (or x
28)) 0) 2))
3421 (goto-char (point-min))
3422 ;; +4 is fuzzy factor.
3423 (insert-char ?
\n (/ (max (- (window-height) (or y
12)) 0) 2))
3426 (goto-char (point-min))
3427 (search-forward "Praxis")
3428 (put-text-property (match-beginning 0) (match-end 0) 'face
'bold
)
3429 (goto-char (point-min)))
3431 (defun gnus-group-setup-buffer ()
3432 (or (get-buffer gnus-group-buffer
)
3434 (switch-to-buffer gnus-group-buffer
)
3435 (gnus-add-current-to-buffer-list)
3437 (and gnus-carpal
(gnus-carpal-setup-buffer 'group
)))))
3439 (defun gnus-group-list-groups (&optional level unread
)
3440 "List newsgroups with level LEVEL or lower that have unread articles.
3441 Default is all subscribed groups.
3442 If argument UNREAD is non-nil, groups with no unread articles are also
3444 (interactive (list (if current-prefix-arg
3445 (prefix-numeric-value current-prefix-arg
)
3447 (gnus-group-default-level nil t
)
3448 gnus-group-default-list-level
3449 gnus-level-subscribed
))))
3451 (setq level
(car gnus-group-list-mode
)
3452 unread
(cdr gnus-group-list-mode
)))
3453 (setq level
(gnus-group-default-level level
))
3454 (gnus-group-setup-buffer) ;May call from out of group buffer
3455 (let ((case-fold-search nil
)
3456 (group (gnus-group-group-name)))
3457 (funcall gnus-group-prepare-function level unread nil
)
3458 (if (zerop (buffer-size))
3459 (gnus-message 5 gnus-no-groups-message
)
3460 (goto-char (point-min))
3462 ;; Go to the first group with unread articles.
3463 (gnus-group-search-forward nil nil nil t
)
3464 ;; Find the right group to put point on. If the current group
3465 ;; has disappeared in the new listing, try to find the next
3466 ;; one. If no next one can be found, just leave point at the
3467 ;; first newsgroup in the buffer.
3468 (if (not (gnus-goto-char
3469 (text-property-any (point-min) (point-max)
3470 'gnus-group
(intern group
))))
3471 (let ((newsrc (nthcdr 3 (gnus-gethash group gnus-newsrc-hashtb
))))
3473 (not (gnus-goto-char
3475 (point-min) (point-max) 'gnus-group
3476 (intern (car (car newsrc
)))))))
3477 (setq newsrc
(cdr newsrc
)))
3478 (or newsrc
(progn (goto-char (point-max))
3479 (forward-line -
1))))))
3480 ;; Adjust cursor point.
3481 (gnus-group-position-cursor))))
3483 (defun gnus-group-prepare-flat (level &optional all lowest regexp
)
3484 "List all newsgroups with unread articles of level LEVEL or lower.
3485 If ALL is non-nil, list groups that have no unread articles.
3486 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
3487 If REGEXP, only list groups matching REGEXP."
3488 (set-buffer gnus-group-buffer
)
3489 (let ((buffer-read-only nil
)
3490 (newsrc (cdr gnus-newsrc-alist
))
3491 (lowest (or lowest
1))
3492 info clevel unread group
)
3494 (if (< lowest gnus-level-zombie
)
3495 ;; List living groups.
3497 (setq info
(car newsrc
)
3500 unread
(car (gnus-gethash group gnus-newsrc-hashtb
)))
3501 (and unread
; This group might be bogus
3503 (string-match regexp group
))
3504 (<= (setq clevel
(car (cdr info
))) level
)
3506 (or all
; We list all groups?
3507 (eq unread t
) ; We list unactivated groups
3508 (> unread
0) ; We list groups with unread articles
3509 (cdr (assq 'tick
(nth 3 info
)))) ; And ticked groups
3510 (gnus-group-insert-group-line
3511 nil group
(car (cdr info
)) (nth 3 info
) unread
(nth 4 info
)))))
3513 ;; List dead groups.
3514 (and (>= level gnus-level-zombie
) (<= lowest gnus-level-zombie
)
3515 (gnus-group-prepare-flat-list-dead
3516 (setq gnus-zombie-list
(sort gnus-zombie-list
'string
<))
3517 gnus-level-zombie ?Z
3519 (and (>= level gnus-level-killed
) (<= lowest gnus-level-killed
)
3520 (gnus-group-prepare-flat-list-dead
3521 (setq gnus-killed-list
(sort gnus-killed-list
'string
<))
3522 gnus-level-killed ?K regexp
))
3524 (gnus-group-set-mode-line)
3525 (setq gnus-group-list-mode
(cons level all
))
3526 (run-hooks 'gnus-group-prepare-hook
)))
3528 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp
)
3529 ;; List zombies and killed lists somewhat faster, which was
3530 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
3531 ;; this by ignoring the group format specification altogether.
3534 (setq group
(car groups
)
3535 groups
(cdr groups
))
3536 (if (or (not regexp
)
3537 (string-match regexp group
))
3540 (insert (format " %c *: %s\n" mark group
))
3541 (add-text-properties
3543 (list 'gnus-group
(intern group
)
3545 'gnus-level level
)))))))
3547 (defun gnus-group-real-name (group)
3548 "Find the real name of a foreign newsgroup."
3549 (if (string-match ":[^:]+$" group
)
3550 (substring group
(1+ (match-beginning 0)))
3553 (defun gnus-group-prefixed-name (group method
)
3554 "Return the whole name from GROUP and METHOD."
3555 (and (stringp method
) (setq method
(gnus-server-to-method method
)))
3556 (concat (format "%s" (car method
))
3558 (assoc (format "%s" (car method
)) (gnus-methods-using 'address
))
3559 (not (string= (nth 1 method
) "")))
3560 (concat "+" (nth 1 method
)))
3563 (defun gnus-group-real-prefix (group)
3564 "Return the prefix of the current group name."
3565 (if (string-match "^[^:]+:" group
)
3566 (substring group
0 (match-end 0))
3569 (defun gnus-group-method-name (group)
3570 "Return the method used for selecting GROUP."
3571 (let ((prefix (gnus-group-real-prefix group
)))
3572 (if (equal prefix
"")
3574 (if (string-match "^[^\\+]+\\+" prefix
)
3575 (list (intern (substring prefix
0 (1- (match-end 0))))
3576 (substring prefix
(match-end 0) (1- (length prefix
))))
3577 (list (intern (substring prefix
0 (1- (length prefix
)))) "")))))
3579 (defun gnus-group-foreign-p (group)
3580 "Return nil if GROUP is native, non-nil if it is foreign."
3581 (string-match ":" group
))
3583 (defun gnus-group-set-info (info &optional method-only-group part
)
3584 (let* ((entry (gnus-gethash
3585 (or method-only-group
(car info
)) gnus-newsrc-hashtb
))
3587 (info (if method-only-group
(nth 2 entry
) info
)))
3588 (if (not method-only-group
)
3591 (error "Trying to change non-existent group %s" method-only-group
))
3592 ;; We have received parts of the actual group info - either the
3593 ;; select method or the group parameters. We first check
3594 ;; whether we have to extend the info, and if so, do that.
3595 (let ((len (length info
))
3596 (total (if (eq part
'method
) 5 6)))
3598 (setcdr (nthcdr (1- len
) info
)
3599 (make-list (- total len
) nil
)))
3600 ;; Then we enter the new info.
3601 (setcar (nthcdr (1- total
) info
) part-info
)))
3602 ;; We uncompress some lists of marked articles.
3604 (if (not (setq marked
(nth 3 info
)))
3607 (or (eq 'score
(car (car marked
)))
3608 (eq 'bookmark
(car (car marked
)))
3609 (eq 'killed
(car (car marked
)))
3610 (setcdr (car marked
)
3611 (gnus-uncompress-range (cdr (car marked
)))))
3612 (setq marked
(cdr marked
)))))
3615 ;; This is a new group, so we just create it.
3617 (set-buffer gnus-group-buffer
)
3619 ;; It's a foreign group...
3620 (gnus-group-make-group
3621 (gnus-group-real-name (car info
))
3622 (prin1-to-string (car (nth 4 info
)))
3623 (nth 1 (nth 4 info
)))
3624 ;; It's a native group.
3625 (gnus-group-make-group (car info
)))
3626 (gnus-message 6 "Note: New group created")
3628 (gnus-gethash (gnus-group-prefixed-name
3629 (gnus-group-real-name (car info
))
3630 (or (nth 4 info
) gnus-select-method
))
3631 gnus-newsrc-hashtb
))))
3632 ;; Whether it was a new group or not, we now have the entry, so we
3633 ;; can do the update.
3636 (setcar (nthcdr 2 entry
) info
)
3637 (if (and (not (eq (car entry
) t
))
3638 (gnus-gethash (car info
) gnus-active-hashtb
))
3639 (let ((marked (nth 3 info
)))
3641 (max 0 (- (length (gnus-list-of-unread-articles
3643 (length (cdr (assq 'tick marked
)))
3644 (length (cdr (assq 'dormant marked
)))))))))
3645 (error "No such group: %s" (car info
)))))
3647 (defun gnus-group-set-method-info (group select-method
)
3648 (gnus-group-set-info select-method group
'method
))
3650 (defun gnus-group-set-params-info (group params
)
3651 (gnus-group-set-info params group
'params
))
3653 (defun gnus-group-update-group-line ()
3654 "This function updates the current line in the newsgroup buffer and
3655 moves the point to the colon."
3656 (let* ((buffer-read-only nil
)
3657 (group (gnus-group-group-name))
3658 (entry (and group
(gnus-gethash group gnus-newsrc-hashtb
))))
3659 (if (and entry
(not (gnus-ephemeral-group-p group
)))
3661 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry
))
3664 (delete-region (point) (progn (forward-line 1) (point)))
3665 (gnus-group-insert-group-line-info group
)
3667 (gnus-group-position-cursor)))
3669 (defun gnus-group-insert-group-line-info (group)
3670 (let ((entry (gnus-gethash group gnus-newsrc-hashtb
))
3674 (setq info
(nth 2 entry
))
3675 (gnus-group-insert-group-line
3676 nil group
(nth 1 info
) (nth 3 info
) (car entry
) (nth 4 info
)))
3677 (setq active
(gnus-gethash group gnus-active-hashtb
))
3678 (gnus-group-insert-group-line
3680 (if (member group gnus-zombie-list
) gnus-level-zombie gnus-level-killed
)
3681 nil
(if active
(- (1+ (cdr active
)) (car active
)) 0) nil
))))
3683 (defun gnus-group-insert-group-line (gformat group level marked number method
)
3684 (let* ((gformat (or gformat gnus-group-line-format-spec
))
3685 (active (gnus-gethash group gnus-active-hashtb
))
3686 (number-total (if active
(1+ (- (cdr active
) (car active
))) 0))
3687 (number-of-dormant (length (cdr (assq 'dormant marked
))))
3688 (number-of-ticked (length (cdr (assq 'tick marked
))))
3689 (number-of-ticked-and-dormant
3690 (+ number-of-ticked number-of-dormant
))
3691 (number-of-unread-unticked
3692 (if (numberp number
) (int-to-string (max 0 number
))
3695 (if (numberp number
)
3696 (max 0 (- number-total number
))
3698 (subscribed (cond ((<= level gnus-level-subscribed
) ?
)
3699 ((<= level gnus-level-unsubscribed
) ?U
)
3700 ((= level gnus-level-zombie
) ?Z
)
3702 (qualified-group (gnus-group-real-name group
))
3703 (newsgroup-description
3704 (if gnus-description-hashtb
3705 (or (gnus-gethash group gnus-description-hashtb
) "")
3707 (moderated (if (member group gnus-moderated-list
) ?m ?
))
3708 (moderated-string (if (eq moderated ?m
) "(m)" ""))
3709 (method (gnus-server-get-method group method
))
3710 (news-server (or (car (cdr method
)) ""))
3711 (news-method (or (car method
) ""))
3713 (if method
(format "(%s:%s)" (car method
) (car (cdr method
))) ""))
3717 (> number-of-ticked
0))
3719 (number (if (eq number t
) "*" (+ number number-of-dormant
3721 (process-marked (if (member group gnus-group-marked
)
3722 gnus-process-mark ?
))
3723 (buffer-read-only nil
)
3724 header
; passed as parameter to user-funcs.
3729 (insert (eval gformat
))
3731 (add-text-properties
3732 b
(1+ b
) (list 'gnus-group
(intern group
)
3733 'gnus-unread
(if (numberp number
)
3734 (string-to-int number-of-unread-unticked
)
3737 'gnus-level level
))))
3739 (defun gnus-group-update-group (group &optional visible-only
)
3740 "Update newsgroup info of GROUP.
3741 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't already."
3743 (set-buffer gnus-group-buffer
)
3744 (let ((buffer-read-only nil
)
3746 (let ((entry (gnus-gethash group gnus-newsrc-hashtb
)))
3748 (not (gnus-ephemeral-group-p group
)))
3750 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry
))
3752 ;; Buffer may be narrowed.
3755 ;; Search a line to modify. If the buffer is large, the search
3756 ;; takes long time. In most cases, current point is on the line
3757 ;; we are looking for. So, first of all, check current line.
3760 (eq (get-text-property (point) 'gnus-group
)
3765 (point-min) (point-max) 'gnus-group
(intern group
)))))
3766 ;; GROUP is listed in current buffer. So, delete old line.
3770 (delete-region (point) (progn (forward-line 1) (point))))
3771 ;; No such line in the buffer, find out where it's supposed to
3772 ;; go, and insert it there (or at the end of the buffer).
3773 ;; Fix by Per Abrahamsen <amanda@iesd.auc.dk>.
3776 (cdr (cdr (gnus-gethash group gnus-newsrc-hashtb
)))))
3782 (point-min) (point-max)
3783 'gnus-group
(intern (car (car entry
)))))))
3784 (setq entry
(cdr entry
)))
3785 (or entry
(goto-char (point-max)))))))
3786 (if (or visible
(not visible-only
))
3787 (gnus-group-insert-group-line-info group
))
3788 (gnus-group-set-mode-line))))
3790 (defun gnus-group-set-mode-line ()
3791 (if (memq 'group gnus-updated-mode-lines
)
3792 (let* ((gformat (or gnus-group-mode-line-format-spec
3793 (setq gnus-group-mode-line-format-spec
3795 gnus-group-mode-line-format
3796 gnus-group-mode-line-format-alist
))))
3797 (news-server (car (cdr gnus-select-method
)))
3798 (news-method (car gnus-select-method
))
3800 header
;Dummy binding for user-defined specs.
3801 (mode-string (eval gformat
)))
3802 (setq mode-string
(eval gformat
))
3803 (if (> (length mode-string
) max-len
)
3804 (setq mode-string
(substring mode-string
0 (- max-len
4))))
3805 (setq mode-line-buffer-identification mode-string
)
3806 (set-buffer-modified-p t
))))
3808 (defun gnus-group-group-name ()
3809 "Get the name of the newsgroup on the current line."
3810 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group
)))
3811 (and group
(symbol-name group
))))
3813 (defun gnus-group-group-level ()
3814 "Get the level of the newsgroup on the current line."
3815 (get-text-property (gnus-point-at-bol) 'gnus-level
))
3817 (defun gnus-group-group-unread ()
3818 "Get the number of unread articles of the newsgroup on the current line."
3819 (get-text-property (gnus-point-at-bol) 'gnus-unread
))
3821 (defun gnus-group-search-forward (&optional backward all level first-too
)
3822 "Find the next newsgroup with unread articles.
3823 If BACKWARD is non-nil, find the previous newsgroup instead.
3824 If ALL is non-nil, just find any newsgroup.
3825 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
3827 If FIRST-TOO, the current line is also eligible as a target."
3828 (let ((way (if backward -
1 1))
3829 (low gnus-level-killed
)
3832 (if (and backward
(progn (beginning-of-line)) (bobp))
3834 (or first-too
(forward-line way
))
3842 (get-text-property (point) 'gnus-unread
)))
3843 (or (eq unread t
) (and unread
(> unread
0))))
3844 (setq lev
(get-text-property (point)
3846 (<= lev gnus-level-subscribed
)))
3848 (and (setq lev
(get-text-property (point)
3857 (zerop (forward-line way
)))))
3859 (progn (gnus-group-position-cursor) t
)
3860 (goto-char (or pos beg
))
3863 ;;; Gnus group mode commands
3867 (defun gnus-group-mark-group (n &optional unmark no-advance
)
3868 "Mark the current group."
3870 (let ((buffer-read-only nil
)
3874 (setq group
(gnus-group-group-name))
3878 (or (cdr (assq 'process gnus-group-mark-positions
)) 2))
3883 (setq gnus-group-marked
(delete group gnus-group-marked
)))
3885 (setq gnus-group-marked
3886 (cons group
(delete group gnus-group-marked
))))
3888 (or no-advance
(zerop (gnus-group-next-group 1))))
3890 (gnus-summary-position-cursor)
3893 (defun gnus-group-unmark-group (n)
3894 "Remove the mark from the current group."
3896 (gnus-group-mark-group n
'unmark
))
3898 (defun gnus-group-mark-region (unmark beg end
)
3899 "Mark all groups between point and mark.
3900 If UNMARK, remove the mark instead."
3901 (interactive "P\nr")
3902 (let ((num (count-lines beg end
)))
3905 (- num
(gnus-group-mark-group num unmark
)))))
3907 (defun gnus-group-remove-mark (group)
3908 (and (gnus-group-goto-group group
)
3910 (gnus-group-mark-group 1 'unmark t
))))
3912 ;; Return a list of groups to work on. Take into consideration N (the
3913 ;; prefix) and the list of marked groups.
3914 (defun gnus-group-process-prefix (n)
3916 (setq n
(prefix-numeric-value n
))
3917 ;; There is a prefix, so we return a list of the N next
3919 (let ((way (if (< n
0) -
1 1))
3924 (setq group
(gnus-group-group-name)))
3925 (setq groups
(cons group groups
))
3927 (forward-line way
)))
3930 ;; No prefix, but a list of marked articles.
3931 (reverse gnus-group-marked
))
3933 ;; Neither marked articles or a prefix, so we return the
3935 (let ((group (gnus-group-group-name)))
3936 (and group
(list group
))))))
3938 ;; Selecting groups.
3940 (defun gnus-group-read-group (&optional all no-article group
)
3941 "Read news in this newsgroup.
3942 If the prefix argument ALL is non-nil, already read articles become
3943 readable. If the optional argument NO-ARTICLE is non-nil, no article
3944 will be auto-selected upon group entry."
3946 (let ((group (or group
(gnus-group-group-name)))
3947 number active marked entry
)
3948 (or group
(error "No group on current line"))
3950 (nth 3 (nth 2 (setq entry
(gnus-gethash group gnus-newsrc-hashtb
)))))
3951 ;; This group might be a dead group. In that case we have to get
3952 ;; the number of unread articles from `gnus-active-hashtb'.
3954 (setq number
(car entry
))
3955 (if (setq active
(gnus-gethash group gnus-active-hashtb
))
3956 (setq number
(- (1+ (cdr active
)) (car active
)))))
3957 (gnus-summary-read-group
3958 group
(or all
(and (numberp number
)
3959 (zerop (+ number
(length (cdr (assq 'tick marked
)))
3960 (length (cdr (assq 'dormant marked
)))))))
3963 (defun gnus-group-select-group (&optional all
)
3964 "Select this newsgroup.
3965 No article is selected automatically.
3966 If argument ALL is non-nil, already read articles become readable."
3968 (gnus-group-read-group all t
))
3970 (defun gnus-group-select-group-all ()
3971 "Select the current group and display all articles in it."
3973 (gnus-group-select-group 'all
))
3975 ;; Enter a group that is not in the group buffer. Non-nil is returned
3976 ;; if selection was successful.
3977 (defun gnus-group-read-ephemeral-group
3978 (group method
&optional activate quit-config
)
3979 (let ((group (if (gnus-group-foreign-p group
) group
3980 (gnus-group-prefixed-name group method
))))
3983 (list t nil
(list group gnus-level-default-subscribed nil nil
3987 (if quit-config quit-config
3988 (cons (current-buffer) 'summary
)))))))
3990 (set-buffer gnus-group-buffer
)
3991 (or (gnus-check-server method
)
3992 (error "Unable to contact server: %s" (gnus-status-message method
)))
3993 (if activate
(or (gnus-request-group group
)
3994 (error "Couldn't request group")))
3996 (gnus-group-read-group t t group
)
3999 (not (equal major-mode
'gnus-group-mode
))))
4001 (defun gnus-group-jump-to-group (group)
4002 "Jump to newsgroup GROUP."
4004 (list (completing-read
4005 "Group: " gnus-active-hashtb nil
4006 (memq gnus-select-method gnus-have-read-active-file
))))
4008 (if (equal group
"")
4009 (error "Empty group name"))
4011 (let ((b (text-property-any
4012 (point-min) (point-max) 'gnus-group
(intern group
))))
4014 ;; Either go to the line in the group buffer...
4016 ;; ... or insert the line.
4018 (gnus-gethash group gnus-active-hashtb
)
4019 (gnus-activate-group group
)
4020 (error "%s error: %s" group
(gnus-status-message group
)))
4022 (gnus-group-update-group group
)
4023 (goto-char (text-property-any
4024 (point-min) (point-max) 'gnus-group
(intern group
)))))
4025 ;; Adjust cursor point.
4026 (gnus-group-position-cursor))
4028 (defun gnus-group-goto-group (group)
4029 "Goto to newsgroup GROUP."
4030 (let ((b (text-property-any (point-min) (point-max)
4031 'gnus-group
(intern group
))))
4032 (and b
(goto-char b
))))
4034 (defun gnus-group-next-group (n)
4035 "Go to next N'th newsgroup.
4036 If N is negative, search backward instead.
4037 Returns the difference between N and the number of skips actually
4040 (gnus-group-next-unread-group n t
))
4042 (defun gnus-group-next-unread-group (n &optional all level
)
4043 "Go to next N'th unread newsgroup.
4044 If N is negative, search backward instead.
4045 If ALL is non-nil, choose any newsgroup, unread or not.
4046 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
4047 such group can be found, the next group with a level higher than
4049 Returns the difference between N and the number of skips actually
4052 (let ((backward (< n
0))
4055 (gnus-group-search-forward
4056 backward
(or (not gnus-group-goto-unread
) all
) level
))
4058 (if (/= 0 n
) (gnus-message 7 "No more%s newsgroups%s" (if all
"" " unread")
4059 (if level
" on this level or higher" "")))
4062 (defun gnus-group-prev-group (n)
4063 "Go to previous N'th newsgroup.
4064 Returns the difference between N and the number of skips actually
4067 (gnus-group-next-unread-group (- n
) t
))
4069 (defun gnus-group-prev-unread-group (n)
4070 "Go to previous N'th unread newsgroup.
4071 Returns the difference between N and the number of skips actually
4074 (gnus-group-next-unread-group (- n
)))
4076 (defun gnus-group-next-unread-group-same-level (n)
4077 "Go to next N'th unread newsgroup on the same level.
4078 If N is negative, search backward instead.
4079 Returns the difference between N and the number of skips actually
4082 (gnus-group-next-unread-group n t
(gnus-group-group-level))
4083 (gnus-group-position-cursor))
4085 (defun gnus-group-prev-unread-group-same-level (n)
4086 "Go to next N'th unread newsgroup on the same level.
4087 Returns the difference between N and the number of skips actually
4090 (gnus-group-next-unread-group (- n
) t
(gnus-group-group-level))
4091 (gnus-group-position-cursor))
4093 (defun gnus-group-best-unread-group (&optional exclude-group
)
4094 "Go to the group with the highest level.
4095 If EXCLUDE-GROUP, do not go to that group."
4097 (goto-char (point-min))
4100 (while (setq unread
(get-text-property (point) 'gnus-unread
))
4101 (if (and (numberp unread
) (> unread
0))
4103 (if (and (< (get-text-property (point) 'gnus-level
) best
)
4104 (or (not exclude-group
)
4105 (not (equal exclude-group
(gnus-group-group-name)))))
4107 (setq best
(get-text-property (point) 'gnus-level
))
4108 (setq best-point
(point))))))
4110 (if best-point
(goto-char best-point
))
4111 (gnus-summary-position-cursor)
4112 (and best-point
(gnus-group-group-name))))
4114 (defun gnus-group-first-unread-group ()
4115 "Go to the first group with unread articles."
4118 (let ((opoint (point))
4120 (goto-char (point-min))
4121 (if (or (eq (setq unread
(gnus-group-group-unread)) t
) ; Not active.
4122 (not (zerop unread
)) ; Has unread articles.
4123 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
4126 nil
)) ; Not success.
4127 (gnus-group-position-cursor)))
4129 (defun gnus-group-enter-server-mode ()
4130 "Jump to the server buffer."
4132 (gnus-server-setup-buffer)
4133 (gnus-configure-windows 'server
)
4134 (gnus-server-prepare))
4136 (defun gnus-group-make-group (name &optional method address
)
4137 "Add a new newsgroup.
4138 The user will be prompted for a NAME, for a select METHOD, and an
4142 (read-string "Group name: ")
4145 "Method: " (append gnus-valid-select-methods gnus-server-alist
)
4147 (if (assoc method gnus-valid-select-methods
)
4149 (if (memq 'prompt-address
4150 (assoc method gnus-valid-select-methods
))
4151 (read-string "Address: ")
4153 (list method nil
)))))
4155 (let* ((meth (and method
(if address
(list (intern method
) address
) method
)))
4156 (nname (if method
(gnus-group-prefixed-name name meth
) name
))
4158 (and (gnus-gethash nname gnus-newsrc-hashtb
)
4159 (error "Group %s already exists" nname
))
4160 (gnus-group-change-level
4161 (setq info
(list t nname gnus-level-default-subscribed nil nil meth
))
4162 gnus-level-default-subscribed gnus-level-killed
4163 (and (gnus-group-group-name)
4164 (gnus-gethash (gnus-group-group-name)
4165 gnus-newsrc-hashtb
))
4167 (gnus-sethash nname
(cons 1 0) gnus-active-hashtb
)
4168 (or (gnus-ephemeral-group-p name
)
4170 (concat "(gnus-group-set-info '" (prin1-to-string (cdr info
)) ")")))
4171 (gnus-group-insert-group-line-info nname
)
4173 (if (assoc method gnus-valid-select-methods
)
4174 (require (intern method
)))
4175 (and (gnus-check-backend-function 'request-create-group nname
)
4176 (gnus-request-create-group nname
))))
4178 (defun gnus-group-edit-group (group &optional part
)
4179 "Edit the group on the current line."
4180 (interactive (list (gnus-group-group-name)))
4181 (let ((done-func '(lambda ()
4182 "Exit editing mode and update the information."
4184 (gnus-group-edit-group-done 'part
'group
)))
4185 (part (or part
'info
))
4186 (winconf (current-window-configuration))
4188 (or group
(error "No group on current line"))
4189 (or (setq info
(nth 2 (gnus-gethash group gnus-newsrc-hashtb
)))
4190 (error "Killed group; can't be edited"))
4191 (set-buffer (get-buffer-create gnus-group-edit-buffer
))
4192 (gnus-configure-windows 'edit-group
)
4193 (gnus-add-current-to-buffer-list)
4195 ;; Suggested by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4196 (use-local-map (copy-keymap emacs-lisp-mode-map
))
4197 (local-set-key "\C-c\C-c" done-func
)
4198 (make-local-variable 'gnus-prev-winconf
)
4199 (setq gnus-prev-winconf winconf
)
4200 ;; We modify the func to let it know what part it is editing.
4201 (setcar (cdr (nth 4 done-func
)) (list 'quote part
))
4202 (setcar (cdr (cdr (nth 4 done-func
))) group
)
4207 ";; Type `C-c C-c' after editing the select method.\n\n")
4209 ";; Type `C-c C-c' after editing the group parameters.\n\n")
4211 ";; Type `C-c C-c' after editing the group info.\n\n")))
4212 (let ((cinfo (gnus-copy-sequence info
))
4214 (if (not (setq marked
(nth 3 cinfo
)))
4217 (or (eq 'score
(car (car marked
)))
4218 (eq 'bookmark
(car (car marked
)))
4219 (eq 'killed
(car (car marked
)))
4220 (not (numberp (car (cdr (car marked
)))))
4221 (setcdr (car marked
)
4222 (gnus-compress-sequence (sort (cdr (car marked
)) '<) t
)))
4223 (setq marked
(cdr marked
))))
4226 (cond ((eq part
'method
)
4227 (or (nth 4 info
) "native"))
4234 (defun gnus-group-edit-group-method (group)
4235 "Edit the select method of GROUP."
4236 (interactive (list (gnus-group-group-name)))
4237 (gnus-group-edit-group group
'method
))
4239 (defun gnus-group-edit-group-parameters (group)
4240 "Edit the group parameters of GROUP."
4241 (interactive (list (gnus-group-group-name)))
4242 (gnus-group-edit-group group
'params
))
4244 (defun gnus-group-edit-group-done (part group
)
4245 "Get info from buffer, update variables and jump to the group buffer."
4246 (set-buffer (get-buffer-create gnus-group-edit-buffer
))
4247 (goto-char (point-min))
4248 (let ((form (read (current-buffer)))
4249 (winconf gnus-prev-winconf
))
4251 (gnus-group-set-info form
)
4252 (gnus-group-set-info form group part
))
4253 (kill-buffer (current-buffer))
4254 (and winconf
(set-window-configuration winconf
))
4255 (set-buffer gnus-group-buffer
)
4256 (gnus-group-update-group (gnus-group-group-name))
4257 (gnus-group-position-cursor)))
4259 (defun gnus-group-make-help-group ()
4260 "Create the Gnus documentation group."
4262 (let ((path (if installation-directory
4263 (cons (concat installation-directory
"etc/") load-path
)
4264 (cons data-directory load-path
)))
4265 (name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
4267 (and (gnus-gethash name gnus-newsrc-hashtb
)
4268 (error "Documentation group already exists"))
4271 (setq file
(concat (file-name-as-directory (car path
))
4273 (setq path
(cdr path
)))
4275 (message "Couldn't find doc group")
4276 (gnus-group-make-group
4277 (gnus-group-real-name name
)
4279 (list 'nndoc-address file
)
4280 (list 'nndoc-article-type
'mbox
)))))
4281 (gnus-group-position-cursor))
4283 (defun gnus-group-make-doc-group (file type
)
4284 "Create a group that uses a single file as the source."
4286 (list (read-file-name "File name: ")
4290 (message "%sFile type (mbox, babyl, digest) [mbd]: " err
)
4291 (setq found
(cond ((= (setq char
(read-char)) ?m
) 'mbox
)
4292 ((= char ?b
) 'babyl
)
4293 ((= char ?d
) 'digest
)
4294 (t (setq err
(format "%c unknown. " char
))
4297 (let* ((file (expand-file-name file
))
4298 (name (gnus-generate-new-group-name
4299 (gnus-group-prefixed-name
4300 (file-name-nondirectory file
) '(nndoc "")))))
4301 (gnus-group-make-group
4302 (gnus-group-real-name name
)
4304 (list 'nndoc-address file
)
4305 (list 'nndoc-article-type type
)))))
4307 (defun gnus-group-make-archive-group (&optional all
)
4308 "Create the (ding) Gnus archive group of the most recent articles.
4309 Given a prefix, create a full group."
4311 (let ((group (gnus-group-prefixed-name
4312 (if all
"ding.archives" "ding.recent") '(nndir ""))))
4313 (and (gnus-gethash group gnus-newsrc-hashtb
)
4314 (error "Archive group already exists"))
4315 (gnus-group-make-group
4316 (gnus-group-real-name group
)
4318 (if all gnus-group-archive-directory
4319 gnus-group-recent-archive-directory
)))
4320 (gnus-group-position-cursor))
4322 (defun gnus-group-make-directory-group (dir)
4323 "Create an nndir group.
4324 The user will be prompted for a directory. The contents of this
4325 directory will be used as a newsgroup. The directory should contain
4326 mail messages or news articles in files that have numeric names."
4328 (list (read-file-name "Create group from directory: ")))
4329 (or (file-exists-p dir
) (error "No such directory"))
4330 (or (file-directory-p dir
) (error "Not a directory"))
4331 (gnus-group-make-group dir
"nndir" dir
)
4332 (gnus-group-position-cursor))
4334 (defun gnus-group-make-kiboze-group (group address scores
)
4335 "Create an nnkiboze group.
4336 The user will be prompted for a name, a regexp to match groups, and
4337 score file entries for articles to include in the group."
4340 (read-string "nnkiboze group name: ")
4341 (read-string "Source groups (regexp): ")
4342 (let ((headers (mapcar (lambda (group) (list group
))
4343 '("subject" "from" "number" "date" "message-id"
4344 "references" "chars" "lines" "xref")))
4345 scores header regexp regexps
)
4346 (while (not (equal "" (setq header
(completing-read
4347 "Match on header: " headers nil t
))))
4349 (while (not (equal "" (setq regexp
(read-string
4350 (format "Match on %s (string): "
4352 (setq regexps
(cons (list regexp nil nil
'r
) regexps
)))
4353 (setq scores
(cons (cons header regexps
) scores
)))
4355 (gnus-group-make-group group
"nnkiboze" address
)
4357 (gnus-set-work-buffer)
4358 (let (emacs-lisp-mode-hook)
4359 (pp scores
(current-buffer)))
4360 (write-region (point-min) (point-max)
4361 (concat (or gnus-kill-files-directory
"~/News")
4362 "nnkiboze:" group
"." gnus-score-file-suffix
)))
4363 (gnus-group-position-cursor))
4365 (defun gnus-group-add-to-virtual (n vgroup
)
4366 "Add the current group to a virtual group."
4368 (list current-prefix-arg
4369 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
4371 (or (eq (car (gnus-find-method-for-group vgroup
)) 'nnvirtual
)
4372 (error "%s is not an nnvirtual group" vgroup
))
4373 (let* ((groups (gnus-group-process-prefix n
))
4374 (method (nth 4 (nth 2 (gnus-gethash vgroup gnus-newsrc-hashtb
)))))
4375 (setcar (cdr method
)
4377 (nth 1 method
) "\\|"
4380 (gnus-group-remove-mark s
)
4381 (concat "\\(^" (regexp-quote s
) "$\\)"))
4383 (gnus-group-position-cursor))
4385 (defun gnus-group-make-empty-virtual (group)
4386 "Create a new, fresh, empty virtual group."
4387 (interactive "sCreate new, empty virtual group: ")
4388 (let* ((method (list 'nnvirtual
"^$"))
4389 (pgroup (gnus-group-prefixed-name group method
)))
4390 ;; Check whether it exists already.
4391 (and (gnus-gethash pgroup gnus-newsrc-hashtb
)
4392 (error "Group %s already exists." pgroup
))
4393 ;; Subscribe the new group after the group on the current line.
4394 (gnus-subscribe-group pgroup
(gnus-group-group-name) method
)
4395 (gnus-group-update-group pgroup
)
4397 (gnus-group-position-cursor)))
4399 (defun gnus-group-enter-directory (dir)
4400 "Enter an ephemeral nneething group."
4401 (interactive "DDirectory to read: ")
4402 (let* ((method (list 'nneething dir
))
4403 (leaf (gnus-group-prefixed-name
4404 (file-name-nondirectory (directory-file-name dir
))
4406 (name (gnus-generate-new-group-name leaf
)))
4407 (let ((nneething-read-only t
))
4408 (or (gnus-group-read-ephemeral-group
4410 (cons (current-buffer) (if (eq major-mode
'gnus-summary-mode
)
4412 (error "Couldn't enter %s" dir
)))))
4414 ;; Group sorting commands
4415 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
4417 (defun gnus-group-sort-groups ()
4418 "Sort the group buffer using `gnus-group-sort-function'."
4420 (setq gnus-newsrc-alist
4421 (sort (cdr gnus-newsrc-alist
) gnus-group-sort-function
))
4422 (gnus-make-hashtable-from-newsrc-alist)
4423 (gnus-group-list-groups))
4425 (defun gnus-group-sort-by-alphabet (info1 info2
)
4426 (string< (car info1
) (car info2
)))
4428 (defun gnus-group-sort-by-unread (info1 info2
)
4429 (let ((n1 (car (gnus-gethash (car info1
) gnus-newsrc-hashtb
)))
4430 (n2 (car (gnus-gethash (car info2
) gnus-newsrc-hashtb
))))
4431 (< (or (and (numberp n1
) n1
) 0)
4432 (or (and (numberp n2
) n2
) 0))))
4434 (defun gnus-group-sort-by-level (info1 info2
)
4435 (< (nth 1 info1
) (nth 1 info2
)))
4437 ;; Group catching up.
4439 (defun gnus-group-catchup-current (&optional n all
)
4440 "Mark all articles not marked as unread in current newsgroup as read.
4441 If prefix argument N is numeric, the ARG next newsgroups will be
4442 caught up. If ALL is non-nil, marked articles will also be marked as
4443 read. Cross references (Xref: header) of articles are ignored.
4444 The difference between N and actual number of newsgroups that were
4445 caught up is returned."
4447 (if (not (or (not gnus-interactive-catchup
) ;Without confirmation?
4451 "Do you really want to mark all articles as read? "
4452 "Mark all unread articles as read? "))))
4454 (let ((groups (gnus-group-process-prefix n
))
4457 ;; Virtual groups have to be given special treatment.
4458 (let ((method (gnus-find-method-for-group (car groups
))))
4459 (if (eq 'nnvirtual
(car method
))
4460 (nnvirtual-catchup-group
4461 (gnus-group-real-name (car groups
)) (nth 1 method
) all
)))
4462 (gnus-group-remove-mark (car groups
))
4464 (gnus-group-goto-group (car groups
))
4465 (gnus-group-catchup (car groups
) all
))
4466 (gnus-group-update-group-line)
4467 (setq ret
(1+ ret
)))
4468 (setq groups
(cdr groups
)))
4469 (gnus-group-next-unread-group 1)
4472 (defun gnus-group-catchup-current-all (&optional n
)
4473 "Mark all articles in current newsgroup as read.
4474 Cross references (Xref: header) of articles are ignored."
4476 (gnus-group-catchup-current n
'all
))
4478 (defun gnus-group-catchup (group &optional all
)
4479 "Mark all articles in GROUP as read.
4480 If ALL is non-nil, all articles are marked as read.
4481 The return value is the number of articles that were marked as read,
4482 or nil if no action could be taken."
4483 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb
))
4485 (marked (nth 3 (nth 2 entry
))))
4486 (if (not (numberp (car entry
)))
4487 (gnus-message 1 "Can't catch up; non-active group")
4488 ;; Do the updating only if the newsgroup isn't killed.
4491 (gnus-update-read-articles
4492 group
(and (not all
) (append (cdr (assq 'tick marked
))
4493 (cdr (assq 'dormant marked
))))
4494 nil
(and (not all
) (cdr (assq 'tick marked
))))
4496 (setq marked
(nth 3 (nth 2 entry
)))
4497 (setcar (nthcdr 3 (nth 2 entry
))
4498 (delq (assq 'dormant marked
)
4499 (nth 3 (nth 2 entry
)))))))
4502 (defun gnus-group-expire-articles (&optional n
)
4503 "Expire all expirable articles in the current newsgroup."
4505 (let ((groups (gnus-group-process-prefix n
))
4507 (or groups
(error "No groups to expire"))
4509 (setq group
(car groups
)
4510 groups
(cdr groups
))
4511 (gnus-group-remove-mark group
)
4512 (if (not (gnus-check-backend-function 'request-expire-articles group
))
4514 (let* ((info (nth 2 (gnus-gethash group gnus-newsrc-hashtb
)))
4515 (expirable (if (memq 'total-expire
(nth 5 info
))
4516 (cons nil
(gnus-list-of-read-articles group
))
4517 (assq 'expire
(nth 3 info
)))))
4520 (gnus-request-expire-articles
4521 (cdr expirable
) group
))))))))
4523 (defun gnus-group-expire-all-groups ()
4524 "Expire all expirable articles in all newsgroups."
4527 (gnus-message 5 "Expiring...")
4528 (let ((gnus-group-marked (mapcar (lambda (info) (car info
))
4529 (cdr gnus-newsrc-alist
))))
4530 (gnus-group-expire-articles nil
)))
4531 (gnus-group-position-cursor)
4532 (gnus-message 5 "Expiring...done"))
4534 (defun gnus-group-set-current-level (n level
)
4535 "Set the level of the next N groups to LEVEL."
4536 (interactive "P\nnLevel: ")
4537 (or (and (>= level
1) (<= level gnus-level-killed
))
4538 (error "Illegal level: %d" level
))
4539 (let ((groups (gnus-group-process-prefix n
))
4542 (setq group
(car groups
)
4543 groups
(cdr groups
))
4544 (gnus-group-remove-mark group
)
4545 (gnus-message 6 "Changed level of %s from %d to %d"
4546 group
(gnus-group-group-level) level
)
4547 (gnus-group-change-level group level
4548 (gnus-group-group-level))
4549 (gnus-group-update-group-line)))
4550 (gnus-group-position-cursor))
4552 (defun gnus-group-unsubscribe-current-group (&optional n
)
4553 "Toggle subscription of the current group.
4554 If given numerical prefix, toggle the N next groups."
4556 (let ((groups (gnus-group-process-prefix n
))
4559 (setq group
(car groups
)
4560 groups
(cdr groups
))
4561 (gnus-group-remove-mark group
)
4562 (gnus-group-unsubscribe-group
4563 group
(if (<= (gnus-group-group-level) gnus-level-subscribed
)
4564 gnus-level-default-unsubscribed
4565 gnus-level-default-subscribed
))
4566 (gnus-group-update-group-line))
4567 (gnus-group-next-group 1)))
4569 (defun gnus-group-unsubscribe-group (group &optional level
)
4570 "Toggle subscribe from/to unsubscribe GROUP.
4571 New newsgroup is added to .newsrc automatically."
4573 (list (completing-read
4574 "Group: " gnus-active-hashtb nil
4575 (memq gnus-select-method gnus-have-read-active-file
))))
4576 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb
)))
4578 ((string-match "^[ \t]$" group
)
4579 (error "Empty group name"))
4581 ;; Toggle subscription flag.
4582 (gnus-group-change-level
4583 newsrc
(if level level
(if (<= (nth 1 (nth 2 newsrc
))
4584 gnus-level-subscribed
)
4585 (1+ gnus-level-subscribed
)
4586 gnus-level-default-subscribed
)))
4587 (gnus-group-update-group group
))
4588 ((and (stringp group
)
4589 (or (not (memq gnus-select-method gnus-have-read-active-file
))
4590 (gnus-gethash group gnus-active-hashtb
)))
4591 ;; Add new newsgroup.
4592 (gnus-group-change-level
4594 (if level level gnus-level-default-subscribed
)
4595 (or (and (member group gnus-zombie-list
)
4598 (and (gnus-group-group-name)
4599 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb
)))
4600 (gnus-group-update-group group
))
4601 (t (error "No such newsgroup: %s" group
)))
4602 (gnus-group-position-cursor)))
4604 (defun gnus-group-transpose-groups (n)
4605 "Move the current newsgroup up N places.
4606 If given a negative prefix, move down instead. The difference between
4607 N and the number of steps taken is returned."
4609 (or (gnus-group-group-name)
4610 (error "No group on current line"))
4611 (gnus-group-kill-group 1)
4613 (forward-line (- n
))
4614 (gnus-group-yank-group)
4615 (gnus-group-position-cursor)))
4617 (defun gnus-group-kill-all-zombies ()
4618 "Kill all zombie newsgroups."
4620 (setq gnus-killed-list
(nconc gnus-zombie-list gnus-killed-list
))
4621 (setq gnus-zombie-list nil
)
4622 (gnus-group-list-groups))
4624 (defun gnus-group-kill-region (begin end
)
4625 "Kill newsgroups in current region (excluding current point).
4626 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
4641 (beginning-of-line) ;Important when LINES < 1
4642 (gnus-group-kill-group lines
)))
4644 (defun gnus-group-kill-group (&optional n
)
4645 "The the next N groups.
4646 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
4647 However, only groups that were alive can be yanked; already killed
4648 groups or zombie groups can't be yanked.
4649 The return value is the name of the (last) group that was killed."
4651 (let ((buffer-read-only nil
)
4652 (groups (gnus-group-process-prefix n
))
4655 (setq group
(car groups
)
4656 groups
(cdr groups
))
4657 (gnus-group-remove-mark group
)
4658 (setq level
(gnus-group-group-level))
4660 (if (setq entry
(gnus-gethash group gnus-newsrc-hashtb
))
4661 (setq gnus-list-of-killed-groups
4662 (cons (cons (car entry
) (nth 2 entry
))
4663 gnus-list-of-killed-groups
)))
4664 (gnus-group-change-level
4665 (if entry entry group
) gnus-level-killed
(if entry nil level
)))
4666 (gnus-group-position-cursor)
4669 (defun gnus-group-yank-group (&optional arg
)
4670 "Yank the last newsgroups killed with \\[gnus-group-kill-group],
4671 inserting it before the current newsgroup. The numeric ARG specifies
4672 how many newsgroups are to be yanked. The name of the (last)
4673 newsgroup yanked is returned."
4675 (if (not arg
) (setq arg
1))
4676 (let (info group prev
)
4677 (while (>= (setq arg
(1- arg
)) 0)
4678 (if (not (setq info
(car gnus-list-of-killed-groups
)))
4679 (error "No more newsgroups to yank"))
4680 (setq group
(nth 2 info
))
4681 ;; Find which newsgroup to insert this one before - search
4682 ;; backward until something suitable is found. If there are no
4683 ;; other newsgroups in this buffer, just make this newsgroup the
4685 (setq prev
(gnus-group-group-name))
4686 (gnus-group-change-level
4687 info
(nth 2 info
) gnus-level-killed
4688 (and prev
(gnus-gethash prev gnus-newsrc-hashtb
))
4690 (gnus-group-insert-group-line-info (nth 1 info
))
4691 (setq gnus-list-of-killed-groups
4692 (cdr gnus-list-of-killed-groups
)))
4694 (gnus-group-position-cursor)
4697 (defun gnus-group-list-all-groups (&optional arg
)
4698 "List all newsgroups with level ARG or lower.
4699 Default is gnus-level-unsubscribed, which lists all subscribed and most
4700 unsubscribed groups."
4702 (gnus-group-list-groups (or arg gnus-level-unsubscribed
) t
))
4704 (defun gnus-group-list-killed ()
4705 "List all killed newsgroups in the group buffer."
4707 (if (not gnus-killed-list
)
4708 (gnus-message 6 "No killed groups")
4709 (let (gnus-group-list-mode)
4710 (funcall gnus-group-prepare-function
4711 gnus-level-killed t gnus-level-killed
))
4712 (goto-char (point-min)))
4713 (gnus-group-position-cursor))
4715 (defun gnus-group-list-zombies ()
4716 "List all zombie newsgroups in the group buffer."
4718 (if (not gnus-zombie-list
)
4719 (gnus-message 6 "No zombie groups")
4720 (let (gnus-group-list-mode)
4721 (funcall gnus-group-prepare-function
4722 gnus-level-zombie t gnus-level-zombie
))
4723 (goto-char (point-min)))
4724 (gnus-group-position-cursor))
4726 (defun gnus-group-get-new-news (&optional arg
)
4727 "Get newly arrived articles.
4728 If ARG is non-nil, it should be a number between one and nine to
4729 specify which levels you are interested in re-scanning."
4731 (run-hooks 'gnus-get-new-news-hook
)
4732 (setq arg
(gnus-group-default-level arg t
))
4733 (if (and gnus-read-active-file
(not arg
))
4735 (gnus-read-active-file)
4736 (gnus-get-unread-articles (or arg
(1+ gnus-level-subscribed
))))
4737 (let ((gnus-read-active-file (if arg nil gnus-read-active-file
)))
4738 (gnus-get-unread-articles (or arg
(1+ gnus-level-subscribed
)))))
4739 (gnus-group-list-groups))
4741 (defun gnus-group-get-new-news-this-group (&optional n
)
4742 "Check for newly arrived news in the current group (and the N-1 next groups).
4743 The difference between N and the number of newsgroup checked is returned.
4744 If N is negative, this group and the N-1 previous groups will be checked."
4746 (let* ((groups (gnus-group-process-prefix n
))
4747 (ret (if (numberp n
) (- n
(length groups
)) 0))
4750 (setq group
(car groups
)
4751 groups
(cdr groups
))
4752 (gnus-group-remove-mark group
)
4753 (or (gnus-get-new-news-in-group group
)
4756 (message "%s error: %s" group
(gnus-status-message group
))
4758 (gnus-group-next-unread-group 1 t
)
4759 (gnus-summary-position-cursor)
4762 (defun gnus-get-new-news-in-group (group)
4764 (gnus-activate-group group
)
4766 (gnus-get-unread-articles-in-group
4767 (nth 2 (gnus-gethash group gnus-newsrc-hashtb
))
4768 (gnus-gethash group gnus-active-hashtb
))
4769 (gnus-group-update-group-line)
4772 (defun gnus-group-fetch-faq (group)
4773 "Fetch the FAQ for the current group."
4774 (interactive (list (gnus-group-real-name (gnus-group-group-name))))
4775 (or group
(error "No group name given"))
4776 (let ((file (concat gnus-group-faq-directory
(gnus-group-real-name group
))))
4777 (if (not (file-exists-p file
))
4778 (error "No such file: %s" file
)
4781 (defun gnus-group-describe-group (force &optional group
)
4782 "Display a description of the current newsgroup."
4783 (interactive (list current-prefix-arg
(gnus-group-group-name)))
4784 (and force
(setq gnus-description-hashtb nil
))
4785 (let ((method (gnus-find-method-for-group group
))
4787 (or group
(error "No group name given"))
4788 (and (or (and gnus-description-hashtb
4789 ;; We check whether this group's method has been
4790 ;; queried for a description file.
4792 (gnus-group-prefixed-name "" method
)
4793 gnus-description-hashtb
))
4794 (setq desc
(gnus-group-get-description group
))
4795 (gnus-read-descriptions-file method
))
4797 (or desc
(gnus-gethash group gnus-description-hashtb
)
4798 "No description available")))))
4800 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
4801 (defun gnus-group-describe-all-groups (&optional force
)
4802 "Pop up a buffer with descriptions of all newsgroups."
4804 (and force
(setq gnus-description-hashtb nil
))
4805 (if (not (or gnus-description-hashtb
4806 (gnus-read-all-descriptions-files)))
4807 (error "Couldn't request descriptions file"))
4808 (let ((buffer-read-only nil
)
4814 (insert (format " *: %-20s %s\n" (symbol-name group
)
4815 (symbol-value group
)))
4816 (add-text-properties
4817 b
(1+ b
) (list 'gnus-group group
4818 'gnus-unread t
'gnus-marked nil
4819 'gnus-level
(1+ gnus-level-subscribed
))))
4820 gnus-description-hashtb
)
4821 (goto-char (point-min))
4822 (gnus-group-position-cursor)))
4824 ;; Suggested by by Daniel Quinlan <quinlan@best.com>.
4825 (defun gnus-group-apropos (regexp &optional search-description
)
4826 "List all newsgroups that have names that match a regexp."
4827 (interactive "sGnus apropos (regexp): ")
4829 (obuf (current-buffer))
4831 ;; Go through all newsgroups that are known to Gnus.
4834 (and (symbol-name group
)
4835 (string-match regexp
(symbol-name group
))
4836 (setq groups
(cons (symbol-name group
) groups
))))
4838 ;; Go through all descriptions that are known to Gnus.
4839 (if search-description
4842 (and (string-match regexp
(symbol-value group
))
4843 (gnus-gethash (symbol-name group
) gnus-active-hashtb
)
4844 (setq groups
(cons (symbol-name group
) groups
))))
4845 gnus-description-hashtb
))
4847 (gnus-message 3 "No groups matched \"%s\"." regexp
)
4848 ;; Print out all the groups.
4850 (pop-to-buffer "*Gnus Help*")
4851 (buffer-disable-undo (current-buffer))
4853 (setq groups
(sort groups
'string
<))
4855 ;; Groups may be entered twice into the list of groups.
4856 (if (not (string= (car groups
) prev
))
4858 (insert (setq prev
(car groups
)) "\n")
4859 (if (and gnus-description-hashtb
4860 (setq des
(gnus-gethash (car groups
)
4861 gnus-description-hashtb
)))
4862 (insert " " des
"\n"))))
4863 (setq groups
(cdr groups
)))
4864 (goto-char (point-min))))
4865 (pop-to-buffer obuf
)))
4867 (defun gnus-group-description-apropos (regexp)
4868 "List all newsgroups that have names or descriptions that match a regexp."
4869 (interactive "sGnus description apropos (regexp): ")
4870 (if (not (or gnus-description-hashtb
4871 (gnus-read-all-descriptions-files)))
4872 (error "Couldn't request descriptions file"))
4873 (gnus-group-apropos regexp t
))
4875 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
4876 (defun gnus-group-list-matching (level regexp
&optional all lowest
)
4877 "List all groups with unread articles that match REGEXP.
4878 If the prefix LEVEL is non-nil, it should be a number that says which
4879 level to cut off listing groups.
4880 If ALL, also list groups with no unread articles.
4881 If LOWEST, don't list groups with level lower than LOWEST."
4882 (interactive "P\nsList newsgroups matching: ")
4883 (gnus-group-prepare-flat (or level gnus-level-subscribed
)
4884 all
(or lowest
1) regexp
)
4885 (goto-char (point-min))
4886 (gnus-group-position-cursor))
4888 (defun gnus-group-list-all-matching (level regexp
&optional lowest
)
4889 "List all groups that match REGEXP.
4890 If the prefix LEVEL is non-nil, it should be a number that says which
4891 level to cut off listing groups.
4892 If LOWEST, don't list groups with level lower than LOWEST."
4893 (interactive "P\nsList newsgroups matching: ")
4894 (gnus-group-list-matching (or level gnus-level-killed
) regexp t lowest
))
4896 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
4897 (defun gnus-group-save-newsrc ()
4898 "Save the Gnus startup files."
4900 (gnus-save-newsrc-file))
4902 (defun gnus-group-restart (&optional arg
)
4903 "Force Gnus to read the .newsrc file."
4905 (gnus-save-newsrc-file)
4906 (gnus-setup-news 'force
)
4907 (gnus-group-list-groups arg
))
4909 (defun gnus-group-read-init-file ()
4910 "Read the Gnus elisp init file."
4912 (gnus-read-init-file))
4914 (defun gnus-group-check-bogus-groups (&optional silent
)
4915 "Check bogus newsgroups.
4916 If given a prefix, don't ask for confirmation before removing a bogus
4919 (gnus-check-bogus-newsgroups (and (not silent
) (not gnus-expert-user
)))
4920 (gnus-group-list-groups))
4922 (defun gnus-group-edit-global-kill (&optional article group
)
4923 "Edit the global kill file.
4924 If GROUP, edit that local kill file instead."
4926 (setq gnus-current-kill-article article
)
4927 (gnus-kill-file-edit-file group
)
4930 (substitute-command-keys
4931 "Editing a global kill file (Type \\[gnus-kill-file-exit] to exit)")))
4933 (defun gnus-group-edit-local-kill (article group
)
4934 "Edit a local kill file."
4935 (interactive (list nil
(gnus-group-group-name)))
4936 (gnus-group-edit-global-kill article group
))
4938 (defun gnus-group-force-update ()
4939 "Update `.newsrc' file."
4941 (gnus-save-newsrc-file))
4943 (defun gnus-group-suspend ()
4944 "Suspend the current Gnus session.
4945 In fact, cleanup buffers except for group mode buffer.
4946 The hook gnus-suspend-gnus-hook is called before actually suspending."
4948 (run-hooks 'gnus-suspend-gnus-hook
)
4949 ;; Kill Gnus buffers except for group mode buffer.
4950 (let ((group-buf (get-buffer gnus-group-buffer
)))
4951 ;; Do this on a separate list in case the user does a ^G before we finish
4952 (let ((gnus-buffer-list
4953 (delq group-buf
(delq gnus-dribble-buffer
4954 (append gnus-buffer-list nil
)))))
4955 (while gnus-buffer-list
4956 (gnus-kill-buffer (car gnus-buffer-list
))
4957 (setq gnus-buffer-list
(cdr gnus-buffer-list
))))
4960 (setq gnus-buffer-list
(list group-buf
))
4961 (bury-buffer group-buf
)
4962 (delete-windows-on group-buf t
)))))
4964 (defun gnus-group-clear-dribble ()
4965 "Clear all information from the dribble buffer."
4967 (gnus-dribble-clear))
4969 (defun gnus-group-exit ()
4970 "Quit reading news after updating .newsrc.eld and .newsrc.
4971 The hook `gnus-exit-gnus-hook' is called before actually exiting."
4973 (if (or noninteractive
;For gnus-batch-kill
4974 (not (gnus-server-opened gnus-select-method
)) ;NNTP connection closed
4975 (not gnus-interactive-exit
) ;Without confirmation
4977 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
4979 (run-hooks 'gnus-exit-gnus-hook
)
4980 ;; Offer to save data from non-quitted summary buffers.
4981 (gnus-offer-save-summaries)
4982 ;; Save the newsrc file(s).
4983 (gnus-save-newsrc-file)
4985 (gnus-close-backends)
4986 ;; Reset everything.
4987 (gnus-clear-system))))
4989 (defun gnus-close-backends ()
4990 ;; Send a close request to all backends that support such a request.
4991 (let ((methods gnus-valid-select-methods
)
4994 (if (fboundp (setq func
(intern (concat (car (car methods
))
4995 "-request-close"))))
4997 (setq methods
(cdr methods
)))))
4999 (defun gnus-group-quit ()
5000 "Quit reading news without updating .newsrc.eld or .newsrc.
5001 The hook `gnus-exit-gnus-hook' is called before actually exiting."
5003 (if (or noninteractive
;For gnus-batch-kill
5004 (zerop (buffer-size))
5005 (not (gnus-server-opened gnus-select-method
))
5007 (not gnus-current-startup-file
)
5009 (format "Quit reading news without saving %s? "
5010 (file-name-nondirectory gnus-current-startup-file
))))
5012 (run-hooks 'gnus-exit-gnus-hook
)
5013 (if gnus-use-full-window
5014 (delete-other-windows)
5015 (gnus-remove-some-windows))
5017 (gnus-close-backends)
5018 (gnus-clear-system))))
5020 (defun gnus-offer-save-summaries ()
5022 (let ((buflist (buffer-list))
5025 (and (setq bufname
(buffer-name (car buflist
)))
5026 (string-match "Summary" bufname
)
5028 (set-buffer bufname
)
5029 ;; We check that this is, indeed, a summary buffer.
5030 (eq major-mode
'gnus-summary-mode
))
5031 (setq buffers
(cons bufname buffers
)))
5032 (setq buflist
(cdr buflist
)))
5035 "Update summary buffer %s? "
5038 (gnus-summary-exit))
5041 (defun gnus-group-describe-briefly ()
5042 "Give a one line description of the group mode commands."
5044 (gnus-message 7 (substitute-command-keys "\\<gnus-group-mode-map>\\[gnus-group-read-group]:Select \\[gnus-group-next-unread-group]:Forward \\[gnus-group-prev-unread-group]:Backward \\[gnus-group-exit]:Exit \\[gnus-info-find-node]:Run Info \\[gnus-group-describe-briefly]:This help")))
5046 (defun gnus-group-browse-foreign-server (method)
5047 "Browse a foreign news server.
5048 If called interactively, this function will ask for a select method
5049 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
5050 If not, METHOD should be a list where the first element is the method
5051 and the second element is the address."
5053 (list (let ((how (completing-read
5055 (append gnus-valid-select-methods gnus-server-alist
)
5057 ;; We either got a backend name or a virtual server name.
5058 ;; If the first, we also need an address.
5059 (if (assoc how gnus-valid-select-methods
)
5061 ;; Suggested by mapjph@bath.ac.uk.
5064 (mapcar (lambda (server) (list server
))
5065 gnus-secondary-servers
)))
5066 ;; We got a server name, so we find the method.
5067 (gnus-server-to-method how
)))))
5068 (gnus-browse-foreign-server method
))
5072 ;;; Browse Server Mode
5075 (defvar gnus-browse-mode-hook nil
)
5076 (defvar gnus-browse-mode-map nil
)
5077 (put 'gnus-browse-mode
'mode-class
'special
)
5079 (if gnus-browse-mode-map
5081 (setq gnus-browse-mode-map
(make-keymap))
5082 (suppress-keymap gnus-browse-mode-map
)
5083 (define-key gnus-browse-mode-map
" " 'gnus-browse-read-group
)
5084 (define-key gnus-browse-mode-map
"=" 'gnus-browse-select-group
)
5085 (define-key gnus-browse-mode-map
"n" 'gnus-browse-next-group
)
5086 (define-key gnus-browse-mode-map
"p" 'gnus-browse-prev-group
)
5087 (define-key gnus-browse-mode-map
"\177" 'gnus-browse-prev-group
)
5088 (define-key gnus-browse-mode-map
"N" 'gnus-browse-next-group
)
5089 (define-key gnus-browse-mode-map
"P" 'gnus-browse-prev-group
)
5090 (define-key gnus-browse-mode-map
"\M-n" 'gnus-browse-next-group
)
5091 (define-key gnus-browse-mode-map
"\M-p" 'gnus-browse-prev-group
)
5092 (define-key gnus-browse-mode-map
"\r" 'gnus-browse-select-group
)
5093 (define-key gnus-browse-mode-map
"u" 'gnus-browse-unsubscribe-current-group
)
5094 (define-key gnus-browse-mode-map
"l" 'gnus-browse-exit
)
5095 (define-key gnus-browse-mode-map
"L" 'gnus-browse-exit
)
5096 (define-key gnus-browse-mode-map
"q" 'gnus-browse-exit
)
5097 (define-key gnus-browse-mode-map
"Q" 'gnus-browse-exit
)
5098 (define-key gnus-browse-mode-map
"\C-c\C-c" 'gnus-browse-exit
)
5099 (define-key gnus-browse-mode-map
"?" 'gnus-browse-describe-briefly
)
5100 (define-key gnus-browse-mode-map
"\C-c\C-i" 'gnus-info-find-node
)
5103 (defvar gnus-browse-current-method nil
)
5104 (defvar gnus-browse-return-buffer nil
)
5106 (defvar gnus-browse-buffer
"*Gnus Browse Server*")
5108 (defun gnus-browse-foreign-server (method &optional return-buffer
)
5109 (setq gnus-browse-current-method method
)
5110 (setq gnus-browse-return-buffer return-buffer
)
5111 (let ((gnus-select-method method
)
5113 (gnus-message 5 "Connecting to %s..." (nth 1 method
))
5114 (or (gnus-check-server method
)
5115 (error "Unable to contact server: %s" (gnus-status-message method
)))
5116 (or (gnus-request-list method
)
5117 (error "Couldn't request list: %s" (gnus-status-message method
)))
5118 (get-buffer-create gnus-browse-buffer
)
5119 (gnus-add-current-to-buffer-list)
5120 (and gnus-carpal
(gnus-carpal-setup-buffer 'browse
))
5121 (gnus-configure-windows 'browse
)
5122 (buffer-disable-undo (current-buffer))
5123 (let ((buffer-read-only nil
))
5126 (setq mode-line-buffer-identification
5128 "Gnus Browse Server {%s:%s}" (car method
) (car (cdr method
))))
5130 (set-buffer nntp-server-buffer
)
5131 (let ((cur (current-buffer)))
5132 (goto-char (point-min))
5133 (or (string= gnus-ignored-newsgroups
"")
5134 (delete-matching-lines gnus-ignored-newsgroups
))
5135 (while (re-search-forward
5136 "\\(^[^ \t]+\\)[ \t]+[0-9]+[ \t]+[0-9]+" nil t
)
5137 (goto-char (match-end 1))
5138 (setq groups
(cons (cons (buffer-substring (match-beginning 1)
5140 (max 0 (- (1+ (read cur
)) (read cur
))))
5142 (setq groups
(sort groups
5144 (string< (car l1
) (car l2
)))))
5145 (let ((buffer-read-only nil
))
5147 (setq group
(car groups
))
5149 (format "K%7d: %s\n" (cdr group
) (car group
)))
5150 (setq groups
(cdr groups
))))
5151 (switch-to-buffer (current-buffer))
5152 (goto-char (point-min))
5153 (gnus-group-position-cursor)))
5155 (defun gnus-browse-mode ()
5156 "Major mode for browsing a foreign server.
5158 All normal editing commands are switched off.
5160 \\<gnus-browse-mode-map>
5161 The only things you can do in this buffer is
5163 1) `\\[gnus-browse-unsubscribe-current-group]' to subscribe to a group.
5164 The group will be inserted into the group buffer upon exit from this
5167 2) `\\[gnus-browse-read-group]' to read a group ephemerally.
5169 3) `\\[gnus-browse-exit]' to return to the group buffer."
5171 (kill-all-local-variables)
5172 (if gnus-visual
(gnus-browse-make-menu-bar))
5173 (gnus-simplify-mode-line)
5174 (setq major-mode
'gnus-browse-mode
)
5175 (setq mode-name
"Browse Server")
5176 (setq mode-line-process nil
)
5177 (use-local-map gnus-browse-mode-map
)
5178 (buffer-disable-undo (current-buffer))
5179 (setq truncate-lines t
)
5180 (setq buffer-read-only t
)
5181 (run-hooks 'gnus-browse-mode-hook
))
5183 (defun gnus-browse-read-group (&optional no-article
)
5184 "Enter the group at the current line."
5186 (let ((group (gnus-browse-group-name)))
5187 (or (gnus-group-read-ephemeral-group
5188 group gnus-browse-current-method nil
5189 (cons (current-buffer) 'browse
))
5190 (error "Couldn't enter %s" group
))))
5192 (defun gnus-browse-select-group ()
5193 "Select the current group."
5195 (gnus-browse-read-group 'no
))
5197 (defun gnus-browse-next-group (n)
5198 "Go to the next group."
5202 (gnus-group-position-cursor)))
5204 (defun gnus-browse-prev-group (n)
5205 "Go to the next group."
5207 (gnus-browse-next-group (- n
)))
5209 (defun gnus-browse-unsubscribe-current-group (arg)
5210 "(Un)subscribe to the next ARG groups."
5213 (error "No group at current line."))
5214 (let ((ward (if (< arg
0) -
1 1))
5216 (while (and (> arg
0)
5218 (gnus-browse-unsubscribe-group)
5219 (zerop (gnus-browse-next-group ward
)))
5220 (setq arg
(1- arg
)))
5221 (gnus-group-position-cursor)
5222 (if (/= 0 arg
) (gnus-message 7 "No more newsgroups"))
5225 (defun gnus-browse-group-name ()
5228 (if (not (re-search-forward ": \\(.*\\)$" (gnus-point-at-eol) t
))
5230 (gnus-group-prefixed-name
5231 (buffer-substring (match-beginning 1) (match-end 1))
5232 gnus-browse-current-method
))))
5234 (defun gnus-browse-unsubscribe-group ()
5235 "Toggle subscription of the current group in the browse buffer."
5237 (buffer-read-only nil
)
5241 ;; If this group it killed, then we want to subscribe it.
5242 (if (= (following-char) ?K
) (setq sub t
))
5243 (setq group
(gnus-browse-group-name))
5247 (gnus-group-change-level
5248 (list t group gnus-level-default-subscribed
5249 nil nil gnus-browse-current-method
)
5250 gnus-level-default-subscribed gnus-level-killed
5251 (and (car (nth 1 gnus-newsrc-alist
))
5252 (gnus-gethash (car (nth 1 gnus-newsrc-alist
))
5253 gnus-newsrc-hashtb
))
5256 (gnus-group-change-level
5257 group gnus-level-killed gnus-level-default-subscribed
)
5261 (defun gnus-browse-exit ()
5262 "Quit browsing and return to the group buffer."
5264 (if (eq major-mode
'gnus-browse-mode
)
5265 (kill-buffer (current-buffer)))
5266 (if gnus-browse-return-buffer
5267 (gnus-configure-windows 'server
'force
)
5268 (gnus-configure-windows 'group
'force
)
5269 (gnus-group-list-groups nil
)))
5271 (defun gnus-browse-describe-briefly ()
5272 "Give a one line description of the group mode commands."
5275 (substitute-command-keys "\\<gnus-browse-mode-map>\\[gnus-group-next-group]:Forward \\[gnus-group-prev-group]:Backward \\[gnus-browse-exit]:Exit \\[gnus-info-find-node]:Run Info \\[gnus-browse-describe-briefly]:This help")))
5279 ;;; Gnus summary mode
5282 (defvar gnus-summary-mode-map nil
)
5283 (defvar gnus-summary-mark-map nil
)
5284 (defvar gnus-summary-mscore-map nil
)
5285 (defvar gnus-summary-article-map nil
)
5286 (defvar gnus-summary-thread-map nil
)
5287 (defvar gnus-summary-goto-map nil
)
5288 (defvar gnus-summary-exit-map nil
)
5289 (defvar gnus-summary-interest-map nil
)
5290 (defvar gnus-summary-sort-map nil
)
5291 (defvar gnus-summary-backend-map nil
)
5292 (defvar gnus-summary-save-map nil
)
5293 (defvar gnus-summary-wash-map nil
)
5294 (defvar gnus-summary-wash-hide-map nil
)
5295 (defvar gnus-summary-wash-highlight-map nil
)
5296 (defvar gnus-summary-wash-time-map nil
)
5297 (defvar gnus-summary-help-map nil
)
5299 (put 'gnus-summary-mode
'mode-class
'special
)
5301 (if gnus-summary-mode-map
5303 (setq gnus-summary-mode-map
(make-keymap))
5304 (suppress-keymap gnus-summary-mode-map
)
5306 ;; Non-orthogonal keys
5308 (define-key gnus-summary-mode-map
" " 'gnus-summary-next-page
)
5309 (define-key gnus-summary-mode-map
"\177" 'gnus-summary-prev-page
)
5310 (define-key gnus-summary-mode-map
"\r" 'gnus-summary-scroll-up
)
5311 (define-key gnus-summary-mode-map
"n" 'gnus-summary-next-unread-article
)
5312 (define-key gnus-summary-mode-map
"p" 'gnus-summary-prev-unread-article
)
5313 (define-key gnus-summary-mode-map
"N" 'gnus-summary-next-article
)
5314 (define-key gnus-summary-mode-map
"P" 'gnus-summary-prev-article
)
5315 (define-key gnus-summary-mode-map
"\M-\C-n" 'gnus-summary-next-same-subject
)
5316 (define-key gnus-summary-mode-map
"\M-\C-p" 'gnus-summary-prev-same-subject
)
5317 (define-key gnus-summary-mode-map
"\M-n" 'gnus-summary-next-unread-subject
)
5318 (define-key gnus-summary-mode-map
"\M-p" 'gnus-summary-prev-unread-subject
)
5319 (define-key gnus-summary-mode-map
"." 'gnus-summary-first-unread-article
)
5320 (define-key gnus-summary-mode-map
"," 'gnus-summary-best-unread-article
)
5321 (define-key gnus-summary-mode-map
5322 "\M-s" 'gnus-summary-search-article-forward
)
5323 (define-key gnus-summary-mode-map
5324 "\M-r" 'gnus-summary-search-article-backward
)
5325 (define-key gnus-summary-mode-map
"<" 'gnus-summary-beginning-of-article
)
5326 (define-key gnus-summary-mode-map
">" 'gnus-summary-end-of-article
)
5327 (define-key gnus-summary-mode-map
"j" 'gnus-summary-goto-subject
)
5328 (define-key gnus-summary-mode-map
"^" 'gnus-summary-refer-parent-article
)
5329 (define-key gnus-summary-mode-map
"\M-^" 'gnus-summary-refer-article
)
5330 (define-key gnus-summary-mode-map
"u" 'gnus-summary-tick-article-forward
)
5331 (define-key gnus-summary-mode-map
"!" 'gnus-summary-tick-article-forward
)
5332 (define-key gnus-summary-mode-map
"U" 'gnus-summary-tick-article-backward
)
5333 (define-key gnus-summary-mode-map
"d" 'gnus-summary-mark-as-read-forward
)
5334 (define-key gnus-summary-mode-map
"D" 'gnus-summary-mark-as-read-backward
)
5335 (define-key gnus-summary-mode-map
"E" 'gnus-summary-mark-as-expirable
)
5336 (define-key gnus-summary-mode-map
"\M-u" 'gnus-summary-clear-mark-forward
)
5337 (define-key gnus-summary-mode-map
"\M-U" 'gnus-summary-clear-mark-backward
)
5338 (define-key gnus-summary-mode-map
5339 "k" 'gnus-summary-kill-same-subject-and-select
)
5340 (define-key gnus-summary-mode-map
"\C-k" 'gnus-summary-kill-same-subject
)
5341 (define-key gnus-summary-mode-map
"\M-\C-k" 'gnus-summary-kill-thread
)
5342 (define-key gnus-summary-mode-map
"\M-\C-l" 'gnus-summary-lower-thread
)
5343 (define-key gnus-summary-mode-map
"e" 'gnus-summary-edit-article
)
5344 (define-key gnus-summary-mode-map
"#" 'gnus-summary-mark-as-processable
)
5345 (define-key gnus-summary-mode-map
"\M-#" 'gnus-summary-unmark-as-processable
)
5346 (define-key gnus-summary-mode-map
"\M-\C-t" 'gnus-summary-toggle-threads
)
5347 (define-key gnus-summary-mode-map
"\M-\C-s" 'gnus-summary-show-thread
)
5348 (define-key gnus-summary-mode-map
"\M-\C-h" 'gnus-summary-hide-thread
)
5349 (define-key gnus-summary-mode-map
"\M-\C-f" 'gnus-summary-next-thread
)
5350 (define-key gnus-summary-mode-map
"\M-\C-b" 'gnus-summary-prev-thread
)
5351 (define-key gnus-summary-mode-map
"\M-\C-u" 'gnus-summary-up-thread
)
5352 (define-key gnus-summary-mode-map
"\M-\C-d" 'gnus-summary-down-thread
)
5353 (define-key gnus-summary-mode-map
"&" 'gnus-summary-execute-command
)
5354 (define-key gnus-summary-mode-map
"c" 'gnus-summary-catchup-and-exit
)
5355 (define-key gnus-summary-mode-map
"\C-w" 'gnus-summary-mark-region-as-read
)
5356 (define-key gnus-summary-mode-map
"\C-t" 'gnus-summary-toggle-truncation
)
5357 (define-key gnus-summary-mode-map
"?" 'gnus-summary-mark-as-dormant
)
5358 (define-key gnus-summary-mode-map
5359 "\C-c\M-\C-s" 'gnus-summary-show-all-expunged
)
5360 (define-key gnus-summary-mode-map
5361 "\C-c\C-s\C-n" 'gnus-summary-sort-by-number
)
5362 (define-key gnus-summary-mode-map
5363 "\C-c\C-s\C-a" 'gnus-summary-sort-by-author
)
5364 (define-key gnus-summary-mode-map
5365 "\C-c\C-s\C-s" 'gnus-summary-sort-by-subject
)
5366 (define-key gnus-summary-mode-map
"\C-c\C-s\C-d" 'gnus-summary-sort-by-date
)
5367 (define-key gnus-summary-mode-map
"\C-c\C-s\C-i" 'gnus-summary-sort-by-score
)
5368 (define-key gnus-summary-mode-map
"=" 'gnus-summary-expand-window
)
5369 (define-key gnus-summary-mode-map
5370 "\C-x\C-s" 'gnus-summary-reselect-current-group
)
5371 (define-key gnus-summary-mode-map
"\M-g" 'gnus-summary-rescan-group
)
5372 (define-key gnus-summary-mode-map
"w" 'gnus-summary-stop-page-breaking
)
5373 (define-key gnus-summary-mode-map
"\C-c\C-r" 'gnus-summary-caesar-message
)
5374 (define-key gnus-summary-mode-map
"\M-t" 'gnus-summary-toggle-mime
)
5375 (define-key gnus-summary-mode-map
"f" 'gnus-summary-followup
)
5376 (define-key gnus-summary-mode-map
"F" 'gnus-summary-followup-with-original
)
5377 (define-key gnus-summary-mode-map
"C" 'gnus-summary-cancel-article
)
5378 (define-key gnus-summary-mode-map
"r" 'gnus-summary-reply
)
5379 (define-key gnus-summary-mode-map
"R" 'gnus-summary-reply-with-original
)
5380 (define-key gnus-summary-mode-map
"\C-c\C-f" 'gnus-summary-mail-forward
)
5381 (define-key gnus-summary-mode-map
"o" 'gnus-summary-save-article
)
5382 (define-key gnus-summary-mode-map
"\C-o" 'gnus-summary-save-article-mail
)
5383 (define-key gnus-summary-mode-map
"|" 'gnus-summary-pipe-output
)
5384 (define-key gnus-summary-mode-map
"\M-k" 'gnus-summary-edit-local-kill
)
5385 (define-key gnus-summary-mode-map
"\M-K" 'gnus-summary-edit-global-kill
)
5386 (define-key gnus-summary-mode-map
"V" 'gnus-version
)
5387 (define-key gnus-summary-mode-map
"\C-c\C-d" 'gnus-summary-describe-group
)
5388 (define-key gnus-summary-mode-map
"q" 'gnus-summary-exit
)
5389 (define-key gnus-summary-mode-map
"Q" 'gnus-summary-exit-no-update
)
5390 (define-key gnus-summary-mode-map
"\C-c\C-i" 'gnus-info-find-node
)
5391 (define-key gnus-summary-mode-map gnus-mouse-2
'gnus-mouse-pick-article
)
5392 (define-key gnus-summary-mode-map
"m" 'gnus-summary-mail-other-window
)
5393 (define-key gnus-summary-mode-map
"a" 'gnus-summary-post-news
)
5394 (define-key gnus-summary-mode-map
5395 "x" 'gnus-summary-remove-lines-marked-as-read
)
5396 ; (define-key gnus-summary-mode-map "X" 'gnus-summary-remove-lines-marked-with)
5397 (define-key gnus-summary-mode-map
"s" 'gnus-summary-isearch-article
)
5398 (define-key gnus-summary-mode-map
"t" 'gnus-summary-toggle-header
)
5399 (define-key gnus-summary-mode-map
"g" 'gnus-summary-show-article
)
5400 ; (define-key gnus-summary-mode-map "?" 'gnus-summary-describe-briefly)
5401 (define-key gnus-summary-mode-map
"l" 'gnus-summary-goto-last-article
)
5402 (define-key gnus-summary-mode-map
"\C-c\C-v\C-v" 'gnus-uu-decode-uu-view
)
5403 (define-key gnus-summary-mode-map
"\C-d" 'gnus-summary-enter-digest-group
)
5404 (define-key gnus-summary-mode-map
"v" 'gnus-summary-verbose-headers
)
5405 (define-key gnus-summary-mode-map
"\C-c\C-b" 'gnus-bug
)
5408 ;; Sort of orthogonal keymap
5409 (define-prefix-command 'gnus-summary-mark-map
)
5410 (define-key gnus-summary-mode-map
"M" 'gnus-summary-mark-map
)
5411 (define-key gnus-summary-mark-map
"t" 'gnus-summary-tick-article-forward
)
5412 (define-key gnus-summary-mark-map
"!" 'gnus-summary-tick-article-forward
)
5413 (define-key gnus-summary-mark-map
"d" 'gnus-summary-mark-as-read-forward
)
5414 (define-key gnus-summary-mark-map
"r" 'gnus-summary-mark-as-read-forward
)
5415 (define-key gnus-summary-mark-map
"c" 'gnus-summary-clear-mark-forward
)
5416 (define-key gnus-summary-mark-map
" " 'gnus-summary-clear-mark-forward
)
5417 (define-key gnus-summary-mark-map
"e" 'gnus-summary-mark-as-expirable
)
5418 (define-key gnus-summary-mark-map
"x" 'gnus-summary-mark-as-expirable
)
5419 (define-key gnus-summary-mark-map
"?" 'gnus-summary-mark-as-dormant
)
5420 (define-key gnus-summary-mark-map
"b" 'gnus-summary-set-bookmark
)
5421 (define-key gnus-summary-mark-map
"B" 'gnus-summary-remove-bookmark
)
5422 (define-key gnus-summary-mark-map
"#" 'gnus-summary-mark-as-processable
)
5423 (define-key gnus-summary-mark-map
"\M-#" 'gnus-summary-unmark-as-processable
)
5424 (define-key gnus-summary-mark-map
5425 "\M-r" 'gnus-summary-remove-lines-marked-as-read
)
5426 (define-key gnus-summary-mark-map
5427 "\M-\C-r" 'gnus-summary-remove-lines-marked-with
)
5428 (define-key gnus-summary-mark-map
"D" 'gnus-summary-show-all-dormant
)
5429 (define-key gnus-summary-mark-map
"\M-D" 'gnus-summary-hide-all-dormant
)
5430 (define-key gnus-summary-mark-map
"S" 'gnus-summary-show-all-expunged
)
5431 (define-key gnus-summary-mark-map
"C" 'gnus-summary-catchup
)
5432 (define-key gnus-summary-mark-map
"H" 'gnus-summary-catchup-to-here
)
5433 (define-key gnus-summary-mark-map
"\C-c" 'gnus-summary-catchup-all
)
5434 (define-key gnus-summary-mark-map
5435 "k" 'gnus-summary-kill-same-subject-and-select
)
5436 (define-key gnus-summary-mark-map
"K" 'gnus-summary-kill-same-subject
)
5438 (define-prefix-command 'gnus-summary-mscore-map
)
5439 (define-key gnus-summary-mark-map
"V" 'gnus-summary-mscore-map
)
5440 (define-key gnus-summary-mscore-map
"c" 'gnus-summary-clear-above
)
5441 (define-key gnus-summary-mscore-map
"u" 'gnus-summary-tick-above
)
5442 (define-key gnus-summary-mscore-map
"m" 'gnus-summary-mark-above
)
5443 (define-key gnus-summary-mscore-map
"k" 'gnus-summary-kill-below
)
5445 (define-key gnus-summary-mark-map
"P" 'gnus-uu-mark-map
)
5447 (define-key gnus-summary-mode-map
"S" 'gnus-summary-send-map
)
5449 (define-prefix-command 'gnus-summary-goto-map
)
5450 (define-key gnus-summary-mode-map
"G" 'gnus-summary-goto-map
)
5451 (define-key gnus-summary-goto-map
"n" 'gnus-summary-next-unread-article
)
5452 (define-key gnus-summary-goto-map
"p" 'gnus-summary-prev-unread-article
)
5453 (define-key gnus-summary-goto-map
"N" 'gnus-summary-next-article
)
5454 (define-key gnus-summary-goto-map
"P" 'gnus-summary-prev-article
)
5455 (define-key gnus-summary-goto-map
"\C-n" 'gnus-summary-next-same-subject
)
5456 (define-key gnus-summary-goto-map
"\C-p" 'gnus-summary-prev-same-subject
)
5457 (define-key gnus-summary-goto-map
"\M-n" 'gnus-summary-next-unread-subject
)
5458 (define-key gnus-summary-goto-map
"\M-p" 'gnus-summary-prev-unread-subject
)
5459 (define-key gnus-summary-goto-map
"f" 'gnus-summary-first-unread-article
)
5460 (define-key gnus-summary-goto-map
"b" 'gnus-summary-best-unread-article
)
5461 (define-key gnus-summary-goto-map
"g" 'gnus-summary-goto-subject
)
5462 (define-key gnus-summary-goto-map
"l" 'gnus-summary-goto-last-article
)
5463 (define-key gnus-summary-goto-map
"p" 'gnus-summary-pop-article
)
5466 (define-prefix-command 'gnus-summary-thread-map
)
5467 (define-key gnus-summary-mode-map
"T" 'gnus-summary-thread-map
)
5468 (define-key gnus-summary-thread-map
"k" 'gnus-summary-kill-thread
)
5469 (define-key gnus-summary-thread-map
"l" 'gnus-summary-lower-thread
)
5470 (define-key gnus-summary-thread-map
"i" 'gnus-summary-raise-thread
)
5471 (define-key gnus-summary-thread-map
"T" 'gnus-summary-toggle-threads
)
5472 (define-key gnus-summary-thread-map
"s" 'gnus-summary-show-thread
)
5473 (define-key gnus-summary-thread-map
"S" 'gnus-summary-show-all-threads
)
5474 (define-key gnus-summary-thread-map
"h" 'gnus-summary-hide-thread
)
5475 (define-key gnus-summary-thread-map
"H" 'gnus-summary-hide-all-threads
)
5476 (define-key gnus-summary-thread-map
"n" 'gnus-summary-next-thread
)
5477 (define-key gnus-summary-thread-map
"p" 'gnus-summary-prev-thread
)
5478 (define-key gnus-summary-thread-map
"u" 'gnus-summary-up-thread
)
5479 (define-key gnus-summary-thread-map
"d" 'gnus-summary-down-thread
)
5480 (define-key gnus-summary-thread-map
"#" 'gnus-uu-mark-thread
)
5483 (define-prefix-command 'gnus-summary-exit-map
)
5484 (define-key gnus-summary-mode-map
"Z" 'gnus-summary-exit-map
)
5485 (define-key gnus-summary-exit-map
"c" 'gnus-summary-catchup-and-exit
)
5486 (define-key gnus-summary-exit-map
"C" 'gnus-summary-catchup-all-and-exit
)
5487 (define-key gnus-summary-exit-map
"E" 'gnus-summary-exit-no-update
)
5488 (define-key gnus-summary-exit-map
"Q" 'gnus-summary-exit
)
5489 (define-key gnus-summary-exit-map
"Z" 'gnus-summary-exit
)
5490 (define-key gnus-summary-exit-map
5491 "n" 'gnus-summary-catchup-and-goto-next-group
)
5492 (define-key gnus-summary-exit-map
"R" 'gnus-summary-reselect-current-group
)
5493 (define-key gnus-summary-exit-map
"G" 'gnus-summary-rescan-group
)
5494 (define-key gnus-summary-exit-map
"N" 'gnus-summary-next-group
)
5495 (define-key gnus-summary-exit-map
"P" 'gnus-summary-prev-group
)
5498 (define-prefix-command 'gnus-summary-article-map
)
5499 (define-key gnus-summary-mode-map
"A" 'gnus-summary-article-map
)
5500 (define-key gnus-summary-article-map
" " 'gnus-summary-next-page
)
5501 (define-key gnus-summary-article-map
"n" 'gnus-summary-next-page
)
5502 (define-key gnus-summary-article-map
"\177" 'gnus-summary-prev-page
)
5503 (define-key gnus-summary-article-map
"p" 'gnus-summary-prev-page
)
5504 (define-key gnus-summary-article-map
"\r" 'gnus-summary-scroll-up
)
5505 (define-key gnus-summary-article-map
"<" 'gnus-summary-beginning-of-article
)
5506 (define-key gnus-summary-article-map
">" 'gnus-summary-end-of-article
)
5507 (define-key gnus-summary-article-map
"b" 'gnus-summary-beginning-of-article
)
5508 (define-key gnus-summary-article-map
"e" 'gnus-summary-end-of-article
)
5509 (define-key gnus-summary-article-map
"^" 'gnus-summary-refer-parent-article
)
5510 (define-key gnus-summary-article-map
"r" 'gnus-summary-refer-parent-article
)
5511 (define-key gnus-summary-article-map
"g" 'gnus-summary-show-article
)
5512 (define-key gnus-summary-article-map
"s" 'gnus-summary-isearch-article
)
5516 (define-prefix-command 'gnus-summary-wash-map
)
5517 (define-key gnus-summary-mode-map
"W" 'gnus-summary-wash-map
)
5519 (define-prefix-command 'gnus-summary-wash-hide-map
)
5520 (define-key gnus-summary-wash-map
"W" 'gnus-summary-wash-hide-map
)
5521 (define-key gnus-summary-wash-hide-map
"a" 'gnus-article-hide
)
5522 (define-key gnus-summary-wash-hide-map
"h" 'gnus-article-hide-headers
)
5523 (define-key gnus-summary-wash-hide-map
"s" 'gnus-article-hide-signature
)
5524 (define-key gnus-summary-wash-hide-map
"c" 'gnus-article-hide-citation
)
5525 (define-key gnus-summary-wash-hide-map
5526 "\C-c" 'gnus-article-hide-citation-maybe
)
5528 (define-prefix-command 'gnus-summary-wash-highlight-map
)
5529 (define-key gnus-summary-wash-map
"H" 'gnus-summary-wash-highlight-map
)
5530 (define-key gnus-summary-wash-highlight-map
"a" 'gnus-article-highlight
)
5531 (define-key gnus-summary-wash-highlight-map
5532 "h" 'gnus-article-highlight-headers
)
5533 (define-key gnus-summary-wash-highlight-map
5534 "c" 'gnus-article-highlight-citation
)
5535 (define-key gnus-summary-wash-highlight-map
5536 "s" 'gnus-article-highlight-signature
)
5538 (define-prefix-command 'gnus-summary-wash-time-map
)
5539 (define-key gnus-summary-wash-map
"T" 'gnus-summary-wash-time-map
)
5540 (define-key gnus-summary-wash-time-map
"z" 'gnus-article-date-ut
)
5541 (define-key gnus-summary-wash-time-map
"u" 'gnus-article-date-ut
)
5542 (define-key gnus-summary-wash-time-map
"l" 'gnus-article-date-local
)
5543 (define-key gnus-summary-wash-time-map
"e" 'gnus-article-date-lapsed
)
5545 (define-key gnus-summary-wash-map
"b" 'gnus-article-add-buttons
)
5546 (define-key gnus-summary-wash-map
"o" 'gnus-article-treat-overstrike
)
5547 (define-key gnus-summary-wash-map
"w" 'gnus-article-word-wrap
)
5548 (define-key gnus-summary-wash-map
"c" 'gnus-article-remove-cr
)
5549 (define-key gnus-summary-wash-map
"q" 'gnus-article-de-quoted-unreadable
)
5550 (define-key gnus-summary-wash-map
"f" 'gnus-article-display-x-face
)
5551 (define-key gnus-summary-wash-map
"l" 'gnus-summary-stop-page-breaking
)
5552 (define-key gnus-summary-wash-map
"r" 'gnus-summary-caesar-message
)
5553 (define-key gnus-summary-wash-map
"t" 'gnus-summary-toggle-header
)
5554 (define-key gnus-summary-wash-map
"m" 'gnus-summary-toggle-mime
)
5557 (define-prefix-command 'gnus-summary-help-map
)
5558 (define-key gnus-summary-mode-map
"H" 'gnus-summary-help-map
)
5559 (define-key gnus-summary-help-map
"v" 'gnus-version
)
5560 (define-key gnus-summary-help-map
"f" 'gnus-summary-fetch-faq
)
5561 (define-key gnus-summary-help-map
"d" 'gnus-summary-describe-group
)
5562 (define-key gnus-summary-help-map
"h" 'gnus-summary-describe-briefly
)
5563 (define-key gnus-summary-help-map
"i" 'gnus-info-find-node
)
5566 (define-prefix-command 'gnus-summary-backend-map
)
5567 (define-key gnus-summary-mode-map
"B" 'gnus-summary-backend-map
)
5568 (define-key gnus-summary-backend-map
"e" 'gnus-summary-expire-articles
)
5569 (define-key gnus-summary-backend-map
"\M-\C-e"
5570 'gnus-summary-expire-articles-now
)
5571 (define-key gnus-summary-backend-map
"\177" 'gnus-summary-delete-article
)
5572 (define-key gnus-summary-backend-map
"m" 'gnus-summary-move-article
)
5573 (define-key gnus-summary-backend-map
"r" 'gnus-summary-respool-article
)
5574 (define-key gnus-summary-backend-map
"w" 'gnus-summary-edit-article
)
5575 (define-key gnus-summary-backend-map
"c" 'gnus-summary-copy-article
)
5576 (define-key gnus-summary-backend-map
"q" 'gnus-summary-fancy-query
)
5577 (define-key gnus-summary-backend-map
"i" 'gnus-summary-import-article
)
5580 (define-prefix-command 'gnus-summary-save-map
)
5581 (define-key gnus-summary-mode-map
"O" 'gnus-summary-save-map
)
5582 (define-key gnus-summary-save-map
"o" 'gnus-summary-save-article
)
5583 (define-key gnus-summary-save-map
"m" 'gnus-summary-save-article-mail
)
5584 (define-key gnus-summary-save-map
"r" 'gnus-summary-save-article-rmail
)
5585 (define-key gnus-summary-save-map
"f" 'gnus-summary-save-article-file
)
5586 (define-key gnus-summary-save-map
"h" 'gnus-summary-save-article-folder
)
5587 (define-key gnus-summary-save-map
"v" 'gnus-summary-save-article-vm
)
5588 (define-key gnus-summary-save-map
"p" 'gnus-summary-pipe-output
)
5589 ; (define-key gnus-summary-save-map "s" 'gnus-soup-add-article)
5591 (define-key gnus-summary-mode-map
"X" 'gnus-uu-extract-map
)
5593 (define-key gnus-summary-mode-map
"\M-&" 'gnus-summary-universal-argument
)
5594 ; (define-key gnus-summary-various-map "\C-s" 'gnus-summary-search-article-forward)
5595 ; (define-key gnus-summary-various-map "\C-r" 'gnus-summary-search-article-backward)
5596 ; (define-key gnus-summary-various-map "r" 'gnus-summary-refer-article)
5597 ; (define-key gnus-summary-various-map "&" 'gnus-summary-execute-command)
5598 ; (define-key gnus-summary-various-map "T" 'gnus-summary-toggle-truncation)
5599 ; (define-key gnus-summary-various-map "e" 'gnus-summary-expand-window)
5600 (define-key gnus-summary-article-map
"D" 'gnus-summary-enter-digest-group
)
5601 ; (define-key gnus-summary-various-map "k" 'gnus-summary-edit-local-kill)
5602 ; (define-key gnus-summary-various-map "K" 'gnus-summary-edit-global-kill)
5604 (define-key gnus-summary-mode-map
"V" 'gnus-summary-score-map
)
5606 ; (define-prefix-command 'gnus-summary-sort-map)
5607 ; (define-key gnus-summary-various-map "s" 'gnus-summary-sort-map)
5608 ; (define-key gnus-summary-sort-map "n" 'gnus-summary-sort-by-number)
5609 ; (define-key gnus-summary-sort-map "a" 'gnus-summary-sort-by-author)
5610 ; (define-key gnus-summary-sort-map "s" 'gnus-summary-sort-by-subject)
5611 ; (define-key gnus-summary-sort-map "d" 'gnus-summary-sort-by-date)
5612 ; (define-key gnus-summary-sort-map "i" 'gnus-summary-sort-by-score)
5614 (define-key gnus-summary-mode-map
"I" 'gnus-summary-increase-score
)
5615 (define-key gnus-summary-mode-map
"L" 'gnus-summary-lower-score
)
5621 (defun gnus-summary-mode (&optional group
)
5622 "Major mode for reading articles.
5624 All normal editing commands are switched off.
5625 \\<gnus-summary-mode-map>
5626 Each line in this buffer represents one article. To read an
5627 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
5628 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
5631 You can also post articles and send mail from this buffer. To
5632 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
5633 of an article, type `\\[gnus-summary-reply]'.
5635 There are approx. one gazillion commands you can execute in this
5636 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
5638 The following commands are available:
5640 \\{gnus-summary-mode-map}"
5642 (if gnus-visual
(gnus-summary-make-menu-bar))
5643 (kill-all-local-variables)
5644 (let ((locals gnus-summary-local-variables
))
5646 (if (consp (car locals
))
5648 (make-local-variable (car (car locals
)))
5649 (set (car (car locals
)) (eval (cdr (car locals
)))))
5650 (make-local-variable (car locals
))
5651 (set (car locals
) nil
))
5652 (setq locals
(cdr locals
))))
5653 (gnus-make-thread-indent-array)
5654 (gnus-simplify-mode-line)
5655 (setq major-mode
'gnus-summary-mode
)
5656 (setq mode-name
"Summary")
5657 (make-local-variable 'minor-mode-alist
)
5658 (use-local-map gnus-summary-mode-map
)
5659 (buffer-disable-undo (current-buffer))
5660 (setq buffer-read-only t
) ;Disable modification
5661 (setq truncate-lines t
)
5662 (setq selective-display t
)
5663 (setq selective-display-ellipses t
) ;Display `...'
5664 (setq buffer-display-table gnus-summary-display-table
)
5665 (setq gnus-newsgroup-name group
)
5666 (run-hooks 'gnus-summary-mode-hook
))
5668 (defun gnus-summary-make-display-table ()
5669 ;; Change the display table. Odd characters have a tendency to mess
5670 ;; up nicely formatted displays - we make all possible glyphs
5671 ;; display only a single character.
5673 ;; We start from the standard display table, if any.
5674 (setq gnus-summary-display-table
5675 (or (copy-sequence standard-display-table
)
5676 (make-display-table)))
5677 ;; Nix out all the control chars...
5679 (while (>= (setq i
(1- i
)) 0)
5680 (aset gnus-summary-display-table i
[??
])))
5681 ;; ... but not newline and cr, of course. (cr is necessary for the
5682 ;; selective display).
5683 (aset gnus-summary-display-table ?
\n nil
)
5684 (aset gnus-summary-display-table ?
\r nil
)
5685 ;; We nix out any glyphs over 126 that are not set already.
5687 (while (>= (setq i
(1- i
)) 127)
5688 ;; Only modify if the entry is nil.
5689 (or (aref gnus-summary-display-table i
)
5690 (aset gnus-summary-display-table i
[??
])))))
5692 (defun gnus-summary-clear-local-variables ()
5693 (let ((locals gnus-summary-local-variables
))
5695 (if (consp (car locals
))
5696 (and (vectorp (car (car locals
)))
5697 (set (car (car locals
)) nil
))
5698 (and (vectorp (car locals
))
5699 (set (car locals
) nil
)))
5700 (setq locals
(cdr locals
)))))
5702 ;; Some summary mode macros.
5704 ;; Return a header specified by a NUMBER.
5705 (defun gnus-get-header-by-number (number)
5707 (set-buffer gnus-summary-buffer
)
5708 (or gnus-newsgroup-headers-hashtb-by-number
5709 (gnus-make-headers-hashtable-by-number))
5710 (gnus-gethash (int-to-string number
)
5711 gnus-newsgroup-headers-hashtb-by-number
)))
5713 ;; Fast version of the function above.
5714 (defmacro gnus-get-header-by-num
(number)
5715 (` (gnus-gethash (int-to-string (, number
))
5716 gnus-newsgroup-headers-hashtb-by-number
)))
5718 (defmacro gnus-summary-search-forward
(&optional unread subject backward
)
5719 "Search for article forward.
5720 If UNREAD is non-nil, only unread articles are selected.
5721 If SUBJECT is non-nil, the article which has the same subject will be
5723 If BACKWARD is non-nil, the search will be performed backwards instead."
5724 (` (gnus-summary-search-subject (, backward
) (, unread
) (, subject
))))
5726 (defmacro gnus-summary-search-backward
(&optional unread subject
)
5727 "Search for article backward.
5728 If 1st optional argument UNREAD is non-nil, only unread article is selected.
5729 If 2nd optional argument SUBJECT is non-nil, the article which has
5730 the same subject will be searched for."
5731 (` (gnus-summary-search-forward (, unread
) (, subject
) t
)))
5733 (defmacro gnus-summary-article-number
(&optional number-or-nil
)
5734 "The article number of the article on the current line.
5735 If there isn's an article number here, then we return the current
5738 '(get-text-property (gnus-point-at-bol) 'gnus-number
)
5739 '(or (get-text-property (gnus-point-at-bol) 'gnus-number
)
5740 gnus-current-article
)))
5742 (defmacro gnus-summary-thread-level
()
5743 "The thread level of the article on the current line."
5744 '(or (get-text-property (gnus-point-at-bol) 'gnus-level
)
5747 (defmacro gnus-summary-article-mark
()
5748 "The mark on the current line."
5749 '(get-text-property (gnus-point-at-bol) 'gnus-mark
))
5751 (defun gnus-summary-subject-string ()
5752 "Return current subject string or nil if nothing."
5753 (let ((article (gnus-summary-article-number))
5756 (setq header
(gnus-get-header-by-num article
))
5758 (mail-header-subject header
))))
5760 ;; Various summary mode internalish functions.
5762 (defun gnus-mouse-pick-article (e)
5765 (gnus-summary-next-page nil t
))
5767 (defun gnus-summary-setup-buffer (group)
5768 "Initialize summary buffer."
5769 (let ((buffer (concat "*Summary " group
"*")))
5770 (if (get-buffer buffer
)
5773 (not gnus-newsgroup-begin
))
5774 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
5775 (setq gnus-summary-buffer
(set-buffer (get-buffer-create buffer
)))
5776 (gnus-add-current-to-buffer-list)
5777 (gnus-summary-mode group
)
5778 (and gnus-carpal
(gnus-carpal-setup-buffer 'summary
))
5779 (setq gnus-newsgroup-name group
)
5782 (defun gnus-set-global-variables ()
5783 ;; Set the global equivalents of the summary buffer-local variables
5784 ;; to the latest values they had. These reflect the summary buffer
5785 ;; that was in action when the last article was fetched.
5786 (if (eq major-mode
'gnus-summary-mode
)
5788 (setq gnus-summary-buffer
(current-buffer))
5789 (let ((name gnus-newsgroup-name
)
5790 (marked gnus-newsgroup-marked
)
5791 (unread gnus-newsgroup-unreads
)
5792 (headers gnus-current-headers
)
5793 (score-file gnus-current-score-file
))
5795 (set-buffer gnus-group-buffer
)
5796 (setq gnus-newsgroup-name name
)
5797 (setq gnus-newsgroup-marked marked
)
5798 (setq gnus-newsgroup-unreads unread
)
5799 (setq gnus-current-headers headers
)
5800 (setq gnus-current-score-file score-file
))))))
5802 (defun gnus-summary-insert-dummy-line (sformat subject number
)
5804 (setq sformat gnus-summary-dummy-line-format-spec
))
5808 (insert (eval sformat
))
5809 (add-text-properties
5811 (list 'gnus-number number
5812 'gnus-mark gnus-dummy-mark
5815 (defvar gnus-thread-indent-array nil
)
5816 (defvar gnus-thread-indent-array-level gnus-thread-indent-level
)
5817 (defun gnus-make-thread-indent-array ()
5819 (if (and gnus-thread-indent-array
5820 (= gnus-thread-indent-level gnus-thread-indent-array-level
))
5822 (setq gnus-thread-indent-array
(make-vector 201 "")
5823 gnus-thread-indent-array-level gnus-thread-indent-level
)
5825 (aset gnus-thread-indent-array n
5826 (make-string (* n gnus-thread-indent-level
) ?
))
5829 (defun gnus-summary-insert-line
5830 (sformat header level current unread replied expirable subject-or-nil
5831 &optional dummy score process
)
5832 (or sformat
(setq sformat gnus-summary-line-format-spec
))
5833 (let* ((indentation (aref gnus-thread-indent-array level
))
5834 (lines (mail-header-lines header
))
5835 (score (or score gnus-summary-default-score
0))
5837 (if (or (null gnus-summary-default-score
)
5838 (<= (abs (- score gnus-summary-default-score
))
5839 gnus-summary-zcore-fuzz
)) ?
5840 (if (< score gnus-summary-default-score
)
5841 gnus-score-below-mark gnus-score-over-mark
)))
5842 (replied (cond (process gnus-process-mark
)
5843 (replied gnus-replied-mark
)
5844 (t gnus-unread-mark
)))
5845 (from (mail-header-from header
))
5847 ((string-match "(.+)" from
)
5848 (substring from
(1+ (match-beginning 0)) (1- (match-end 0))))
5849 ((string-match "<[^>]+> *$" from
)
5850 (let ((beg (match-beginning 0)))
5851 (or (and (string-match "^\"[^\"]*\"" from
)
5852 (substring from
(1+ (match-beginning 0))
5853 (1- (match-end 0))))
5854 (substring from
0 beg
))))
5856 (subject (mail-header-subject header
))
5857 (number (mail-header-number header
))
5858 (opening-bracket (if dummy ?\
< ?\
[))
5859 (closing-bracket (if dummy ?\
> ?\
]))
5860 (buffer-read-only nil
)
5861 (b (progn (beginning-of-line) (point))))
5862 (or (numberp lines
) (setq lines
0))
5863 (insert (eval sformat
))
5864 (add-text-properties
5865 b
(1+ b
) (list 'gnus-number number
5866 'gnus-mark
(or unread gnus-unread-mark
)
5867 'gnus-level level
))))
5869 (defun gnus-summary-update-line (&optional dont-update
)
5870 ;; Update summary line after change.
5871 (or (not gnus-summary-default-score
)
5872 gnus-summary-inhibit-highlight
5873 (let ((gnus-summary-inhibit-highlight t
)
5874 (article (gnus-summary-article-number)))
5877 (if (and gnus-summary-mark-below
5878 (< (gnus-summary-article-score)
5879 gnus-summary-mark-below
))
5880 (and (not (memq article gnus-newsgroup-marked
))
5881 (not (memq article gnus-newsgroup-dormant
))
5882 (memq article gnus-newsgroup-unreads
)
5883 (gnus-summary-mark-article-as-read gnus-low-score-mark
))
5884 (and (eq (gnus-summary-article-mark) gnus-low-score-mark
)
5885 (gnus-summary-mark-article-as-unread gnus-unread-mark
))))
5887 (run-hooks 'gnus-summary-update-hook
))))))
5889 (defun gnus-summary-update-lines (&optional beg end
)
5890 ;; Mark article as read (or not) by taking into account scores.
5891 (let ((beg (or beg
(point-min)))
5892 (end (or end
(point-max))))
5893 (if (or (not gnus-summary-default-score
)
5894 gnus-summary-inhibit-highlight
)
5896 (let ((gnus-summary-inhibit-highlight t
)
5899 (set-buffer gnus-summary-buffer
)
5902 (while (and (not (eobp)) (< (point) end
))
5903 (if (and gnus-summary-mark-below
5905 (setq article
(get-text-property
5906 (point) 'gnus-number
))
5907 gnus-newsgroup-scored
))
5908 gnus-summary-default-score
0)
5909 gnus-summary-mark-below
))
5910 ;; We want to possibly mark it as read...
5911 (and (not (memq article gnus-newsgroup-marked
))
5912 (not (memq article gnus-newsgroup-dormant
))
5913 (memq article gnus-newsgroup-unreads
)
5914 (gnus-summary-mark-article-as-read gnus-low-score-mark
))
5915 ;; We want to possibly mark it as unread.
5916 (and (eq (get-text-property (point) 'gnus-mark
)
5917 gnus-low-score-mark
)
5918 (gnus-summary-mark-article-as-unread gnus-unread-mark
)))
5919 ;; Do the visual highlights at the same time.
5920 (and gnus-visual
(run-hooks 'gnus-summary-update-hook
))
5921 (forward-line 1)))))))
5923 (defvar gnus-tmp-gathered nil
)
5925 (defun gnus-summary-number-of-articles-in-thread (thread &optional char
)
5926 ;; Sum up all elements (and sub-elements) in a list.
5928 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
5929 (if (and (consp thread
) (cdr thread
))
5932 'gnus-summary-number-of-articles-in-thread
5936 (if (> number
1) gnus-not-empty-thread-mark
5937 gnus-empty-thread-mark
)
5940 (defun gnus-summary-read-group
5941 (group &optional show-all no-article kill-buffer
)
5942 "Start reading news in newsgroup GROUP.
5943 If SHOW-ALL is non-nil, already read articles are also listed.
5944 If NO-ARTICLE is non-nil, no article is selected initially."
5945 (gnus-message 5 "Retrieving newsgroup: %s..." group
)
5946 (let* ((new-group (gnus-summary-setup-buffer group
))
5947 (quit-config (gnus-group-quit-config group
))
5948 (did-select (and new-group
(gnus-select-newsgroup group show-all
))))
5951 (gnus-set-global-variables)
5952 (gnus-kill-buffer kill-buffer
)
5953 (gnus-configure-windows 'summary
'force
)
5954 (gnus-set-mode-line 'summary
)
5955 (gnus-summary-position-cursor)
5959 (and (eq major-mode
'gnus-summary-mode
)
5960 (not (equal (current-buffer) kill-buffer
))
5962 (kill-buffer (current-buffer))
5963 (if (not quit-config
)
5965 (set-buffer gnus-group-buffer
)
5966 (gnus-group-jump-to-group group
)
5967 (gnus-group-next-unread-group 1))
5968 (if (not (buffer-name (car quit-config
)))
5969 (gnus-configure-windows 'group
'force
)
5970 (set-buffer (car quit-config
))
5971 (and (eq major-mode
'gnus-summary-mode
)
5972 (gnus-set-global-variables))
5973 (gnus-configure-windows (cdr quit-config
))))))
5974 (message "Can't select group")
5976 ((eq did-select
'quit
)
5977 (and (eq major-mode
'gnus-summary-mode
)
5978 (not (equal (current-buffer) kill-buffer
))
5979 (kill-buffer (current-buffer)))
5980 (gnus-kill-buffer kill-buffer
)
5981 (if (not quit-config
)
5983 (set-buffer gnus-group-buffer
)
5984 (gnus-group-jump-to-group group
)
5985 (gnus-group-next-unread-group 1)
5986 (gnus-configure-windows 'group
'force
))
5987 (if (not (buffer-name (car quit-config
)))
5988 (gnus-configure-windows 'group
'force
)
5989 (set-buffer (car quit-config
))
5990 (and (eq major-mode
'gnus-summary-mode
)
5991 (gnus-set-global-variables))
5992 (gnus-configure-windows (cdr quit-config
))))
5995 (gnus-set-global-variables)
5996 ;; Save the active value in effect when the group was entered.
5997 (setq gnus-newsgroup-active
5999 (gnus-gethash gnus-newsgroup-name gnus-active-hashtb
)))
6000 ;; You can change the subjects in this hook.
6001 (run-hooks 'gnus-select-group-hook
)
6002 ;; Do score processing.
6003 (and gnus-use-scoring
(gnus-possibly-score-headers))
6004 (gnus-update-format-specifications)
6005 ;; Generate the summary buffer.
6006 (gnus-summary-prepare)
6007 (if (zerop (buffer-size))
6008 (cond (gnus-newsgroup-dormant
6009 (gnus-summary-show-all-dormant))
6010 ((and gnus-newsgroup-scored show-all
)
6011 (gnus-summary-show-all-expunged))))
6012 ;; Function `gnus-apply-kill-file' must be called in this hook.
6013 (run-hooks 'gnus-apply-kill-hook
)
6014 (if (zerop (buffer-size))
6016 ;; This newsgroup is empty.
6017 (gnus-summary-catchup-and-exit nil t
) ;Without confirmations.
6018 (gnus-message 6 "No unread news")
6019 (gnus-kill-buffer kill-buffer
)
6023 ;; (let ((gnus-summary-buffer kill-buffer))
6024 ;; (gnus-configure-windows 'group))))
6025 ;; Hide conversation thread subtrees. We cannot do this in
6026 ;; gnus-summary-prepare-hook since kill processing may not
6027 ;; work with hidden articles.
6028 (and gnus-show-threads
6029 gnus-thread-hide-subtree
6030 (gnus-summary-hide-all-threads))
6031 ;; Show first unread article if requested.
6032 (goto-char (point-min))
6033 (if (and (not no-article
)
6034 gnus-auto-select-first
6035 (gnus-summary-first-unread-article))
6037 (gnus-configure-windows 'summary
'force
))
6038 (gnus-set-mode-line 'summary
)
6039 (gnus-summary-position-cursor)
6040 ;; If in async mode, we send some info to the backend.
6041 (and gnus-newsgroup-async
6042 (setq gnus-newsgroup-threads
(nreverse gnus-newsgroup-threads
))
6043 (gnus-request-asynchronous
6045 (if (and gnus-asynchronous-article-function
6046 (fboundp gnus-asynchronous-article-function
))
6047 (funcall gnus-asynchronous-article-function
6048 gnus-newsgroup-threads
)
6049 gnus-newsgroup-threads
)))
6050 (gnus-kill-buffer kill-buffer
)
6051 (if (not (get-buffer-window gnus-group-buffer
))
6053 ;; gotta use windows, because recenter does weird stuff if
6054 ;; the current buffer ain't the displayed window.
6055 (let ((owin (selected-window)))
6056 (select-window (get-buffer-window gnus-group-buffer
))
6057 (and (gnus-group-goto-group group
)
6059 (select-window owin
))))
6062 (defun gnus-summary-prepare ()
6063 ;; Generate the summary buffer.
6064 (let ((buffer-read-only nil
))
6066 (gnus-summary-prepare-threads
6067 (if gnus-show-threads
6068 (gnus-gather-threads
6070 (if (and gnus-summary-expunge-below
6071 (not gnus-fetch-old-headers
))
6072 (gnus-make-threads-and-expunge)
6073 (gnus-make-threads))))
6074 gnus-newsgroup-headers
)
6076 (gnus-summary-update-lines)
6077 ;; Create the header hashtb.
6078 (gnus-make-headers-hashtable-by-number)
6079 ;; Call hooks for modifying summary buffer.
6080 ;; Suggested by sven@tde.LTH.Se (Sven Mattisson).
6081 (goto-char (point-min))
6082 (run-hooks 'gnus-summary-prepare-hook
)))
6084 (defun gnus-gather-threads (threads)
6085 "Gather threads that have lost their roots."
6086 (if (not gnus-summary-make-false-root
)
6088 (let ((hashtb (gnus-make-hashtable 1023))
6091 subject hthread whole-subject
)
6094 (setq subject
(mail-header-subject (car (car threads
)))))
6095 (if gnus-summary-gather-subject-limit
6096 (or (and (numberp gnus-summary-gather-subject-limit
)
6097 (> (length subject
) gnus-summary-gather-subject-limit
)
6099 (substring subject
0
6100 gnus-summary-gather-subject-limit
)))
6101 (and (eq 'fuzzy gnus-summary-gather-subject-limit
)
6102 (setq subject
(gnus-simplify-subject-fuzzy subject
))))
6103 (setq subject
(gnus-simplify-subject-re subject
)))
6105 (gnus-gethash subject hashtb
))
6107 (or (stringp (car (car hthread
)))
6108 (setcar hthread
(list whole-subject
(car hthread
))))
6109 (setcdr (car hthread
) (nconc (cdr (car hthread
))
6110 (list (car threads
))))
6111 (setcdr prev
(cdr threads
))
6112 (setq threads prev
))
6113 (gnus-sethash subject threads hashtb
))
6115 (setq threads
(cdr threads
)))
6118 (defun gnus-make-threads ()
6119 ;; This function takes the dependencies already made by
6120 ;; `gnus-get-newsgroup-headers' and builds the trees. First we go
6121 ;; through the dependencies in the hash table and finds all the
6122 ;; roots. Roots do not refer back to any valid articles.
6123 (gnus-message 6 "Threading...")
6124 (let (roots new-roots
)
6125 (and gnus-fetch-old-headers
6126 (eq gnus-headers-retrieved-by
'nov
)
6127 (gnus-build-old-threads))
6130 (if (not (car (symbol-value refs
)))
6131 (setq roots
(append (cdr (symbol-value refs
)) roots
))
6132 ;; Ok, these refer back to valid articles, but if
6133 ;; `gnus-thread-ignore-subject' is nil, we have to check that
6134 ;; the root has the same subject as its children. The children
6135 ;; that do not are made into roots and removed from the list
6137 (or gnus-thread-ignore-subject
6138 (let* ((prev (symbol-value refs
))
6139 (subject (gnus-simplify-subject-re
6140 (mail-header-subject (car prev
))))
6141 (headers (cdr prev
)))
6143 (if (not (string= subject
6144 (gnus-simplify-subject-re
6145 (mail-header-subject (car headers
)))))
6147 (setq new-roots
(cons (car headers
) new-roots
))
6148 (setcdr prev
(cdr headers
)))
6149 (setq prev headers
))
6150 (setq headers
(cdr headers
)))))))
6151 gnus-newsgroup-dependencies
)
6153 ;; We enter the new roots into the dependencies structure to
6154 ;; ensure that any possible later thread-regeneration will be
6156 (let ((r new-roots
))
6158 (gnus-sethash (concat (mail-header-id (car r
)) ".boo")
6159 (list nil
(car r
)) gnus-newsgroup-dependencies
)
6162 (setq roots
(nconc new-roots roots
))
6165 (mapcar 'gnus-trim-thread
6167 (mapcar 'gnus-cut-thread
6168 (mapcar 'gnus-make-sub-thread roots
))))
6169 (gnus-message 6 "Threading...done"))))
6172 (defun gnus-make-threads-and-expunge ()
6173 ;; This function takes the dependencies already made by
6174 ;; `gnus-get-newsgroup-headers' and builds the trees. First we go
6175 ;; through the dependencies in the hash table and finds all the
6176 ;; roots. Roots do not refer back to any valid articles.
6177 (gnus-message 6 "Threading...")
6178 (let ((default (or gnus-summary-default-score
0))
6179 (below gnus-summary-expunge-below
)
6180 roots article new-roots
)
6181 (and gnus-fetch-old-headers
6182 (eq gnus-headers-retrieved-by
'nov
)
6183 (gnus-build-old-threads))
6186 (if (not (car (symbol-value refs
)))
6187 ;; These articles do not refer back to any other articles -
6189 (let ((headers (cdr (symbol-value refs
))))
6190 ;; We weed out the low-scored articles.
6192 (if (not (< (or (cdr (assq (mail-header-number (car headers
))
6193 gnus-newsgroup-scored
)) default
)
6196 (setq roots
(cons (car headers
) roots
))
6197 ;; It is below, so we mark it as read.
6198 (setq gnus-newsgroup-unreads
6199 (delq (mail-header-number (car headers
))
6200 gnus-newsgroup-unreads
))
6201 (setq gnus-newsgroup-reads
6202 (cons (cons (mail-header-number (car headers
))
6203 gnus-low-score-mark
)
6204 gnus-newsgroup-reads
)))
6205 (setq headers
(cdr headers
))))
6206 ;; Ok, these refer back to valid articles, but if
6207 ;; `gnus-thread-ignore-subject' is nil, we have to check that
6208 ;; the root has the same subject as its children. The children
6209 ;; that do not are made into roots and removed from the list
6211 (or gnus-thread-ignore-subject
6212 (let* ((prev (symbol-value refs
))
6213 (subject (gnus-simplify-subject-re
6214 (mail-header-subject (car prev
))))
6215 (headers (cdr prev
)))
6217 (if (not (string= subject
6218 (gnus-simplify-subject-re
6219 (mail-header-subject (car headers
)))))
6221 (if (not (< (or (cdr (assq (mail-header-number
6223 gnus-newsgroup-scored
))
6225 (setq new-roots
(cons (car headers
) new-roots
))
6226 (setq gnus-newsgroup-unreads
6227 (delq (mail-header-number (car headers
))
6228 gnus-newsgroup-unreads
))
6229 (setq gnus-newsgroup-reads
6230 (cons (cons (mail-header-number (car headers
))
6231 gnus-low-score-mark
)
6232 gnus-newsgroup-reads
)))
6233 (setcdr prev
(cdr headers
)))
6234 (setq prev headers
))
6235 (setq headers
(cdr headers
)))))
6236 ;; If this article is expunged, some of the children might be
6238 (if (< (or (cdr (assq (mail-header-number (car (symbol-value refs
)))
6239 gnus-newsgroup-scored
)) default
)
6241 (let* ((prev (symbol-value refs
))
6242 (headers (cdr prev
)))
6244 (setq article
(mail-header-number (car headers
)))
6245 (if (not (< (or (cdr (assq article gnus-newsgroup-scored
))
6247 (progn (setq new-roots
(cons (car headers
) new-roots
))
6248 (setq prev headers
))
6249 (setq gnus-newsgroup-unreads
6250 (delq article gnus-newsgroup-unreads
))
6251 (setq gnus-newsgroup-reads
6252 (cons (cons article gnus-low-score-mark
)
6253 gnus-newsgroup-reads
))
6254 (setcdr prev
(cdr headers
)))
6255 (setq headers
(cdr headers
))))
6256 ;; It was not expunged, but we look at expunged children.
6257 (let* ((prev (symbol-value refs
))
6258 (headers (cdr prev
))
6261 (setq article
(mail-header-number (car headers
)))
6262 (if (not (< (or (cdr (assq article gnus-newsgroup-scored
))
6265 (setq gnus-newsgroup-unreads
6266 (delq article gnus-newsgroup-unreads
))
6267 (setq gnus-newsgroup-reads
6268 (cons (cons article gnus-low-score-mark
)
6269 gnus-newsgroup-reads
))
6270 (setcdr prev
(cdr headers
)))
6271 (setq headers
(cdr headers
)))))))
6272 gnus-newsgroup-dependencies
)
6274 ;; We enter the new roots into the dependencies structure to
6275 ;; ensure that any possible later thread-regeneration will be
6277 (let ((r new-roots
))
6279 (gnus-sethash (concat (mail-header-id (car r
)) ".boo")
6280 (list nil
(car r
)) gnus-newsgroup-dependencies
)
6283 (setq roots
(nconc new-roots roots
))
6286 (mapcar 'gnus-trim-thread
6288 (mapcar 'gnus-cut-thread
6289 (mapcar 'gnus-make-sub-thread roots
))))
6290 (gnus-message 6 "Threading...done"))))
6293 (defun gnus-cut-thread (thread)
6294 ;; Remove leaf dormant or ancient articles from THREAD.
6295 (let ((head (car thread
))
6296 (tail (apply 'append
(mapcar 'gnus-cut-thread
(cdr thread
)))))
6297 (if (and (null tail
)
6298 (let ((number (mail-header-number head
)))
6299 (or (memq number gnus-newsgroup-ancient
)
6300 (memq number gnus-newsgroup-dormant
)
6301 (and gnus-summary-expunge-below
6302 (eq gnus-fetch-old-headers
'some
)
6303 (< (or (cdr (assq number gnus-newsgroup-scored
))
6304 gnus-summary-default-score
0)
6305 gnus-summary-expunge-below
)
6307 (setq gnus-newsgroup-unreads
6308 (delq number gnus-newsgroup-unreads
))
6309 (setq gnus-newsgroup-reads
6310 (cons (cons number gnus-low-score-mark
)
6311 gnus-newsgroup-reads
))
6314 (list (cons head tail
)))))
6316 (defun gnus-trim-thread (thread)
6317 ;; Remove root ancient articles with only one child from THREAD.
6318 (if (and (eq gnus-fetch-old-headers
'some
)
6319 (memq (mail-header-number (car thread
)) gnus-newsgroup-ancient
)
6320 (= (length thread
) 2))
6321 (gnus-trim-thread (nth 1 thread
))
6324 (defun gnus-make-sub-thread (root)
6325 ;; This function makes a sub-tree for a node in the tree.
6326 (let ((children (reverse (cdr (gnus-gethash (downcase (mail-header-id root
))
6327 gnus-newsgroup-dependencies
)))))
6328 (cons root
(mapcar 'gnus-make-sub-thread children
))))
6330 (defun gnus-build-old-threads ()
6331 ;; Look at all the articles that refer back to old articles, and
6332 ;; fetch the headers for the articles that aren't there. This will
6333 ;; build complete threads - if the roots haven't been expired by the
6338 (if (not (car (symbol-value refs
)))
6340 (setq heads
(cdr (symbol-value refs
)))
6342 (if (not (memq (mail-header-number (car heads
))
6343 gnus-newsgroup-dormant
))
6345 (setq id
(symbol-name refs
))
6346 (while (and (setq id
(gnus-build-get-header id
))
6347 (not (car (gnus-gethash
6348 id gnus-newsgroup-dependencies
)))))
6350 (setq heads
(cdr heads
)))))))
6351 gnus-newsgroup-dependencies
)))
6353 (defun gnus-build-get-header (id)
6354 ;; Look through the buffer of NOV lines and find the header to
6355 ;; ID. Enter this line into the dependencies hash table, and return
6356 ;; the id of the parent article (if any).
6357 (let ((deps gnus-newsgroup-dependencies
)
6361 (set-buffer nntp-server-buffer
)
6362 (goto-char (point-min))
6363 (while (and (not found
) (search-forward id nil t
))
6365 (setq found
(looking-at
6366 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
6367 (regexp-quote id
))))
6368 (or found
(beginning-of-line 2)))
6373 (setq header
(gnus-nov-parse-line
6374 (read (current-buffer)) deps
))
6375 (setq ref
(mail-header-references header
))
6376 (string-match "\\(<[^>]+>\\) *$" ref
)
6377 (substring ref
(match-beginning 1) (match-end 1))))))
6379 (setq gnus-newsgroup-headers
(cons header gnus-newsgroup-headers
)
6380 gnus-newsgroup-ancient
(cons (mail-header-number header
)
6381 gnus-newsgroup-ancient
))))))
6383 ;; Re-build the thread containing ID.
6384 (defun gnus-rebuild-thread (id)
6385 (let ((dep gnus-newsgroup-dependencies
)
6386 (buffer-read-only nil
)
6387 parent headers refs thread art
)
6388 (while (and id
(setq headers
6389 (car (setq art
(gnus-gethash (downcase id
) dep
)))))
6391 (setq id
(and (setq refs
(mail-header-references headers
))
6392 (string-match "\\(<[^>]+>\\) *$" refs
)
6393 (substring refs
(match-beginning 1) (match-end 1)))))
6394 (setq thread
(gnus-make-sub-thread (car parent
)))
6395 (gnus-rebuild-remove-articles thread
)
6396 (let ((beg (point)))
6397 (gnus-summary-prepare-threads (list thread
))
6398 (gnus-summary-update-lines beg
(point)))))
6400 ;; Delete all lines in the summary buffer that correspond to articles
6402 (defun gnus-rebuild-remove-articles (thread)
6403 (and (gnus-summary-goto-subject (mail-header-number (car thread
)))
6405 (mapcar (lambda (th) (gnus-rebuild-remove-articles th
)) (cdr thread
)))
6407 (defun gnus-sort-threads (threads)
6408 ;; Sort threads as specified in `gnus-thread-sort-functions'.
6409 (let ((fun gnus-thread-sort-functions
))
6411 (gnus-message 6 "Sorting with %S..." fun
)
6412 (setq threads
(sort threads
(car fun
))
6414 (if gnus-thread-sort-functions
6415 (gnus-message 6 "Sorting...done"))
6418 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
6419 (defmacro gnus-thread-header
(thread)
6420 ;; Return header of first article in THREAD.
6421 ;; Note that THREAD must never, evr be anything else than a variable -
6422 ;; using some other form will lead to serious barfage.
6423 (or (symbolp thread
) (signal 'wrong-type-argument
'(symbolp thread
)))
6424 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
6425 (list 'byte-code
"\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
6428 (defun gnus-thread-sort-by-number (h1 h2
)
6429 "Sort threads by root article number."
6430 (< (mail-header-number (gnus-thread-header h1
))
6431 (mail-header-number (gnus-thread-header h2
))))
6433 (defun gnus-thread-sort-by-author (h1 h2
)
6434 "Sort threads by root author."
6436 (let ((extract (funcall
6437 gnus-extract-address-components
6438 (mail-header-from (gnus-thread-header h1
)))))
6439 (or (car extract
) (cdr extract
)))
6440 (let ((extract (funcall
6441 gnus-extract-address-components
6442 (mail-header-from (gnus-thread-header h2
)))))
6443 (or (car extract
) (cdr extract
)))))
6445 (defun gnus-thread-sort-by-subject (h1 h2
)
6446 "Sort threads by root subject."
6448 (downcase (gnus-simplify-subject-re
6449 (mail-header-subject (gnus-thread-header h1
))))
6450 (downcase (gnus-simplify-subject-re
6451 (mail-header-subject (gnus-thread-header h2
))))))
6453 (defun gnus-thread-sort-by-date (h1 h2
)
6454 "Sort threads by root article date."
6456 (gnus-sortable-date (mail-header-date (gnus-thread-header h1
)))
6457 (gnus-sortable-date (mail-header-date (gnus-thread-header h2
)))))
6459 (defun gnus-thread-sort-by-score (h1 h2
)
6460 "Sort threads by root article score.
6461 Unscored articles will be counted as having a score of zero."
6462 (> (or (cdr (assq (mail-header-number (gnus-thread-header h1
))
6463 gnus-newsgroup-scored
))
6464 gnus-summary-default-score
0)
6465 (or (cdr (assq (mail-header-number (gnus-thread-header h2
))
6466 gnus-newsgroup-scored
))
6467 gnus-summary-default-score
0)))
6469 (defun gnus-thread-sort-by-total-score (h1 h2
)
6470 "Sort threads by the sum of all scores in the thread.
6471 Unscored articles will be counted as having a score of zero."
6472 (> (gnus-thread-total-score h1
) (gnus-thread-total-score h2
)))
6474 (defun gnus-thread-total-score (thread)
6475 ;; This function find the total score of THREAD.
6477 (if (stringp (car thread
))
6478 (apply gnus-thread-score-function
0
6479 (mapcar 'gnus-thread-total-score-1
(cdr thread
)))
6480 (gnus-thread-total-score-1 thread
))
6481 (gnus-thread-total-score-1 (list thread
))))
6483 (defun gnus-thread-total-score-1 (root)
6484 ;; This function find the total score of the thread below ROOT.
6485 (setq root
(car root
))
6486 (apply gnus-thread-score-function
6487 (or (cdr (assq (mail-header-number root
) gnus-newsgroup-scored
))
6488 gnus-summary-default-score
0)
6489 (mapcar 'gnus-thread-total-score
6490 (cdr (gnus-gethash (downcase (mail-header-id root
))
6491 gnus-newsgroup-dependencies
)))))
6493 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
6494 (defvar gnus-tmp-prev-subject
"")
6496 (defun gnus-summary-prepare-threads (threads &optional cull
)
6497 "Prepare summary buffer from THREADS and indentation LEVEL.
6498 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
6499 or a straight list of headers."
6500 (message "Generating summary...")
6502 thread header number subject stack state gnus-tmp-gathered
)
6503 (if (vectorp (car threads
))
6504 ;; If this is a straight (sic) list of headers, then a
6505 ;; threaded summary display isn't required, so we just create
6506 ;; an unthreaded one.
6507 (gnus-summary-prepare-unthreaded threads cull
)
6509 ;; Do the threaded display.
6511 (while (or threads stack
)
6514 ;; If there are some threads, we do them before the
6515 ;; threads on the stack.
6516 (setq thread threads
6517 header
(car (car thread
)))
6518 ;; There were no current threads, so we pop something off
6520 (setq state
(car stack
)
6524 header
(car (car thread
))))
6526 (if (stringp header
)
6528 ;; The header is a dummy root.
6530 ((eq gnus-summary-make-false-root
'adopt
)
6531 ;; We let the first article adopt the rest.
6532 (let ((th (car (cdr (car thread
)))))
6535 (setcdr th
(cdr (cdr (car thread
))))
6536 (setq gnus-tmp-gathered
6538 (lambda (h) (mail-header-number (car h
)))
6539 (cdr (cdr (car thread
))))
6541 (setcdr (cdr (car thread
)) nil
))
6543 ((eq gnus-summary-make-false-root
'empty
)
6544 ;; We print adopted articles with empty subject fields.
6545 (setq gnus-tmp-gathered
6547 (lambda (h) (mail-header-number (car h
)))
6548 (cdr (cdr (car thread
))))
6551 ((eq gnus-summary-make-false-root
'dummy
)
6552 ;; We output a dummy root.
6553 (gnus-summary-insert-dummy-line
6554 nil header
(mail-header-number
6555 (car (car (cdr (car thread
)))))))
6557 ;; We do not make a root for the gathered
6558 ;; sub-threads at all.
6561 (setq number
(mail-header-number header
)
6562 subject
(mail-header-subject header
))
6564 ;; Do the async thing.
6565 (and gnus-newsgroup-async
6566 (setq gnus-newsgroup-threads
6567 (cons (cons number
(mail-header-lines header
))
6568 gnus-newsgroup-threads
)))
6570 ;; We may have to root out some bad articles...
6573 (cond ((and (memq (setq number
(mail-header-number header
))
6574 gnus-newsgroup-dormant
)
6577 ((and gnus-summary-expunge-below
6578 (< (or (cdr (assq number gnus-newsgroup-scored
))
6579 gnus-summary-default-score
0)
6580 gnus-summary-expunge-below
))
6582 (setq gnus-newsgroup-unreads
6583 (delq number gnus-newsgroup-unreads
))
6584 (setq gnus-newsgroup-reads
6585 (cons (cons number gnus-low-score-mark
)
6586 gnus-newsgroup-reads
)))))
6592 (gnus-summary-insert-line
6593 nil header level nil
6595 ((memq number gnus-newsgroup-marked
) gnus-ticked-mark
)
6596 ((memq number gnus-newsgroup-dormant
) gnus-dormant-mark
)
6597 ((memq number gnus-newsgroup-unreads
) gnus-unread-mark
)
6598 ((memq number gnus-newsgroup-expirable
) gnus-expirable-mark
)
6599 (t (or (cdr (assq number gnus-newsgroup-reads
))
6600 gnus-ancient-mark
)))
6601 (memq number gnus-newsgroup-replied
)
6602 (memq number gnus-newsgroup-expirable
)
6604 ((and gnus-thread-ignore-subject
6606 (gnus-simplify-subject-re gnus-tmp-prev-subject
)
6607 (gnus-simplify-subject-re subject
))))
6610 (if (and (eq gnus-summary-make-false-root
'empty
)
6611 (memq number gnus-tmp-gathered
))
6612 gnus-summary-same-subject
6614 (t gnus-summary-same-subject
))
6615 (and (eq gnus-summary-make-false-root
'adopt
)
6616 (memq number gnus-tmp-gathered
))
6617 (cdr (assq number gnus-newsgroup-scored
))
6618 (memq number gnus-newsgroup-processable
))
6620 (setq gnus-tmp-prev-subject subject
)))))
6623 (setq stack
(cons (cons (max 0 level
) (nthcdr 1 thread
)) stack
)))
6624 (setq level
(1+ level
))
6625 (setq threads
(cdr (car thread
))))))
6626 (message "Generating summary...done"))
6630 (defun gnus-summary-prepare-unthreaded (headers &optional cull
)
6631 (let (header number
)
6633 ;; Do the async thing, if that is required.
6634 (if gnus-newsgroup-async
6635 (setq gnus-newsgroup-threads
6637 (cons (mail-header-number h
) (mail-header-lines h
)))
6641 (setq header
(car headers
)
6642 headers
(cdr headers
)
6643 number
(mail-header-number header
))
6645 ;; We may have to root out some bad articles...
6648 (memq (setq number
(mail-header-number header
))
6649 gnus-newsgroup-dormant
)))
6650 ((and cull gnus-summary-expunge-below
6651 (< (or (cdr (assq number gnus-newsgroup-scored
))
6652 gnus-summary-default-score
0)
6653 gnus-summary-expunge-below
))
6654 (setq gnus-newsgroup-unreads
6655 (delq number gnus-newsgroup-unreads
))
6656 (setq gnus-newsgroup-reads
6657 (cons (cons number gnus-low-score-mark
)
6658 gnus-newsgroup-reads
)))
6660 (gnus-summary-insert-line
6662 (cond ((memq number gnus-newsgroup-marked
) gnus-ticked-mark
)
6663 ((memq number gnus-newsgroup-dormant
) gnus-dormant-mark
)
6664 ((memq number gnus-newsgroup-unreads
) gnus-unread-mark
)
6665 ((memq number gnus-newsgroup-expirable
) gnus-expirable-mark
)
6666 (t (or (cdr (assq number gnus-newsgroup-reads
))
6667 gnus-ancient-mark
)))
6668 (memq number gnus-newsgroup-replied
)
6669 (memq number gnus-newsgroup-expirable
)
6670 (mail-header-subject header
) nil
6671 (cdr (assq number gnus-newsgroup-scored
))
6672 (memq number gnus-newsgroup-processable
)))))))
6674 (defun gnus-select-newsgroup (group &optional read-all
)
6675 "Select newsgroup GROUP.
6676 If READ-ALL is non-nil, all articles in the group are selected."
6677 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb
))
6678 (info (nth 2 entry
))
6681 (or (gnus-check-server
6682 (setq gnus-current-select-method
(gnus-find-method-for-group group
)))
6683 (error "Couldn't open server"))
6685 (or (and entry
(not (eq (car entry
) t
))) ; Either it's active...
6686 (gnus-activate-group group
) ; Or we can activate it...
6687 (progn ; Or we bug out.
6688 (kill-buffer (current-buffer))
6689 (error "Couldn't request group %s: %s"
6690 group
(gnus-status-message group
))))
6692 (setq gnus-newsgroup-name group
)
6693 (setq gnus-newsgroup-unselected nil
)
6694 (setq gnus-newsgroup-unreads
(gnus-list-of-unread-articles group
))
6696 (and gnus-asynchronous
6697 (gnus-check-backend-function
6698 'request-asynchronous gnus-newsgroup-name
)
6699 (setq gnus-newsgroup-async
6700 (gnus-request-asynchronous gnus-newsgroup-name
)))
6702 (setq articles
(gnus-articles-to-read group read-all
))
6706 (gnus-message 3 "Couldn't select newsgroup")
6708 ((eq articles
0) nil
)
6710 ;; Init the dependencies hash table.
6711 (setq gnus-newsgroup-dependencies
6712 (gnus-make-hashtable (length articles
)))
6713 ;; Retrieve the headers and read them in.
6714 (gnus-message 5 "Fetching headers...")
6715 (setq gnus-newsgroup-headers
6716 (if (eq 'nov
(setq gnus-headers-retrieved-by
6717 ;; This is a naughty hack. To get the
6718 ;; retrieval of old headers to work, we
6719 ;; set `nntp-nov-gap' to nil (locally),
6720 ;; and then just retrieve the headers.
6722 (if gnus-fetch-old-headers
6724 (gnus-retrieve-headers
6725 (if (not (eq 1 (car articles
)))
6728 gnus-newsgroup-name
))
6729 (gnus-retrieve-headers
6730 articles gnus-newsgroup-name
))))
6732 (gnus-get-newsgroup-headers-xover articles
))
6733 ;; If we were to fetch old headers, but the backend didn't
6734 ;; support XOVER, then it is possible we fetched one article
6735 ;; that we shouldn't have. If that's the case, we remove it.
6736 (if (or (not gnus-fetch-old-headers
)
6737 (eq 1 (car articles
)))
6740 (set-buffer nntp-server-buffer
)
6741 (goto-char (point-min))
6743 (looking-at "[0-9]+[ \t]+1[ \t]") ; This is not a NOV line.
6744 (delete-region ; So we delete this head.
6746 (search-forward "\n.\n" nil t
)))))
6747 (gnus-get-newsgroup-headers)))
6748 (gnus-message 5 "Fetching headers...done")
6749 ;; Remove canceled articles from the list of unread articles.
6750 (setq gnus-newsgroup-unreads
6751 (gnus-set-sorted-intersection
6752 gnus-newsgroup-unreads
6753 (mapcar (lambda (headers) (mail-header-number headers
))
6754 gnus-newsgroup-headers
)))
6755 ;; Adjust and set lists of article marks.
6758 (gnus-adjust-marked-articles info
)
6759 (setq gnus-newsgroup-marked
6761 (cdr (assq 'tick
(setq marked
(nth 3 info
))))))
6762 (setq gnus-newsgroup-replied
6763 (copy-sequence (cdr (assq 'reply marked
))))
6764 (setq gnus-newsgroup-expirable
6765 (copy-sequence (cdr (assq 'expire marked
))))
6766 (setq gnus-newsgroup-killed
6767 (copy-sequence (cdr (assq 'killed marked
))))
6768 (setq gnus-newsgroup-bookmarks
6769 (copy-sequence (cdr (assq 'bookmark marked
))))
6770 (setq gnus-newsgroup-dormant
6771 (copy-sequence (cdr (assq 'dormant marked
))))
6772 (setq gnus-newsgroup-scored
6773 (copy-sequence (cdr (assq 'score marked
))))
6774 (setq gnus-newsgroup-processable nil
)))
6775 ;; Check whether auto-expire is to be done in this group.
6776 (setq gnus-newsgroup-auto-expire
6777 (or (and (stringp gnus-auto-expirable-newsgroups
)
6778 (string-match gnus-auto-expirable-newsgroups group
))
6779 (memq 'auto-expire
(nth 5 info
))))
6780 ;; First and last article in this newsgroup.
6781 (and gnus-newsgroup-headers
6782 (setq gnus-newsgroup-begin
6783 (mail-header-number (car gnus-newsgroup-headers
)))
6784 (setq gnus-newsgroup-end
6786 (gnus-last-element gnus-newsgroup-headers
))))
6787 (setq gnus-reffed-article-number -
1)
6788 ;; GROUP is successfully selected.
6789 (or gnus-newsgroup-headers t
)))))
6791 (defun gnus-articles-to-read (group read-all
)
6792 ;; Find out what articles the user wants to read.
6794 ;; Select all articles if `read-all' is non-nil, or if all the
6795 ;; unread articles are dormant articles.
6797 (= (length gnus-newsgroup-unreads
)
6798 (length gnus-newsgroup-dormant
)))
6799 (gnus-uncompress-range
6800 (gnus-gethash group gnus-active-hashtb
))
6801 gnus-newsgroup-unreads
))
6802 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles
))
6803 (scored (length scored-list
))
6804 (number (length articles
))
6805 (marked (+ (length gnus-newsgroup-marked
)
6806 (length gnus-newsgroup-dormant
)))
6813 (cond ((and (or (<= scored marked
)
6815 (numberp gnus-large-newsgroup
)
6816 (> number gnus-large-newsgroup
))
6820 "How many articles from %s (default %d): "
6821 gnus-newsgroup-name number
))))
6822 (if (string-match "^[ \t]*$" input
)
6824 ((and (> scored marked
) (< scored number
))
6828 "%s %s (%d scored, %d total): "
6829 "How many articles from"
6830 group scored number
))))
6831 (if (string-match "^[ \t]*$" input
)
6835 (setq select
(if (stringp select
) (string-to-number select
) select
))
6836 (if (or (null select
) (zerop select
))
6838 (if (and (not (zerop scored
)) (<= (abs select
) scored
))
6840 (setq articles
(sort scored-list
'<))
6841 (setq number
(length articles
)))
6842 (setq articles
(copy-sequence articles
)))
6844 (if (< (abs select
) number
)
6846 ;; Select the N oldest articles.
6847 (setcdr (nthcdr (1- (abs select
)) articles
) nil
)
6848 ;; Select the N most recent articles.
6849 (setq articles
(nthcdr (- number select
) articles
))))
6850 (setq gnus-newsgroup-unselected
6851 (gnus-sorted-intersection
6852 gnus-newsgroup-unreads
6853 (gnus-sorted-complement gnus-newsgroup-unreads articles
)))
6856 (defun gnus-killed-articles (killed articles
)
6859 (if (inline (gnus-member-of-range (car articles
) killed
))
6860 (setq out
(cons (car articles
) out
)))
6861 (setq articles
(cdr articles
)))
6864 (defun gnus-adjust-marked-articles (info &optional active
)
6865 "Remove all marked articles that are no longer legal."
6866 (let ((marked-lists (nth 3 info
))
6867 (active (or active
(gnus-gethash (car info
) gnus-active-hashtb
)))
6869 ;; There are many types of marked articles.
6871 (setq m
(cdr (setq prev
(car marked-lists
))))
6872 (cond ((or (eq 'tick
(car prev
)) (eq 'dormant
(car prev
)))
6873 ;; Make sure that all ticked articles are a subset of the
6874 ;; unread/unselected articles.
6876 (if (or (memq (car m
) gnus-newsgroup-unreads
)
6877 (memq (car m
) gnus-newsgroup-unselected
))
6879 (setcdr prev
(cdr m
)))
6881 ((eq 'score
(car prev
))
6882 ;; Scored articles should be a subset of
6883 ;; unread/unselected articles.
6885 (if (or (memq (car (car m
)) gnus-newsgroup-unreads
)
6886 (memq (car (car m
)) gnus-newsgroup-unreads
))
6888 (setcdr prev
(cdr m
)))
6890 ((eq 'bookmark
(car prev
))
6891 ;; Bookmarks should be a subset of active articles.
6893 (if (< (car (car m
)) (car active
))
6894 (setcdr prev
(cdr m
))
6897 ((eq 'killed
(car prev
))
6898 ;; Articles that have been through the kill process are
6899 ;; to be a subset of active articles.
6900 (while (and m
(< (or (and (numberp (car m
)) (car m
))
6903 (setcdr prev
(cdr m
))
6905 (if (and m
(< (or (and (numberp (car m
)) (car m
))
6908 (setcar (if (numberp (car m
)) m
(car m
)) (car active
))))
6909 ((or (eq 'reply
(car prev
)) (eq 'expire
(car prev
)))
6910 ;; The replied and expirable articles have to be articles
6913 (if (< (car m
) (car active
))
6914 (setcdr prev
(cdr m
))
6917 (setq marked-lists
(cdr marked-lists
)))
6918 ;; Remove all lists that are empty.
6919 (setq marked-lists
(nth 3 info
))
6922 (while (= 1 (length (car marked-lists
)))
6923 (setq marked-lists
(cdr marked-lists
)))
6924 (setq m
(cdr (setq prev marked-lists
)))
6926 (if (= 1 (length (car m
)))
6927 (setcdr prev
(cdr m
))
6930 (setcar (nthcdr 3 info
) marked-lists
)))
6931 ;; Finally, if there are no marked lists at all left, and if there
6932 ;; are no elements after the lists in the info list, we just chop
6933 ;; the info list off before the marked lists.
6934 (and (null marked-lists
)
6935 (not (nthcdr 4 info
))
6936 (setcdr (nthcdr 2 info
) nil
)))
6939 (defun gnus-set-marked-articles
6940 (info ticked replied expirable killed dormant bookmark score
)
6941 "Enter the various lists of marked articles into the newsgroup info list."
6943 (and ticked
(setq newmarked
(cons (cons 'tick ticked
) nil
)))
6944 (and replied
(setq newmarked
(cons (cons 'reply replied
) newmarked
)))
6945 (and expirable
(setq newmarked
(cons (cons 'expire expirable
)
6947 (and killed
(setq newmarked
(cons (cons 'killed killed
) newmarked
)))
6948 (and dormant
(setq newmarked
(cons (cons 'dormant dormant
) newmarked
)))
6949 (and bookmark
(setq newmarked
(cons (cons 'bookmark bookmark
)
6951 (and score
(setq newmarked
(cons (cons 'score score
) newmarked
)))
6954 (setcar (nthcdr 3 info
) newmarked
)
6955 (and (not newmarked
)
6956 (not (nthcdr 4 info
))
6957 (setcdr (nthcdr 2 info
) nil
)))
6959 (setcdr (nthcdr 2 info
) (list newmarked
))))))
6961 (defun gnus-add-marked-articles (group type articles
&optional info force
)
6962 ;; Add ARTICLES of TYPE to the info of GROUP.
6963 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
6964 ;; add, but replace marked articles of TYPE with ARTICLES.
6965 (let ((info (or info
(nth 2 (gnus-gethash group gnus-newsrc-hashtb
))))
6968 (and (not (setq marked
(nthcdr 3 info
)))
6969 (setcdr (nthcdr 2 info
) (list (list (cons type articles
)))))
6970 (and (not (setq m
(assq type
(car marked
))))
6971 (setcar marked
(cons (cons type articles
) (car marked
))))
6974 (nconc m articles
)))))
6976 (defun gnus-set-mode-line (where)
6977 "This function sets the mode line of the article or summary buffers.
6978 If WHERE is `summary', the summary mode line format will be used."
6979 (if (memq where gnus-updated-mode-lines
)
6982 (set-buffer gnus-summary-buffer
)
6983 (let* ((mformat (if (eq where
'article
)
6984 gnus-article-mode-line-format-spec
6985 gnus-summary-mode-line-format-spec
))
6986 (buffer-name (if (eq where
'article
)
6988 (get-buffer gnus-article-buffer
))
6990 (group-name gnus-newsgroup-name
)
6991 (article-number (or gnus-current-article
0))
6992 (unread (- (length gnus-newsgroup-unreads
)
6993 (length gnus-newsgroup-dormant
)))
6994 (unread-and-unticked
6995 (- unread
(length gnus-newsgroup-marked
)))
6996 (unselected (length gnus-newsgroup-unselected
))
6997 (unread-and-unselected
6998 (cond ((and (zerop unread-and-unticked
)
6999 (zerop unselected
)) "")
7001 (format "{%d more}" unread-and-unticked
))
7002 (t (format "{%d(+%d) more}"
7003 unread-and-unticked unselected
))))
7005 (if gnus-current-headers
7006 (mail-header-subject gnus-current-headers
) ""))
7007 (max-len (and gnus-mode-non-string-length
7008 (- (frame-width) gnus-mode-non-string-length
)))
7009 header
);; passed as argument to any user-format-funcs
7010 (setq mode-string
(eval mformat
))
7011 (or (numberp max-len
)
7012 (setq max-len
(length mode-string
)))
7013 (if (< max-len
4) (setq max-len
4))
7014 (if (> (length mode-string
) max-len
)
7015 ;; modified by MORIOKA Tomohiko <morioka@jaist.ac.jp>
7016 ;; function `substring' might cut on a middle
7017 ;; of multi-octet character.
7019 (concat (gnus-truncate-string mode-string
(- max-len
3))
7021 (setq mode-string
(format (format "%%-%ds" max-len
)
7023 (setq mode-line-buffer-identification mode-string
)
7024 (set-buffer-modified-p t
))))
7026 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads
)
7027 "Go through the HEADERS list and add all Xrefs to a hash table.
7028 The resulting hash table is returned, or nil if no Xrefs were found."
7029 (let* ((from-method (gnus-find-method-for-group from-newsgroup
))
7031 (gnus-group-foreign-p from-newsgroup
)
7033 (assoc (symbol-name (car from-method
))
7034 gnus-valid-select-methods
))))
7035 (gnus-group-real-prefix from-newsgroup
)))
7036 (xref-hashtb (make-vector 63 0))
7037 start group entry number xrefs header
)
7039 (setq header
(car headers
))
7040 (if (and (setq xrefs
(mail-header-xref header
))
7041 (not (memq (mail-header-number header
) unreads
)))
7044 (while (string-match "\\([^ ]+\\):\\([0-9]+\\)" xrefs start
)
7045 (setq start
(match-end 0))
7046 (setq group
(concat prefix
(substring xrefs
(match-beginning 1)
7049 (string-to-int (substring xrefs
(match-beginning 2)
7051 (if (setq entry
(gnus-gethash group xref-hashtb
))
7052 (setcdr entry
(cons number
(cdr entry
)))
7053 (gnus-sethash group
(cons number nil
) xref-hashtb
)))))
7054 (setq headers
(cdr headers
)))
7055 (if start xref-hashtb nil
)))
7057 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads expirable
)
7058 "Look through all the headers and mark the Xrefs as read."
7059 (let ((virtual (memq 'virtual
7060 (assoc (symbol-name (car (gnus-find-method-for-group
7062 gnus-valid-select-methods
)))
7063 name entry info xref-hashtb idlist method
7066 (set-buffer gnus-group-buffer
)
7067 (if (setq xref-hashtb
7068 (gnus-create-xref-hashtb from-newsgroup headers unreads
))
7071 (if (string= from-newsgroup
(setq name
(symbol-name group
)))
7073 (setq idlist
(symbol-value group
))
7074 ;; Dead groups are not updated.
7076 (setq entry
(gnus-gethash name gnus-newsrc-hashtb
)
7078 (if (stringp (setq nth4
(nth 4 info
)))
7079 (setq nth4
(gnus-server-to-method nth4
))))
7080 ;; Only do the xrefs if the group has the same
7081 ;; select method as the group we have just read.
7082 (or (gnus-methods-equal-p
7083 nth4
(gnus-find-method-for-group from-newsgroup
))
7086 (setq method
(gnus-find-method-for-group
7088 (and (equal (car nth4
) (car method
))
7089 (equal (nth 1 nth4
) (nth 1 method
))))
7090 gnus-use-cross-reference
7091 (or (not (eq gnus-use-cross-reference t
))
7093 ;; Only do cross-references on subscribed
7094 ;; groups, if that is what is wanted.
7095 (<= (nth 1 info
) gnus-level-subscribed
)))
7096 (gnus-group-make-articles-read name idlist expirable
))))
7099 (defun gnus-group-make-articles-read (group articles expirable
)
7101 (entry (gnus-gethash group gnus-newsrc-hashtb
))
7102 (info (nth 2 entry
))
7103 (active (gnus-gethash group gnus-active-hashtb
))
7104 exps expirable range
)
7105 ;; First peel off all illegal article numbers.
7107 (let ((ids articles
)
7108 (ticked (cdr (assq 'tick
(nth 3 info
))))
7109 (dormant (cdr (assq 'dormant
(nth 3 info
))))
7114 (if (and first
(> id
(cdr active
)))
7116 ;; We'll end up in this situation in one particular
7117 ;; obscure situation. If you re-scan a group and get
7118 ;; a new article that is cross-posted to a different
7119 ;; group that has not been re-scanned, you might get
7120 ;; crossposted article that has a higher number than
7121 ;; Gnus believes possible. So we re-activate this
7122 ;; group as well. This might mean doing the
7123 ;; crossposting thingy will *increase* the number
7124 ;; of articles in some groups. Tsk, tsk.
7125 (setq active
(or (gnus-activate-group group
) active
))))
7126 (if (or (> id
(cdr active
))
7130 (setq articles
(delq id articles
)))
7131 (and (memq id expirable
)
7132 (setq exps
(cons id exps
)))
7133 (setq ids
(cdr ids
)))))
7134 ;; Update expirable articles.
7135 (gnus-add-marked-articles nil
'expirable exps info
)
7139 (setcar (nthcdr 2 info
) (cons 1 (1- (car active
)))))
7140 (setcar (nthcdr 2 info
)
7144 (setq articles
(sort articles
'<)))))
7145 ;; Then we have to re-compute how many unread
7146 ;; articles there are in this group.
7151 (setq num
(- (1+ (cdr active
)) (car active
))))
7152 ((not (listp (cdr range
)))
7153 (setq num
(- (cdr active
) (- (1+ (cdr range
))
7157 (if (numberp (car range
))
7159 (setq num
(+ num
(- (1+ (cdr (car range
)))
7160 (car (car range
))))))
7161 (setq range
(cdr range
)))
7162 (setq num
(- (cdr active
) num
))))
7163 ;; Update the number of unread articles.
7167 (length (cdr (assq 'tick
(nth 3 info
))))
7169 (cdr (assq 'dormant
(nth 3 info
)))))))
7170 ;; Update the group buffer.
7171 (gnus-group-update-group group t
)))))
7173 (defun gnus-methods-equal-p (m1 m2
)
7174 (let ((m1 (or m1 gnus-select-method
))
7175 (m2 (or m2 gnus-select-method
)))
7177 (and (eq (car m1
) (car m2
))
7178 (or (not (memq 'address
(assoc (symbol-name (car m1
))
7179 gnus-valid-select-methods
)))
7180 (equal (nth 1 m1
) (nth 1 m2
)))))))
7182 (defsubst gnus-header-value
()
7183 (buffer-substring (match-end 0) (gnus-point-at-eol)))
7185 (defvar gnus-newsgroup-none-id
0)
7187 (defun gnus-get-newsgroup-headers ()
7188 (setq gnus-article-internal-prepare-hook nil
)
7189 (let ((cur nntp-server-buffer
)
7190 (dependencies gnus-newsgroup-dependencies
)
7191 headers id dep end ref
)
7193 (set-buffer nntp-server-buffer
)
7194 ;; Allow the user to mangle the headers before parsing them.
7195 (run-hooks 'gnus-parse-headers-hook
)
7196 (goto-char (point-min))
7197 ;; Search to the beginning of the next header. Error messages
7198 ;; do not begin with 2 or 3.
7199 (while (re-search-forward "^[23][0-9]+ " nil t
)
7200 (let ((header (make-vector 9 nil
))
7201 (case-fold-search t
)
7206 (mail-header-set-number header
(read cur
))
7207 ;; This implementation of this function, with nine
7208 ;; search-forwards instead of the one re-search-forward and
7209 ;; a case (which basically was the old function) is actually
7210 ;; about twice as fast, even though it looks messier. You
7211 ;; can't have everything, I guess. Speed and elegance
7212 ;; doesn't always come hand in hand.
7214 (narrow-to-region (point) (or (save-excursion
7215 (search-forward "\n.\n" nil t
))
7217 (if (search-forward "\nfrom: " nil t
)
7218 (mail-header-set-from header
(gnus-header-value))
7219 (mail-header-set-from header
"(nobody)"))
7221 (if (search-forward "\nsubject: " nil t
)
7222 (mail-header-set-subject header
(gnus-header-value))
7223 (mail-header-set-subject header
"(none)"))
7225 (and (search-forward "\nxref: " nil t
)
7226 (mail-header-set-xref header
(gnus-header-value)))
7228 (or (numberp (and (search-forward "\nlines: " nil t
)
7229 (mail-header-set-lines header
(read cur
))))
7230 (mail-header-set-lines header
0))
7232 (and (search-forward "\ndate: " nil t
)
7233 (mail-header-set-date header
(gnus-header-value)))
7235 (if (search-forward "\nmessage-id: " nil t
)
7236 (mail-header-set-id header
(setq id
(gnus-header-value)))
7237 ;; If there was no message-id, we just fake one to make
7238 ;; subsequent routines simpler.
7241 (setq id
(concat "none+"
7243 (setq gnus-newsgroup-none-id
7244 (1+ gnus-newsgroup-none-id
)))))))
7246 (if (search-forward "\nreferences: " nil t
)
7248 (mail-header-set-references header
(gnus-header-value))
7249 (setq end
(match-end 0))
7256 (search-backward ">" end t
)
7259 (search-backward "<" end t
)
7261 ;; Get the references from the in-reply-to header if there
7262 ;; ware no references and the in-reply-to header looks
7264 (if (and (search-forward "\nin-reply-to: " nil t
)
7265 (setq in-reply-to
(gnus-header-value))
7266 (string-match "<[^>]+>" in-reply-to
))
7268 (mail-header-set-references
7270 (setq ref
(substring in-reply-to
(match-beginning 0)
7272 (setq ref
(downcase ref
)))
7274 ;; We do some threading while we read the headers. The
7275 ;; message-id and the last reference are both entered into
7276 ;; the same hash table. Some tippy-toeing around has to be
7277 ;; done in case an article has arrived before the article
7278 ;; which it refers to.
7279 (if (boundp (setq dep
(intern (downcase id
) dependencies
)))
7280 (if (car (symbol-value dep
))
7281 ;; An article with this Message-ID has already
7282 ;; been seen, so we ignore this one, except we add
7283 ;; any additional Xrefs (in case the two articles
7284 ;; came from different servers.
7286 (mail-header-set-xref
7287 (car (symbol-value dep
))
7288 (concat (or (mail-header-xref
7289 (car (symbol-value dep
))) "")
7290 (or (mail-header-xref header
) "")))
7292 (setcar (symbol-value dep
) header
))
7293 (set dep
(list header
)))
7296 (if (boundp (setq dep
(intern ref dependencies
)))
7297 (setcdr (symbol-value dep
)
7298 (cons header
(cdr (symbol-value dep
))))
7299 (set dep
(list nil header
)))
7300 (setq headers
(cons header headers
))))
7301 (goto-char (point-max))))))
7302 (nreverse headers
)))
7304 ;; The following macros and functions were written by Felix Lee
7305 ;; <flee@cse.psu.edu>.
7307 (defmacro gnus-nov-read-integer
()
7309 (if (= (following-char) ?
\t)
7311 (let ((num (condition-case nil
(read buffer
) (error nil
))))
7312 (if (numberp num
) num
0)))
7313 (or (eobp) (forward-char 1))))
7315 (defmacro gnus-nov-skip-field
()
7316 '(search-forward "\t" eol
'move
))
7318 (defmacro gnus-nov-field
()
7319 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol
)))
7321 ;; Goes through the xover lines and returns a list of vectors
7322 (defun gnus-get-newsgroup-headers-xover (sequence)
7323 "Parse the news overview data in the server buffer, and return a
7324 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
7325 ;; Get the Xref when the users reads the articles since most/some
7326 ;; NNTP servers do not include Xrefs when using XOVER.
7327 (setq gnus-article-internal-prepare-hook
'(gnus-article-get-xrefs))
7328 (let ((cur nntp-server-buffer
)
7329 (dependencies gnus-newsgroup-dependencies
)
7330 number headers header
)
7332 (set-buffer nntp-server-buffer
)
7333 ;; Allow the user to mangle the headers before parsing them.
7334 (run-hooks 'gnus-parse-headers-hook
)
7335 (goto-char (point-min))
7336 (while (and sequence
(not (eobp)))
7337 (setq number
(read cur
))
7338 (while (and sequence
(< (car sequence
) number
))
7339 (setq sequence
(cdr sequence
)))
7341 (eq number
(car sequence
))
7343 (setq sequence
(cdr sequence
))
7345 (inline (gnus-nov-parse-line number dependencies
)))
7346 (setq headers
(cons header headers
)))))
7348 (setq headers
(nreverse headers
)))
7351 ;; This function has to be called with point after the article number
7352 ;; on the beginning of the line.
7353 (defun gnus-nov-parse-line (number dependencies
)
7355 (eol (gnus-point-at-eol))
7356 (buffer (current-buffer))
7359 ;; overview: [num subject from date id refs chars lines misc]
7360 (narrow-to-region (point) eol
)
7361 (or (eobp) (forward-char))
7367 (gnus-nov-field) ; subject
7368 (gnus-nov-field) ; from
7369 (gnus-nov-field) ; date
7370 (setq id
(or (gnus-nov-field)
7373 (setq none
(1+ none
)))))) ; id
7376 (let ((beg (point)))
7377 (search-forward "\t" eol
)
7378 (if (search-backward ">" beg t
)
7384 (search-backward "<" beg t
)
7387 (gnus-nov-field)) ; refs
7388 (gnus-nov-read-integer) ; chars
7389 (gnus-nov-read-integer) ; lines
7390 (if (= (following-char) ?
\n)
7392 (gnus-nov-field)) ; misc
7396 (message "Strange nov line.")
7402 ;; We build the thread tree.
7404 (if (boundp (setq dep
(intern (downcase id
) dependencies
)))
7405 (if (car (symbol-value dep
))
7406 ;; An article with this Message-ID has already been seen,
7407 ;; so we ignore this one, except we add any additional
7408 ;; Xrefs (in case the two articles came from different
7411 (mail-header-set-xref
7412 (car (symbol-value dep
))
7413 (concat (or (mail-header-xref (car (symbol-value dep
))) "")
7414 (or (mail-header-xref header
) "")))
7416 (setcar (symbol-value dep
) header
))
7417 (set dep
(list header
))))
7420 (if (boundp (setq dep
(intern (or ref
"none")
7422 (setcdr (symbol-value dep
)
7423 (cons header
(cdr (symbol-value dep
))))
7424 (set dep
(list nil header
)))))
7427 (defun gnus-article-get-xrefs ()
7428 "Fill in the Xref value in `gnus-current-headers', if necessary.
7429 This is meant to be called in `gnus-article-internal-prepare-hook'."
7430 (let ((headers (save-excursion (set-buffer gnus-summary-buffer
)
7431 gnus-current-headers
)))
7432 (or (not gnus-use-cross-reference
)
7434 (and (mail-header-xref headers
)
7435 (not (string= (mail-header-xref headers
) "")))
7436 (let ((case-fold-search t
)
7439 (gnus-narrow-to-headers)
7440 (goto-char (point-min))
7441 (if (or (and (eq (downcase (following-char)) ?x
)
7442 (looking-at "Xref:"))
7443 (search-forward "\nXref:" nil t
))
7445 (goto-char (1+ (match-end 0)))
7446 (setq xref
(buffer-substring (point)
7447 (progn (end-of-line) (point))))
7448 (mail-header-set-xref headers xref
))))))))
7450 (defalias 'gnus-find-header-by-number
'gnus-get-header-by-number
)
7451 (make-obsolete 'gnus-find-header-by-number
'gnus-get-header-by-number
)
7453 (defun gnus-make-headers-hashtable-by-number ()
7454 "Make hashtable for the variable gnus-newsgroup-headers by number."
7456 (set-buffer gnus-summary-buffer
)
7457 (let ((headers gnus-newsgroup-headers
)
7459 (setq gnus-newsgroup-headers-hashtb-by-number
7460 (gnus-make-hashtable (length headers
)))
7462 (setq header
(car headers
))
7463 (gnus-sethash (int-to-string (mail-header-number header
))
7464 header gnus-newsgroup-headers-hashtb-by-number
)
7465 (setq headers
(cdr headers
))))))
7467 (defun gnus-more-header-backward ()
7468 "Find new header backward."
7469 (let ((first (car (gnus-gethash gnus-newsgroup-name gnus-active-hashtb
)))
7470 (artnum gnus-newsgroup-begin
)
7472 (while (and (not header
)
7474 (setq artnum
(1- artnum
))
7475 (setq header
(gnus-read-header artnum
)))
7478 (defun gnus-more-header-forward (&optional backward
)
7479 "Find new header forward.
7480 If BACKWARD, find new header backward instead."
7482 (gnus-more-header-backward)
7483 (let ((last (cdr (gnus-gethash gnus-newsgroup-name gnus-active-hashtb
)))
7484 (artnum gnus-newsgroup-end
)
7486 (while (and (not header
)
7488 (setq artnum
(1+ artnum
))
7489 (setq header
(gnus-read-header artnum
)))
7492 (defun gnus-extend-newsgroup (header &optional backward
)
7493 "Extend newsgroup selection with HEADER.
7494 Optional argument BACKWARD means extend toward backward."
7496 (let ((artnum (mail-header-number header
)))
7497 (setq gnus-newsgroup-headers
7499 (cons header gnus-newsgroup-headers
)
7500 (nconc gnus-newsgroup-headers
(list header
))))
7501 (setq gnus-newsgroup-unselected
7502 (delq artnum gnus-newsgroup-unselected
))
7503 (setq gnus-newsgroup-begin
(min gnus-newsgroup-begin artnum
))
7504 (setq gnus-newsgroup-end
(max gnus-newsgroup-end artnum
)))))
7506 (defun gnus-summary-work-articles (n)
7507 "Return a list of articles to be worked upon. The prefix argument,
7508 the list of process marked articles, and the current article will be
7509 taken into consideration."
7511 (if (and n
(numberp n
))
7512 (let ((backward (< n
0))
7516 (setq articles
(cons (gnus-summary-article-number)
7518 (gnus-summary-search-forward nil nil backward
))
7520 (sort articles
(function <)))
7521 (or (reverse gnus-newsgroup-processable
)
7522 (list (gnus-summary-article-number))))))
7524 (defun gnus-summary-search-group (&optional backward use-level
)
7525 "Search for next unread newsgroup.
7526 If optional argument BACKWARD is non-nil, search backward instead."
7528 (set-buffer gnus-group-buffer
)
7529 (if (gnus-group-search-forward
7530 backward nil
(if use-level
(gnus-group-group-level) nil
))
7531 (gnus-group-group-name))))
7533 (defun gnus-summary-best-group (&optional exclude-group
)
7534 "Find the name of the best unread group.
7535 If EXCLUDE-GROUP, do not go to this group."
7537 (set-buffer gnus-group-buffer
)
7539 (gnus-group-best-unread-group exclude-group
))))
7541 (defun gnus-subject-equal (s1 s2
)
7543 ((null gnus-summary-gather-subject-limit
)
7544 (equal (gnus-simplify-subject-re s1
)
7545 (gnus-simplify-subject-re s2
)))
7546 ((eq gnus-summary-gather-subject-limit
'fuzzy
)
7547 (equal (gnus-simplify-subject-fuzzy s1
)
7548 (gnus-simplify-subject-fuzzy s2
)))
7549 ((numberp gnus-summary-gather-subject-limit
)
7550 (equal (gnus-limit-string s1 gnus-summary-gather-subject-limit
)
7551 (gnus-limit-string s2 gnus-summary-gather-subject-limit
)))
7555 (defun gnus-summary-search-subject (&optional backward unread subject
)
7556 "Search for article forward.
7557 If BACKWARD is non-nil, search backward.
7558 If UNREAD is non-nil, only unread articles are selected.
7559 If SUBJECT is non-nil, the article which has the same subject will be
7561 (let ((func (if backward
'previous-single-property-change
7562 'next-single-property-change
))
7567 (and gnus-summary-check-current unread
7568 (eq (get-text-property (point) 'gnus-mark
) gnus-unread-mark
)
7572 (forward-char (if backward
(if (bobp) 0 -
1) (if (eobp) 0 1)))
7575 (setq pos
(funcall func
(point) 'gnus-number
))
7576 (goto-char (if backward
(1- pos
) pos
))
7580 (eq (get-text-property (point) 'gnus-mark
)
7584 (inline (gnus-summary-subject-string)))
7586 (gnus-subject-equal subject psubject
)))))))
7587 (if backward
(if (bobp) nil
(forward-char -
1) t
)
7588 (if (eobp) nil
(forward-char 1) t
)))))
7590 (progn (goto-char beg
) nil
)
7592 (get-text-property (point) 'gnus-number
)
7593 (gnus-summary-show-thread)
7594 (gnus-summary-position-cursor)))))
7596 (defun gnus-summary-pseudo-article ()
7597 "The thread level of the article on the current line."
7598 (get-text-property (gnus-point-at-bol) 'gnus-pseudo
))
7600 (defalias 'gnus-summary-score
'gnus-summary-article-score
)
7601 (make-obsolete 'gnus-summary-score
'gnus-summary-article-score
)
7602 (defun gnus-summary-article-score ()
7603 "Return current article score."
7604 (or (cdr (assq (gnus-summary-article-number) gnus-newsgroup-scored
))
7605 gnus-summary-default-score
0))
7607 (defun gnus-summary-recenter ()
7608 "Center point in the summary window.
7609 If `gnus-auto-center-summary' is nil, or the article buffer isn't
7610 displayed, no centering will be performed."
7611 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
7612 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
7613 (let* ((top (cond ((< (window-height) 4) 0)
7614 ((< (window-height) 7) 1)
7616 (height (1- (window-height)))
7617 (bottom (save-excursion (goto-char (point-max))
7618 (forward-line (- height
))
7620 (window (get-buffer-window (current-buffer))))
7622 ;; The user has to want it,
7623 gnus-auto-center-summary
7624 ;; the article buffer must be displayed,
7625 (get-buffer-window gnus-article-buffer
)
7626 ;; Set the window start to either `bottom', which is the biggest
7627 ;; possible valid number, or the second line from the top,
7628 ;; whichever is the least.
7630 window
(min bottom
(save-excursion (forward-line (- top
)) (point)))))))
7632 ;; Function written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
7633 (defun gnus-short-group-name (group &optional levels
)
7634 "Collapse GROUP name LEVELS."
7635 (let* ((name "") (foreign "") (depth -
1) (skip 1)
7638 (while (string-match "\\." group skip
)
7639 (setq skip
(match-end 0)
7642 (if (string-match ":" group
)
7643 (setq foreign
(substring group
0 (match-end 0))
7644 group
(substring group
(match-end 0))))
7646 (if (and (string-match "\\." group
) (> levels
0))
7647 (setq name
(concat name
(substring group
0 1))
7648 group
(substring group
(match-end 0))
7650 name
(concat name
"."))
7651 (setq name
(concat foreign name group
)
7655 (defun gnus-summary-jump-to-group (newsgroup)
7656 "Move point to NEWSGROUP in group mode buffer."
7657 ;; Keep update point of group mode buffer if visible.
7658 (if (eq (current-buffer) (get-buffer gnus-group-buffer
))
7659 (save-window-excursion
7660 ;; Take care of tree window mode.
7661 (if (get-buffer-window gnus-group-buffer
)
7662 (pop-to-buffer gnus-group-buffer
))
7663 (gnus-group-jump-to-group newsgroup
))
7665 ;; Take care of tree window mode.
7666 (if (get-buffer-window gnus-group-buffer
)
7667 (pop-to-buffer gnus-group-buffer
)
7668 (set-buffer gnus-group-buffer
))
7669 (gnus-group-jump-to-group newsgroup
))))
7671 ;; This function returns a list of article numbers based on the
7672 ;; difference between the ranges of read articles in this group and
7673 ;; the range of active articles.
7674 (defun gnus-list-of-unread-articles (group)
7675 (let* ((read (nth 2 (nth 2 (gnus-gethash group gnus-newsrc-hashtb
))))
7676 (active (gnus-gethash group gnus-active-hashtb
))
7679 ;; If none are read, then all are unread.
7681 (setq first
(car active
))
7682 ;; If the range of read articles is a single range, then the
7683 ;; first unread article is the article after the last read
7684 ;; article. Sounds logical, doesn't it?
7685 (if (not (listp (cdr read
)))
7686 (setq first
(1+ (cdr read
)))
7687 ;; `read' is a list of ranges.
7688 (if (/= (setq nlast
(or (and (numberp (car read
)) (car read
))
7689 (car (car read
)))) 1)
7693 (while (< first nlast
)
7694 (setq unread
(cons first unread
))
7695 (setq first
(1+ first
))))
7696 (setq first
(1+ (if (atom (car read
)) (car read
) (cdr (car read
)))))
7697 (setq nlast
(if (atom (car (cdr read
)))
7699 (car (car (cdr read
)))))
7700 (setq read
(cdr read
)))))
7701 ;; And add the last unread articles.
7702 (while (<= first last
)
7703 (setq unread
(cons first unread
))
7704 (setq first
(1+ first
)))
7705 ;; Return the list of unread articles.
7708 (defun gnus-list-of-read-articles (group)
7709 (let ((info (nth 2 (gnus-gethash group gnus-newsrc-hashtb
)))
7710 (active (gnus-gethash group gnus-active-hashtb
)))
7712 (gnus-sorted-complement
7713 (gnus-uncompress-range active
)
7714 (gnus-list-of-unread-articles group
)))))
7716 ;; Various summary commands
7718 (defun gnus-summary-universal-argument ()
7719 "Perform any operation on all articles marked with the process mark."
7721 (gnus-set-global-variables)
7722 (let ((articles (reverse gnus-newsgroup-processable
))
7724 (or articles
(error "No articles marked"))
7725 (or (setq func
(key-binding (read-key-sequence "C-c C-u")))
7726 (error "Undefined key"))
7728 (gnus-summary-goto-subject (car articles
))
7729 (command-execute func
)
7730 (gnus-summary-remove-process-mark (car articles
))
7731 (setq articles
(cdr articles
)))))
7733 (defun gnus-summary-toggle-truncation (&optional arg
)
7734 "Toggle truncation of summary lines.
7735 With arg, turn line truncation on iff arg is positive."
7737 (setq truncate-lines
7738 (if (null arg
) (not truncate-lines
)
7739 (> (prefix-numeric-value arg
) 0)))
7742 (defun gnus-summary-reselect-current-group (&optional all
)
7743 "Once exit and then reselect the current newsgroup.
7744 The prefix argument ALL means to select all articles."
7746 (gnus-set-global-variables)
7747 (let ((current-subject (gnus-summary-article-number))
7748 (group gnus-newsgroup-name
))
7749 (setq gnus-newsgroup-begin nil
)
7750 (gnus-summary-exit t
)
7751 ;; We have to adjust the point of group mode buffer because the
7752 ;; current point was moved to the next unread newsgroup by
7754 (gnus-summary-jump-to-group group
)
7755 (gnus-group-read-group all t
)
7756 (gnus-summary-goto-subject current-subject
)))
7758 (defun gnus-summary-rescan-group (&optional all
)
7759 "Exit the newsgroup, ask for new articles, and select the newsgroup."
7761 (gnus-set-global-variables)
7762 ;; Fix by Ilja Weis <kult@uni-paderborn.de>.
7763 (let ((group gnus-newsgroup-name
))
7765 (gnus-summary-jump-to-group group
)
7767 (set-buffer gnus-group-buffer
)
7768 (gnus-group-get-new-news-this-group 1))
7769 (gnus-summary-jump-to-group group
)
7770 (gnus-group-read-group all
)))
7772 (defun gnus-summary-update-info ()
7773 (let* ((group gnus-newsgroup-name
))
7774 (if gnus-newsgroup-kill-headers
7775 (setq gnus-newsgroup-killed
7776 (gnus-compress-sequence
7778 (gnus-set-sorted-intersection
7779 (gnus-uncompress-range gnus-newsgroup-killed
)
7780 (setq gnus-newsgroup-unselected
7781 (sort gnus-newsgroup-unselected
'<)))
7782 (setq gnus-newsgroup-unreads
7783 (sort gnus-newsgroup-unreads
'<))) t
)))
7784 (or (listp (cdr gnus-newsgroup-killed
))
7785 (setq gnus-newsgroup-killed
(list gnus-newsgroup-killed
)))
7786 (let ((headers gnus-newsgroup-headers
))
7787 (gnus-close-group group
)
7788 (run-hooks 'gnus-exit-group-hook
)
7789 (gnus-update-read-articles
7790 group gnus-newsgroup-unreads gnus-newsgroup-unselected
7791 gnus-newsgroup-marked
7792 t gnus-newsgroup-replied gnus-newsgroup-expirable
7793 gnus-newsgroup-killed gnus-newsgroup-dormant
7794 gnus-newsgroup-bookmarks
7795 (and gnus-save-score gnus-newsgroup-scored
))
7796 (and gnus-use-cross-reference
7797 (gnus-mark-xrefs-as-read
7798 group headers gnus-newsgroup-unreads gnus-newsgroup-expirable
))
7799 ;; Do adaptive scoring, and possibly save score files.
7800 (and gnus-newsgroup-adaptive
7801 (gnus-score-adaptive))
7802 (and gnus-use-scoring
7803 (fboundp 'gnus-score-save
)
7804 (funcall 'gnus-score-save
))
7805 ;; Do not switch windows but change the buffer to work.
7806 (set-buffer gnus-group-buffer
)
7807 (or (gnus-ephemeral-group-p gnus-newsgroup-name
)
7808 (gnus-group-update-group group
)))))
7810 (defun gnus-summary-exit (&optional temporary
)
7811 "Exit reading current newsgroup, and then return to group selection mode.
7812 gnus-exit-group-hook is called with no arguments if that value is non-nil."
7814 (gnus-set-global-variables)
7815 (gnus-kill-save-kill-buffer)
7816 (let* ((group gnus-newsgroup-name
)
7817 (quit-config (gnus-group-quit-config gnus-newsgroup-name
))
7819 (buf (current-buffer)))
7820 (run-hooks 'gnus-summary-prepare-exit-hook
)
7821 ;; Make all changes in this group permanent.
7822 (gnus-summary-update-info)
7824 (and gnus-use-cache
(gnus-cache-possibly-remove-articles))
7825 ;; Make sure where I was, and go to next newsgroup.
7826 (set-buffer gnus-group-buffer
)
7829 (gnus-group-jump-to-group group
)
7830 (gnus-group-next-unread-group 1)))
7833 ;; We set all buffer-local variables to nil. It is unclear why
7834 ;; this is needed, but if we don't, buffer-local variables are
7835 ;; not garbage-collected, it seems. This would the lead to en
7836 ;; ever-growing Emacs.
7838 (gnus-summary-clear-local-variables)
7839 ;; We clear the global counterparts of the buffer-local
7840 ;; variables as well, just to be on the safe side.
7841 (gnus-configure-windows 'group
'force
)
7842 (gnus-summary-clear-local-variables)
7843 ;; Return to group mode buffer.
7844 (if (eq mode
'gnus-summary-mode
)
7845 (gnus-kill-buffer buf
))
7846 (if (get-buffer gnus-article-buffer
)
7847 (bury-buffer gnus-article-buffer
))
7848 (setq gnus-current-select-method gnus-select-method
)
7849 (pop-to-buffer gnus-group-buffer
)
7850 (if (not quit-config
)
7852 (gnus-group-jump-to-group group
)
7853 (gnus-group-next-unread-group 1))
7854 (if (not (buffer-name (car quit-config
)))
7855 (gnus-configure-windows 'group
'force
)
7856 (set-buffer (car quit-config
))
7857 (and (eq major-mode
'gnus-summary-mode
)
7858 (gnus-set-global-variables))
7859 (gnus-configure-windows (cdr quit-config
))))
7860 (run-hooks 'gnus-summary-exit-hook
))))
7862 (defalias 'gnus-summary-quit
'gnus-summary-exit-no-update
)
7863 (defun gnus-summary-exit-no-update (&optional no-questions
)
7864 "Quit reading current newsgroup without updating read article info."
7866 (gnus-set-global-variables)
7867 (let* ((group gnus-newsgroup-name
)
7868 (quit-config (gnus-group-quit-config group
)))
7869 (if (or no-questions
7871 (gnus-y-or-n-p "Do you really wanna quit reading this group? "))
7873 (gnus-close-group group
)
7874 (gnus-summary-clear-local-variables)
7875 (set-buffer gnus-group-buffer
)
7876 (gnus-summary-clear-local-variables)
7877 ;; Return to group selection mode.
7878 (gnus-configure-windows 'group
'force
)
7879 (if (get-buffer gnus-summary-buffer
)
7880 (kill-buffer gnus-summary-buffer
))
7881 (if (get-buffer gnus-article-buffer
)
7882 (bury-buffer gnus-article-buffer
))
7883 (if (equal (gnus-group-group-name) group
)
7884 (gnus-group-next-unread-group 1))
7887 (if (not (buffer-name (car quit-config
)))
7888 (gnus-configure-windows 'group
'force
)
7889 (set-buffer (car quit-config
))
7890 (and (eq major-mode
'gnus-summary-mode
)
7891 (gnus-set-global-variables))
7892 (gnus-configure-windows (cdr quit-config
)))))))))
7894 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
7895 (defun gnus-summary-fetch-faq (group)
7896 "Fetch the FAQ for the current group."
7897 (interactive (list gnus-newsgroup-name
))
7898 (let (gnus-faq-buffer)
7899 (and (setq gnus-faq-buffer
(gnus-group-fetch-faq group
))
7900 (gnus-configure-windows 'summary-faq
))))
7902 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
7903 (defun gnus-summary-describe-group (&optional force
)
7904 "Describe the current newsgroup."
7906 (gnus-group-describe-group force gnus-newsgroup-name
))
7908 (defun gnus-summary-describe-briefly ()
7909 "Describe summary mode commands briefly."
7912 (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")))
7914 ;; Walking around group mode buffer from summary mode.
7916 (defun gnus-summary-next-group (&optional no-article target-group backward
)
7917 "Exit current newsgroup and then select next unread newsgroup.
7918 If prefix argument NO-ARTICLE is non-nil, no article is selected
7919 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
7920 previous group instead."
7922 (gnus-set-global-variables)
7923 (let ((current-group gnus-newsgroup-name
)
7924 (current-buffer (current-buffer))
7926 ;; First we semi-exit this group to update Xrefs and all variables.
7927 ;; We can't do a real exit, because the window conf must remain
7928 ;; the same in case the user is prompted for info, and we don't
7929 ;; want the window conf to change before that...
7930 (gnus-summary-exit t
)
7931 (while (not entered
)
7932 ;; Then we find what group we are supposed to enter.
7933 (set-buffer gnus-group-buffer
)
7934 (gnus-group-jump-to-group current-group
)
7937 (if (eq gnus-keep-same-level
'best
)
7938 (gnus-summary-best-group gnus-newsgroup-name
)
7939 (gnus-summary-search-group backward gnus-keep-same-level
))))
7940 (if (not target-group
)
7941 ;; There are no further groups, so we return to the group
7944 (gnus-message 5 "Returning to the group buffer")
7946 (set-buffer current-buffer
)
7947 (gnus-summary-exit))
7948 ;; We try to enter the target group.
7949 (gnus-group-jump-to-group target-group
)
7950 (let ((unreads (gnus-group-group-unread)))
7951 (if (and (or (eq t unreads
)
7952 (and unreads
(not (zerop unreads
))))
7953 (gnus-summary-read-group
7954 target-group nil no-article current-buffer
))
7956 (setq current-group target-group
7957 target-group nil
)))))))
7959 (defun gnus-summary-next-group-old (&optional no-article group backward
)
7960 "Exit current newsgroup and then select next unread newsgroup.
7961 If prefix argument NO-ARTICLE is non-nil, no article is selected initially.
7962 If BACKWARD, go to previous group instead."
7964 (gnus-set-global-variables)
7965 (let ((ingroup gnus-newsgroup-name
)
7966 (sumbuf (current-buffer))
7968 (set-buffer gnus-group-buffer
)
7970 (or (and (numberp (setq num
(car (gnus-gethash
7971 group gnus-newsrc-hashtb
))))
7975 (gnus-group-jump-to-group group
)
7977 (gnus-group-jump-to-group ingroup
))
7978 (gnus-summary-search-group backward
)
7979 (let ((group (or group
(gnus-summary-search-group backward
))))
7981 (gnus-summary-exit t
) ;Update all information.
7983 (gnus-summary-exit-no-update t
)
7984 (gnus-group-jump-to-group ingroup
)
7985 (setq group
(gnus-summary-search-group backward
))
7986 (gnus-message 5 "Selecting %s..." group
)
7987 (set-buffer gnus-group-buffer
)
7988 ;; We are now in group mode buffer.
7989 ;; Make sure group mode buffer point is on GROUP.
7990 (gnus-group-jump-to-group group
)
7991 (if (not (eq gnus-auto-select-next
'quietly
))
7993 (gnus-summary-read-group group nil no-article sumbuf
)
7994 (and (string= gnus-newsgroup-name ingroup
)
7995 (bufferp sumbuf
) (buffer-name sumbuf
)
7997 (set-buffer (setq gnus-summary-buffer sumbuf
))
7998 (gnus-summary-exit-no-update t
))))
7999 (let ((prevgroup group
))
8000 (gnus-group-jump-to-group ingroup
)
8001 (setq group
(gnus-summary-search-group backward
))
8002 (gnus-summary-read-group group nil no-article sumbuf
)
8003 (while (and (string= gnus-newsgroup-name ingroup
)
8005 (buffer-name sumbuf
)
8006 (not (string= prevgroup
(gnus-group-group-name))))
8007 (set-buffer gnus-group-buffer
)
8008 (gnus-summary-read-group
8009 (setq prevgroup
(gnus-group-group-name))
8010 nil no-article sumbuf
))
8011 (and (string= prevgroup
(gnus-group-group-name))
8012 ;; We have reached the final group in the group
8015 (if (buffer-name sumbuf
)
8018 (gnus-summary-exit)))))))))))
8020 (defun gnus-summary-prev-group (&optional no-article
)
8021 "Exit current newsgroup and then select previous unread newsgroup.
8022 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
8024 (gnus-summary-next-group no-article nil t
))
8026 ;; Walking around summary lines.
8028 (defun gnus-summary-first-subject (&optional unread
)
8029 "Go to the first unread subject.
8030 If UNREAD is non-nil, go to the first unread article.
8031 Returns nil if there are no unread articles."
8035 (goto-char (point-min)))
8038 (point-min) (point-max) 'gnus-mark gnus-unread-mark
))
8041 ;; There are no unread articles.
8042 (gnus-message 3 "No more unread articles")
8044 (gnus-summary-position-cursor)))
8046 (defun gnus-summary-next-subject (n &optional unread dont-display
)
8047 "Go to next N'th summary line.
8048 If N is negative, go to the previous N'th subject line.
8049 If UNREAD is non-nil, only unread articles are selected.
8050 The difference between N and the actual number of steps taken is
8053 (let ((backward (< n
0))
8056 (gnus-summary-search-forward unread nil backward
))
8058 (if (/= 0 n
) (gnus-message 7 "No more%s articles"
8059 (if unread
" unread" "")))
8062 (gnus-summary-recenter)
8063 (gnus-summary-position-cursor)))
8066 (defun gnus-summary-next-unread-subject (n)
8067 "Go to next N'th unread summary line."
8069 (gnus-summary-next-subject n t
))
8071 (defun gnus-summary-prev-subject (n &optional unread
)
8072 "Go to previous N'th summary line.
8073 If optional argument UNREAD is non-nil, only unread article is selected."
8075 (gnus-summary-next-subject (- n
) unread
))
8077 (defun gnus-summary-prev-unread-subject (n)
8078 "Go to previous N'th unread summary line."
8080 (gnus-summary-next-subject (- n
) t
))
8082 (defun gnus-summary-goto-subject (article)
8083 "Go the subject line of ARTICLE."
8087 (completing-read "Article number: "
8091 (int-to-string (mail-header-number headers
))))
8092 gnus-newsgroup-headers
)
8093 nil
'require-match
))))
8094 (or article
(error "No article number"))
8096 (if (not (gnus-goto-char (text-property-any (point-min) (point-max)
8097 'gnus-number article
)))
8099 (gnus-summary-show-thread)
8100 ;; Skip dummy articles.
8101 (if (eq (gnus-summary-article-mark) gnus-dummy-mark
)
8108 (gnus-summary-position-cursor)))))
8110 ;; Walking around summary lines with displaying articles.
8112 (defun gnus-summary-expand-window (&optional arg
)
8113 "Make the summary buffer take up the entire Emacs frame.
8114 Given a prefix, will force an `article' buffer configuration."
8116 (gnus-set-global-variables)
8118 (gnus-configure-windows 'article
'force
)
8119 (gnus-configure-windows 'summary
'force
)))
8121 (defun gnus-summary-display-article (article &optional all-header
)
8122 "Display ARTICLE in article buffer."
8123 (gnus-set-global-variables)
8127 (gnus-article-prepare article all-header
)
8128 (gnus-summary-show-thread)
8129 (if (eq (gnus-summary-article-mark) gnus-dummy-mark
)
8132 (gnus-summary-position-cursor)))
8133 (run-hooks 'gnus-select-article-hook
)
8134 (gnus-summary-recenter)
8135 (gnus-summary-goto-subject article
)
8136 ;; Successfully display article.
8137 (gnus-summary-update-line)
8138 (gnus-article-set-window-start
8139 (cdr (assq article gnus-newsgroup-bookmarks
)))
8142 (defun gnus-summary-select-article (&optional all-headers force pseudo article
)
8143 "Select the current article.
8144 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
8145 non-nil, the article will be re-fetched even if it already present in
8146 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
8148 (and (not pseudo
) (gnus-summary-pseudo-article)
8149 (error "This is a pseudo-article."))
8150 (let ((article (or article
(gnus-summary-article-number)))
8151 (all-headers (not (not all-headers
))) ;Must be T or NIL.
8155 (set-buffer gnus-summary-buffer
)
8156 (if (or (null gnus-current-article
)
8157 (null gnus-article-current
)
8158 (null (get-buffer gnus-article-buffer
))
8159 (not (eq article
(cdr gnus-article-current
)))
8160 (not (equal (car gnus-article-current
) gnus-newsgroup-name
))
8162 ;; The requested article is different from the current article.
8164 (gnus-summary-display-article article all-headers
)
8166 (if (or all-headers gnus-show-all-headers
)
8167 (gnus-article-show-all-headers))
8170 (gnus-article-set-window-start
8171 (cdr (assq article gnus-newsgroup-bookmarks
)))))))
8173 (defun gnus-summary-set-current-mark (&optional current-mark
)
8174 "Obsolete function."
8177 (defun gnus-summary-next-article (&optional unread subject backward
)
8178 "Select the next article.
8179 If UNREAD, only unread articles are selected.
8180 If SUBJECT, only articles with SUBJECT are selected.
8181 If BACKWARD, the previous article is selected instead of the next."
8183 (gnus-set-global-variables)
8186 ;; Is there such an article?
8187 ((and (gnus-summary-search-forward unread subject backward
)
8188 (or (gnus-summary-display-article (gnus-summary-article-number))
8189 (eq (gnus-summary-article-mark) gnus-canceled-mark
)))
8190 (gnus-summary-position-cursor))
8191 ;; If not, we try the first unread, if that is wanted.
8193 gnus-auto-select-same
8194 (or (gnus-summary-first-unread-article)
8195 (eq (gnus-summary-article-mark) gnus-canceled-mark
)))
8196 (gnus-summary-position-cursor)
8197 (gnus-message 6 "Wrapped"))
8198 ;; Try to get next/previous article not displayed in this group.
8199 ((and gnus-auto-extend-newsgroup
8200 (not unread
) (not subject
)
8201 (setq header
(gnus-more-header-forward backward
)))
8202 (gnus-extend-newsgroup header backward
)
8203 (let ((buffer-read-only nil
))
8204 (goto-char (if backward
(point-min) (point-max)))
8205 (gnus-summary-prepare-threads (list header
)))
8206 (gnus-summary-goto-article (if backward gnus-newsgroup-begin
8207 gnus-newsgroup-end
)))
8208 ;; Go to next/previous group.
8210 (or (gnus-ephemeral-group-p gnus-newsgroup-name
)
8211 (gnus-summary-jump-to-group gnus-newsgroup-name
))
8212 (let ((cmd last-command-char
)
8214 (if (eq gnus-keep-same-level
'best
)
8215 (gnus-summary-best-group gnus-newsgroup-name
)
8216 (gnus-summary-search-group backward gnus-keep-same-level
))))
8217 ;; For some reason, the group window gets selected. We change
8219 (select-window (get-buffer-window (current-buffer)))
8220 ;; Keep just the event type of CMD.
8221 ;(and (listp cmd) (setq cmd (car cmd)))
8222 ;; Select next unread newsgroup automagically.
8224 ((not gnus-auto-select-next
)
8225 (gnus-message 7 "No more%s articles" (if unread
" unread" "")))
8226 ((eq gnus-auto-select-next
'quietly
)
8228 (if (gnus-ephemeral-group-p gnus-newsgroup-name
)
8230 (gnus-message 7 "No more%s articles (%s)..."
8231 (if unread
" unread" "")
8232 (if group
(concat "selecting " group
)
8234 (gnus-summary-next-group nil group backward
)))
8236 (let ((keystrokes '(?\C-n ?\C-p
))
8238 (while (or (null key
) (memq key keystrokes
))
8240 7 "No more%s articles%s" (if unread
" unread" "")
8242 (not (gnus-ephemeral-group-p gnus-newsgroup-name
)))
8243 (format " (Type %s for %s [%s])"
8244 (single-key-description cmd
) group
8245 (car (gnus-gethash group gnus-newsrc-hashtb
)))
8246 (format " (Type %s to exit %s)"
8247 (single-key-description cmd
)
8248 gnus-newsgroup-name
)))
8249 ;; Confirm auto selection.
8250 (let* ((event (read-char)))
8251 (setq key
(if (listp event
) (car event
) event
))
8252 (if (memq key keystrokes
)
8253 (let ((obuf (current-buffer)))
8254 (switch-to-buffer gnus-group-buffer
)
8256 (gnus-group-jump-to-group group
))
8258 (execute-kbd-macro (char-to-string key
))
8260 (setq group
(gnus-group-group-name))
8261 (switch-to-buffer obuf
)))))
8264 (gnus-ephemeral-group-p gnus-newsgroup-name
))
8266 (gnus-summary-next-group nil group backward
))
8267 (execute-kbd-macro (char-to-string key
)))))))))))
8269 (defun gnus-summary-next-unread-article ()
8270 "Select unread article after current one."
8272 (gnus-summary-next-article t
(and gnus-auto-select-same
8273 (gnus-summary-subject-string))))
8275 (defun gnus-summary-prev-article (&optional unread subject
)
8276 "Select the article after the current one.
8277 If UNREAD is non-nil, only unread articles are selected."
8279 (gnus-summary-next-article unread subject t
))
8281 (defun gnus-summary-prev-unread-article ()
8282 "Select unred article before current one."
8284 (gnus-summary-prev-article t
(and gnus-auto-select-same
8285 (gnus-summary-subject-string))))
8287 (defun gnus-summary-next-page (&optional lines circular
)
8288 "Show next page of selected article.
8289 If end of article, select next article.
8290 Argument LINES specifies lines to be scrolled up.
8291 If CIRCULAR is non-nil, go to the start of the article instead of
8292 instead of selecting the next article when reaching the end of the
8295 (setq gnus-summary-buffer
(current-buffer))
8296 (gnus-set-global-variables)
8297 (let ((article (gnus-summary-article-number))
8299 (gnus-configure-windows 'article
)
8300 (if (or (null gnus-current-article
)
8301 (null gnus-article-current
)
8302 (/= article
(cdr gnus-article-current
))
8303 (not (equal (car gnus-article-current
) gnus-newsgroup-name
)))
8304 ;; Selected subject is different from current article's.
8305 (gnus-summary-display-article article
)
8306 (gnus-eval-in-buffer-window
8308 (setq endp
(gnus-article-next-page lines
)))
8311 (gnus-summary-beginning-of-article))
8313 (gnus-message 3 "End of message"))
8315 (gnus-summary-next-unread-article)))))
8316 (gnus-summary-recenter)
8317 (gnus-summary-position-cursor)))
8319 (defun gnus-summary-prev-page (&optional lines
)
8320 "Show previous page of selected article.
8321 Argument LINES specifies lines to be scrolled down."
8323 (gnus-set-global-variables)
8324 (let ((article (gnus-summary-article-number)))
8325 (gnus-configure-windows 'article
)
8326 (if (or (null gnus-current-article
)
8327 (null gnus-article-current
)
8328 (/= article
(cdr gnus-article-current
))
8329 (not (equal (car gnus-article-current
) gnus-newsgroup-name
)))
8330 ;; Selected subject is different from current article's.
8331 (gnus-summary-display-article article
)
8332 (gnus-summary-recenter)
8333 (gnus-eval-in-buffer-window gnus-article-buffer
8334 (gnus-article-prev-page lines
))))
8335 (gnus-summary-position-cursor))
8337 (defun gnus-summary-scroll-up (lines)
8338 "Scroll up (or down) one line current article.
8339 Argument LINES specifies lines to be scrolled up (or down if negative)."
8341 (gnus-set-global-variables)
8342 (gnus-configure-windows 'article
)
8343 (or (gnus-summary-select-article nil nil
'pseudo
)
8344 (gnus-eval-in-buffer-window
8347 (if (gnus-article-next-page lines
)
8348 (gnus-message 3 "End of message")))
8350 (gnus-article-prev-page (- lines
))))))
8351 (gnus-summary-recenter)
8352 (gnus-summary-position-cursor))
8354 (defun gnus-summary-next-same-subject ()
8355 "Select next article which has the same subject as current one."
8357 (gnus-set-global-variables)
8358 (gnus-summary-next-article nil
(gnus-summary-subject-string)))
8360 (defun gnus-summary-prev-same-subject ()
8361 "Select previous article which has the same subject as current one."
8363 (gnus-set-global-variables)
8364 (gnus-summary-prev-article nil
(gnus-summary-subject-string)))
8366 (defun gnus-summary-next-unread-same-subject ()
8367 "Select next unread article which has the same subject as current one."
8369 (gnus-set-global-variables)
8370 (gnus-summary-next-article t
(gnus-summary-subject-string)))
8372 (defun gnus-summary-prev-unread-same-subject ()
8373 "Select previous unread article which has the same subject as current one."
8375 (gnus-set-global-variables)
8376 (gnus-summary-prev-article t
(gnus-summary-subject-string)))
8378 (defun gnus-summary-first-unread-article ()
8379 "Select the first unread article.
8380 Return nil if there are no unread articles."
8382 (gnus-set-global-variables)
8384 (if (gnus-summary-first-subject t
)
8386 (gnus-summary-show-thread)
8387 (gnus-summary-first-subject t
)
8388 (gnus-summary-display-article (gnus-summary-article-number))))
8389 (gnus-summary-position-cursor)))
8391 (defun gnus-summary-best-unread-article ()
8392 "Select the unread article with the highest score."
8394 (gnus-set-global-variables)
8395 (let ((best -
1000000)
8398 (or (gnus-summary-first-subject t
)
8399 (error "No unread articles"))
8403 (and (> (setq score
(gnus-summary-article-score)) best
)
8405 article
(gnus-summary-article-number)))
8407 (gnus-summary-search-subject nil t
))))
8409 (error "No unread articles")
8410 (gnus-summary-goto-article article
))
8411 (gnus-summary-position-cursor)))
8413 (defun gnus-summary-goto-article (article &optional all-headers
)
8414 "Fetch ARTICLE and display it if it exists.
8415 If ALL-HEADERS is non-nil, no header lines are hidden."
8421 (mapcar (lambda (headers)
8422 (list (int-to-string (mail-header-number headers
))))
8423 gnus-newsgroup-headers
)
8424 nil
'require-match
))))
8426 (and (gnus-summary-goto-subject article
)
8427 (gnus-summary-display-article article all-headers
))
8428 (gnus-summary-position-cursor)))
8430 (defun gnus-summary-goto-last-article ()
8431 "Go to the previously read article."
8434 (and gnus-last-article
8435 (gnus-summary-goto-article gnus-last-article
))
8436 (gnus-summary-position-cursor)))
8438 (defun gnus-summary-pop-article (number)
8439 "Pop one article off the history and go to the previous.
8440 NUMBER articles will be popped off."
8443 (setq gnus-newsgroup-history
8444 (cdr (setq to
(nthcdr number gnus-newsgroup-history
))))
8446 (gnus-summary-goto-article (car to
))
8447 (error "Article history empty")))
8448 (gnus-summary-position-cursor))
8450 ;; Summary article oriented commands
8452 (defun gnus-summary-refer-parent-article (n)
8453 "Refer parent article N times.
8454 The difference between N and the number of articles fetched is returned."
8456 (gnus-set-global-variables)
8460 (let ((ref (mail-header-references (gnus-get-header-by-num
8461 (gnus-summary-article-number)))))
8462 (if (and ref
(not (equal ref
""))
8463 (string-match "<[^<>]*>[ \t]*$" ref
))
8464 (gnus-summary-refer-article
8465 (substring ref
(match-beginning 0) (match-end 0)))
8466 (gnus-message 1 "No references in article %d"
8467 (gnus-summary-article-number))
8470 (gnus-summary-position-cursor)
8473 (defun gnus-summary-refer-article (message-id)
8474 "Refer article specified by MESSAGE-ID.
8475 NOTE: This command only works with newsgroups that use real or simulated NNTP."
8476 (interactive "sMessage-ID: ")
8477 (if (or (not (stringp message-id
))
8478 (zerop (length message-id
)))
8480 ;; Construct the correct Message-ID if necessary.
8481 ;; Suggested by tale@pawl.rpi.edu.
8482 (or (string-match "^<" message-id
)
8483 (setq message-id
(concat "<" message-id
)))
8484 (or (string-match ">$" message-id
)
8485 (setq message-id
(concat message-id
">")))
8486 (let ((header (car (gnus-gethash (downcase message-id
)
8487 gnus-newsgroup-dependencies
))))
8489 (or (gnus-summary-goto-article (mail-header-number header
))
8490 ;; The header has been read, but the article had been
8491 ;; expunged, so we insert it again.
8493 (gnus-summary-insert-line
8494 nil header
0 nil gnus-read-mark nil nil
8495 (mail-header-subject header
))
8497 (mail-header-number header
)))
8498 (let ((gnus-override-method gnus-refer-article-method
)
8499 (gnus-ancient-mark gnus-read-mark
)
8500 (tmp-point (window-start
8501 (get-buffer-window gnus-article-buffer
)))
8503 (and gnus-refer-article-method
8504 (gnus-check-server gnus-refer-article-method
))
8505 ;; Save the old article buffer.
8507 (set-buffer (gnus-article-setup-buffer))
8508 (gnus-kill-buffer " *temp Article*")
8509 (setq tmp-buf
(rename-buffer " *temp Article*")))
8511 (if (gnus-article-prepare
8512 message-id nil
(gnus-read-header message-id
))
8514 (setq number
(mail-header-number gnus-current-headers
))
8515 (gnus-rebuild-thread message-id
)
8516 (gnus-summary-goto-subject number
)
8517 (if (null gnus-use-full-window
)
8519 (delete-windows-on tmp-buf
)
8520 (gnus-configure-windows 'article
'force
)))
8521 (gnus-summary-recenter)
8522 (gnus-article-set-window-start
8523 (cdr (assq number gnus-newsgroup-bookmarks
)))
8525 (run-hooks 'gnus-visual-mark-article-hook
))
8527 ;; We restore the old article buffer.
8529 (kill-buffer gnus-article-buffer
)
8530 (set-buffer tmp-buf
)
8531 (rename-buffer gnus-article-buffer
)
8532 (let ((buffer-read-only nil
))
8534 (set-window-start (get-buffer-window (current-buffer))
8535 tmp-point
)))))))))))
8537 (defun gnus-summary-enter-digest-group ()
8538 "Enter a digest group based on the current article."
8540 (gnus-set-global-variables)
8541 (gnus-summary-select-article)
8542 ;; We do not want a narrowed article.
8543 (gnus-summary-stop-page-breaking)
8544 (let ((name (format "%s-%d"
8545 (gnus-group-prefixed-name
8546 gnus-newsgroup-name
(list 'nndoc
""))
8547 gnus-current-article
))
8548 (ogroup gnus-newsgroup-name
)
8549 (buf (current-buffer)))
8550 (if (gnus-group-read-ephemeral-group
8551 name
(list 'nndoc name
8552 (list 'nndoc-address
(get-buffer gnus-article-buffer
))
8553 '(nndoc-article-type digest
))
8555 (setcdr (nthcdr 4 (nth 2 (gnus-gethash name gnus-newsrc-hashtb
)))
8556 (list (list (cons 'to-group ogroup
))))
8557 (switch-to-buffer buf
)
8558 (gnus-set-global-variables)
8559 (gnus-configure-windows 'summary
)
8560 (gnus-message 3 "Article not a digest?"))))
8562 (defun gnus-summary-isearch-article ()
8563 "Do incremental search forward on current article."
8565 (gnus-set-global-variables)
8566 (gnus-summary-select-article)
8567 (gnus-eval-in-buffer-window
8568 gnus-article-buffer
(isearch-forward)))
8570 (defun gnus-summary-search-article-forward (regexp &optional backward
)
8571 "Search for an article containing REGEXP forward.
8572 If BACKWARD, search backward instead."
8575 (format "Search article %s (regexp%s): "
8576 (if current-prefix-arg
"backward" "forward")
8577 (if gnus-last-search-regexp
8578 (concat ", default " gnus-last-search-regexp
)
8580 current-prefix-arg
))
8581 (gnus-set-global-variables)
8582 (if (string-equal regexp
"")
8583 (setq regexp
(or gnus-last-search-regexp
""))
8584 (setq gnus-last-search-regexp regexp
))
8585 (if (gnus-summary-search-article regexp backward
)
8586 (gnus-article-set-window-start
8587 (cdr (assq (gnus-summary-article-number) gnus-newsgroup-bookmarks
)))
8588 (error "Search failed: \"%s\"" regexp
)))
8590 (defun gnus-summary-search-article-backward (regexp)
8591 "Search for an article containing REGEXP backward."
8594 (format "Search article backward (regexp%s): "
8595 (if gnus-last-search-regexp
8596 (concat ", default " gnus-last-search-regexp
)
8598 (gnus-summary-search-article-forward regexp
'backward
))
8600 (defun gnus-summary-search-article (regexp &optional backward
)
8601 "Search for an article containing REGEXP.
8602 Optional argument BACKWARD means do search for backward.
8603 gnus-select-article-hook is not called during the search."
8604 (let ((gnus-select-article-hook nil
) ;Disable hook.
8605 (gnus-mark-article-hook nil
) ;Inhibit marking as read.
8608 (function re-search-backward
) (function re-search-forward
)))
8611 ;; Hidden thread subtrees must be searched for ,too.
8612 (gnus-summary-show-all-threads)
8613 (if (eobp) (forward-line -
1))
8614 ;; First of all, search current article.
8615 ;; We don't want to read article again from NNTP server nor reset
8617 (gnus-summary-select-article)
8618 (gnus-message 9 "Searching article: %d..." gnus-current-article
)
8619 (setq last gnus-current-article
)
8620 (gnus-eval-in-buffer-window
8624 ;; Begin search from current point.
8625 (setq found
(funcall re-search regexp nil t
))))
8626 ;; Then search next articles.
8627 (while (and (not found
)
8628 (gnus-summary-display-article
8629 (gnus-summary-search-subject backward nil nil
)))
8630 (gnus-message 9 "Searching article: %d..." gnus-current-article
)
8631 (gnus-eval-in-buffer-window
8635 (goto-char (if backward
(point-max) (point-min)))
8636 (setq found
(funcall re-search regexp nil t
)))))
8638 ;; Adjust article pointer.
8639 (or (eq last gnus-current-article
)
8640 (setq gnus-last-article last
))
8641 ;; Return T if found such article.
8644 (defun gnus-summary-execute-command (header regexp command
&optional backward
)
8645 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
8646 If HEADER is an empty string (or nil), the match is done on the entire
8647 article. If BACKWARD (the prefix) is non-nil, search backward instead."
8649 (list (let ((completion-ignore-case t
))
8652 (mapcar (lambda (string) (list string
))
8653 '("Number" "Subject" "From" "Lines" "Date"
8654 "Message-ID" "Xref" "References"))
8655 nil
'require-match
))
8656 (read-string "Regexp: ")
8657 (read-key-sequence "Command: ")
8658 current-prefix-arg
))
8659 (gnus-set-global-variables)
8660 ;; Hidden thread subtrees must be searched as well.
8661 (gnus-summary-show-all-threads)
8662 ;; We don't want to change current point nor window configuration.
8664 (save-window-excursion
8665 (gnus-message 6 "Executing %s..." (key-description command
))
8666 ;; We'd like to execute COMMAND interactively so as to give arguments.
8667 (gnus-execute header regexp
8669 (call-interactively '(, (key-binding command
)))))
8671 (gnus-message 6 "Executing %s...done" (key-description command
)))))
8673 (defun gnus-summary-beginning-of-article ()
8674 "Scroll the article back to the beginning."
8676 (gnus-set-global-variables)
8677 (gnus-summary-select-article)
8678 (gnus-configure-windows 'article
)
8679 (gnus-eval-in-buffer-window
8682 (goto-char (point-min))
8683 (and gnus-break-pages
(gnus-narrow-to-page))))
8685 (defun gnus-summary-end-of-article ()
8686 "Scroll to the end of the article."
8688 (gnus-set-global-variables)
8689 (gnus-summary-select-article)
8690 (gnus-configure-windows 'article
)
8691 (gnus-eval-in-buffer-window
8694 (goto-char (point-max))
8696 (and gnus-break-pages
(gnus-narrow-to-page))))
8698 (defun gnus-summary-show-article ()
8699 "Force re-fetching of the current article."
8701 (gnus-set-global-variables)
8702 (gnus-summary-select-article nil
'force
)
8703 (gnus-configure-windows 'article
)
8704 (gnus-summary-position-cursor))
8706 (defun gnus-summary-verbose-headers (&optional arg
)
8707 "Toggle permanent full header display.
8708 If ARG is a positive number, turn header display on.
8709 If ARG is a negative number, turn header display off."
8711 (gnus-set-global-variables)
8712 (gnus-summary-toggle-header arg
)
8713 (setq gnus-show-all-headers
8714 (cond ((or (not (numberp arg
))
8716 (not gnus-show-all-headers
))
8720 (defun gnus-summary-toggle-header (&optional arg
)
8721 "Show the headers if they are hidden, or hide them if they are shown.
8722 If ARG is a positive number, show the entire header.
8723 If ARG is a negative number, hide the unwanted header lines."
8725 (gnus-set-global-variables)
8727 (set-buffer gnus-article-buffer
)
8728 (let ((buffer-read-only nil
))
8730 (if (> arg
0) (remove-text-properties (point-min) (point-max)
8731 gnus-hidden-properties
)
8732 (if (< arg
0) (run-hooks 'gnus-article-display-hook
)))
8733 (if (text-property-any (point-min) (point-max) 'invisible t
)
8734 (remove-text-properties
8735 (point-min) (point-max) gnus-hidden-properties
)
8736 ;; We hide the headers. This song and dance act below is
8737 ;; done because `gnus-have-all-headers' is buffer-local to
8738 ;; the summary buffer, and we only want to temporarily
8739 ;; change it in that buffer. Ugh.
8740 (let ((have gnus-have-all-headers
))
8742 (set-buffer gnus-summary-buffer
)
8743 (setq gnus-have-all-headers nil
)
8745 (set-buffer gnus-article-buffer
)
8746 (run-hooks 'gnus-article-display-hook
))
8747 (setq gnus-have-all-headers have
)))))
8748 (set-window-point (get-buffer-window (current-buffer)) (point-min)))))
8750 (defun gnus-summary-show-all-headers ()
8751 "Make all header lines visible."
8753 (gnus-set-global-variables)
8754 (gnus-article-show-all-headers))
8756 (defun gnus-summary-toggle-mime (&optional arg
)
8757 "Toggle MIME processing.
8758 If ARG is a positive number, turn MIME processing on."
8760 (gnus-set-global-variables)
8761 (setq gnus-show-mime
8762 (if (null arg
) (not gnus-show-mime
)
8763 (> (prefix-numeric-value arg
) 0)))
8764 (gnus-summary-select-article t
'force
))
8766 (defun gnus-summary-caesar-message (&optional arg
)
8767 "Caesar rotate the current article by 13.
8768 The numerical prefix specifies how manu places to rotate each letter
8771 (gnus-set-global-variables)
8772 (gnus-summary-select-article)
8773 (let ((mail-header-separator ""))
8774 (gnus-eval-in-buffer-window
8778 (let ((start (window-start)))
8779 (news-caesar-buffer-body arg
)
8780 (set-window-start (get-buffer-window (current-buffer)) start
))))))
8782 (defun gnus-summary-stop-page-breaking ()
8783 "Stop page breaking in the current article."
8785 (gnus-set-global-variables)
8786 (gnus-summary-select-article)
8787 (gnus-eval-in-buffer-window gnus-article-buffer
(widen)))
8789 ;; Suggested by Brian Edmonds <bedmonds@prodigy.bc.ca>.
8791 (defun gnus-summary-move-article (&optional n to-newsgroup select-method
)
8792 "Move the current article to a different newsgroup.
8793 If N is a positive number, move the N next articles.
8794 If N is a negative number, move the N previous articles.
8795 If N is nil and any articles have been marked with the process mark,
8796 move those articles instead.
8797 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8798 If SELECT-METHOD is symbol, do not move to a specific newsgroup, but
8799 re-spool using this method.
8800 For this function to work, both the current newsgroup and the
8801 newsgroup that you want to move to have to support the `request-move'
8802 and `request-accept' functions. (Ie. mail newsgroups at present.)"
8804 (gnus-set-global-variables)
8805 (or (gnus-check-backend-function 'request-move-article gnus-newsgroup-name
)
8806 (error "The current newsgroup does not support article moving"))
8807 (let ((articles (gnus-summary-work-articles n
))
8808 (prefix (gnus-group-real-prefix gnus-newsgroup-name
))
8809 art-group to-method sel-met
)
8810 (if (and (not to-newsgroup
) (not select-method
))
8813 (format "Where do you want to move %s? %s"
8814 (if (> (length articles
) 1)
8815 (format "these %d articles" (length articles
))
8817 (if gnus-current-move-group
8818 (format "(%s default) " gnus-current-move-group
)
8820 gnus-active-hashtb nil nil prefix
)))
8823 (if (or (string= to-newsgroup
"") (string= to-newsgroup prefix
))
8824 (setq to-newsgroup
(or gnus-current-move-group
"")))
8825 (or (gnus-gethash to-newsgroup gnus-active-hashtb
)
8826 (gnus-activate-group to-newsgroup
)
8827 (error "No such group: %s" to-newsgroup
))
8828 (setq gnus-current-move-group to-newsgroup
)))
8829 (setq to-method
(if select-method
(list select-method
"")
8830 (gnus-find-method-for-group to-newsgroup
)))
8831 (or (gnus-check-backend-function 'request-accept-article
(car to-method
))
8832 (error "%s does not support article copying" (car to-method
)))
8833 (or (gnus-check-server to-method
)
8834 (error "Can't open server %s" (car to-method
)))
8835 (gnus-message 6 "Moving to %s: %s..."
8836 (or select-method to-newsgroup
) articles
)
8839 (gnus-request-move-article
8840 (car articles
) ; Article to move
8841 gnus-newsgroup-name
; From newsgroup
8842 (nth 1 (gnus-find-method-for-group
8843 gnus-newsgroup-name
)) ; Server
8844 (list 'gnus-request-accept-article
8846 (list 'quote select-method
)
8848 (not (cdr articles
))) ; Accept form
8849 (not (cdr articles
)))) ; Only save nov last time
8850 (let* ((buffer-read-only nil
)
8853 (gnus-gethash (car art-group
) gnus-newsrc-hashtb
)
8855 (gnus-group-prefixed-name
8857 (if select-method
(list select-method
"")
8858 (gnus-find-method-for-group to-newsgroup
)))
8859 gnus-newsrc-hashtb
)))
8860 (info (nth 2 entry
))
8861 (article (car articles
)))
8862 (gnus-summary-goto-subject article
)
8864 (delete-region (point) (progn (forward-line 1) (point)))
8865 ;; Update the group that has been moved to.
8867 () ; This group does not exist yet.
8868 (if (not (memq article gnus-newsgroup-unreads
))
8869 (setcar (cdr (cdr info
))
8870 (gnus-add-to-range (nth 2 info
)
8871 (list (cdr art-group
)))))
8872 ;; Copy any marks over to the new group.
8873 (let ((marks '((tick . gnus-newsgroup-marked
)
8874 (dormant . gnus-newsgroup-dormant
)
8875 (expire . gnus-newsgroup-expirable
)
8876 (bookmark . gnus-newsgroup-bookmarks
)
8877 (reply . gnus-newsgroup-replied
)))
8878 (to-article (cdr art-group
)))
8880 (if (memq article
(symbol-value (cdr (car marks
))))
8881 (gnus-add-marked-articles
8882 (car info
) (car (car marks
)) (list to-article
) info
))
8883 (setq marks
(cdr marks
)))))
8885 (setq gnus-newsgroup-marked
(delq article gnus-newsgroup-marked
))
8886 (setq gnus-newsgroup-unreads
(delq article gnus-newsgroup-unreads
))
8887 (setq gnus-newsgroup-dormant
8888 (delq article gnus-newsgroup-dormant
))
8889 (setq gnus-newsgroup-reads
8890 (cons (cons article gnus-canceled-mark
)
8891 gnus-newsgroup-reads
)))
8892 (gnus-message 1 "Couldn't move article %s" (car articles
)))
8893 (gnus-summary-remove-process-mark (car articles
))
8894 (setq articles
(cdr articles
)))
8895 (gnus-set-mode-line 'summary
)))
8897 (defun gnus-summary-respool-article (&optional n respool-method
)
8898 "Respool the current article.
8899 The article will be squeezed through the mail spooling process again,
8900 which means that it will be put in some mail newsgroup or other
8901 depending on `nnmail-split-methods'.
8902 If N is a positive number, respool the N next articles.
8903 If N is a negative number, respool the N previous articles.
8904 If N is nil and any articles have been marked with the process mark,
8905 respool those articles instead.
8907 Respooling can be done both from mail groups and \"real\" newsgroups.
8908 In the former case, the articles in question will be moved from the
8909 current group into whatever groups they are destined to. In the
8910 latter case, they will be copied into the relevant groups."
8912 (gnus-set-global-variables)
8913 (let ((respool-methods (gnus-methods-using 'respool
))
8915 (symbol-name (car (gnus-find-method-for-group gnus-newsgroup-name
)))))
8917 (setq respool-method
8919 "What method do you want to use when respooling? "
8920 respool-methods nil t methname
)))
8921 (or (string= respool-method
"")
8922 (if (assoc (symbol-name
8923 (car (gnus-find-method-for-group gnus-newsgroup-name
)))
8925 (gnus-summary-move-article n nil
(intern respool-method
))
8926 (gnus-summary-copy-article n nil
(intern respool-method
))))))
8928 ;; Suggested by gregj@unidata.com (Gregory J. Grubbs).
8929 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method
)
8930 "Move the current article to a different newsgroup.
8931 If N is a positive number, move the N next articles.
8932 If N is a negative number, move the N previous articles.
8933 If N is nil and any articles have been marked with the process mark,
8934 move those articles instead.
8935 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8936 If SELECT-METHOD is symbol, do not move to a specific newsgroup, but
8937 re-spool using this method.
8938 For this function to work, the newsgroup that you want to move to have
8939 to support the `request-move' and `request-accept'
8940 functions. (Ie. mail newsgroups at present.)"
8942 (gnus-set-global-variables)
8943 (let ((articles (gnus-summary-work-articles n
))
8944 (copy-buf (get-buffer-create "*copy work*"))
8945 (prefix (gnus-group-real-prefix gnus-newsgroup-name
))
8946 art-group to-method
)
8947 (buffer-disable-undo copy-buf
)
8948 (if (and (not to-newsgroup
) (not select-method
))
8951 (format "Where do you want to copy %s? %s"
8952 (if (> (length articles
) 1)
8953 (format "these %d articles" (length articles
))
8955 (if gnus-current-move-group
8956 (format "(%s default) " gnus-current-move-group
)
8958 gnus-active-hashtb nil nil prefix
)))
8961 (if (or (string= to-newsgroup
"") (string= to-newsgroup prefix
))
8962 (setq to-newsgroup
(or gnus-current-move-group
"")))
8963 (or (gnus-gethash to-newsgroup gnus-active-hashtb
)
8964 (gnus-activate-group to-newsgroup
)
8965 (error "No such group: %s" to-newsgroup
))
8966 (setq gnus-current-move-group to-newsgroup
)))
8967 (setq to-method
(if select-method
(list select-method
"")
8968 (gnus-find-method-for-group to-newsgroup
)))
8969 (or (gnus-check-backend-function 'request-accept-article
(car to-method
))
8970 (error "%s does not support article copying" (car to-method
)))
8971 (or (gnus-check-server to-method
)
8972 (error "Can't open server %s" (car to-method
)))
8974 (gnus-message 6 "Copying to %s: %s..."
8975 (or select-method to-newsgroup
) articles
)
8978 (set-buffer copy-buf
)
8979 (gnus-request-article-this-buffer
8980 (car articles
) gnus-newsgroup-name
)
8981 (gnus-request-accept-article
8982 (if select-method
(list 'quote select-method
) to-newsgroup
)
8983 (not (cdr articles
)))))
8986 (gnus-gethash (car art-group
) gnus-newsrc-hashtb
)
8988 (gnus-group-prefixed-name
8990 (if select-method
(list select-method
"")
8991 (gnus-find-method-for-group to-newsgroup
)))
8992 gnus-newsrc-hashtb
)))
8993 (info (nth 2 entry
))
8994 (article (car articles
)))
8995 ;; We copy the info over to the new group.
8997 () ; This group does not exist (yet).
8998 (if (not (memq article gnus-newsgroup-unreads
))
8999 (setcar (cdr (cdr info
))
9000 (gnus-add-to-range (nth 2 info
)
9001 (list (cdr art-group
)))))
9002 ;; Copy any marks over to the new group.
9003 (let ((marks '((tick . gnus-newsgroup-marked
)
9004 (dormant . gnus-newsgroup-dormant
)
9005 (expire . gnus-newsgroup-expirable
)
9006 (bookmark . gnus-newsgroup-bookmarks
)
9007 (reply . gnus-newsgroup-replied
)))
9008 (to-article (cdr art-group
)))
9010 (if (memq article
(symbol-value (cdr (car marks
))))
9011 (gnus-add-marked-articles
9012 (car info
) (car (car marks
)) (list to-article
) info
))
9013 (setq marks
(cdr marks
))))))
9014 (gnus-message 1 "Couldn't copy article %s" (car articles
)))
9015 (gnus-summary-remove-process-mark (car articles
))
9016 (setq articles
(cdr articles
)))
9017 (kill-buffer copy-buf
)))
9019 (defun gnus-summary-import-article (file)
9020 "Import a random file into a mail newsgroup."
9021 (interactive "fImport file: ")
9022 (let ((group gnus-newsgroup-name
)
9024 (or (gnus-check-backend-function 'request-accept-article group
)
9025 (error "%s does not support article importing" group
))
9026 (or (file-readable-p file
)
9027 (not (file-regular-p file
))
9028 (error "Can't read %s" file
))
9030 (set-buffer (get-buffer-create " *import file*"))
9031 (buffer-disable-undo (current-buffer))
9033 (insert-file-contents file
)
9034 (goto-char (point-min))
9035 (if (nnheader-article-p)
9037 (setq atts
(file-attributes file
))
9038 (insert "From: " (read-string "From: ") "\n"
9039 "Subject: " (read-string "Subject: ") "\n"
9040 "Date: " (current-time-string (nth 5 atts
)) "\n"
9041 "Chars: " (int-to-string (nth 7 atts
)) "\n\n"))
9042 (gnus-request-accept-article group t
)
9043 (kill-buffer (current-buffer)))))
9045 (defun gnus-summary-expire-articles ()
9046 "Expire all articles that are marked as expirable in the current group."
9048 (if (not (gnus-check-backend-function
9049 'request-expire-articles gnus-newsgroup-name
))
9051 (let* ((info (nth 2 (gnus-gethash gnus-newsgroup-name
9052 gnus-newsrc-hashtb
)))
9053 (total (memq 'total-expire
(nth 5 info
)))
9054 (expirable (if total
9055 (gnus-list-of-read-articles gnus-newsgroup-name
)
9056 (setq gnus-newsgroup-expirable
9057 (sort gnus-newsgroup-expirable
'<))))
9061 (gnus-message 6 "Expiring articles...")
9062 ;; The list of articles that weren't expired is returned.
9063 (setq es
(gnus-request-expire-articles expirable gnus-newsgroup-name
))
9064 (or total
(setq gnus-newsgroup-expirable es
))
9065 ;; We go through the old list of expirable, and mark all
9066 ;; really expired articles as nonexistent.
9067 (or (eq es expirable
) ;If nothing was expired, we don't mark.
9068 (let ((gnus-use-cache nil
))
9070 (or (memq (car expirable
) es
)
9071 (gnus-summary-mark-article
9072 (car expirable
) gnus-canceled-mark
))
9073 (setq expirable
(cdr expirable
)))))
9074 (gnus-message 6 "Expiring articles...done")))))
9076 (defun gnus-summary-expire-articles-now ()
9077 "Expunge all expirable articles in the current group.
9078 This means that *all* articles that are marked as expirable will be
9079 deleted forever, right now."
9081 (or gnus-expert-user
9083 "Are you really, really, really sure you want to expunge? ")
9085 (let ((nnmail-expiry-wait -
1)
9086 (nnmail-expiry-wait-function nil
))
9087 (gnus-summary-expire-articles)))
9089 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
9090 (defun gnus-summary-delete-article (&optional n
)
9091 "Delete the N next (mail) articles.
9092 This command actually deletes articles. This is not a marking
9093 command. The article will disappear forever from you life, never to
9095 If N is negative, delete backwards.
9096 If N is nil and articles have been marked with the process mark,
9097 delete these instead."
9099 (or (gnus-check-backend-function 'request-expire-articles
9100 gnus-newsgroup-name
)
9101 (error "The current newsgroup does not support article deletion."))
9102 ;; Compute the list of articles to delete.
9103 (let ((articles (gnus-summary-work-articles n
))
9105 (if (and gnus-novice-user
9107 (format "Do you really want to delete %s forever? "
9108 (if (> (length articles
) 1) "these articles"
9111 ;; Delete the articles.
9112 (setq not-deleted
(gnus-request-expire-articles
9113 articles gnus-newsgroup-name
'force
))
9115 (gnus-summary-remove-process-mark (car articles
))
9116 ;; The backend might not have been able to delete the article
9118 (or (memq (car articles
) not-deleted
)
9119 (gnus-summary-mark-article (car articles
) gnus-canceled-mark
))
9120 (setq articles
(cdr articles
))))
9121 (gnus-summary-position-cursor)
9122 (gnus-set-mode-line 'summary
)
9125 (defun gnus-summary-edit-article (&optional force
)
9126 "Enter into a buffer and edit the current article.
9127 This will have permanent effect only in mail groups.
9128 If FORCE is non-nil, allow editing of articles even in read-only
9132 (not (gnus-group-read-only-p))
9133 (error "The current newsgroup does not support article editing."))
9134 (gnus-summary-select-article t
)
9135 (gnus-configure-windows 'article
)
9136 (select-window (get-buffer-window gnus-article-buffer
))
9137 (gnus-message 6 "C-c C-c to end edits")
9138 (setq buffer-read-only nil
)
9140 (use-local-map (copy-keymap (current-local-map)))
9141 (local-set-key "\C-c\C-c" 'gnus-summary-edit-article-done
)
9142 (buffer-enable-undo)
9144 (goto-char (point-min))
9145 (search-forward "\n\n" nil t
))
9147 (defun gnus-summary-edit-article-done ()
9148 "Make edits to the current article permanent."
9150 (if (gnus-group-read-only-p)
9152 (gnus-summary-edit-article-postpone)
9153 (message "The current newsgroup does not support article editing.")
9155 (let ((buf (buffer-substring-no-properties (point-min) (point-max))))
9158 (if (not (gnus-request-replace-article
9159 (cdr gnus-article-current
) (car gnus-article-current
)
9161 (error "Couldn't replace article.")
9163 (use-local-map gnus-article-mode-map
)
9164 (setq buffer-read-only t
)
9165 (buffer-disable-undo (current-buffer))
9166 (gnus-configure-windows 'summary
))
9167 (and gnus-visual
(run-hooks 'gnus-visual-mark-article-hook
)))))
9169 (defun gnus-summary-edit-article-postpone ()
9170 "Postpone changes to the current article."
9173 (use-local-map gnus-article-mode-map
)
9174 (setq buffer-read-only t
)
9175 (buffer-disable-undo (current-buffer))
9176 (gnus-configure-windows 'summary
)
9177 (and gnus-visual
(run-hooks 'gnus-visual-mark-article-hook
)))
9179 (defun gnus-summary-fancy-query ()
9180 "Query where the fancy respool algorithm would put this article."
9182 (gnus-summary-select-article)
9184 (set-buffer gnus-article-buffer
)
9186 (goto-char (point-min))
9187 (search-forward "\n\n")
9188 (narrow-to-region (point-min) (point))
9189 (pp-eval-expression (list 'quote
(nnmail-split-fancy))))))
9191 ;; Summary score commands.
9193 ;; Suggested by boubaker@cenatls.cena.dgac.fr.
9195 (defun gnus-summary-raise-score (n)
9196 "Raise the score of the current article by N."
9198 (gnus-summary-set-score (+ (gnus-summary-article-score) n
)))
9200 (defun gnus-summary-set-score (n)
9201 "Set the score of the current article to N."
9203 ;; Skip dummy header line.
9205 (gnus-summary-show-thread)
9206 (if (eq (gnus-summary-article-mark) gnus-dummy-mark
)
9208 (let ((buffer-read-only nil
))
9210 (gnus-summary-update-mark
9211 (if (= n
(or gnus-summary-default-score
0)) ?
9212 (if (< n
(or gnus-summary-default-score
0))
9213 gnus-score-below-mark gnus-score-over-mark
)) 'score
))
9214 (let* ((article (gnus-summary-article-number))
9215 (score (assq article gnus-newsgroup-scored
)))
9216 (if score
(setcdr score n
)
9217 (setq gnus-newsgroup-scored
9218 (cons (cons article n
) gnus-newsgroup-scored
))))
9219 (gnus-summary-update-line)))
9221 (defun gnus-summary-current-score ()
9222 "Return the score of the current article."
9224 (message "%s" (gnus-summary-article-score)))
9226 ;; Summary marking commands.
9228 (defun gnus-summary-raise-same-subject-and-select (score)
9229 "Raise articles which has the same subject with SCORE and select the next."
9231 (let ((subject (gnus-summary-subject-string)))
9232 (gnus-summary-raise-score score
)
9233 (while (gnus-summary-search-subject nil nil subject
)
9234 (gnus-summary-raise-score score
))
9235 (gnus-summary-next-article t
)))
9237 (defun gnus-summary-raise-same-subject (score)
9238 "Raise articles which has the same subject with SCORE."
9240 (let ((subject (gnus-summary-subject-string)))
9241 (gnus-summary-raise-score score
)
9242 (while (gnus-summary-search-subject nil nil subject
)
9243 (gnus-summary-raise-score score
))
9244 (gnus-summary-next-subject 1 t
)))
9246 (defun gnus-score-default (level)
9247 (if level
(prefix-numeric-value level
)
9248 gnus-score-interactive-default-score
))
9250 (defun gnus-summary-raise-thread (&optional score
)
9251 "Raise the score of the articles in the current thread with SCORE."
9253 (setq score
(gnus-score-default score
))
9256 (let ((level (gnus-summary-thread-level)))
9257 (gnus-summary-raise-score score
)
9258 (while (and (zerop (gnus-summary-next-subject 1 nil t
))
9259 (> (gnus-summary-thread-level) level
))
9260 (gnus-summary-raise-score score
))
9262 (let ((gnus-summary-check-current t
))
9263 (or (zerop (gnus-summary-next-subject 1 t
))
9265 (gnus-summary-recenter)
9266 (gnus-summary-position-cursor)
9267 (gnus-set-mode-line 'summary
))
9269 (defun gnus-summary-lower-same-subject-and-select (score)
9270 "Raise articles which has the same subject with SCORE and select the next."
9272 (gnus-summary-raise-same-subject-and-select (- score
)))
9274 (defun gnus-summary-lower-same-subject (score)
9275 "Raise articles which has the same subject with SCORE."
9277 (gnus-summary-raise-same-subject (- score
)))
9279 (defun gnus-summary-lower-thread (&optional score
)
9280 "Lower score of articles in the current thread with SCORE."
9282 (gnus-summary-raise-thread (- (1- (gnus-score-default score
)))))
9284 (defun gnus-summary-kill-same-subject-and-select (&optional unmark
)
9285 "Mark articles which has the same subject as read, and then select the next.
9286 If UNMARK is positive, remove any kind of mark.
9287 If UNMARK is negative, tick articles."
9290 (setq unmark
(prefix-numeric-value unmark
)))
9292 (gnus-summary-mark-same-subject
9293 (gnus-summary-subject-string) unmark
)))
9294 ;; Select next unread article. If auto-select-same mode, should
9295 ;; select the first unread article.
9296 (gnus-summary-next-article t
(and gnus-auto-select-same
9297 (gnus-summary-subject-string)))
9298 (gnus-message 7 "%d article%s marked as %s"
9299 count
(if (= count
1) " is" "s are")
9300 (if unmark
"unread" "read"))))
9302 (defun gnus-summary-kill-same-subject (&optional unmark
)
9303 "Mark articles which has the same subject as read.
9304 If UNMARK is positive, remove any kind of mark.
9305 If UNMARK is negative, tick articles."
9308 (setq unmark
(prefix-numeric-value unmark
)))
9310 (gnus-summary-mark-same-subject
9311 (gnus-summary-subject-string) unmark
)))
9312 ;; If marked as read, go to next unread subject.
9314 ;; Go to next unread subject.
9315 (gnus-summary-next-subject 1 t
))
9316 (gnus-message 7 "%d articles are marked as %s"
9317 count
(if unmark
"unread" "read"))))
9319 (defun gnus-summary-mark-same-subject (subject &optional unmark
)
9320 "Mark articles with same SUBJECT as read, and return marked number.
9321 If optional argument UNMARK is positive, remove any kinds of marks.
9322 If optional argument UNMARK is negative, mark articles as unread instead."
9326 ((null unmark
) ; Mark as read.
9329 (gnus-summary-mark-article-as-read gnus-killed-mark
)
9330 (gnus-summary-show-thread) t
)
9331 (gnus-summary-search-forward nil subject
))
9332 (setq count
(1+ count
))))
9333 ((> unmark
0) ; Tick.
9336 (gnus-summary-mark-article-as-unread gnus-ticked-mark
)
9337 (gnus-summary-show-thread) t
)
9338 (gnus-summary-search-forward nil subject
))
9339 (setq count
(1+ count
))))
9340 (t ; Mark as unread.
9343 (gnus-summary-mark-article-as-unread gnus-unread-mark
)
9344 (gnus-summary-show-thread) t
)
9345 (gnus-summary-search-forward nil subject
))
9346 (setq count
(1+ count
)))))
9347 (gnus-set-mode-line 'summary
)
9348 ;; Return the number of marked articles.
9351 (defun gnus-summary-mark-as-processable (n &optional unmark
)
9352 "Set the process mark on the next N articles.
9353 If N is negative, mark backward instead. If UNMARK is non-nil, remove
9354 the process mark instead. The difference between N and the actual
9355 number of articles marked is returned."
9357 (let ((backward (< n
0))
9362 (gnus-summary-remove-process-mark
9363 (gnus-summary-article-number))
9364 (gnus-summary-set-process-mark (gnus-summary-article-number)))
9365 (zerop (gnus-summary-next-subject (if backward -
1 1) nil t
)))
9367 (if (/= 0 n
) (gnus-message 7 "No more articles"))
9368 (gnus-summary-recenter)
9369 (gnus-summary-position-cursor)
9372 (defun gnus-summary-unmark-as-processable (n)
9373 "Remove the process mark from the next N articles.
9374 If N is negative, mark backward instead. The difference between N and
9375 the actual number of articles marked is returned."
9377 (gnus-summary-mark-as-processable n t
))
9379 (defun gnus-summary-unmark-all-processable ()
9380 "Remove the process mark from all articles."
9383 (while gnus-newsgroup-processable
9384 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable
))))
9385 (gnus-summary-position-cursor))
9387 (defun gnus-summary-mark-as-expirable (n)
9388 "Mark N articles forward as expirable.
9389 If N is negative, mark backward instead. The difference between N and
9390 the actual number of articles marked is returned."
9392 (gnus-summary-mark-forward n gnus-expirable-mark
))
9394 (defun gnus-summary-mark-article-as-replied (article)
9395 "Mark ARTICLE replied and update the summary line."
9396 (setq gnus-newsgroup-replied
(cons article gnus-newsgroup-replied
))
9397 (let ((buffer-read-only nil
))
9398 (if (gnus-summary-goto-subject article
)
9400 (gnus-summary-update-mark gnus-replied-mark
'replied
)
9403 (defun gnus-summary-set-bookmark (article)
9404 "Set a bookmark in current article."
9405 (interactive (list (gnus-summary-article-number)))
9406 (if (or (not (get-buffer gnus-article-buffer
))
9407 (not gnus-current-article
)
9408 (not gnus-article-current
)
9409 (not (equal gnus-newsgroup-name
(car gnus-article-current
))))
9410 (error "No current article selected"))
9411 ;; Remove old bookmark, if one exists.
9412 (let ((old (assq article gnus-newsgroup-bookmarks
)))
9413 (if old
(setq gnus-newsgroup-bookmarks
9414 (delq old gnus-newsgroup-bookmarks
))))
9415 ;; Set the new bookmark, which is on the form
9416 ;; (article-number . line-number-in-body).
9417 (setq gnus-newsgroup-bookmarks
9421 (set-buffer gnus-article-buffer
)
9425 (goto-char (point-min))
9426 (search-forward "\n\n" nil t
)
9429 gnus-newsgroup-bookmarks
))
9430 (gnus-message 6 "A bookmark has been added to the current article."))
9432 (defun gnus-summary-remove-bookmark (article)
9433 "Remove the bookmark from the current article."
9434 (interactive (list (gnus-summary-article-number)))
9435 ;; Remove old bookmark, if one exists.
9436 (let ((old (assq article gnus-newsgroup-bookmarks
)))
9439 (setq gnus-newsgroup-bookmarks
9440 (delq old gnus-newsgroup-bookmarks
))
9441 (gnus-message 6 "Removed bookmark."))
9442 (gnus-message 6 "No bookmark in current article."))))
9444 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9445 (defun gnus-summary-mark-as-dormant (n)
9446 "Mark N articles forward as dormant.
9447 If N is negative, mark backward instead. The difference between N and
9448 the actual number of articles marked is returned."
9450 (gnus-summary-mark-forward n gnus-dormant-mark
))
9452 (defun gnus-summary-set-process-mark (article)
9453 "Set the process mark on ARTICLE and update the summary line."
9454 (setq gnus-newsgroup-processable
9456 (delq article gnus-newsgroup-processable
)))
9457 (let ((buffer-read-only nil
))
9458 (if (gnus-summary-goto-subject article
)
9460 (gnus-summary-show-thread)
9461 (and (eq (gnus-summary-article-mark) gnus-dummy-mark
)
9463 (gnus-summary-update-mark gnus-process-mark
'replied
)
9466 (defun gnus-summary-remove-process-mark (article)
9467 "Remove the process mark from ARTICLE and update the summary line."
9468 (setq gnus-newsgroup-processable
(delq article gnus-newsgroup-processable
))
9469 (let ((buffer-read-only nil
))
9470 (if (gnus-summary-goto-subject article
)
9472 (gnus-summary-show-thread)
9473 (and (eq (gnus-summary-article-mark) gnus-dummy-mark
)
9475 (gnus-summary-update-mark ?
'replied
)
9476 (if (memq article gnus-newsgroup-replied
)
9477 (gnus-summary-update-mark gnus-replied-mark
'replied
))
9480 (defun gnus-summary-mark-forward (n &optional mark no-expire
)
9481 "Mark N articles as read forwards.
9482 If N is negative, mark backwards instead.
9483 Mark with MARK. If MARK is ? , ?! or ??, articles will be
9485 The difference between N and the actual number of articles marked is
9488 (gnus-set-global-variables)
9489 (let ((backward (< n
0))
9490 (gnus-summary-goto-unread
9491 (and gnus-summary-goto-unread
9492 (not (memq mark
(list gnus-unread-mark
9493 gnus-ticked-mark gnus-dormant-mark
)))))
9495 (mark (or mark gnus-del-mark
)))
9497 (gnus-summary-mark-article nil mark no-expire
)
9498 (zerop (gnus-summary-next-subject
9499 (if backward -
1 1) gnus-summary-goto-unread t
)))
9501 (if (/= 0 n
) (gnus-message 7 "No more %sarticles" (if mark
"" "unread ")))
9502 (gnus-summary-recenter)
9503 (gnus-summary-position-cursor)
9504 (gnus-set-mode-line 'summary
)
9507 (defun gnus-summary-mark-article-as-read (mark)
9508 "Mark the current article quickly as read with MARK."
9509 (let ((article (gnus-summary-article-number)))
9510 (setq gnus-newsgroup-unreads
(delq article gnus-newsgroup-unreads
))
9511 (setq gnus-newsgroup-marked
(delq article gnus-newsgroup-marked
))
9512 (setq gnus-newsgroup-dormant
(delq article gnus-newsgroup-dormant
))
9513 (setq gnus-newsgroup-reads
9514 (cons (cons article mark
) gnus-newsgroup-reads
))
9515 ;; Possibly remove from cache, if that is used.
9516 (and gnus-use-cache
(gnus-cache-enter-remove-article article
))
9517 (and gnus-newsgroup-auto-expire
9518 (or (= mark gnus-killed-mark
) (= mark gnus-del-mark
)
9519 (= mark gnus-catchup-mark
) (= mark gnus-low-score-mark
)
9520 (= mark gnus-read-mark
))
9522 (setq mark gnus-expirable-mark
)
9523 (setq gnus-newsgroup-expirable
9524 (cons article gnus-newsgroup-expirable
))))
9525 (while (eq (gnus-summary-article-mark) gnus-dummy-mark
)
9528 (gnus-summary-update-mark mark
'unread
)
9531 (defun gnus-summary-mark-article-as-unread (mark)
9532 "Mark the current article quickly as unread with MARK."
9533 (let ((article (gnus-summary-article-number)))
9534 (or (memq article gnus-newsgroup-unreads
)
9535 (setq gnus-newsgroup-unreads
(cons article gnus-newsgroup-unreads
)))
9536 (setq gnus-newsgroup-marked
(delq article gnus-newsgroup-marked
))
9537 (setq gnus-newsgroup-dormant
(delq article gnus-newsgroup-dormant
))
9538 (setq gnus-newsgroup-expirable
(delq article gnus-newsgroup-expirable
))
9539 (setq gnus-newsgroup-reads
9540 (delq (assq article gnus-newsgroup-reads
)
9541 gnus-newsgroup-reads
))
9542 (if (= mark gnus-ticked-mark
)
9543 (setq gnus-newsgroup-marked
(cons article gnus-newsgroup-marked
)))
9544 (if (= mark gnus-dormant-mark
)
9545 (setq gnus-newsgroup-dormant
(cons article gnus-newsgroup-dormant
)))
9547 ;; See whether the article is to be put in the cache.
9549 (vectorp (gnus-get-header-by-num article
))
9551 (gnus-cache-possibly-enter-article
9552 gnus-newsgroup-name article
9553 (gnus-get-header-by-num article
)
9554 (= mark gnus-ticked-mark
)
9555 (= mark gnus-dormant-mark
) (= mark gnus-unread-mark
))))
9557 (while (eq (gnus-summary-article-mark) gnus-dummy-mark
)
9560 (gnus-summary-update-mark mark
'unread
)
9563 (defun gnus-summary-mark-article (&optional article mark no-expire
)
9564 "Mark ARTICLE with MARK. MARK can be any character.
9565 Four MARK strings are reserved: `? ' (unread), `?!' (ticked), `??'
9566 (dormant) and `?E' (expirable).
9567 If MARK is nil, then the default character `?D' is used.
9568 If ARTICLE is nil, then the article on the current line will be
9571 (setq mark
(aref mark
0)))
9572 ;; If no mark is given, then we check auto-expiring.
9573 (and (not no-expire
)
9574 gnus-newsgroup-auto-expire
9577 (or (= mark gnus-killed-mark
) (= mark gnus-del-mark
)
9578 (= mark gnus-catchup-mark
) (= mark gnus-low-score-mark
)
9579 (= mark gnus-read-mark
))))
9580 (setq mark gnus-expirable-mark
))
9581 (let* ((mark (or mark gnus-del-mark
))
9582 (article (or article
(gnus-summary-article-number))))
9583 (or article
(error "No article on current line"))
9584 (if (or (= mark gnus-unread-mark
)
9585 (= mark gnus-ticked-mark
)
9586 (= mark gnus-dormant-mark
))
9587 (gnus-mark-article-as-unread article mark
)
9588 (gnus-mark-article-as-read article mark
))
9590 ;; See whether the article is to be put in the cache.
9592 (not (= mark gnus-canceled-mark
))
9593 (vectorp (gnus-get-header-by-num article
))
9595 (gnus-cache-possibly-enter-article
9596 gnus-newsgroup-name article
9597 (gnus-get-header-by-num article
)
9598 (= mark gnus-ticked-mark
)
9599 (= mark gnus-dormant-mark
) (= mark gnus-unread-mark
))))
9601 (if (gnus-summary-goto-subject article
)
9602 (let ((buffer-read-only nil
))
9603 (gnus-summary-show-thread)
9604 (and (eq (gnus-summary-article-mark) gnus-dummy-mark
)
9607 (gnus-summary-update-mark mark
'unread
)
9610 (defun gnus-summary-update-mark (mark type
)
9612 (let ((forward (cdr (assq type gnus-summary-mark-positions
)))
9613 (buffer-read-only nil
)
9617 (forward-char forward
)
9618 (setq plist
(text-properties-at (point)))
9621 (and plist
(add-text-properties (1- (point)) (point) plist
))
9622 (and (eq type
'unread
)
9624 (add-text-properties (1- (point)) (point) (list 'gnus-mark mark
))
9625 (gnus-summary-update-line (eq mark gnus-unread-mark
)))))))
9627 (defun gnus-mark-article-as-read (article &optional mark
)
9628 "Enter ARTICLE in the pertinent lists and remove it from others."
9629 ;; Make the article expirable.
9630 (let ((mark (or mark gnus-del-mark
)))
9631 (if (= mark gnus-expirable-mark
)
9632 (setq gnus-newsgroup-expirable
(cons article gnus-newsgroup-expirable
))
9633 (setq gnus-newsgroup-expirable
(delq article gnus-newsgroup-expirable
)))
9634 ;; Remove from unread and marked lists.
9635 (setq gnus-newsgroup-unreads
(delq article gnus-newsgroup-unreads
))
9636 (setq gnus-newsgroup-marked
(delq article gnus-newsgroup-marked
))
9637 (setq gnus-newsgroup-dormant
(delq article gnus-newsgroup-dormant
))
9638 (setq gnus-newsgroup-reads
9639 (cons (cons article mark
) gnus-newsgroup-reads
))
9640 ;; Possibly remove from cache, if that is used.
9641 (and gnus-use-cache
(gnus-cache-enter-remove-article article
))))
9643 (defun gnus-mark-article-as-unread (article &optional mark
)
9644 "Enter ARTICLE in the pertinent lists and remove it from others."
9645 (let ((mark (or mark gnus-ticked-mark
)))
9646 ;; Add to unread list.
9647 (or (memq article gnus-newsgroup-unreads
)
9648 (setq gnus-newsgroup-unreads
(cons article gnus-newsgroup-unreads
)))
9649 (setq gnus-newsgroup-marked
(delq article gnus-newsgroup-marked
))
9650 (setq gnus-newsgroup-dormant
(delq article gnus-newsgroup-dormant
))
9651 (setq gnus-newsgroup-expirable
(delq article gnus-newsgroup-expirable
))
9652 (setq gnus-newsgroup-reads
9653 (delq (assq article gnus-newsgroup-reads
)
9654 gnus-newsgroup-reads
))
9655 (if (= mark gnus-ticked-mark
)
9656 (setq gnus-newsgroup-marked
(cons article gnus-newsgroup-marked
)))
9657 (if (= mark gnus-dormant-mark
)
9658 (setq gnus-newsgroup-dormant
(cons article gnus-newsgroup-dormant
)))))
9660 (defalias 'gnus-summary-mark-as-unread-forward
9661 'gnus-summary-tick-article-forward
)
9662 (make-obsolete 'gnus-summary-mark-as-unread-forward
9663 'gnus-summary-tick-article-forward
)
9664 (defun gnus-summary-tick-article-forward (n)
9665 "Tick N articles forwards.
9666 If N is negative, tick backwards instead.
9667 The difference between N and the number of articles ticked is returned."
9669 (gnus-summary-mark-forward n gnus-ticked-mark
))
9671 (defalias 'gnus-summary-mark-as-unread-backward
9672 'gnus-summary-tick-article-backward
)
9673 (make-obsolete 'gnus-summary-mark-as-unread-backward
9674 'gnus-summary-tick-article-backward
)
9675 (defun gnus-summary-tick-article-backward (n)
9676 "Tick N articles backwards.
9677 The difference between N and the number of articles ticked is returned."
9679 (gnus-summary-mark-forward (- n
) gnus-ticked-mark
))
9681 (defalias 'gnus-summary-mark-as-unread
'gnus-summary-tick-article
)
9682 (make-obsolete 'gnus-summary-mark-as-unread
'gnus-summary-tick-article
)
9683 (defun gnus-summary-tick-article (&optional article clear-mark
)
9684 "Mark current article as unread.
9685 Optional 1st argument ARTICLE specifies article number to be marked as unread.
9686 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
9687 (gnus-summary-mark-article article
(if clear-mark gnus-unread-mark
9690 (defun gnus-summary-mark-as-read-forward (n)
9691 "Mark N articles as read forwards.
9692 If N is negative, mark backwards instead.
9693 The difference between N and the actual number of articles marked is
9696 (gnus-summary-mark-forward n gnus-del-mark t
))
9698 (defun gnus-summary-mark-as-read-backward (n)
9699 "Mark the N articles as read backwards.
9700 The difference between N and the actual number of articles marked is
9703 (gnus-summary-mark-forward (- n
) gnus-del-mark t
))
9705 (defun gnus-summary-mark-as-read (&optional article mark
)
9706 "Mark current article as read.
9707 ARTICLE specifies the article to be marked as read.
9708 MARK specifies a string to be inserted at the beginning of the line."
9709 (gnus-summary-mark-article article mark
))
9711 (defun gnus-summary-clear-mark-forward (n)
9712 "Clear marks from N articles forward.
9713 If N is negative, clear backward instead.
9714 The difference between N and the number of marks cleared is returned."
9716 (gnus-summary-mark-forward n gnus-unread-mark
))
9718 (defun gnus-summary-clear-mark-backward (n)
9719 "Clear marks from N articles backward.
9720 The difference between N and the number of marks cleared is returned."
9722 (gnus-summary-mark-forward (- n
) gnus-unread-mark
))
9724 (defun gnus-summary-mark-unread-as-read ()
9725 "Intended to be used by `gnus-summary-mark-article-hook'."
9726 (or (memq gnus-current-article gnus-newsgroup-marked
)
9727 (memq gnus-current-article gnus-newsgroup-dormant
)
9728 (memq gnus-current-article gnus-newsgroup-expirable
)
9729 (gnus-summary-mark-article gnus-current-article gnus-read-mark
)))
9731 (defun gnus-summary-mark-region-as-read (point mark all
)
9732 "Mark all unread articles between point and mark as read.
9733 If given a prefix, mark all articles between point and mark as read,
9734 even ticked and dormant ones."
9735 (interactive "r\nP")
9745 (not (memq (gnus-summary-article-number)
9746 gnus-newsgroup-marked
))
9747 (not (memq (gnus-summary-article-number)
9748 gnus-newsgroup-dormant
))))
9749 (gnus-summary-mark-article
9750 (gnus-summary-article-number) gnus-del-mark
))
9752 (zerop (forward-line 1))))))
9754 ;; Fix by Per Abrahamsen <amanda@iesd.auc.dk>.
9755 (defalias 'gnus-summary-delete-marked-as-read
9756 'gnus-summary-remove-lines-marked-as-read
)
9757 (make-obsolete 'gnus-summary-delete-marked-as-read
9758 'gnus-summary-remove-lines-marked-as-read
)
9759 (defun gnus-summary-remove-lines-marked-as-read ()
9760 "Remove lines that are marked as read."
9762 (gnus-summary-remove-lines-marked-with
9764 (lambda (char) (char-to-string (symbol-value char
)))
9765 '(gnus-del-mark gnus-read-mark gnus-ancient-mark
9766 gnus-killed-mark gnus-kill-file-mark
9767 gnus-low-score-mark gnus-expirable-mark
9768 gnus-canceled-mark gnus-catchup-mark
)
9771 (defalias 'gnus-summary-delete-marked-with
9772 'gnus-summary-remove-lines-marked-with
)
9773 (make-obsolete 'gnus-summary-delete-marked-with
9774 'gnus-summary-remove-lines-marked-with
)
9775 ;; Rewrite by Daniel Quinlan <quinlan@best.com>.
9776 (defun gnus-summary-remove-lines-marked-with (marks)
9777 "Remove lines that are marked with MARKS (e.g. \"DK\")."
9778 (interactive "sMarks: ")
9779 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
9780 (gnus-set-global-variables)
9781 (let ((buffer-read-only nil
)
9783 (let ((gnus-summary-check-current t
))
9784 (gnus-summary-search-forward t
)
9785 (gnus-summary-article-number)))
9786 (marks (concat "^[" marks
"]")))
9787 (goto-char (point-min))
9788 (if gnus-newsgroup-adaptive
9789 (gnus-score-remove-lines-adaptive marks
)
9790 (while (re-search-forward marks nil t
)
9791 (gnus-delete-line)))
9792 ;; If we use dummy roots, we have to do an additional sweep over
9794 (if (not (eq gnus-summary-make-false-root
'dummy
))
9796 (goto-char (point-min))
9797 (setq marks
(concat "^[" (char-to-string gnus-dummy-mark
) "]"))
9798 (while (re-search-forward marks nil t
)
9799 (if (gnus-subject-equal
9800 (gnus-summary-subject-string)
9803 (gnus-summary-subject-string)))
9806 (gnus-delete-line))))
9807 (or (zerop (buffer-size))
9808 (gnus-summary-goto-subject orig-article
)
9810 (gnus-summary-prev-subject 1)
9811 (gnus-summary-position-cursor)))))
9813 (defun gnus-summary-expunge-below (&optional score
)
9814 "Remove articles with score less than SCORE."
9816 (gnus-set-global-variables)
9817 (setq score
(if score
9818 (prefix-numeric-value score
)
9819 (or gnus-summary-default-score
0)))
9821 (set-buffer gnus-summary-buffer
)
9822 (goto-char (point-min))
9823 (let ((buffer-read-only nil
)
9826 (if (< (gnus-summary-article-score) score
)
9830 (delete-region beg
(point)))
9833 (or (zerop (buffer-size))
9835 (gnus-summary-prev-subject 1)
9836 (gnus-summary-position-cursor))))))
9838 (defun gnus-summary-mark-below (score mark
)
9839 "Mark articles with score less than SCORE with MARK."
9840 (interactive "P\ncMark: ")
9841 (gnus-set-global-variables)
9842 (setq score
(if score
9843 (prefix-numeric-value score
)
9844 (or gnus-summary-default-score
0)))
9846 (set-buffer gnus-summary-buffer
)
9847 (goto-char (point-min))
9849 (and (< (gnus-summary-article-score) score
)
9850 (gnus-summary-mark-article nil mark
))
9853 (defun gnus-summary-kill-below (&optional score
)
9854 "Mark articles with score below SCORE as read."
9856 (gnus-set-global-variables)
9857 (gnus-summary-mark-below score gnus-killed-mark
))
9859 (defun gnus-summary-clear-above (&optional score
)
9860 "Clear all marks from articles with score above SCORE."
9862 (gnus-set-global-variables)
9863 (gnus-summary-mark-above score gnus-unread-mark
))
9865 (defun gnus-summary-tick-above (&optional score
)
9866 "Tick all articles with score above SCORE."
9868 (gnus-set-global-variables)
9869 (gnus-summary-mark-above score gnus-ticked-mark
))
9871 (defun gnus-summary-mark-above (score mark
)
9872 "Mark articles with score over SCORE with MARK."
9873 (interactive "P\ncMark: ")
9874 (gnus-set-global-variables)
9875 (setq score
(if score
9876 (prefix-numeric-value score
)
9877 (or gnus-summary-default-score
0)))
9879 (set-buffer gnus-summary-buffer
)
9880 (goto-char (point-min))
9882 (if (> (gnus-summary-article-score) score
)
9884 (gnus-summary-mark-article nil mark
)
9886 (forward-line 1)))))
9888 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9889 (defun gnus-summary-show-all-expunged ()
9890 "Display all the hidden articles that were expunged for low scores."
9892 (gnus-set-global-variables)
9893 (let ((buffer-read-only nil
))
9894 (let ((scored gnus-newsgroup-scored
)
9897 (or (gnus-summary-goto-subject (car (car scored
)))
9898 (and (setq h
(gnus-get-header-by-num (car (car scored
))))
9899 (< (cdr (car scored
)) gnus-summary-expunge-below
)
9900 (setq headers
(cons h headers
))))
9901 (setq scored
(cdr scored
)))
9902 (or headers
(error "No expunged articles hidden."))
9903 (goto-char (point-min))
9905 (gnus-summary-update-lines
9908 (gnus-summary-prepare-unthreaded (nreverse headers
))
9910 (goto-char (point-min))
9911 (gnus-summary-position-cursor)))
9913 (defun gnus-summary-show-all-dormant ()
9914 "Display all the hidden articles that are marked as dormant."
9916 (gnus-set-global-variables)
9917 (let ((buffer-read-only nil
))
9918 (let ((dormant gnus-newsgroup-dormant
)
9921 (or (gnus-summary-goto-subject (car dormant
))
9922 (and (setq h
(gnus-get-header-by-num (car dormant
)))
9923 (setq headers
(cons h headers
))))
9924 (setq dormant
(cdr dormant
)))
9925 (or headers
(error "No dormant articles hidden."))
9926 (goto-char (point-min))
9928 (gnus-summary-update-lines
9931 (gnus-summary-prepare-unthreaded (nreverse headers
))
9933 (goto-char (point-min))
9934 (gnus-summary-position-cursor)))
9936 (defun gnus-summary-hide-all-dormant ()
9937 "Hide all dormant articles."
9939 (gnus-set-global-variables)
9940 (gnus-summary-remove-lines-marked-with (char-to-string gnus-dormant-mark
))
9941 (gnus-summary-position-cursor))
9943 (defun gnus-summary-catchup (&optional all quietly to-here not-mark
)
9944 "Mark all articles not marked as unread in this newsgroup as read.
9945 If prefix argument ALL is non-nil, all articles are marked as read.
9946 If QUIETLY is non-nil, no questions will be asked.
9947 If TO-HERE is non-nil, it should be a point in the buffer. All
9948 articles before this point will be marked as read.
9949 The number of articles marked as read is returned."
9951 (gnus-set-global-variables)
9954 (not gnus-interactive-catchup
) ;Without confirmation?
9958 "Mark absolutely all articles as read? "
9959 "Mark all unread articles as read? ")))
9961 (not gnus-newsgroup-adaptive
)
9962 (not gnus-newsgroup-auto-expire
))
9964 (and all
(setq gnus-newsgroup-marked nil
9965 gnus-newsgroup-dormant nil
))
9966 (setq gnus-newsgroup-unreads
9967 (append gnus-newsgroup-marked gnus-newsgroup-dormant
)))
9968 ;; We actually mark all articles as canceled, which we
9969 ;; have to do when using auto-expiry or adaptive scoring.
9970 (gnus-summary-show-all-threads)
9971 (if (gnus-summary-first-subject (not all
))
9973 (if to-here
(< (point) to-here
) t
)
9974 (gnus-summary-mark-article-as-read gnus-catchup-mark
)
9975 (gnus-summary-search-subject nil
(not all
)))))
9977 (setq gnus-newsgroup-unreads
9978 (append gnus-newsgroup-marked
9979 gnus-newsgroup-dormant
)))))
9980 (let ((method (gnus-find-method-for-group gnus-newsgroup-name
)))
9981 (if (and (not to-here
) (eq 'nnvirtual
(car method
)))
9982 (nnvirtual-catchup-group
9983 (gnus-group-real-name gnus-newsgroup-name
) (nth 1 method
) all
)))
9984 (gnus-summary-position-cursor)))
9986 (defun gnus-summary-catchup-to-here (&optional all
)
9987 "Mark all unticked articles before the current one as read.
9988 If ALL is non-nil, also mark ticked and dormant articles as read."
9990 (gnus-set-global-variables)
9992 (and (zerop (forward-line -
1))
9995 (gnus-summary-catchup all t
(point))
9996 (gnus-set-mode-line 'summary
))))
9997 (gnus-summary-position-cursor))
9999 (defun gnus-summary-catchup-all (&optional quietly
)
10000 "Mark all articles in this newsgroup as read."
10002 (gnus-set-global-variables)
10003 (gnus-summary-catchup t quietly
))
10005 (defun gnus-summary-catchup-and-exit (&optional all quietly
)
10006 "Mark all articles not marked as unread in this newsgroup as read, then exit.
10007 If prefix argument ALL is non-nil, all articles are marked as read."
10009 (gnus-set-global-variables)
10010 (gnus-summary-catchup all quietly nil
'fast
)
10011 ;; Select next newsgroup or exit.
10012 (if (and (eq gnus-auto-select-next
'quietly
)
10013 (not (gnus-ephemeral-group-p gnus-newsgroup-name
)))
10014 (gnus-summary-next-group nil
)
10015 (gnus-summary-exit)))
10017 (defun gnus-summary-catchup-all-and-exit (&optional quietly
)
10018 "Mark all articles in this newsgroup as read, and then exit."
10020 (gnus-set-global-variables)
10021 (gnus-summary-catchup-and-exit t quietly
))
10023 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
10024 (defun gnus-summary-catchup-and-goto-next-group (&optional all
)
10025 "Mark all articles in this group as read and select the next group.
10026 If given a prefix, mark all articles, unread as well as ticked, as
10029 (gnus-set-global-variables)
10030 (gnus-summary-catchup all
)
10031 (gnus-summary-next-group))
10033 ;; Thread-based commands.
10035 (defun gnus-summary-toggle-threads (&optional arg
)
10036 "Toggle showing conversation threads.
10037 If ARG is positive number, turn showing conversation threads on."
10039 (gnus-set-global-variables)
10040 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end
)))
10041 (setq gnus-show-threads
10042 (if (null arg
) (not gnus-show-threads
)
10043 (> (prefix-numeric-value arg
) 0)))
10044 (gnus-summary-prepare)
10045 (gnus-summary-goto-subject current
)
10046 (gnus-summary-position-cursor)))
10048 (defun gnus-summary-show-all-threads ()
10049 "Show all threads."
10051 (gnus-set-global-variables)
10053 (let ((buffer-read-only nil
))
10054 (subst-char-in-region (point-min) (point-max) ?\^M ?
\n t
)))
10055 (gnus-summary-position-cursor))
10057 (defun gnus-summary-show-thread ()
10058 "Show thread subtrees.
10059 Returns nil if no thread was there to be shown."
10061 (gnus-set-global-variables)
10062 (let ((buffer-read-only nil
)
10063 (orig (prog1 (point) (gnus-summary-hide-thread)))
10064 ;; first goto end then to beg, to have point at beg after let
10065 (end (progn (end-of-line) (point)))
10066 (beg (progn (beginning-of-line) (point))))
10068 ;; Any hidden lines here?
10069 (search-forward "\r" end t
)
10070 (subst-char-in-region beg end ?\^M ?
\n t
)
10072 (gnus-summary-position-cursor))))
10074 (defun gnus-summary-hide-all-threads ()
10075 "Hide all thread subtrees."
10077 (gnus-set-global-variables)
10079 (goto-char (point-min))
10080 (gnus-summary-hide-thread)
10081 (while (and (not (eobp)) (zerop (forward-line 1)))
10082 (gnus-summary-hide-thread)))
10083 (gnus-summary-position-cursor))
10085 (defun gnus-summary-hide-thread ()
10086 "Hide thread subtrees.
10087 Returns nil if no threads were there to be hidden."
10089 (gnus-set-global-variables)
10090 (let ((buffer-read-only nil
)
10092 (level (gnus-summary-thread-level))
10094 ;; Go forward until either the buffer ends or the subthread
10098 (while (and (zerop (forward-line 1))
10099 (> (gnus-summary-thread-level) level
))
10100 (setq end
(point)))
10104 (search-backward "\n" start t
))
10105 (subst-char-in-region start end ?
\n ?\^M t
)
10107 (gnus-summary-position-cursor)))))
10109 (defun gnus-summary-go-to-next-thread (&optional previous
)
10110 "Go to the same level (or less) next thread.
10111 If PREVIOUS is non-nil, go to previous thread instead.
10112 Return the article number moved to, or nil if moving was impossible."
10113 (let ((level (gnus-summary-thread-level))
10114 (article (gnus-summary-article-number)))
10116 (while (and (zerop (forward-line -
1))
10117 (> (gnus-summary-thread-level) level
)))
10118 (while (and (save-excursion
10121 (zerop (forward-line 1))
10122 (> (gnus-summary-thread-level) level
))))
10123 (gnus-summary-recenter)
10124 (gnus-summary-position-cursor)
10125 (let ((oart (gnus-summary-article-number)))
10126 (and (/= oart article
) oart
))))
10128 (defun gnus-summary-next-thread (n)
10129 "Go to the same level next N'th thread.
10130 If N is negative, search backward instead.
10131 Returns the difference between N and the number of skips actually
10134 (gnus-set-global-variables)
10135 (let ((backward (< n
0))
10137 (while (and (> n
0)
10138 (gnus-summary-go-to-next-thread backward
))
10140 (gnus-summary-position-cursor)
10141 (if (/= 0 n
) (gnus-message 7 "No more threads"))
10144 (defun gnus-summary-prev-thread (n)
10145 "Go to the same level previous N'th thread.
10146 Returns the difference between N and the number of skips actually
10149 (gnus-set-global-variables)
10150 (gnus-summary-next-thread (- n
)))
10152 (defun gnus-summary-go-down-thread (&optional same
)
10153 "Go down one level in the current thread.
10154 If SAME is non-nil, also move to articles of the same level."
10155 (let ((level (gnus-summary-thread-level))
10157 (if (and (zerop (forward-line 1))
10158 (> (gnus-summary-thread-level) level
))
10163 (defun gnus-summary-go-up-thread ()
10164 "Go up one level in the current thread."
10165 (let ((level (gnus-summary-thread-level))
10167 (while (and (zerop (forward-line -
1))
10168 (>= (gnus-summary-thread-level) level
)))
10169 (if (>= (gnus-summary-thread-level) level
)
10175 (defun gnus-summary-down-thread (n)
10176 "Go down thread N steps.
10177 If N is negative, go up instead.
10178 Returns the difference between N and how many steps down that were
10181 (gnus-set-global-variables)
10184 (while (and (> n
0)
10185 (if up
(gnus-summary-go-up-thread)
10186 (gnus-summary-go-down-thread)))
10188 (gnus-summary-position-cursor)
10189 (if (/= 0 n
) (gnus-message 7 "Can't go further"))
10192 (defun gnus-summary-up-thread (n)
10193 "Go up thread N steps.
10194 If N is negative, go up instead.
10195 Returns the difference between N and how many steps down that were
10198 (gnus-set-global-variables)
10199 (gnus-summary-down-thread (- n
)))
10201 (defun gnus-summary-kill-thread (&optional unmark
)
10202 "Mark articles under current thread as read.
10203 If the prefix argument is positive, remove any kinds of marks.
10204 If the prefix argument is negative, tick articles instead."
10206 (gnus-set-global-variables)
10208 (setq unmark
(prefix-numeric-value unmark
)))
10210 (level (gnus-summary-thread-level)))
10212 ;; Expand the thread.
10213 (gnus-summary-show-thread)
10215 ;; Mark the article...
10216 (cond ((null unmark
) (gnus-summary-mark-article-as-read
10218 ((> unmark
0) (gnus-summary-mark-article-as-unread
10220 (t (gnus-summary-mark-article-as-unread gnus-ticked-mark
)))
10221 ;; ...and go forward until either the buffer ends or the subtree
10223 (if (not (and (zerop (forward-line 1))
10224 (> (gnus-summary-thread-level) level
)))
10225 (setq killing nil
))))
10226 ;; Hide killed subtrees.
10228 gnus-thread-hide-killed
10229 (gnus-summary-hide-thread))
10230 ;; If marked as read, go to next unread subject.
10232 ;; Go to next unread subject.
10233 (gnus-summary-next-subject 1 t
)))
10234 (gnus-set-mode-line 'summary
))
10236 ;; Summary sorting commands
10238 (defun gnus-summary-sort-by-number (&optional reverse
)
10239 "Sort summary buffer by article number.
10240 Argument REVERSE means reverse order."
10242 (gnus-set-global-variables)
10244 ;; `gnus-summary-article-number' is a macro, and `sort-subr' wants
10245 ;; a function, so we wrap it.
10246 (cons (lambda () (gnus-summary-article-number))
10247 'gnus-thread-sort-by-number
) reverse
))
10249 (defun gnus-summary-sort-by-author (&optional reverse
)
10250 "Sort summary buffer by author name alphabetically.
10251 If case-fold-search is non-nil, case of letters is ignored.
10252 Argument REVERSE means reverse order."
10254 (gnus-set-global-variables)
10258 (let* ((header (gnus-get-header-by-num (gnus-summary-article-number)))
10260 (if (not (vectorp header
))
10262 (setq extract
(funcall gnus-extract-address-components
10263 (mail-header-from header
)))
10264 (concat (or (car extract
) (cdr extract
))
10265 "\r" (int-to-string (mail-header-number header
))
10266 "\r" (mail-header-subject header
)))))
10267 'gnus-thread-sort-by-author
)
10270 (defun gnus-summary-sort-by-subject (&optional reverse
)
10271 "Sort summary buffer by subject alphabetically. `Re:'s are ignored.
10272 If case-fold-search is non-nil, case of letters is ignored.
10273 Argument REVERSE means reverse order."
10275 (gnus-set-global-variables)
10279 (let* ((header (gnus-get-header-by-num (gnus-summary-article-number)))
10281 (if (not (vectorp header
))
10283 (setq extract
(funcall gnus-extract-address-components
10284 (mail-header-from header
)))
10286 (downcase (gnus-simplify-subject (gnus-summary-subject-string) t
))
10287 "\r" (int-to-string (mail-header-number header
))
10288 "\r" (or (car extract
) (cdr extract
))))))
10289 'gnus-thread-sort-by-subject
)
10292 (defun gnus-summary-sort-by-date (&optional reverse
)
10293 "Sort summary buffer by date.
10294 Argument REVERSE means reverse order."
10296 (gnus-set-global-variables)
10300 (gnus-sortable-date
10302 (gnus-get-header-by-num (gnus-summary-article-number)))))
10303 'gnus-thread-sort-by-date
)
10306 (defun gnus-summary-sort-by-score (&optional reverse
)
10307 "Sort summary buffer by score.
10308 Argument REVERSE means reverse order."
10310 (gnus-set-global-variables)
10312 (cons (lambda () (gnus-summary-article-score))
10313 'gnus-thread-sort-by-score
)
10316 (defvar gnus-summary-already-sorted nil
)
10317 (defun gnus-summary-sort (predicate reverse
)
10318 ;; Sort summary buffer by PREDICATE. REVERSE means reverse order.
10319 (if gnus-summary-already-sorted
10321 (let (buffer-read-only)
10322 (if (not gnus-show-threads
)
10323 ;; We do untreaded sorting...
10325 (goto-char (point-min))
10326 (sort-subr reverse
'forward-line
'end-of-line
(car predicate
)))
10327 ;; ... or we do threaded sorting.
10328 (let ((gnus-thread-sort-functions (list (cdr predicate
)))
10329 (gnus-summary-prepare-hook nil
)
10330 (gnus-summary-already-sorted nil
))
10331 ;; We do that by simply regenerating the threads.
10332 (gnus-summary-prepare)
10333 (and gnus-show-threads
10334 gnus-thread-hide-subtree
10335 (gnus-summary-hide-all-threads))
10336 ;; If in async mode, we send some info to the backend.
10337 (and gnus-newsgroup-async
10338 (setq gnus-newsgroup-threads
(nreverse gnus-newsgroup-threads
))
10339 (gnus-request-asynchronous
10340 gnus-newsgroup-name
10341 (if (and gnus-asynchronous-article-function
10342 (fboundp gnus-asynchronous-article-function
))
10343 (funcall gnus-asynchronous-article-function
10344 gnus-newsgroup-threads
)
10345 gnus-newsgroup-threads
))))))))
10348 (defun gnus-sortable-date (date)
10349 "Make sortable string by string-lessp from DATE.
10350 Timezone package is used."
10351 (let* ((date (timezone-fix-time date nil nil
)) ;[Y M D H M S]
10352 (year (aref date
0))
10353 (month (aref date
1))
10354 (day (aref date
2)))
10355 (timezone-make-sortable-date
10357 (timezone-make-time-string
10358 (aref date
3) (aref date
4) (aref date
5)))))
10361 ;; Summary saving commands.
10363 (defun gnus-summary-save-article (&optional n
)
10364 "Save the current article using the default saver function.
10365 If N is a positive number, save the N next articles.
10366 If N is a negative number, save the N previous articles.
10367 If N is nil and any articles have been marked with the process mark,
10368 save those articles instead.
10369 The variable `gnus-default-article-saver' specifies the saver function."
10371 (gnus-set-global-variables)
10372 (let ((articles (gnus-summary-work-articles n
)))
10374 (let ((header (gnus-get-header-by-num (car articles
))))
10375 (if (vectorp header
)
10377 (save-window-excursion
10378 (gnus-summary-select-article t nil nil
(car articles
)))
10379 (or gnus-save-all-headers
10380 (gnus-article-hide-headers t
))
10381 ;; Remove any X-Gnus lines.
10384 (set-buffer gnus-article-buffer
)
10385 (let ((buffer-read-only nil
))
10386 (goto-char (point-min))
10387 (narrow-to-region (point) (or (search-forward "\n\n" nil t
)
10389 (while (re-search-forward "^X-Gnus" nil t
)
10390 (beginning-of-line)
10391 (delete-region (point)
10392 (progn (forward-line 1) (point))))
10394 (save-window-excursion
10395 (if gnus-default-article-saver
10396 (funcall gnus-default-article-saver
)
10397 (error "No default saver is defined."))))
10398 (if (assq 'name header
)
10399 (gnus-copy-file (cdr (assq 'name header
)))
10400 (gnus-message 1 "Article %d is unsavable" (car articles
)))))
10401 (gnus-summary-remove-process-mark (car articles
))
10402 (setq articles
(cdr articles
)))
10403 (gnus-summary-position-cursor)
10406 (defun gnus-summary-pipe-output (&optional arg
)
10407 "Pipe the current article to a subprocess.
10408 If N is a positive number, pipe the N next articles.
10409 If N is a negative number, pipe the N previous articles.
10410 If N is nil and any articles have been marked with the process mark,
10411 pipe those articles instead."
10413 (gnus-set-global-variables)
10414 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe
))
10415 (gnus-summary-save-article arg
)))
10417 (defun gnus-summary-save-article-mail (&optional arg
)
10418 "Append the current article to an mail file.
10419 If N is a positive number, save the N next articles.
10420 If N is a negative number, save the N previous articles.
10421 If N is nil and any articles have been marked with the process mark,
10422 save those articles instead."
10424 (gnus-set-global-variables)
10425 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail
))
10426 (gnus-summary-save-article arg
)))
10428 (defun gnus-summary-save-article-rmail (&optional arg
)
10429 "Append the current article to an rmail file.
10430 If N is a positive number, save the N next articles.
10431 If N is a negative number, save the N previous articles.
10432 If N is nil and any articles have been marked with the process mark,
10433 save those articles instead."
10435 (gnus-set-global-variables)
10436 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail
))
10437 (gnus-summary-save-article arg
)))
10439 (defun gnus-summary-save-article-file (&optional arg
)
10440 "Append the current article to a file.
10441 If N is a positive number, save the N next articles.
10442 If N is a negative number, save the N previous articles.
10443 If N is nil and any articles have been marked with the process mark,
10444 save those articles instead."
10446 (gnus-set-global-variables)
10447 (let ((gnus-default-article-saver 'gnus-summary-save-in-file
))
10448 (gnus-summary-save-article arg
)))
10450 (defun gnus-read-save-file-name (prompt default-name
)
10451 (let ((methods gnus-split-methods
)
10453 (if (not gnus-split-methods
)
10456 (set-buffer gnus-article-buffer
)
10457 (gnus-narrow-to-headers)
10459 (goto-char (point-min))
10460 (and (condition-case ()
10461 (re-search-forward (car (car methods
)) nil t
)
10463 (setq split-name
(cons (nth 1 (car methods
)) split-name
)))
10464 (setq methods
(cdr methods
)))
10466 (cond ((null split-name
)
10468 (concat prompt
" (default "
10469 (file-name-nondirectory default-name
) ") ")
10470 (file-name-directory default-name
)
10472 ((= 1 (length split-name
))
10474 (concat prompt
" (default " (car split-name
) ") ")
10475 gnus-article-save-directory
10476 (concat gnus-article-save-directory
(car split-name
))))
10478 (setq split-name
(mapcar (lambda (el) (list el
))
10479 (nreverse split-name
)))
10480 (let ((result (completing-read
10481 (concat prompt
" ")
10482 split-name nil nil
)))
10483 (concat gnus-article-save-directory
10484 (if (string= result
"")
10485 (car (car split-name
))
10488 (defun gnus-summary-save-in-rmail (&optional filename
)
10489 "Append this article to Rmail file.
10490 Optional argument FILENAME specifies file name.
10491 Directory to save to is default to `gnus-article-save-directory' which
10492 is initialized from the SAVEDIR environment variable."
10494 (gnus-set-global-variables)
10495 (let ((default-name
10496 (funcall gnus-rmail-save-name gnus-newsgroup-name
10497 gnus-current-headers gnus-newsgroup-last-rmail
)))
10499 (setq filename
(gnus-read-save-file-name
10500 "Save in rmail file:" default-name
)))
10501 (gnus-make-directory (file-name-directory filename
))
10502 (gnus-eval-in-buffer-window
10503 gnus-article-buffer
10507 (gnus-output-to-rmail filename
))))
10508 ;; Remember the directory name to save articles
10509 (setq gnus-newsgroup-last-rmail filename
)))
10511 (defun gnus-summary-save-in-mail (&optional filename
)
10512 "Append this article to Unix mail file.
10513 Optional argument FILENAME specifies file name.
10514 Directory to save to is default to `gnus-article-save-directory' which
10515 is initialized from the SAVEDIR environment variable."
10517 (gnus-set-global-variables)
10518 (let ((default-name
10519 (funcall gnus-mail-save-name gnus-newsgroup-name
10520 gnus-current-headers gnus-newsgroup-last-mail
)))
10522 (setq filename
(gnus-read-save-file-name
10523 "Save in Unix mail file:" default-name
)))
10525 (expand-file-name filename
10527 (file-name-directory default-name
))))
10528 (gnus-make-directory (file-name-directory filename
))
10529 (gnus-eval-in-buffer-window
10530 gnus-article-buffer
10534 (if (and (file-readable-p filename
) (mail-file-babyl-p filename
))
10535 (gnus-output-to-rmail filename
)
10536 (rmail-output filename
1 t t
)))))
10537 ;; Remember the directory name to save articles.
10538 (setq gnus-newsgroup-last-mail filename
)))
10540 (defun gnus-summary-save-in-file (&optional filename
)
10541 "Append this article to file.
10542 Optional argument FILENAME specifies file name.
10543 Directory to save to is default to `gnus-article-save-directory' which
10544 is initialized from the SAVEDIR environment variable."
10546 (gnus-set-global-variables)
10547 (let ((default-name
10548 (funcall gnus-file-save-name gnus-newsgroup-name
10549 gnus-current-headers gnus-newsgroup-last-file
)))
10551 (setq filename
(gnus-read-save-file-name
10552 "Save in file:" default-name
)))
10553 (gnus-make-directory (file-name-directory filename
))
10554 (gnus-eval-in-buffer-window
10555 gnus-article-buffer
10559 (gnus-output-to-file filename
))))
10560 ;; Remember the directory name to save articles.
10561 (setq gnus-newsgroup-last-file filename
)))
10563 (defun gnus-summary-save-in-pipe (&optional command
)
10564 "Pipe this article to subprocess."
10566 (gnus-set-global-variables)
10567 (let ((command (read-string "Shell command on article: "
10568 gnus-last-shell-command
)))
10569 (if (string-equal command
"")
10570 (setq command gnus-last-shell-command
))
10571 (gnus-eval-in-buffer-window
10572 gnus-article-buffer
10575 (shell-command-on-region (point-min) (point-max) command nil
)))
10576 (setq gnus-last-shell-command command
)))
10578 ;; Summary extract commands
10580 (defun gnus-summary-insert-pseudos (pslist &optional not-view
)
10581 (let ((buffer-read-only nil
)
10582 (article (gnus-summary-article-number))
10584 (or (gnus-summary-goto-subject article
)
10585 (error (format "No such article: %d" article
)))
10586 (gnus-summary-position-cursor)
10587 ;; If all commands are to be bunched up on one line, we collect
10589 (if gnus-view-pseudos-separately
10591 (let ((ps (setq pslist
(sort pslist
'gnus-pseudos
<)))
10594 (setq action
(cdr (assq 'action
(car ps
))))
10595 (setq files
(list (cdr (assq 'name
(car ps
)))))
10596 (while (and ps
(cdr ps
)
10597 (string= (or action
"1")
10598 (or (cdr (assq 'action
(car (cdr ps
)))) "2")))
10599 (setq files
(cons (cdr (assq 'name
(car (cdr ps
)))) files
))
10600 (setcdr ps
(cdr (cdr ps
))))
10603 (if (not (string-match "%s" action
))
10604 (setq files
(cons " " files
)))
10605 (setq files
(cons " " files
))
10606 (and (assq 'execute
(car ps
))
10607 (setcdr (assq 'execute
(car ps
))
10608 (funcall (if (string-match "%s" action
)
10611 (mapconcat (lambda (f) f
) files
" ")))))
10612 (setq ps
(cdr ps
)))))
10613 (if (and gnus-view-pseudos
(not not-view
))
10615 (and (assq 'execute
(car pslist
))
10616 (gnus-execute-command (cdr (assq 'execute
(car pslist
)))
10617 (eq gnus-view-pseudos
'not-confirm
)))
10618 (setq pslist
(cdr pslist
)))
10621 (gnus-summary-goto-subject (or (cdr (assq 'article
(car pslist
)))
10622 (gnus-summary-article-number)))
10625 (insert " " (file-name-nondirectory
10626 (cdr (assq 'name
(car pslist
))))
10627 ": " (or (cdr (assq 'execute
(car pslist
))) "") "\n")
10628 (add-text-properties
10629 b
(1+ b
) (list 'gnus-number gnus-reffed-article-number
10630 'gnus-mark gnus-unread-mark
10632 'gnus-pseudo
(car pslist
)))
10634 (gnus-sethash (int-to-string gnus-reffed-article-number
)
10635 (car pslist
) gnus-newsgroup-headers-hashtb-by-number
)
10636 (setq gnus-newsgroup-unreads
10637 (cons gnus-reffed-article-number gnus-newsgroup-unreads
))
10638 (setq gnus-reffed-article-number
(1- gnus-reffed-article-number
))
10639 (setq pslist
(cdr pslist
)))))))
10641 (defun gnus-pseudos< (p1 p2
)
10642 (let ((c1 (cdr (assq 'action p1
)))
10643 (c2 (cdr (assq 'action p2
))))
10644 (and c1 c2
(string< c1 c2
))))
10646 (defun gnus-request-pseudo-article (props)
10647 (cond ((assq 'execute props
)
10648 (gnus-execute-command (cdr (assq 'execute props
)))))
10649 (let ((gnus-current-article (gnus-summary-article-number)))
10650 (run-hooks 'gnus-mark-article-hook
)))
10652 (defun gnus-execute-command (command &optional automatic
)
10654 (gnus-article-setup-buffer)
10655 (set-buffer gnus-article-buffer
)
10656 (let ((command (if automatic command
(read-string "Command: " command
)))
10657 (buffer-read-only nil
))
10659 (insert "$ " command
"\n\n")
10660 (if gnus-view-pseudo-asynchronously
10661 (start-process "gnus-execute" nil
"sh" "-c" command
)
10662 (call-process "sh" nil t nil
"-c" command
)))))
10664 (defun gnus-copy-file (file &optional to
)
10667 (list (read-file-name "Copy file: " default-directory
)
10668 (read-file-name "Copy file to: " default-directory
)))
10669 (gnus-set-global-variables)
10670 (or to
(setq to
(read-file-name "Copy file to: " default-directory
)))
10671 (and (file-directory-p to
)
10672 (setq to
(concat (file-name-as-directory to
)
10673 (file-name-nondirectory file
))))
10674 (copy-file file to
))
10676 ;; Summary kill commands.
10678 (defun gnus-summary-edit-global-kill (article)
10679 "Edit the \"global\" kill file."
10680 (interactive (list (gnus-summary-article-number)))
10681 (gnus-set-global-variables)
10682 (gnus-group-edit-global-kill article
))
10684 (defun gnus-summary-edit-local-kill ()
10685 "Edit a local kill file applied to the current newsgroup."
10687 (gnus-set-global-variables)
10688 (setq gnus-current-headers
10690 (int-to-string (gnus-summary-article-number))
10691 gnus-newsgroup-headers-hashtb-by-number
))
10692 (gnus-set-global-variables)
10693 (gnus-group-edit-local-kill
10694 (gnus-summary-article-number) gnus-newsgroup-name
))
10698 ;;; Gnus article mode
10701 (put 'gnus-article-mode
'mode-class
'special
)
10703 (defvar gnus-bugaboo nil
)
10705 (if gnus-article-mode-map
10707 (setq gnus-article-mode-map
(make-keymap))
10708 (suppress-keymap gnus-article-mode-map
)
10709 (define-key gnus-article-mode-map
" " 'gnus-article-next-page
)
10710 (define-key gnus-article-mode-map
"\177" 'gnus-article-prev-page
)
10711 (define-key gnus-article-mode-map
"\C-c^" 'gnus-article-refer-article
)
10712 (define-key gnus-article-mode-map
"h" 'gnus-article-show-summary
)
10713 (define-key gnus-article-mode-map
"s" 'gnus-article-show-summary
)
10714 (define-key gnus-article-mode-map
"\C-c\C-m" 'gnus-article-mail
)
10715 (define-key gnus-article-mode-map
"?" 'gnus-article-describe-briefly
)
10716 (define-key gnus-article-mode-map gnus-mouse-2
'gnus-article-push-button
)
10717 (define-key gnus-article-mode-map
"\r" 'gnus-article-press-button
)
10718 (define-key gnus-article-mode-map
"\t" 'gnus-article-next-button
)
10719 (define-key gnus-article-mode-map
"\C-c\C-b" 'gnus-bug
)
10721 ;; Duplicate almost all summary keystrokes in the article mode map.
10724 "p" "N" "P" "\M-\C-n" "\M-\C-p"
10725 "\M-n" "\M-p" "." "," "\M-s" "\M-r" "<" ">" "j"
10726 "u" "!" "U" "d" "D" "E" "\M-u" "\M-U" "k" "\C-k" "\M-\C-k"
10727 "\M-\C-l" "e" "#" "\M-#" "\M-\C-t" "\M-\C-s" "\M-\C-h"
10728 "\M-\C-f" "\M-\C-b" "\M-\C-u" "\M-\C-d" "&" "\C-w"
10729 "\C-t" "?" "\C-c\M-\C-s" "\C-c\C-s\C-n" "\C-c\C-s\C-a"
10730 "\C-c\C-s\C-s" "\C-c\C-s\C-d" "\C-c\C-s\C-i" "\C-x\C-s"
10731 "\M-g" "w" "\C-c\C-r" "\M-t" "C"
10732 "o" "\C-o" "|" "\M-k" "\M-K" "V" "\C-c\C-d"
10733 "\C-c\C-i" "x" "X" "t" "g" "?" "l"
10734 "\C-c\C-v\C-v" "\C-d" "v"
10735 ;; "Mt" "M!" "Md" "Mr"
10736 ;; "Mc" "M " "Me" "Mx" "M?" "Mb" "MB" "M#" "M\M-#" "M\M-r"
10737 ;; "M\M-\C-r" "MD" "M\M-D" "MS" "MC" "MH" "M\C-c" "Mk" "MK"
10738 ;; "Ms" "Mc" "Mu" "Mm" "Mk" "Gn" "Gp" "GN" "GP" "G\C-n" "G\C-p"
10739 ;; "G\M-n" "G\M-p" "Gf" "Gb" "Gg" "Gl" "Gp" "Tk" "Tl" "Ti" "TT"
10740 ;; "Ts" "TS" "Th" "TH" "Tn" "Tp" "Tu" "Td" "T#" "A " "An" "A\177" "Ap"
10741 ;; "A\r" "A<" "A>" "Ab" "Ae" "A^" "Ar" "Aw" "Ac" "Ag" "At" "Am"
10742 ;; "As" "Wh" "Ws" "Wc" "Wo" "Ww" "Wd" "Wq" "Wf" "Wt" "W\C-t"
10743 ;; "WT" "WA" "Wa" "WH" "WC" "WS" "Wb" "Hv" "Hf" "Hd" "Hh" "Hi"
10744 ;; "Be" "B\177" "Bm" "Br" "Bw" "Bc" "Bq" "Bi" "Oo" "Om" "Or"
10745 ;; "Of" "Oh" "Ov" "Op" "Vu" "V\C-s" "V\C-r" "Vr" "V&" "VT" "Ve"
10746 ;; "VD" "Vk" "VK" "Vsn" "Vsa" "Vss" "Vsd" "Vsi"
10748 (while (and gnus-bugaboo commands
) ; disabled
10749 (define-key gnus-article-mode-map
(car commands
)
10750 'gnus-article-summary-command
)
10751 (setq commands
(cdr commands
))))
10753 (let ((commands (list "q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F"
10754 ;; "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
10755 "=" "n" "^" "\M-^")))
10756 (while (and gnus-bugaboo commands
) ; disabled
10757 (define-key gnus-article-mode-map
(car commands
)
10758 'gnus-article-summary-command-nosave
)
10759 (setq commands
(cdr commands
)))))
10762 (defun gnus-article-mode ()
10763 "Major mode for displaying an article.
10765 All normal editing commands are switched off.
10767 The following commands are available:
10769 \\<gnus-article-mode-map>
10770 \\[gnus-article-next-page]\t Scroll the article one page forwards
10771 \\[gnus-article-prev-page]\t Scroll the article one page backwards
10772 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
10773 \\[gnus-article-show-summary]\t Display the summary buffer
10774 \\[gnus-article-mail]\t Send a reply to the address near point
10775 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
10776 \\[gnus-info-find-node]\t Go to the Gnus info node"
10778 (if gnus-visual
(gnus-article-make-menu-bar))
10779 (kill-all-local-variables)
10780 (gnus-simplify-mode-line)
10781 (setq mode-name
"Article")
10782 (setq major-mode
'gnus-article-mode
)
10783 (make-local-variable 'minor-mode-alist
)
10784 (or (assq 'gnus-show-mime minor-mode-alist
)
10785 (setq minor-mode-alist
10786 (cons (list 'gnus-show-mime
" MIME") minor-mode-alist
)))
10787 (use-local-map gnus-article-mode-map
)
10788 (make-local-variable 'page-delimiter
)
10789 (setq page-delimiter gnus-page-delimiter
)
10790 (buffer-disable-undo (current-buffer))
10791 (setq buffer-read-only t
) ;Disable modification
10792 (run-hooks 'gnus-article-mode-hook
))
10794 (defun gnus-article-setup-buffer ()
10795 "Initialize article mode buffer."
10796 ;; Returns the article buffer.
10797 (if (get-buffer gnus-article-buffer
)
10799 (set-buffer gnus-article-buffer
)
10800 (buffer-disable-undo (current-buffer))
10801 (setq buffer-read-only t
)
10802 (gnus-add-current-to-buffer-list)
10803 (or (eq major-mode
'gnus-article-mode
)
10804 (gnus-article-mode))
10807 (set-buffer (get-buffer-create gnus-article-buffer
))
10808 (gnus-add-current-to-buffer-list)
10809 (gnus-article-mode)
10810 (current-buffer))))
10812 ;; Set article window start at LINE, where LINE is the number of lines
10813 ;; from the head of the article.
10814 (defun gnus-article-set-window-start (&optional line
)
10816 (get-buffer-window gnus-article-buffer
)
10818 (set-buffer gnus-article-buffer
)
10819 (goto-char (point-min))
10822 (gnus-message 6 "Moved to bookmark")
10823 (search-forward "\n\n" nil t
)
10824 (forward-line line
)
10827 (defun gnus-request-article-this-buffer (article group
)
10828 "Get an article and insert it into this buffer."
10829 (setq group
(or group gnus-newsgroup-name
))
10831 ;; Open server if it has closed.
10832 (gnus-check-server (gnus-find-method-for-group group
))
10834 ;; Using `gnus-request-article' directly will insert the article into
10835 ;; `nntp-server-buffer' - so we'll save some time by not having to
10836 ;; copy it from the server buffer into the article buffer.
10838 ;; We only request an article by message-id when we do not have the
10839 ;; headers for it, so we'll have to get those.
10840 (and (stringp article
)
10841 (let ((gnus-override-method gnus-refer-article-method
))
10842 (gnus-read-header article
)))
10844 ;; If the article number is negative, that means that this article
10845 ;; doesn't belong in this newsgroup (possibly), so we find its
10846 ;; message-id and request it by id instead of number.
10847 (if (not (numberp article
))
10850 (set-buffer gnus-summary-buffer
)
10851 (let ((header (gnus-get-header-by-num article
)))
10853 (if (vectorp header
)
10854 ;; It's a real article.
10855 (setq article
(mail-header-id header
))
10856 ;; It is an extracted pseudo-article.
10857 (setq article
'pseudo
)
10858 (gnus-request-pseudo-article header
)))
10860 (let ((method (gnus-find-method-for-group gnus-newsgroup-name
)))
10861 (if (not (eq (car method
) 'nneething
))
10863 (let ((dir (concat (file-name-as-directory (nth 1 method
))
10864 (mail-header-subject header
))))
10865 (if (file-directory-p dir
)
10867 (setq article
'nneething
)
10868 (gnus-group-enter-directory dir
)))))))))
10870 ;; Check the cache.
10871 (if (and gnus-use-cache
10873 (gnus-cache-request-article article group
))
10875 ;; Get the article and put into the article buffer.
10876 (if (or (stringp article
) (numberp article
))
10879 ;; There may be some overlays that we have to kill...
10881 (let ((overlays (and (fboundp 'overlays-at
)
10882 (overlays-at (point-min)))))
10884 (delete-overlay (car overlays
))
10885 (setq overlays
(cdr overlays
))))
10887 (let ((gnus-override-method
10888 (and (stringp article
) gnus-refer-article-method
)))
10889 (and (gnus-request-article article group
(current-buffer))
10893 (defun gnus-read-header (id)
10894 "Read the headers of article ID and enter them into the Gnus system."
10896 (if (not (setq header
10897 (car (if (let ((gnus-nov-is-evil t
))
10898 (gnus-retrieve-headers
10899 (list id
) gnus-newsgroup-name
))
10900 (gnus-get-newsgroup-headers)))))
10903 (mail-header-set-number header gnus-reffed-article-number
))
10904 (setq gnus-newsgroup-headers
(cons header gnus-newsgroup-headers
))
10905 (gnus-sethash (int-to-string (mail-header-number header
)) header
10906 gnus-newsgroup-headers-hashtb-by-number
)
10908 (setq gnus-reffed-article-number
(1- gnus-reffed-article-number
)))
10909 (setq gnus-current-headers header
)
10912 (defun gnus-article-prepare (article &optional all-headers header
)
10913 "Prepare ARTICLE in article mode buffer.
10914 ARTICLE should either be an article number or a Message-ID.
10915 If ARTICLE is an id, HEADER should be the article headers.
10916 If ALL-HEADERS is non-nil, no headers are hidden."
10918 ;; Make sure we start in a summary buffer.
10919 (or (eq major-mode
'gnus-summary-mode
)
10920 (set-buffer gnus-summary-buffer
))
10921 (setq gnus-summary-buffer
(current-buffer))
10922 ;; Make sure the connection to the server is alive.
10923 (or (gnus-server-opened (gnus-find-method-for-group gnus-newsgroup-name
))
10926 (gnus-find-method-for-group gnus-newsgroup-name
))
10927 (gnus-request-group gnus-newsgroup-name t
)))
10928 (let* ((article (if header
(mail-header-number header
) article
))
10929 (summary-buffer (current-buffer))
10930 (internal-hook gnus-article-internal-prepare-hook
)
10931 (group gnus-newsgroup-name
)
10934 (gnus-article-setup-buffer)
10935 (set-buffer gnus-article-buffer
)
10936 (if (not (setq result
(let ((buffer-read-only nil
))
10937 (gnus-request-article-this-buffer
10939 ;; There is no such article.
10941 (if (not (numberp article
))
10943 (setq gnus-article-current
10944 (cons gnus-newsgroup-name article
))
10945 (set-buffer gnus-summary-buffer
)
10946 (setq gnus-current-article article
)
10947 (gnus-summary-mark-article article gnus-canceled-mark
))
10948 (gnus-message 1 "No such article (may be canceled)")
10951 (if (or (eq result
'pseudo
) (eq result
'nneething
))
10954 (set-buffer summary-buffer
)
10955 (setq gnus-last-article gnus-current-article
10956 gnus-newsgroup-history
(cons gnus-current-article
10957 gnus-newsgroup-history
)
10958 gnus-current-article
0
10959 gnus-current-headers nil
10960 gnus-article-current nil
)
10961 (if (eq result
'nneething
)
10962 (gnus-configure-windows 'summary
)
10963 (gnus-configure-windows 'article
))
10964 (gnus-set-global-variables))
10965 (gnus-set-mode-line 'article
))
10966 ;; The result from the `request' was an actual article -
10967 ;; or at least some text that is now displayed in the
10969 (if (and (numberp article
)
10970 (not (eq article gnus-current-article
)))
10971 ;; Seems like a new article has been selected.
10972 ;; `gnus-current-article' must be an article number.
10974 (set-buffer summary-buffer
)
10975 (setq gnus-last-article gnus-current-article
10976 gnus-newsgroup-history
(cons gnus-current-article
10977 gnus-newsgroup-history
)
10978 gnus-current-article article
10979 gnus-current-headers
10980 (gnus-get-header-by-num gnus-current-article
)
10981 gnus-article-current
10982 (cons gnus-newsgroup-name gnus-current-article
))
10983 (gnus-summary-show-thread)
10984 (run-hooks 'gnus-mark-article-hook
)
10985 (gnus-set-mode-line 'summary
)
10987 (run-hooks 'gnus-visual-mark-article-hook
))
10988 ;; Set the global newsgroup variables here.
10989 ;; Suggested by Jim Sisolak
10990 ;; <sisolak@trans4.neep.wisc.edu>.
10991 (gnus-set-global-variables)
10992 (setq gnus-have-all-headers
10993 (or all-headers gnus-show-all-headers
))
10994 (and gnus-use-cache
10995 (vectorp (gnus-get-header-by-number article
))
10996 (gnus-cache-possibly-enter-article
10998 (gnus-get-header-by-number article
)
10999 (memq article gnus-newsgroup-marked
)
11000 (memq article gnus-newsgroup-dormant
)
11001 (memq article gnus-newsgroup-unreads
)))))
11002 ;; Hooks for getting information from the article.
11003 ;; This hook must be called before being narrowed.
11004 (let (buffer-read-only)
11005 (run-hooks 'internal-hook
)
11006 (run-hooks 'gnus-article-prepare-hook
)
11007 ;; Decode MIME message.
11008 (if (and gnus-show-mime
11009 (or (not gnus-strict-mime
)
11010 (gnus-fetch-field "Mime-Version")))
11011 (funcall gnus-show-mime-method
))
11012 ;; Perform the article display hooks.
11013 (run-hooks 'gnus-article-display-hook
))
11015 (goto-char (point-min))
11016 (and gnus-break-pages
(gnus-narrow-to-page))
11017 (gnus-set-mode-line 'article
)
11018 (gnus-configure-windows 'article
)
11019 (goto-char (point-min))
11022 (defun gnus-article-show-all-headers ()
11023 "Show all article headers in article mode buffer."
11025 (gnus-article-setup-buffer)
11026 (set-buffer gnus-article-buffer
)
11027 (let ((buffer-read-only nil
))
11028 (remove-text-properties (point-min) (point-max)
11029 gnus-hidden-properties
))))
11031 (defun gnus-article-hide-headers-if-wanted ()
11032 "Hide unwanted headers if `gnus-have-all-headers' is nil.
11033 Provided for backwards compatibility."
11034 (or (save-excursion (set-buffer gnus-summary-buffer
) gnus-have-all-headers
)
11035 (gnus-article-hide-headers)))
11037 (defun gnus-article-hide-headers (&optional delete
)
11038 "Hide unwanted headers and possibly sort them as well."
11041 (set-buffer gnus-article-buffer
)
11043 (let ((sorted gnus-sorted-header-list
)
11044 (buffer-read-only nil
)
11045 want-list beg want-l
)
11046 ;; First we narrow to just the headers.
11048 (goto-char (point-min))
11049 ;; Hide any "From " lines at the beginning of (mail) articles.
11050 (while (looking-at "From ")
11053 (add-text-properties (point-min) (point) gnus-hidden-properties
))
11054 ;; Then treat the rest of the header lines.
11057 (progn (search-forward "\n\n" nil t
) (forward-line -
1) (point)))
11058 ;; Then we use the two regular expressions
11059 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
11060 ;; select which header lines is to remain visible in the
11062 (goto-char (point-min))
11063 (while (re-search-forward "^[^ \t]*:" nil t
)
11064 (beginning-of-line)
11065 ;; We add the headers we want to keep to a list and delete
11066 ;; them from the buffer.
11067 (if (or (and (stringp gnus-visible-headers
)
11068 (looking-at gnus-visible-headers
))
11069 (and (not (stringp gnus-visible-headers
))
11070 (stringp gnus-ignored-headers
)
11071 (not (looking-at gnus-ignored-headers
))))
11075 ;; Be sure to get multi-line headers...
11076 (re-search-forward "^[^ \t]*:" nil t
)
11077 (beginning-of-line)
11079 (cons (buffer-substring beg
(point)) want-list
))
11080 (delete-region beg
(point))
11083 ;; Next we perform the sorting by looking at
11084 ;; `gnus-sorted-header-list'.
11085 (goto-char (point-min))
11086 (while (and sorted want-list
)
11087 (setq want-l want-list
)
11089 (not (string-match (car sorted
) (car want-l
))))
11090 (setq want-l
(cdr want-l
)))
11093 (insert (car want-l
))
11094 (setq want-list
(delq (car want-l
) want-list
))))
11095 (setq sorted
(cdr sorted
)))
11096 ;; Any headers that were not matched by the sorted list we
11097 ;; just tack on the end of the visible header list.
11099 (insert (car want-list
))
11100 (setq want-list
(cdr want-list
)))
11101 ;; And finally we make the unwanted headers invisible.
11103 (delete-region (point) (point-max))
11104 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>.
11105 (add-text-properties (point) (point-max) gnus-hidden-properties
))))))
11107 ;; Written by Per Abrahamsen <amanda@iesd.auc.dk>.
11108 (defun gnus-article-treat-overstrike ()
11109 "Translate overstrikes into bold text."
11112 (set-buffer gnus-article-buffer
)
11113 (let ((buffer-read-only nil
))
11114 (while (search-forward "\b" nil t
)
11115 (let ((next (following-char))
11116 (previous (char-after (- (point) 2))))
11117 (cond ((eq next previous
)
11118 (put-text-property (- (point) 2) (point)
11120 (put-text-property (point) (1+ (point))
11123 (put-text-property (1- (point)) (1+ (point))
11125 (put-text-property (1- (point)) (point)
11128 (put-text-property (- (point) 2) (point)
11130 (put-text-property (point) (1+ (point))
11131 'face
'underline
))))))))
11133 (defun gnus-article-word-wrap ()
11134 "Format too long lines."
11137 (set-buffer gnus-article-buffer
)
11138 (let ((buffer-read-only nil
))
11139 (goto-char (point-min))
11140 (search-forward "\n\n" nil t
)
11142 (let ((paragraph-start "^[>|#:<;* ]*[ \t]*$")
11143 (adaptive-fill-regexp "[ \t]*\\([|#:<;>*]+ *\\)?")
11144 (adaptive-fill-mode t
))
11145 (while (not (eobp))
11146 (and (>= (current-column) (min fill-column
(window-width)))
11147 (/= (preceding-char) ?
:)
11148 (fill-paragraph nil
))
11149 (end-of-line 2))))))
11151 (defun gnus-article-remove-cr ()
11152 "Remove carriage returns from an article."
11155 (set-buffer gnus-article-buffer
)
11156 (let ((buffer-read-only nil
))
11157 (goto-char (point-min))
11158 (while (search-forward "\r" nil t
)
11159 (replace-match "" t t
)))))
11161 (defun gnus-article-display-x-face (&optional force
)
11162 "Look for an X-Face header and display it if present."
11163 (interactive (list 'force
))
11165 (set-buffer gnus-article-buffer
)
11166 (let ((inhibit-point-motion-hooks t
)
11167 (case-fold-search nil
)
11170 (goto-char (point-min))
11171 (search-forward "\n\n")
11172 (narrow-to-region (point-min) (point))
11173 (goto-char (point-min))
11174 (setq from
(mail-fetch-field "from"))
11175 (if (not (and gnus-article-x-face-command
11177 (not gnus-article-x-face-too-ugly
)
11178 (and gnus-article-x-face-too-ugly from
11179 (not (string-match gnus-article-x-face-too-ugly
11182 (goto-char (point-min))
11183 (re-search-forward "^X-Face: " nil t
))))
11185 (let ((beg (point))
11186 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t
))))
11187 (if (symbolp gnus-article-x-face-command
)
11188 (and (or (fboundp gnus-article-x-face-command
)
11189 (error "%s is not a function"
11190 gnus-article-x-face-command
))
11191 (funcall gnus-article-x-face-command beg end
))
11192 (call-process-region beg end
"sh" nil
0 nil
11193 "-c" gnus-article-x-face-command
))))))))
11195 (defun gnus-article-de-quoted-unreadable (&optional force
)
11196 "Do a naive translation of a quoted-printable-encoded article.
11197 This is in no way, shape or form meant as a replacement for real MIME
11198 processing, but is simply a stop-gap measure until MIME support is
11200 If FORCE, decode the article whether it is marked as quoted-printable
11202 (interactive (list 'force
))
11204 (set-buffer gnus-article-buffer
)
11205 (let ((case-fold-search t
)
11206 (buffer-read-only nil
)
11207 (type (gnus-fetch-field "content-transfer-encoding")))
11208 (if (or force
(and type
(string-match "quoted-printable" type
)))
11210 (goto-char (point-min))
11211 (search-forward "\n\n" nil
'move
)
11212 (gnus-mime-decode-quoted-printable (point) (point-max)))))))
11214 (defun gnus-mime-decode-quoted-printable (from to
)
11215 ;; Decode quoted-printable from region between FROM and TO.
11218 (while (search-forward "=" to t
)
11219 (cond ((eq (following-char) ?
\n)
11222 ((looking-at "[0-9A-F][0-9A-F]")
11224 (insert (hexl-hex-string-to-integer
11225 (buffer-substring (point) (+ 2 (point)))))
11229 ((gnus-message 3 "Malformed MIME quoted-printable message"))))))
11231 (defvar gnus-article-time-units
11232 (list (cons 'year
(* 365.25 24 60 60))
11233 (cons 'week
(* 7 24 60 60))
11234 (cons 'day
(* 24 60 60))
11235 (cons 'hour
(* 60 60))
11239 (defun gnus-article-date-ut (&optional type
)
11240 "Convert DATE date to universal time in the current article.
11241 If TYPE is `local', convert to local time; if it is `lapsed', output
11242 how much time has lapsed since DATE."
11243 (interactive (list 'ut
))
11244 (let ((date (mail-header-date (or gnus-current-headers
11245 (gnus-get-header-by-number
11246 (gnus-summary-article-number))"")))
11247 (date-regexp "^Date: \\|^X-Sent: "))
11252 (set-buffer gnus-article-buffer
)
11253 (let ((buffer-read-only nil
))
11254 (goto-char (point-min))
11255 (if (and (re-search-forward date-regexp nil t
)
11257 (beginning-of-line)
11258 (looking-at date-regexp
)))
11259 (delete-region (gnus-point-at-bol)
11260 (progn (end-of-line) (1+ (point))))
11261 (goto-char (point-min))
11262 (goto-char (- (search-forward "\n\n") 2)))
11266 (concat "Date: " (condition-case ()
11267 (timezone-make-date-arpa-standard date
)
11273 (timezone-make-date-arpa-standard date nil
"UT")
11277 ;; If the date is seriously mangled, the timezone
11278 ;; functions are liable to bug out, so we condition-case
11279 ;; the entire thing.
11280 (let* ((real-sec (condition-case ()
11281 (- (gnus-seconds-since-epoch
11282 (timezone-make-date-arpa-standard
11283 (current-time-string)
11284 (current-time-zone) "UT"))
11285 (gnus-seconds-since-epoch
11286 (timezone-make-date-arpa-standard
11289 (sec (abs real-sec
))
11297 (if (zerop (setq num
(ffloor (/ sec
(cdr unit
)))))
11299 (setq sec
(- sec
(* num
(cdr unit
))))
11301 (concat (if prev
", " "") (int-to-string
11303 " " (symbol-name (car unit
))
11304 (if (> num
1) "s" ""))
11306 gnus-article-time-units
"")
11309 " in the future\n")))))
11311 (error "Unknown conversion type: %s" type
)))))))))
11313 (defun gnus-article-date-local ()
11314 "Convert the current article date to the local timezone."
11316 (gnus-article-date-ut 'local
))
11318 (defun gnus-article-date-lapsed ()
11319 "Convert the current article date to time lapsed since it was sent."
11321 (gnus-article-date-ut 'lapsed
))
11323 (defun gnus-article-maybe-highlight ()
11324 "Do some article highlighting if `gnus-visual' is non-nil."
11325 (if gnus-visual
(gnus-article-highlight-some)))
11329 (defun gnus-output-to-rmail (file-name)
11330 "Append the current article to an Rmail file named FILE-NAME."
11332 ;; Most of these codes are borrowed from rmailout.el.
11333 (setq file-name
(expand-file-name file-name
))
11334 (setq rmail-default-rmail-file file-name
)
11335 (let ((artbuf (current-buffer))
11336 (tmpbuf (get-buffer-create " *Gnus-output*")))
11338 (or (get-file-buffer file-name
)
11339 (file-exists-p file-name
)
11340 (if (gnus-yes-or-no-p
11341 (concat "\"" file-name
"\" does not exist, create it? "))
11342 (let ((file-buffer (create-file-buffer file-name
)))
11344 (set-buffer file-buffer
)
11345 (rmail-insert-rmail-file-header)
11346 (let ((require-final-newline nil
))
11347 (write-region (point-min) (point-max) file-name t
1)))
11348 (kill-buffer file-buffer
))
11349 (error "Output file does not exist")))
11350 (set-buffer tmpbuf
)
11351 (buffer-disable-undo (current-buffer))
11353 (insert-buffer-substring artbuf
)
11354 (gnus-convert-article-to-rmail)
11355 ;; Decide whether to append to a file or to an Emacs buffer.
11356 (let ((outbuf (get-file-buffer file-name
)))
11358 (append-to-file (point-min) (point-max) file-name
)
11359 ;; File has been visited, in buffer OUTBUF.
11360 (set-buffer outbuf
)
11361 (let ((buffer-read-only nil
)
11362 (msg (and (boundp 'rmail-current-message
)
11363 (symbol-value 'rmail-current-message
))))
11364 ;; If MSG is non-nil, buffer is in RMAIL mode.
11367 (narrow-to-region (point-max) (point-max))))
11368 (insert-buffer-substring tmpbuf
)
11371 (goto-char (point-min))
11373 (search-backward "\^_")
11374 (narrow-to-region (point) (point-max))
11375 (goto-char (1+ (point-min)))
11376 (rmail-count-new-messages t
)
11377 (rmail-show-message msg
)))))))
11378 (kill-buffer tmpbuf
)))
11380 (defun gnus-output-to-file (file-name)
11381 "Append the current article to a file named FILE-NAME."
11382 (setq file-name
(expand-file-name file-name
))
11383 (let ((artbuf (current-buffer))
11384 (tmpbuf (get-buffer-create " *Gnus-output*")))
11386 (set-buffer tmpbuf
)
11387 (buffer-disable-undo (current-buffer))
11389 (insert-buffer-substring artbuf
)
11390 ;; Append newline at end of the buffer as separator, and then
11391 ;; save it to file.
11392 (goto-char (point-max))
11394 (append-to-file (point-min) (point-max) file-name
))
11395 (kill-buffer tmpbuf
)))
11397 (defun gnus-convert-article-to-rmail ()
11398 "Convert article in current buffer to Rmail message format."
11399 (let ((buffer-read-only nil
))
11400 ;; Convert article directly into Babyl format.
11401 ;; Suggested by Rob Austein <sra@lcs.mit.edu>
11402 (goto-char (point-min))
11403 (insert "\^L\n0, unseen,,\n*** EOOH ***\n")
11404 (while (search-forward "\n\^_" nil t
) ;single char
11405 (replace-match "\n^_" t t
)) ;2 chars: "^" and "_"
11406 (goto-char (point-max))
11409 (defun gnus-narrow-to-page (&optional arg
)
11410 "Make text outside current page invisible except for page delimiter.
11411 A numeric arg specifies to move forward or backward by that many pages,
11412 thus showing a page other than the one point was originally in."
11414 (setq arg
(if arg
(prefix-numeric-value arg
) 0))
11416 (forward-page -
1) ;Beginning of current page.
11421 (forward-page (1- arg
))))
11422 ;; Find the end of the page.
11424 ;; If we stopped due to end of buffer, stay there.
11425 ;; If we stopped after a page delimiter, put end of restriction
11426 ;; at the beginning of that line.
11427 ;; These are commented out.
11428 ;; (if (save-excursion (beginning-of-line)
11429 ;; (looking-at page-delimiter))
11430 ;; (beginning-of-line))
11431 (narrow-to-region (point)
11433 ;; Find the top of the page.
11435 ;; If we found beginning of buffer, stay there.
11436 ;; If extra text follows page delimiter on same line,
11438 ;; Otherwise, show text starting with following line.
11439 (if (and (eolp) (not (bobp)))
11443 (defun gnus-gmt-to-local ()
11444 "Rewrite Date header described in GMT to local in current buffer.
11445 Intended to be used with gnus-article-prepare-hook."
11449 (goto-char (point-min))
11450 (narrow-to-region (point-min)
11451 (progn (search-forward "\n\n" nil
'move
) (point)))
11452 (goto-char (point-min))
11453 (if (re-search-forward "^Date:[ \t]\\(.*\\)$" nil t
)
11454 (let ((buffer-read-only nil
)
11455 (date (buffer-substring-no-properties
11456 (match-beginning 1) (match-end 1))))
11457 (delete-region (match-beginning 1) (match-end 1))
11459 (timezone-make-date-arpa-standard
11460 date nil
(current-time-zone))))))))
11463 ;; Article mode commands
11465 (defun gnus-article-next-page (&optional lines
)
11466 "Show next page of current article.
11467 If end of article, return non-nil. Otherwise return nil.
11468 Argument LINES specifies lines to be scrolled up."
11470 (move-to-window-line -
1)
11471 ;; Fixed by enami@ptgd.sony.co.jp (enami tsugutomo)
11472 (if (save-excursion
11474 (and (pos-visible-in-window-p) ;Not continuation line.
11476 ;; Nothing in this page.
11477 (if (or (not gnus-break-pages
)
11480 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
11482 (gnus-narrow-to-page 1) ;Go to next page.
11484 ;; More in this page.
11488 ;; Long lines may cause an end-of-buffer error.
11489 (goto-char (point-max))))
11492 (defun gnus-article-prev-page (&optional lines
)
11493 "Show previous page of current article.
11494 Argument LINES specifies lines to be scrolled down."
11496 (move-to-window-line 0)
11497 (if (and gnus-break-pages
11499 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
11501 (gnus-narrow-to-page -
1) ;Go to previous page.
11502 (goto-char (point-max))
11504 (scroll-down lines
)))
11506 (defun gnus-article-refer-article ()
11507 "Read article specified by message-id around point."
11509 (search-forward ">" nil t
) ;Move point to end of "<....>".
11510 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t
)
11512 (buffer-substring (match-beginning 1) (match-end 1))))
11513 (set-buffer gnus-summary-buffer
)
11514 (gnus-summary-refer-article message-id
))
11515 (error "No references around point")))
11517 (defun gnus-article-show-summary ()
11518 "Reconfigure windows to show summary buffer."
11520 (gnus-configure-windows 'article
)
11521 (gnus-summary-goto-subject gnus-current-article
))
11523 (defun gnus-article-describe-briefly ()
11524 "Describe article mode commands briefly."
11527 (substitute-command-keys "\\<gnus-article-mode-map>\\[gnus-article-next-page]:Next page \\[gnus-article-prev-page]:Prev page \\[gnus-article-show-summary]:Show summary \\[gnus-info-find-node]:Run Info \\[gnus-article-describe-briefly]:This help")))
11529 (defun gnus-article-summary-command ()
11530 "Execute the last keystroke in the summary buffer."
11532 (let ((obuf (current-buffer))
11533 (owin (current-window-configuration))
11535 (switch-to-buffer gnus-summary-buffer
'norecord
)
11536 (setq func
(lookup-key (current-local-map) (this-command-keys)))
11537 (call-interactively func
)
11539 (set-window-configuration owin
)
11540 (set-window-point (get-buffer-window (current-buffer)) (point))))
11542 (defun gnus-article-summary-command-nosave ()
11543 "Execute the last keystroke in the summary buffer."
11546 (pop-to-buffer gnus-summary-buffer
'norecord
)
11547 (setq func
(lookup-key (current-local-map) (this-command-keys)))
11548 (call-interactively func
)))
11551 ;; Basic ideas by emv@math.lsa.umich.edu (Edward Vielmetti)
11554 (defalias 'gnus-batch-kill
'gnus-batch-score
)
11556 (defun gnus-batch-score ()
11557 "Run batched scoring.
11558 Usage: emacs -batch -l gnus -f gnus-batch-score <newsgroups> ...
11559 Newsgroups is a list of strings in Bnews format. If you want to score
11560 the comp hierarchy, you'd say \"comp.all\". If you would not like to
11561 score the alt hierarchy, you'd say \"!alt.all\"."
11564 (gnus-newsrc-parse-options
11565 (apply (function concat
)
11566 (mapcar (lambda (g) (concat g
" "))
11567 command-line-args-left
))))
11568 (gnus-expert-user t
)
11569 (nnmail-spool-file nil
)
11570 (gnus-use-dribble-file nil
)
11571 (yes (car yes-and-no
))
11572 (no (cdr yes-and-no
))
11574 ;; Disable verbose message.
11575 gnus-novice-user gnus-large-newsgroup
)
11576 ;; Eat all arguments.
11577 (setq command-line-args-left nil
)
11580 ;; Apply kills to specified newsgroups in command line arguments.
11581 (setq newsrc
(cdr gnus-newsrc-alist
))
11583 (setq group
(car (car newsrc
)))
11584 (setq entry
(gnus-gethash group gnus-newsrc-hashtb
))
11585 (if (and (<= (nth 1 (car newsrc
)) gnus-level-subscribed
)
11587 (or (eq (car entry
) t
)
11588 (not (zerop (car entry
)))))
11589 (if yes
(string-match yes group
) t
)
11590 (or (null no
) (not (string-match no group
))))
11592 (gnus-summary-read-group group nil t
)
11593 (and (eq (current-buffer) (get-buffer gnus-summary-buffer
))
11594 (gnus-summary-exit))))
11595 (setq newsrc
(cdr newsrc
)))
11597 (switch-to-buffer gnus-group-buffer
)
11598 (gnus-group-save-newsrc)))
11600 (defun gnus-apply-kill-file ()
11601 "Apply a kill file to the current newsgroup.
11602 Returns the number of articles marked as read."
11603 (if (or (file-exists-p (gnus-newsgroup-kill-file nil
))
11604 (file-exists-p (gnus-newsgroup-kill-file gnus-newsgroup-name
)))
11605 (gnus-apply-kill-file-internal)
11608 (defun gnus-kill-save-kill-buffer ()
11610 (let ((file (gnus-newsgroup-kill-file gnus-newsgroup-name
)))
11611 (if (get-file-buffer file
)
11613 (set-buffer (get-file-buffer file
))
11614 (and (buffer-modified-p) (save-buffer))
11615 (kill-buffer (current-buffer)))))))
11617 (defvar gnus-kill-file-name
"KILL"
11618 "Suffix of the kill files.")
11620 (defun gnus-newsgroup-kill-file (newsgroup)
11621 "Return the name of a kill file name for NEWSGROUP.
11622 If NEWSGROUP is nil, return the global kill file name instead."
11623 (cond ((or (null newsgroup
)
11624 (string-equal newsgroup
""))
11625 ;; The global KILL file is placed at top of the directory.
11626 (expand-file-name gnus-kill-file-name
11627 (or gnus-kill-files-directory
"~/News")))
11628 ((gnus-use-long-file-name 'not-kill
)
11629 ;; Append ".KILL" to newsgroup name.
11630 (expand-file-name (concat (gnus-newsgroup-savable-name newsgroup
)
11631 "." gnus-kill-file-name
)
11632 (or gnus-kill-files-directory
"~/News")))
11634 ;; Place "KILL" under the hierarchical directory.
11635 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup
)
11636 "/" gnus-kill-file-name
)
11637 (or gnus-kill-files-directory
"~/News")))))
11644 (defvar gnus-dribble-ignore nil
)
11645 (defvar gnus-dribble-eval-file nil
)
11647 (defun gnus-dribble-file-name ()
11648 (concat gnus-current-startup-file
"-dribble"))
11650 (defun gnus-dribble-enter (string)
11651 (if (and (not gnus-dribble-ignore
)
11652 gnus-dribble-buffer
11653 (buffer-name gnus-dribble-buffer
))
11654 (let ((obuf (current-buffer)))
11655 (set-buffer gnus-dribble-buffer
)
11656 (insert string
"\n")
11657 (set-window-point (get-buffer-window (current-buffer)) (point-max))
11658 (set-buffer obuf
))))
11660 (defun gnus-dribble-read-file ()
11661 (let ((dribble-file (gnus-dribble-file-name)))
11663 (set-buffer (setq gnus-dribble-buffer
11665 (file-name-nondirectory dribble-file
))))
11666 (gnus-add-current-to-buffer-list)
11668 (set-visited-file-name dribble-file
)
11669 (buffer-disable-undo (current-buffer))
11670 (bury-buffer (current-buffer))
11671 (set-buffer-modified-p nil
)
11672 (let ((auto (make-auto-save-file-name))
11673 (gnus-dribble-ignore t
))
11674 (if (or (file-exists-p auto
) (file-exists-p dribble-file
))
11676 (if (file-newer-than-file-p auto dribble-file
)
11677 (setq dribble-file auto
))
11678 (insert-file-contents dribble-file
)
11679 (if (not (zerop (buffer-size)))
11680 (set-buffer-modified-p t
))
11682 "Auto-save file exists. Do you want to read it? ")
11683 (setq gnus-dribble-eval-file t
))))))))
11685 (defun gnus-dribble-eval-file ()
11686 (if (not gnus-dribble-eval-file
)
11688 (setq gnus-dribble-eval-file nil
)
11690 (let ((gnus-dribble-ignore t
))
11691 (set-buffer gnus-dribble-buffer
)
11692 (eval-buffer (current-buffer))))))
11694 (defun gnus-dribble-delete-file ()
11695 (if (file-exists-p (gnus-dribble-file-name))
11696 (delete-file (gnus-dribble-file-name)))
11697 (if gnus-dribble-buffer
11699 (set-buffer gnus-dribble-buffer
)
11700 (let ((auto (make-auto-save-file-name)))
11701 (if (file-exists-p auto
)
11702 (delete-file auto
))
11704 (set-buffer-modified-p nil
)))))
11706 (defun gnus-dribble-save ()
11707 (if (and gnus-dribble-buffer
11708 (buffer-name gnus-dribble-buffer
))
11710 (set-buffer gnus-dribble-buffer
)
11713 (defun gnus-dribble-clear ()
11715 (if (gnus-buffer-exists-p gnus-dribble-buffer
)
11717 (set-buffer gnus-dribble-buffer
)
11719 (set-buffer-modified-p nil
)
11720 (setq buffer-saved-size
(buffer-size))))))
11723 ;;; Server Communication
11726 (defun gnus-start-news-server (&optional confirm
)
11727 "Open a method for getting news.
11728 If CONFIRM is non-nil, the user will be asked for an NNTP server."
11730 (if gnus-current-select-method
11731 ;; Stream is already opened.
11733 ;; Open NNTP server.
11734 (if (null gnus-nntp-service
) (setq gnus-nntp-server nil
))
11737 ;; Read server name with completion.
11738 (setq gnus-nntp-server
11739 (completing-read "NNTP server: "
11740 (mapcar (lambda (server) (list server
))
11741 (cons (list gnus-nntp-server
)
11742 gnus-secondary-servers
))
11743 nil nil gnus-nntp-server
))))
11745 (if (and gnus-nntp-server
11746 (stringp gnus-nntp-server
)
11747 (not (string= gnus-nntp-server
"")))
11748 (setq gnus-select-method
11749 (cond ((or (string= gnus-nntp-server
"")
11750 (string= gnus-nntp-server
"::"))
11751 (list 'nnspool
(system-name)))
11752 ((string-match "^:" gnus-nntp-server
)
11753 (list 'nnmh gnus-nntp-server
11754 (list 'nnmh-directory
11755 (file-name-as-directory
11757 (concat "~/" (substring
11758 gnus-nntp-server
1)))))
11759 (list 'nnmh-get-new-mail nil
)))
11761 (list 'nntp gnus-nntp-server
)))))
11763 (setq how
(car gnus-select-method
))
11764 (cond ((eq how
'nnspool
)
11766 (gnus-message 5 "Looking up local news spool..."))
11769 (gnus-message 5 "Looking up mh spool..."))
11772 (setq gnus-current-select-method gnus-select-method
)
11773 (run-hooks 'gnus-open-server-hook
)
11775 ;; gnus-open-server-hook might have opened it
11776 (gnus-server-opened gnus-select-method
)
11777 (gnus-open-server gnus-select-method
)
11780 "%s open error: '%s'. Continue? "
11781 (nth 1 gnus-select-method
)
11782 (gnus-status-message gnus-select-method
)))
11784 (gnus-message 1 "Couldn't open server on %s"
11785 (nth 1 gnus-select-method
))
11789 (defun gnus-check-server (&optional method
)
11790 "If the news server is down, start it up again."
11791 (let ((method (if method method gnus-select-method
)))
11792 (and (stringp method
)
11793 (setq method
(gnus-server-to-method method
)))
11794 (if (gnus-server-opened method
)
11795 ;; Stream is already opened.
11798 (gnus-message 5 "Opening server %s on %s..." (car method
) (nth 1 method
))
11799 (run-hooks 'gnus-open-server-hook
)
11801 (gnus-open-server method
)
11804 (defun gnus-nntp-message (&optional message
)
11805 "Check the status of the NNTP server.
11806 If the status of the server is clear and MESSAGE is non-nil, MESSAGE
11807 is returned insted of the status string."
11808 (let ((status (gnus-status-message (gnus-find-method-for-group
11809 gnus-newsgroup-name
)))
11810 (message (or message
"")))
11811 (if (and (stringp status
) (> (length status
) 0))
11814 (defun gnus-get-function (method function
)
11815 (and (stringp method
)
11816 (setq method
(gnus-server-to-method method
)))
11817 (let ((func (intern (format "%s-%s" (car method
) function
))))
11818 (if (not (fboundp func
))
11820 (require (car method
))
11821 (if (not (fboundp func
))
11822 (error "No such function: %s" func
))))
11825 ;;; Interface functions to the backends.
11827 (defun gnus-open-server (method)
11828 (funcall (gnus-get-function method
'open-server
)
11829 (nth 1 method
) (nthcdr 2 method
)))
11831 (defun gnus-close-server (method)
11832 (funcall (gnus-get-function method
'close-server
) (nth 1 method
)))
11834 (defun gnus-request-list (method)
11835 (funcall (gnus-get-function method
'request-list
) (nth 1 method
)))
11837 (defun gnus-request-list-newsgroups (method)
11838 (funcall (gnus-get-function method
'request-list-newsgroups
) (nth 1 method
)))
11840 (defun gnus-request-newgroups (date method
)
11841 (funcall (gnus-get-function method
'request-newgroups
)
11842 date
(nth 1 method
)))
11844 (defun gnus-server-opened (method)
11845 (funcall (gnus-get-function method
'server-opened
) (nth 1 method
)))
11847 (defun gnus-status-message (method)
11848 (let ((method (if (stringp method
) (gnus-find-method-for-group method
)
11850 (funcall (gnus-get-function method
'status-message
) (nth 1 method
))))
11852 (defun gnus-request-group (group &optional dont-check
)
11853 (let ((method (gnus-find-method-for-group group
)))
11854 (funcall (gnus-get-function method
'request-group
)
11855 (gnus-group-real-name group
) (nth 1 method
) dont-check
)))
11857 (defun gnus-request-asynchronous (group &optional articles
)
11858 (let ((method (gnus-find-method-for-group group
)))
11859 (funcall (gnus-get-function method
'request-asynchronous
)
11860 (gnus-group-real-name group
) (nth 1 method
) articles
)))
11862 (defun gnus-list-active-group (group)
11863 (let ((method (gnus-find-method-for-group group
))
11864 (func 'list-active-group
))
11865 (and (gnus-check-backend-function func group
)
11866 (funcall (gnus-get-function method func
)
11867 (gnus-group-real-name group
) (nth 1 method
)))))
11869 (defun gnus-request-group-description (group)
11870 (let ((method (gnus-find-method-for-group group
))
11871 (func 'request-group-description
))
11872 (and (gnus-check-backend-function func group
)
11873 (funcall (gnus-get-function method func
)
11874 (gnus-group-real-name group
) (nth 1 method
)))))
11876 (defun gnus-close-group (group)
11877 (let ((method (gnus-find-method-for-group group
)))
11878 (funcall (gnus-get-function method
'close-group
)
11879 (gnus-group-real-name group
) (nth 1 method
))))
11881 (defun gnus-retrieve-headers (articles group
)
11882 (let ((method (gnus-find-method-for-group group
)))
11883 (if (and gnus-use-cache
(numberp (car articles
)))
11884 (gnus-cache-retrieve-headers articles group
)
11885 (funcall (gnus-get-function method
'retrieve-headers
)
11886 articles
(gnus-group-real-name group
) (nth 1 method
)))))
11888 (defun gnus-retrieve-groups (groups method
)
11889 (funcall (gnus-get-function method
'retrieve-groups
) groups
(nth 1 method
)))
11891 (defun gnus-request-article (article group
&optional buffer
)
11892 (let ((method (gnus-find-method-for-group group
)))
11893 (funcall (gnus-get-function method
'request-article
)
11894 article
(gnus-group-real-name group
) (nth 1 method
) buffer
)))
11896 (defun gnus-request-head (article group
)
11897 (let ((method (gnus-find-method-for-group group
)))
11898 (funcall (gnus-get-function method
'request-head
)
11899 article
(gnus-group-real-name group
) (nth 1 method
))))
11901 (defun gnus-request-body (article group
)
11902 (let ((method (gnus-find-method-for-group group
)))
11903 (funcall (gnus-get-function method
'request-body
)
11904 article
(gnus-group-real-name group
) (nth 1 method
))))
11906 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
11907 (defun gnus-request-post-buffer (post group subject header artbuf
11908 info follow-to respect-poster
)
11909 (let* ((info (or info
(and group
(nth 2 (gnus-gethash
11910 group gnus-newsrc-hashtb
)))))
11912 (if (and gnus-post-method
11913 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
11915 (format "%s" (car (gnus-find-method-for-group
11916 gnus-newsgroup-name
)))
11917 gnus-valid-select-methods
)))
11919 (gnus-find-method-for-group gnus-newsgroup-name
))))
11920 (or (gnus-check-server method
)
11921 (error "Can't open server %s:%s" (car method
) (nth 1 method
)))
11922 (let ((mail-self-blind nil
)
11923 (mail-archive-file-name nil
))
11924 (funcall (gnus-get-function method
'request-post-buffer
)
11925 post group subject header artbuf info follow-to
11928 (defun gnus-request-post (method &optional force
)
11929 (and (stringp method
)
11930 (setq method
(gnus-server-to-method method
)))
11931 (and (not force
) gnus-post-method
11932 (memq 'post
(assoc (format "%s" (car method
))
11933 gnus-valid-select-methods
))
11934 (setq method gnus-post-method
))
11935 (funcall (gnus-get-function method
'request-post
)
11938 (defun gnus-request-expire-articles (articles group
&optional force
)
11939 (let ((method (gnus-find-method-for-group group
)))
11940 (funcall (gnus-get-function method
'request-expire-articles
)
11941 articles
(gnus-group-real-name group
) (nth 1 method
)
11944 (defun gnus-request-move-article
11945 (article group server accept-function
&optional last
)
11946 (let ((method (gnus-find-method-for-group group
)))
11947 (funcall (gnus-get-function method
'request-move-article
)
11948 article
(gnus-group-real-name group
)
11949 (nth 1 method
) accept-function last
)))
11951 (defun gnus-request-accept-article (group &optional last
)
11952 (let ((func (if (symbolp group
) group
11953 (car (gnus-find-method-for-group group
)))))
11954 (funcall (intern (format "%s-request-accept-article" func
))
11955 (if (stringp group
) (gnus-group-real-name group
) group
)
11958 (defun gnus-request-replace-article (article group buffer
)
11959 (let ((func (car (gnus-find-method-for-group group
))))
11960 (funcall (intern (format "%s-request-replace-article" func
))
11961 article
(gnus-group-real-name group
) buffer
)))
11963 (defun gnus-request-create-group (group)
11964 (let ((method (gnus-find-method-for-group group
)))
11965 (funcall (gnus-get-function method
'request-create-group
)
11966 (gnus-group-real-name group
) (nth 1 method
))))
11968 (defun gnus-member-of-valid (symbol group
)
11969 (memq symbol
(assoc
11970 (format "%s" (car (gnus-find-method-for-group group
)))
11971 gnus-valid-select-methods
)))
11973 (defun gnus-secondary-method-p (method)
11974 (let ((methods gnus-secondary-select-methods
)
11975 (gmethod (gnus-server-get-method nil method
)))
11976 (while (and methods
11977 (not (equal (gnus-server-get-method nil
(car methods
))
11979 (setq methods
(cdr methods
)))
11982 (defun gnus-find-method-for-group (group &optional info
)
11983 (or gnus-override-method
11985 gnus-select-method
)
11986 (let ((info (or info
(nth 2 (gnus-gethash group gnus-newsrc-hashtb
))))
11989 (not (setq method
(nth 4 info
))))
11990 (setq method gnus-select-method
)
11992 (cond ((stringp method
)
11993 (gnus-server-to-method method
))
11994 ((stringp (car method
))
11995 (gnus-server-extend-method group method
))
11998 (gnus-server-add-address method
))))
12000 (defun gnus-check-backend-function (func group
)
12001 (let ((method (if (stringp group
) (car (gnus-find-method-for-group group
))
12003 (fboundp (intern (format "%s-%s" method func
)))))
12005 (defun gnus-methods-using (method)
12006 (let ((valids gnus-valid-select-methods
)
12009 (if (memq method
(car valids
))
12010 (setq outs
(cons (car valids
) outs
)))
12011 (setq valids
(cdr valids
)))
12015 ;;; Active & Newsrc File Handling
12018 ;; Newsrc related functions.
12019 ;; Gnus internal format of gnus-newsrc-alist:
12020 ;; (("alt.general" 3 (1 . 1))
12021 ;; ("alt.misc" 3 ((1 . 10) (12 . 15)))
12022 ;; ("alt.test" 7 (1 . 99) (45 57 93)) ...)
12023 ;; The first item is the group name; the second is the subscription
12024 ;; level; the third is either a range of a list of ranges of read
12025 ;; articles, the optional fourth element is a list of marked articles,
12026 ;; the optional fifth element is the select method.
12028 ;; Gnus internal format of gnus-newsrc-hashtb:
12029 ;; (95 ("alt.general" 3 (1 . 1)) ("alt.misc" 3 ((1 . 10) (12 . 15))) ...)
12030 ;; This is the entry for "alt.misc". The first element is the number
12031 ;; of unread articles in "alt.misc". The cdr of this entry is the
12032 ;; element *before* "alt.misc" in gnus-newsrc-alist, which makes is
12033 ;; trivial to remove or add new elements into gnus-newsrc-alist
12034 ;; without scanning the entire list. So, to get the actual information
12035 ;; of "alt.misc", you'd say something like
12036 ;; (nth 2 (gnus-gethash "alt.misc" gnus-newsrc-hashtb))
12038 ;; Gnus internal format of gnus-active-hashtb:
12042 ;; The only element in each entry in this hash table is a range of
12043 ;; (possibly) available articles. (Articles in this range may have
12044 ;; been expired or canceled.)
12046 ;; Gnus internal format of gnus-killed-list and gnus-zombie-list:
12047 ;; ("alt.misc" "alt.test" "alt.general" ...)
12049 (defun gnus-setup-news (&optional rawfile level
)
12050 "Setup news information.
12051 If RAWFILE is non-nil, the .newsrc file will also be read.
12052 If LEVEL is non-nil, the news will be set up at level LEVEL."
12053 (let ((init (not (and gnus-newsrc-alist gnus-active-hashtb
(not rawfile
)))))
12054 ;; Clear some variables to re-initialize news information.
12055 (if init
(setq gnus-newsrc-alist nil
12056 gnus-active-hashtb nil
))
12058 ;; Read the newsrc file and create `gnus-newsrc-hashtb'.
12059 (if init
(gnus-read-newsrc-file rawfile
))
12061 ;; If we don't read the complete active file, we fill in the
12063 (if (or (null gnus-read-active-file
)
12064 (eq gnus-read-active-file
'some
))
12065 (gnus-update-active-hashtb-from-killed))
12067 ;; Read the active file and create `gnus-active-hashtb'.
12068 ;; If `gnus-read-active-file' is nil, then we just create an empty
12069 ;; hash table. The partial filling out of the hash table will be
12070 ;; done in `gnus-get-unread-articles'.
12071 (and gnus-read-active-file
12073 (gnus-read-active-file))
12075 (or gnus-active-hashtb
12076 (setq gnus-active-hashtb
(make-vector 4095 0)))
12078 ;; Possibly eval the dribble file.
12079 (and init gnus-use-dribble-file
(gnus-dribble-eval-file))
12081 (gnus-update-format-specifications)
12083 ;; Find new newsgroups and treat them.
12084 (if (and init gnus-check-new-newsgroups gnus-read-active-file
(not level
)
12085 (gnus-check-server gnus-select-method
))
12086 (gnus-find-new-newsgroups))
12088 ;; Find the number of unread articles in each non-dead group.
12089 (let ((gnus-read-active-file (and (not level
) gnus-read-active-file
)))
12090 (gnus-get-unread-articles (or level
(1+ gnus-level-subscribed
))))
12092 (if (and init gnus-check-bogus-newsgroups
12093 gnus-read-active-file
(not level
)
12094 (gnus-server-opened gnus-select-method
))
12095 (gnus-check-bogus-newsgroups))))
12097 (defun gnus-find-new-newsgroups ()
12098 "Search for new newsgroups and add them.
12099 Each new newsgroup will be treated with `gnus-subscribe-newsgroup-method.'
12100 The `-n' option line from .newsrc is respected."
12102 (or (gnus-check-first-time-used)
12103 (if (or (consp gnus-check-new-newsgroups
)
12104 (eq gnus-check-new-newsgroups
'ask-server
))
12105 (gnus-ask-server-for-new-groups)
12107 group new-newsgroups
)
12108 (gnus-message 5 "Looking for new newsgroups...")
12109 (or gnus-have-read-active-file
(gnus-read-active-file))
12110 (setq gnus-newsrc-last-checked-date
(current-time-string))
12111 (if (not gnus-killed-hashtb
) (gnus-make-hashtable-from-killed))
12112 ;; Go though every newsgroup in `gnus-active-hashtb' and compare
12113 ;; with `gnus-newsrc-hashtb' and `gnus-killed-hashtb'.
12116 (if (or (null (setq group
(symbol-name sym
)))
12117 (null (symbol-value sym
))
12118 (gnus-gethash group gnus-killed-hashtb
)
12119 (gnus-gethash group gnus-newsrc-hashtb
))
12121 (let ((do-sub (gnus-matches-options-n group
)))
12123 ((eq do-sub
'subscribe
)
12124 (setq groups
(1+ groups
))
12125 (gnus-sethash group group gnus-killed-hashtb
)
12126 (funcall gnus-subscribe-options-newsgroup-method group
))
12127 ((eq do-sub
'ignore
)
12130 (setq groups
(1+ groups
))
12131 (gnus-sethash group group gnus-killed-hashtb
)
12132 (if gnus-subscribe-hierarchical-interactive
12133 (setq new-newsgroups
(cons group new-newsgroups
))
12134 (funcall gnus-subscribe-newsgroup-method group
)))))))
12135 gnus-active-hashtb
)
12137 (gnus-subscribe-hierarchical-interactive new-newsgroups
))
12138 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
12140 (gnus-message 6 "%d new newsgroup%s arrived."
12141 groups
(if (> groups
1) "s have" " has"))
12142 (gnus-message 6 "No new newsgroups."))))))
12144 (defun gnus-matches-options-n (group)
12145 ;; Returns `subscribe' if the group is to be unconditionally
12146 ;; subscribed, `ignore' if it is to be ignored, and nil if there is
12147 ;; no match for the group.
12149 ;; First we check the two user variables.
12151 ((and gnus-options-subscribe
12152 (string-match gnus-options-subscribe group
))
12154 ((and gnus-options-not-subscribe
12155 (string-match gnus-options-not-subscribe group
))
12157 ;; Then we go through the list that was retrieved from the .newsrc
12158 ;; file. This list has elements on the form
12159 ;; `(REGEXP . {ignore,subscribe})'. The first match found (the list
12160 ;; is in the reverse order of the options line) is returned.
12162 (let ((regs gnus-newsrc-options-n
))
12164 (not (string-match (car (car regs
)) group
)))
12165 (setq regs
(cdr regs
)))
12166 (and regs
(cdr (car regs
)))))))
12168 (defun gnus-ask-server-for-new-groups ()
12169 (let* ((date (or gnus-newsrc-last-checked-date
(current-time-string)))
12170 (methods (cons gnus-select-method
12172 (and (consp gnus-check-new-newsgroups
)
12173 gnus-check-new-newsgroups
)
12174 gnus-secondary-select-methods
)))
12176 (new-date (current-time-string))
12177 (hashtb (gnus-make-hashtable 100))
12178 group new-newsgroups got-new method
)
12179 ;; Go through both primary and secondary select methods and
12180 ;; request new newsgroups.
12182 (setq method
(gnus-server-get-method nil
(car methods
)))
12183 (and (gnus-check-server method
)
12184 (gnus-request-newgroups date method
)
12187 (set-buffer nntp-server-buffer
)
12188 ;; Enter all the new groups in a hashtable.
12189 (gnus-active-to-gnus-format method hashtb
'ignore
)))
12190 (setq methods
(cdr methods
)))
12191 (and got-new
(setq gnus-newsrc-last-checked-date new-date
))
12192 ;; Now all new groups from all select methods are in `hashtb'.
12194 (lambda (group-sym)
12195 (setq group
(symbol-name group-sym
))
12196 (if (or (null group
)
12197 (null (symbol-value group-sym
))
12198 (gnus-gethash group gnus-newsrc-hashtb
)
12199 (member group gnus-zombie-list
)
12200 (member group gnus-killed-list
))
12201 ;; The group is already known.
12203 (and (symbol-value group-sym
)
12204 (gnus-sethash group
(symbol-value group-sym
) gnus-active-hashtb
))
12205 (let ((do-sub (gnus-matches-options-n group
)))
12206 (cond ((eq do-sub
'subscribe
)
12207 (setq groups
(1+ groups
))
12208 (gnus-sethash group group gnus-killed-hashtb
)
12210 gnus-subscribe-options-newsgroup-method group
))
12211 ((eq do-sub
'ignore
)
12214 (setq groups
(1+ groups
))
12215 (gnus-sethash group group gnus-killed-hashtb
)
12216 (if gnus-subscribe-hierarchical-interactive
12217 (setq new-newsgroups
(cons group new-newsgroups
))
12218 (funcall gnus-subscribe-newsgroup-method group
)))))))
12221 (gnus-subscribe-hierarchical-interactive new-newsgroups
))
12222 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
12224 (gnus-message 6 "%d new newsgroup%s arrived."
12225 groups
(if (> groups
1) "s have" " has")))
12228 (defun gnus-check-first-time-used ()
12229 (if (or (> (length gnus-newsrc-alist
) 1)
12230 (file-exists-p gnus-startup-file
)
12231 (file-exists-p (concat gnus-startup-file
".el"))
12232 (file-exists-p (concat gnus-startup-file
".eld")))
12234 (gnus-message 6 "First time user; subscribing you to default groups")
12235 (or gnus-have-read-active-file
(gnus-read-active-file))
12236 (setq gnus-newsrc-last-checked-date
(current-time-string))
12237 (let ((groups gnus-default-subscribed-newsgroups
)
12241 (setq groups
(or groups gnus-backup-default-subscribed-newsgroups
))
12244 (if (null (setq group
(symbol-name sym
)))
12246 (let ((do-sub (gnus-matches-options-n group
)))
12248 ((eq do-sub
'subscribe
)
12249 (gnus-sethash group group gnus-killed-hashtb
)
12250 (funcall gnus-subscribe-options-newsgroup-method group
))
12251 ((eq do-sub
'ignore
)
12254 (setq gnus-killed-list
(cons group gnus-killed-list
)))))))
12255 gnus-active-hashtb
)
12257 (if (gnus-gethash (car groups
) gnus-active-hashtb
)
12258 (gnus-group-change-level
12259 (car groups
) gnus-level-default-subscribed gnus-level-killed
))
12260 (setq groups
(cdr groups
)))
12261 (gnus-group-make-help-group)
12262 (and gnus-novice-user
12263 (gnus-message 7 "`A k' to list killed groups"))))))
12265 (defun gnus-subscribe-group (group previous
&optional method
)
12266 (gnus-group-change-level
12268 (list t group gnus-level-default-subscribed nil nil method
)
12270 gnus-level-default-subscribed gnus-level-killed previous t
))
12272 ;; `gnus-group-change-level' is the fundamental function for changing
12273 ;; subscription levels of newsgroups. This might mean just changing
12274 ;; from level 1 to 2, which is pretty trivial, from 2 to 6 or back
12275 ;; again, which subscribes/unsubscribes a group, which is equally
12276 ;; trivial. Changing from 1-7 to 8-9 means that you kill a group, and
12277 ;; from 8-9 to 1-7 means that you remove the group from the list of
12278 ;; killed (or zombie) groups and add them to the (kinda) subscribed
12279 ;; groups. And last but not least, moving from 8 to 9 and 9 to 8,
12280 ;; which is trivial.
12281 ;; ENTRY can either be a string (newsgroup name) or a list (if
12282 ;; FROMKILLED is t, it's a list on the format (NUM INFO-LIST),
12283 ;; otherwise it's a list in the format of the `gnus-newsrc-hashtb'
12285 ;; LEVEL is the new level of the group, OLDLEVEL is the old level and
12286 ;; PREVIOUS is the group (in hashtb entry format) to insert this group
12288 (defun gnus-group-change-level (entry level
&optional oldlevel
12289 previous fromkilled
)
12290 (let (group info active num
)
12291 ;; Glean what info we can from the arguments
12293 (if fromkilled
(setq group
(nth 1 entry
))
12294 (setq group
(car (nth 2 entry
))))
12295 (setq group entry
))
12296 (if (and (stringp entry
)
12298 (< oldlevel gnus-level-zombie
))
12299 (setq entry
(gnus-gethash entry gnus-newsrc-hashtb
)))
12300 (if (and (not oldlevel
)
12302 (setq oldlevel
(car (cdr (nth 2 entry
)))))
12303 (if (stringp previous
)
12304 (setq previous
(gnus-gethash previous gnus-newsrc-hashtb
)))
12306 (if (and (>= oldlevel gnus-level-zombie
)
12307 (gnus-gethash group gnus-newsrc-hashtb
))
12308 ;; We are trying to subscribe a group that is already
12312 (or (gnus-ephemeral-group-p group
)
12313 (gnus-dribble-enter
12314 (format "(gnus-group-change-level %S %S %S %S %S)"
12315 group level oldlevel
(car (nth 2 previous
)) fromkilled
)))
12317 ;; Then we remove the newgroup from any old structures, if needed.
12318 ;; If the group was killed, we remove it from the killed or zombie
12319 ;; list. If not, and it is in fact going to be killed, we remove
12320 ;; it from the newsrc hash table and assoc.
12321 (cond ((>= oldlevel gnus-level-zombie
)
12322 (if (= oldlevel gnus-level-zombie
)
12323 (setq gnus-zombie-list
(delete group gnus-zombie-list
))
12324 (setq gnus-killed-list
(delete group gnus-killed-list
))))
12326 (if (and (>= level gnus-level-zombie
)
12329 (gnus-sethash (car (nth 2 entry
)) nil gnus-newsrc-hashtb
)
12331 (setcdr (gnus-gethash (car (nth 3 entry
))
12332 gnus-newsrc-hashtb
)
12334 (setcdr (cdr entry
) (cdr (cdr (cdr entry
))))))))
12336 ;; Finally we enter (if needed) the list where it is supposed to
12337 ;; go, and change the subscription level. If it is to be killed,
12338 ;; we enter it into the killed or zombie list.
12339 (cond ((>= level gnus-level-zombie
)
12340 ;; Remove from the hash table.
12341 (gnus-sethash group nil gnus-newsrc-hashtb
)
12342 (or (gnus-group-foreign-p group
)
12343 ;; We do not enter foreign groups into the list of dead
12345 (if (= level gnus-level-zombie
)
12346 (setq gnus-zombie-list
(cons group gnus-zombie-list
))
12347 (setq gnus-killed-list
(cons group gnus-killed-list
)))))
12349 ;; If the list is to be entered into the newsrc assoc, and
12350 ;; it was killed, we have to create an entry in the newsrc
12351 ;; hashtb format and fix the pointers in the newsrc assoc.
12352 (if (>= oldlevel gnus-level-zombie
)
12356 (setq info
(cdr entry
))
12357 (setq num
(car entry
)))
12358 (setq active
(gnus-gethash group gnus-active-hashtb
))
12360 (if active
(- (1+ (cdr active
)) (car active
)) t
))
12361 ;; Check whether the group is foreign. If so, the
12362 ;; foreign select method has to be entered into the
12364 (let ((method (gnus-group-method-name group
)))
12365 (if (eq method gnus-select-method
)
12366 (setq info
(list group level nil
))
12367 (setq info
(list group level nil nil method
)))))
12370 (let ((p gnus-newsrc-alist
))
12371 (while (cdr (cdr p
))
12374 (setq entry
(cons info
(cdr (cdr previous
))))
12377 (setcdr (cdr previous
) entry
)
12378 (gnus-sethash group
(cons num
(cdr previous
))
12379 gnus-newsrc-hashtb
))
12380 (setcdr previous entry
)
12381 (gnus-sethash group
(cons num previous
)
12382 gnus-newsrc-hashtb
))
12384 (setcdr (gnus-gethash (car (car (cdr entry
)))
12385 gnus-newsrc-hashtb
)
12387 ;; It was alive, and it is going to stay alive, so we
12388 ;; just change the level and don't change any pointers or
12389 ;; hash table entries.
12390 (setcar (cdr (car (cdr (cdr entry
)))) level
)))))))
12392 (defun gnus-kill-newsgroup (newsgroup)
12393 "Obsolete function. Kills a newsgroup."
12394 (gnus-group-change-level
12395 (gnus-gethash newsgroup gnus-newsrc-hashtb
) gnus-level-killed
))
12397 (defun gnus-check-bogus-newsgroups (&optional confirm
)
12398 "Remove bogus newsgroups.
12399 If CONFIRM is non-nil, the user has to confirm the deletion of every
12401 (let ((newsrc (cdr gnus-newsrc-alist
))
12403 (gnus-message 5 "Checking bogus newsgroups...")
12404 (or gnus-have-read-active-file
(gnus-read-active-file))
12405 ;; Find all bogus newsgroup that are subscribed.
12407 (setq group
(car (car newsrc
)))
12408 (if (or (gnus-gethash group gnus-active-hashtb
) ; Active
12409 (nth 4 (car newsrc
)) ; Foreign
12411 (not (gnus-y-or-n-p
12412 (format "Remove bogus newsgroup: %s " group
)))))
12415 ;; Found a bogus newsgroup.
12416 (setq bogus
(cons group bogus
)))
12417 (setq newsrc
(cdr newsrc
)))
12418 ;; Remove all bogus subscribed groups by first killing them, and
12419 ;; then removing them from the list of killed groups.
12421 (and (setq entry
(gnus-gethash (car bogus
) gnus-newsrc-hashtb
))
12423 (gnus-group-change-level entry gnus-level-killed
)
12424 (setq gnus-killed-list
(delete (car bogus
) gnus-killed-list
))))
12425 (setq bogus
(cdr bogus
)))
12426 ;; Then we remove all bogus groups from the list of killed and
12427 ;; zombie groups. They are are removed without confirmation.
12428 (let ((dead-lists '(gnus-killed-list gnus-zombie-list
))
12431 (setq killed
(symbol-value (car dead-lists
)))
12433 (setq group
(car killed
))
12434 (or (gnus-gethash group gnus-active-hashtb
)
12435 ;; The group is bogus.
12436 (set (car dead-lists
)
12437 (delete group
(symbol-value (car dead-lists
)))))
12438 (setq killed
(cdr killed
)))
12439 (setq dead-lists
(cdr dead-lists
))))
12440 (gnus-message 5 "Checking bogus newsgroups...done")))
12442 (defun gnus-check-duplicate-killed-groups ()
12443 "Remove duplicates from the list of killed groups."
12445 (let ((killed gnus-killed-list
))
12447 (gnus-message 9 "%d" (length killed
))
12448 (setcdr killed
(delete (car killed
) (cdr killed
)))
12449 (setq killed
(cdr killed
)))))
12451 ;; Go though `gnus-newsrc-alist' and compare with `gnus-active-hashtb'
12452 ;; and compute how many unread articles there are in each group.
12453 (defun gnus-get-unread-articles (&optional level
)
12454 (let* ((newsrc (cdr gnus-newsrc-alist
))
12455 (level (or level
(1+ gnus-level-subscribed
)))
12458 (cond ((and gnus-activate-foreign-newsgroups
12459 (not (numberp gnus-activate-foreign-newsgroups
)))
12460 (1+ gnus-level-subscribed
))
12461 ((numberp gnus-activate-foreign-newsgroups
)
12462 gnus-activate-foreign-newsgroups
)
12465 info group active virtuals method
)
12466 (gnus-message 5 "Checking new news...")
12469 (setq info
(car newsrc
)
12471 active
(gnus-gethash group gnus-active-hashtb
))
12473 ;; Check newsgroups. If the user doesn't want to check them, or
12474 ;; they can't be checked (for instance, if the news server can't
12475 ;; be reached) we just set the number of unread articles in this
12476 ;; newsgroup to t. This means that Gnus thinks that there are
12477 ;; unread articles, but it has no idea how many.
12478 (if (and (setq method
(nth 4 info
))
12479 (not (gnus-server-equal gnus-select-method
12480 (gnus-server-get-method nil method
)))
12481 (not (gnus-secondary-method-p method
)))
12482 ;; These groups are foreign. Check the level.
12483 (if (<= (nth 1 info
) foreign-level
)
12484 (if (eq (car (if (stringp method
)
12485 (gnus-server-to-method method
)
12486 (nth 4 info
))) 'nnvirtual
)
12487 ;; We have to activate the virtual groups after all
12488 ;; the others, so we just pop them on a list for
12490 (setq virtuals
(cons info virtuals
))
12491 (and (setq active
(gnus-activate-group (car info
)))
12492 ;; Close the groups as we look at them!
12493 (gnus-close-group group
))))
12495 ;; These groups are native or secondary.
12496 (if (and (not gnus-read-active-file
)
12497 (<= (nth 1 info
) level
))
12499 (or gnus-read-active-file
(gnus-check-server method
))
12500 (setq active
(gnus-activate-group (car info
))))))
12503 (gnus-get-unread-articles-in-group info active
)
12504 ;; The group couldn't be reached, so we nix out the number of
12505 ;; unread articles and stuff.
12506 (gnus-sethash group nil gnus-active-hashtb
)
12507 (setcar (gnus-gethash group gnus-newsrc-hashtb
) t
))
12509 (setq newsrc
(cdr newsrc
)))
12511 ;; Activate the virtual groups. This has to be done after all the
12513 ;; !!! If one virtual group contains another virtual group, even
12514 ;; doing it this way might cause problems.
12516 (and (setq active
(gnus-activate-group (car (car virtuals
))))
12517 (gnus-get-unread-articles-in-group (car virtuals
) active
))
12518 (setq virtuals
(cdr virtuals
)))
12520 (gnus-message 5 "Checking new news...done")))
12522 ;; Create a hash table out of the newsrc alist. The `car's of the
12523 ;; alist elements are used as keys.
12524 (defun gnus-make-hashtable-from-newsrc-alist ()
12525 (let ((alist gnus-newsrc-alist
)
12526 (ohashtb gnus-newsrc-hashtb
)
12528 (setq gnus-newsrc-hashtb
(gnus-make-hashtable (length alist
)))
12530 (setq prev
(setq gnus-newsrc-alist
12531 (if (equal (car (car gnus-newsrc-alist
))
12534 (cons (list "dummy.group" 0 nil
) alist
)))))
12536 (gnus-sethash (car (car alist
))
12537 (cons (and ohashtb
(car (gnus-gethash
12538 (car (car alist
)) ohashtb
)))
12539 prev
) gnus-newsrc-hashtb
)
12541 alist
(cdr alist
)))))
12543 (defun gnus-make-hashtable-from-killed ()
12544 "Create a hash table from the killed and zombie lists."
12545 (let ((lists '(gnus-killed-list gnus-zombie-list
))
12547 (setq gnus-killed-hashtb
12548 (gnus-make-hashtable
12549 (+ (length gnus-killed-list
) (length gnus-zombie-list
))))
12551 (setq list
(symbol-value (car lists
)))
12552 (setq lists
(cdr lists
))
12554 (gnus-sethash (car list
) (car list
) gnus-killed-hashtb
)
12555 (setq list
(cdr list
))))))
12557 (defun gnus-get-unread-articles-in-group (info active
)
12558 (let* ((range (nth 2 info
))
12560 (marked (nth 3 info
)))
12561 ;; If a cache is present, we may have to alter the active info.
12562 (and gnus-use-cache
12563 (gnus-cache-possibly-alter-active (car info
) active
))
12564 ;; Modify the list of read articles according to what articles
12565 ;; are available; then tally the unread articles and add the
12566 ;; number to the group hash table entry.
12568 ((zerop (cdr active
))
12571 (setq num
(- (1+ (cdr active
)) (car active
))))
12572 ((not (listp (cdr range
)))
12573 ;; Fix a single (num . num) range according to the
12574 ;; active hash table.
12575 ;; Fix by Carsten Bormann <cabo@Informatik.Uni-Bremen.DE>.
12576 (and (< (cdr range
) (car active
)) (setcdr range
(1- (car active
))))
12577 (and (> (cdr range
) (cdr active
)) (setcdr range
(cdr active
)))
12578 ;; Compute number of unread articles.
12579 (setq num
(max 0 (- (cdr active
) (- (1+ (cdr range
)) (car range
))))))
12581 ;; The read list is a list of ranges. Fix them according to
12582 ;; the active hash table.
12583 ;; First peel off any elements that are below the lower
12585 (while (and (cdr range
)
12587 (or (and (atom (car (cdr range
))) (car (cdr range
)))
12588 (car (car (cdr range
))))))
12589 (if (numberp (car range
))
12592 (or (and (numberp (car (cdr range
)))
12594 (cdr (car (cdr range
))))))
12595 (setcdr (car range
)
12596 (or (and (numberp (nth 1 range
)) (nth 1 range
))
12597 (cdr (car (cdr range
))))))
12598 (setcdr range
(cdr (cdr range
))))
12599 ;; Adjust the first element to be the same as the lower limit.
12600 (if (and (not (atom (car range
)))
12601 (< (cdr (car range
)) (car active
)))
12602 (setcdr (car range
) (1- (car active
))))
12603 ;; Then we want to peel off any elements that are higher
12604 ;; than the upper active limit.
12605 (let ((srange range
))
12606 ;; Go past all legal elements.
12607 (while (and (cdr srange
)
12608 (<= (or (and (atom (car (cdr srange
)))
12609 (car (cdr srange
)))
12610 (car (car (cdr srange
)))) (cdr active
)))
12611 (setq srange
(cdr srange
)))
12613 ;; Nuke all remaining illegal elements.
12614 (setcdr srange nil
))
12616 ;; Adjust the final element.
12617 (if (and (not (atom (car srange
)))
12618 (> (cdr (car srange
)) (cdr active
)))
12619 (setcdr (car srange
) (cdr active
))))
12620 ;; Compute the number of unread articles.
12622 (setq num
(+ num
(- (1+ (or (and (atom (car range
)) (car range
))
12623 (cdr (car range
))))
12624 (or (and (atom (car range
)) (car range
))
12625 (car (car range
))))))
12626 (setq range
(cdr range
)))
12627 (setq num
(max 0 (- (cdr active
) num
)))))
12630 (and (assq 'tick marked
)
12631 (inline (gnus-remove-illegal-marked-articles
12632 (assq 'tick marked
) (nth 2 info
))))
12633 (and (assq 'dormant marked
)
12634 (inline (gnus-remove-illegal-marked-articles
12635 (assq 'dormant marked
) (nth 2 info
))))
12637 (gnus-gethash (car info
) gnus-newsrc-hashtb
)
12638 (setq num
(max 0 (- num
(length (cdr (assq 'tick marked
)))
12639 (length (cdr (assq 'dormant marked
)))))))))
12642 (defun gnus-remove-illegal-marked-articles (marked ranges
)
12643 (let ((m (cdr marked
)))
12644 ;; Make sure that all ticked articles are a subset of the unread
12647 (if (gnus-member-of-range (car m
) ranges
)
12648 (setcdr marked
(cdr m
))
12650 (setq m
(cdr m
)))))
12652 (defun gnus-activate-group (group)
12653 ;; Check whether a group has been activated or not.
12654 (let ((method (gnus-find-method-for-group group
))
12656 (and (gnus-check-server method
)
12657 ;; We escape all bugs and quit here to make it possible to
12658 ;; continue if a group is so out-there that it reports bugs
12661 (gnus-request-group group
)
12665 (set-buffer nntp-server-buffer
)
12666 (goto-char (point-min))
12667 ;; Parse the result we got from `gnus-request-group'.
12668 (and (looking-at "[0-9]+ [0-9]+ \\([0-9]+\\) [0-9]+")
12670 (goto-char (match-beginning 1))
12672 group
(setq active
(cons (read (current-buffer))
12673 (read (current-buffer))))
12674 gnus-active-hashtb
))
12675 ;; Return the new active info.
12678 (defun gnus-update-read-articles
12679 (group unread unselected ticked
&optional domarks replied expirable killed
12680 dormant bookmark score
)
12681 "Update the list of read and ticked articles in GROUP using the
12682 UNREAD and TICKED lists.
12683 Note: UNSELECTED has to be sorted over `<'.
12684 Returns whether the updating was successful."
12685 (let* ((active (or gnus-newsgroup-active
12686 (gnus-gethash group gnus-active-hashtb
)))
12687 (entry (gnus-gethash group gnus-newsrc-hashtb
))
12688 (info (nth 2 entry
))
12689 (marked (nth 3 info
))
12691 (unread (sort (copy-sequence unread
) (function <)))
12693 (if (or (not info
) (not active
))
12694 ;; There is no info on this group if it was, in fact,
12695 ;; killed. Gnus stores no information on killed groups, so
12696 ;; there's nothing to be done.
12697 ;; One could store the information somewhere temporarily,
12698 ;; perhaps... Hmmm...
12700 ;; Remove any negative articles numbers.
12701 (while (and unread
(< (car unread
) 0))
12702 (setq unread
(cdr unread
)))
12703 ;; Remove any expired article numbers
12704 (while (and unread
(< (car unread
) (car active
)))
12705 (setq unread
(cdr unread
)))
12706 (while (and ticked
(< (car ticked
) (car active
)))
12707 (setq ticked
(cdr ticked
)))
12708 (while (and dormant
(< (car dormant
) (car active
)))
12709 (setq dormant
(cdr dormant
)))
12710 (setq unread
(sort (append unselected unread
) '<))
12711 ;; Compute the ranges of read articles by looking at the list of
12712 ;; unread articles.
12714 (if (/= (car unread
) prev
)
12715 (setq read
(cons (if (= prev
(1- (car unread
))) prev
12716 (cons prev
(1- (car unread
)))) read
)))
12717 (setq prev
(1+ (car unread
)))
12718 (setq unread
(cdr unread
)))
12719 (if (<= prev
(cdr active
))
12720 (setq read
(cons (cons prev
(cdr active
)) read
)))
12721 ;; Enter this list into the group info.
12722 (setcar (cdr (cdr info
))
12723 (if (> (length read
) 1) (nreverse read
) read
))
12724 ;; Enter the list of ticked articles.
12725 (gnus-set-marked-articles
12727 (if domarks replied
(cdr (assq 'reply marked
)))
12728 (if domarks expirable
(cdr (assq 'expire marked
)))
12729 (if domarks killed
(cdr (assq 'killed marked
)))
12730 (if domarks dormant
(cdr (assq 'dormant marked
)))
12731 (if domarks bookmark
(cdr (assq 'bookmark marked
)))
12732 (if domarks score
(cdr (assq 'score marked
))))
12733 ;; Set the number of unread articles in gnus-newsrc-hashtb.
12734 (gnus-get-unread-articles-in-group
12735 info
(gnus-gethash group gnus-active-hashtb
))
12738 (defun gnus-make-articles-unread (group articles
)
12739 "Mark ARTICLES in GROUP as unread."
12740 (let* ((info (nth 2 (or (gnus-gethash group gnus-newsrc-hashtb
)
12741 (gnus-gethash (gnus-group-real-name group
)
12742 gnus-newsrc-hashtb
))))
12743 (ranges (nth 2 info
))
12746 (and (gnus-member-of-range (car articles
) ranges
)
12747 (setq news
(cons (car articles
) news
)))
12748 (setq articles
(cdr articles
)))
12751 (setcar (nthcdr 2 info
)
12752 (gnus-remove-from-range (nth 2 info
) (nreverse news
)))
12753 (gnus-group-update-group group t
))))
12755 ;; Enter all dead groups into the hashtb.
12756 (defun gnus-update-active-hashtb-from-killed ()
12757 (let ((hashtb (setq gnus-active-hashtb
(make-vector 4095 0)))
12758 (lists (list gnus-killed-list gnus-zombie-list
))
12761 (setq killed
(car lists
))
12763 (gnus-sethash (car killed
) nil hashtb
)
12764 (setq killed
(cdr killed
)))
12765 (setq lists
(cdr lists
)))))
12767 ;; Get the active file(s) from the backend(s).
12768 (defun gnus-read-active-file ()
12769 (gnus-group-set-mode-line)
12770 (let ((methods (if (gnus-check-server gnus-select-method
)
12771 ;; The native server is available.
12772 (cons gnus-select-method gnus-secondary-select-methods
)
12773 ;; The native server is down, so we just do the
12775 gnus-secondary-select-methods
))
12777 (setq gnus-have-read-active-file nil
)
12779 (set-buffer nntp-server-buffer
)
12781 (let* ((method (gnus-server-get-method nil
(car methods
)))
12782 (where (nth 1 method
))
12783 (mesg (format "Reading active file%s via %s..."
12784 (if (and where
(not (zerop (length where
))))
12785 (concat " from " where
) "")
12787 (gnus-message 5 mesg
)
12788 (if (not (gnus-check-server method
))
12791 ((and (eq gnus-read-active-file
'some
)
12792 (gnus-check-backend-function 'retrieve-groups
(car method
)))
12793 (let ((newsrc (cdr gnus-newsrc-alist
))
12794 (gmethod (gnus-server-get-method nil method
))
12797 (and (gnus-server-equal
12798 (gnus-find-method-for-group
12799 (car (car newsrc
)) (car newsrc
))
12801 (setq groups
(cons (gnus-group-real-name
12802 (car (car newsrc
))) groups
)))
12803 (setq newsrc
(cdr newsrc
)))
12804 (gnus-check-server method
)
12805 (setq list-type
(gnus-retrieve-groups groups method
))
12809 1 "Cannot read partial active file from %s server."
12813 ((eq list-type
'active
)
12814 (gnus-active-to-gnus-format method gnus-active-hashtb
))
12816 (gnus-groups-to-gnus-format method gnus-active-hashtb
)))))
12818 (if (not (gnus-request-list method
))
12820 (gnus-message 1 "Cannot read active file from %s server."
12823 (gnus-active-to-gnus-format method
)
12824 ;; We mark this active file as read.
12825 (setq gnus-have-read-active-file
12826 (cons method gnus-have-read-active-file
))
12827 (gnus-message 5 "%sdone" mesg
))))))
12828 (setq methods
(cdr methods
))))))
12830 ;; Read an active file and place the results in `gnus-active-hashtb'.
12831 (defun gnus-active-to-gnus-format (method &optional hashtb ignore-errors
)
12832 (let ((cur (current-buffer))
12834 (if (and gnus-active-hashtb
12835 (not (equal method gnus-select-method
)))
12837 (setq gnus-active-hashtb
12838 (if (equal method gnus-select-method
)
12839 (gnus-make-hashtable
12840 (count-lines (point-min) (point-max)))
12841 (gnus-make-hashtable 4096))))))
12842 (flag-hashtb (gnus-make-hashtable 60)))
12843 ;; Delete unnecessary lines.
12844 (goto-char (point-min))
12845 (while (search-forward "\nto." nil t
)
12846 (delete-region (1+ (match-beginning 0))
12847 (progn (forward-line 1) (point))))
12848 (or (string= gnus-ignored-newsgroups
"")
12850 (goto-char (point-min))
12851 (delete-matching-lines gnus-ignored-newsgroups
)))
12852 ;; Make the group names readable as a lisp expression even if they
12853 ;; contain special characters.
12854 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
12855 (goto-char (point-max))
12856 (while (re-search-backward "[][';?()#]" nil t
)
12858 ;; If these are groups from a foreign select method, we insert the
12859 ;; group prefix in front of the group names.
12860 (and method
(not (gnus-server-equal
12861 (gnus-server-get-method nil method
)
12862 (gnus-server-get-method nil gnus-select-method
)))
12863 (let ((prefix (gnus-group-prefixed-name "" method
)))
12864 (goto-char (point-min))
12865 (while (and (not (eobp))
12866 (progn (insert prefix
)
12867 (zerop (forward-line 1)))))))
12868 ;; Store the active file in a hash table.
12869 (goto-char (point-min))
12870 (if (string-match "%[oO]" gnus-group-line-format
)
12871 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
12872 ;; If we want information on moderated groups, we use this
12874 (let* ((mod-hashtb (make-vector 7 0))
12875 (m (intern "m" mod-hashtb
))
12877 (while (not (eobp))
12878 (condition-case nil
12880 (narrow-to-region (point) (gnus-point-at-eol))
12881 (setq group
(let ((obarray hashtb
)) (read cur
)))
12882 (if (and (numberp (setq max
(read cur
)))
12883 (numberp (setq min
(read cur
)))
12885 (skip-chars-forward " \t")
12887 (or (= (following-char) ?
=)
12888 (= (following-char) ?x
)
12889 (= (following-char) ?j
)))))
12890 (set group
(cons min max
))
12892 ;; Enter moderated groups into a list.
12893 (if (eq (let ((obarray mod-hashtb
)) (read cur
)) m
)
12894 (setq gnus-moderated-list
12895 (cons (symbol-name group
) gnus-moderated-list
))))
12902 ;; And if we do not care about moderation, we use this loop,
12903 ;; which is faster.
12904 (let (group max min
)
12905 (while (not (eobp))
12908 (narrow-to-region (point) (gnus-point-at-eol))
12909 ;; group gets set to a symbol interned in the hash table
12910 ;; (what a hack!!) - jwz
12911 (setq group
(let ((obarray hashtb
)) (read cur
)))
12912 (if (and (numberp (setq max
(read cur
)))
12913 (numberp (setq min
(read cur
)))
12915 (skip-chars-forward " \t")
12917 (or (= (following-char) ?
=)
12918 (= (following-char) ?x
)
12919 (= (following-char) ?j
)))))
12920 (set group
(cons min max
))
12928 (gnus-message 3 "Warning - illegal active: %s"
12930 (gnus-point-at-bol) (gnus-point-at-eol)))))))
12932 (forward-line 1))))))
12934 (defun gnus-groups-to-gnus-format (method &optional hashtb
)
12935 ;; Parse a "groups" active file.
12936 (let ((cur (current-buffer))
12938 (if (and method gnus-active-hashtb
)
12940 (setq gnus-active-hashtb
12941 (gnus-make-hashtable
12942 (count-lines (point-min) (point-max)))))))
12943 (prefix (and method
12944 (not (gnus-server-equal
12945 (gnus-server-get-method nil method
)
12946 (gnus-server-get-method nil gnus-select-method
)))
12947 (gnus-group-prefixed-name "" method
))))
12949 (goto-char (point-min))
12950 ;; We split this into to separate loops, one with the prefix
12951 ;; and one without to speed the reading up somewhat.
12953 (let (min max opoint group
)
12954 (while (not (eobp))
12957 (read cur
) (read cur
)
12958 (setq min
(read cur
)
12961 (skip-chars-forward " \t")
12964 (set (let ((obarray hashtb
)) (read cur
))
12966 (error (and group
(symbolp group
) (set group nil
))))
12968 (let (min max group
)
12969 (while (not (eobp))
12971 (if (= (following-char) ?
2)
12973 (read cur
) (read cur
)
12974 (setq min
(read cur
)
12976 (set (setq group
(let ((obarray hashtb
)) (read cur
)))
12978 (error (and group
(symbolp group
) (set group nil
))))
12979 (forward-line 1))))))
12981 (defun gnus-read-newsrc-file (&optional force
)
12982 "Read startup file.
12983 If FORCE is non-nil, the .newsrc file is read."
12984 ;; Reset variables that might be defined in the .newsrc.eld file.
12985 (let ((variables gnus-variable-list
))
12987 (set (car variables
) nil
)
12988 (setq variables
(cdr variables
))))
12989 (let* ((newsrc-file gnus-current-startup-file
)
12990 (quick-file (concat newsrc-file
".el")))
12992 ;; We always load the .newsrc.eld file. If always contains
12993 ;; much information that can not be gotten from the .newsrc
12994 ;; file (ticked articles, killed groups, foreign methods, etc.)
12995 (gnus-read-newsrc-el-file quick-file
)
12998 (and (file-newer-than-file-p newsrc-file quick-file
)
12999 (file-newer-than-file-p newsrc-file
13000 (concat quick-file
"d")))
13001 (not gnus-newsrc-alist
))
13002 ;; We read the .newsrc file. Note that if there if a
13003 ;; .newsrc.eld file exists, it has already been read, and
13004 ;; the `gnus-newsrc-hashtb' has been created. While reading
13005 ;; the .newsrc file, Gnus will only use the information it
13006 ;; can find there for changing the data already read -
13007 ;; ie. reading the .newsrc file will not trash the data
13008 ;; already read (except for read articles).
13010 (gnus-message 5 "Reading %s..." newsrc-file
)
13011 (set-buffer (find-file-noselect newsrc-file
))
13012 (buffer-disable-undo (current-buffer))
13013 (gnus-newsrc-to-gnus-format)
13014 (kill-buffer (current-buffer))
13015 (gnus-message 5 "Reading %s...done" newsrc-file
))))))
13017 (defun gnus-read-newsrc-el-file (file)
13018 (let ((ding-file (concat file
"d")))
13019 ;; We always, always read the .eld file.
13020 (gnus-message 5 "Reading %s..." ding-file
)
13021 (let (gnus-newsrc-assoc)
13022 (condition-case nil
13023 (load ding-file t t t
)
13025 (and gnus-newsrc-assoc
(setq gnus-newsrc-alist gnus-newsrc-assoc
)))
13026 (let ((inhibit-quit t
))
13027 (gnus-uncompress-newsrc-alist))
13028 (gnus-make-hashtable-from-newsrc-alist)
13029 (if (not (file-newer-than-file-p file ding-file
))
13031 ;; Old format quick file
13032 (gnus-message 5 "Reading %s..." file
)
13033 ;; The .el file is newer than the .eld file, so we read that one
13035 (gnus-read-old-newsrc-el-file file
))))
13037 ;; Parse the old-style quick startup file
13038 (defun gnus-read-old-newsrc-el-file (file)
13039 (let (newsrc killed marked group m
)
13041 (let ((gnus-killed-assoc nil
)
13042 gnus-marked-assoc gnus-newsrc-alist gnus-newsrc-assoc
)
13044 (condition-case nil
13047 (setq newsrc gnus-newsrc-assoc
13048 killed gnus-killed-assoc
13049 marked gnus-marked-assoc
)))
13050 (setq gnus-newsrc-alist nil
)
13052 (setq group
(car newsrc
))
13053 (let ((info (nth 2 (gnus-gethash (car group
) gnus-newsrc-hashtb
))))
13056 (setcar (nthcdr 2 info
) (cdr (cdr group
)))
13058 (if (nth 1 group
) gnus-level-default-subscribed
13059 gnus-level-default-unsubscribed
))
13060 (setq gnus-newsrc-alist
(cons info gnus-newsrc-alist
)))
13061 (setq gnus-newsrc-alist
13065 (if (nth 1 group
) gnus-level-default-subscribed
13066 gnus-level-default-unsubscribed
)
13067 (cdr (cdr group
))))
13068 gnus-newsrc-alist
)))
13069 (if (setq m
(assoc (car group
) marked
))
13070 (setcdr (cdr (cdr info
))
13071 (cons (list (cons 'tick
(cdr m
))) nil
))))
13072 (setq newsrc
(cdr newsrc
)))
13073 (setq newsrc killed
)
13075 (setcar newsrc
(car (car newsrc
)))
13076 (setq newsrc
(cdr newsrc
)))
13077 (setq gnus-killed-list killed
))
13078 ;; The .el file version of this variable does not begin with
13079 ;; "options", while the .eld version does, so we just add it if it
13082 gnus-newsrc-options
13084 (and (not (string-match "^ *options" gnus-newsrc-options
))
13085 (setq gnus-newsrc-options
(concat "options " gnus-newsrc-options
)))
13086 (and (not (string-match "\n$" gnus-newsrc-options
))
13087 (setq gnus-newsrc-options
(concat gnus-newsrc-options
"\n")))
13088 ;; Finally, if we read some options lines, we parse them.
13089 (or (string= gnus-newsrc-options
"")
13090 (gnus-newsrc-parse-options gnus-newsrc-options
))))
13092 (setq gnus-newsrc-alist
(nreverse gnus-newsrc-alist
))
13093 (gnus-make-hashtable-from-newsrc-alist)))
13095 (defun gnus-make-newsrc-file (file)
13096 "Make server dependent file name by catenating FILE and server host name."
13097 (let* ((file (expand-file-name file nil
))
13098 (real-file (concat file
"-" (nth 1 gnus-select-method
))))
13099 (if (or (file-exists-p real-file
)
13100 (file-exists-p (concat real-file
".el"))
13101 (file-exists-p (concat real-file
".eld")))
13104 (defun gnus-uncompress-newsrc-alist ()
13105 ;; Uncompress all lists of marked articles in the newsrc assoc.
13106 (let ((newsrc gnus-newsrc-alist
)
13109 (if (not (setq marked
(nth 3 (car newsrc
))))
13112 (or (eq 'score
(car (car marked
)))
13113 (eq 'bookmark
(car (car marked
)))
13114 (eq 'killed
(car (car marked
)))
13115 (setcdr (car marked
) (gnus-uncompress-range (cdr (car marked
)))))
13116 (setq marked
(cdr marked
))))
13117 (setq newsrc
(cdr newsrc
)))))
13119 (defun gnus-compress-newsrc-alist ()
13120 ;; Compress all lists of marked articles in the newsrc assoc.
13121 (let ((newsrc gnus-newsrc-alist
)
13124 (if (not (setq marked
(nth 3 (car newsrc
))))
13127 (or (eq 'score
(car (car marked
)))
13128 (eq 'bookmark
(car (car marked
)))
13129 (eq 'killed
(car (car marked
)))
13130 (setcdr (car marked
)
13132 (gnus-compress-sequence
13133 (sort (cdr (car marked
)) '<) t
)
13134 (error (cdr (car marked
))))))
13135 (setq marked
(cdr marked
))))
13136 (setq newsrc
(cdr newsrc
)))))
13138 (defun gnus-newsrc-to-gnus-format ()
13139 (setq gnus-newsrc-options
"")
13140 (setq gnus-newsrc-options-n nil
)
13142 (or gnus-active-hashtb
13143 (setq gnus-active-hashtb
(make-vector 4095 0)))
13144 (let ((buf (current-buffer))
13145 (already-read (> (length gnus-newsrc-alist
) 1))
13146 group subscribed options-symbol newsrc Options-symbol
13148 (goto-char (point-min))
13149 ;; We intern the symbol `options' in the active hashtb so that we
13150 ;; can `eq' against it later.
13151 (set (setq options-symbol
(intern "options" gnus-active-hashtb
)) nil
)
13152 (set (setq Options-symbol
(intern "Options" gnus-active-hashtb
)) nil
)
13154 (while (not (eobp))
13155 ;; We first read the first word on the line by narrowing and
13156 ;; then reading into `gnus-active-hashtb'. Most groups will
13157 ;; already exist in that hashtb, so this will save some string
13161 (progn (skip-chars-forward "^ \t!:\n") (point)))
13162 (goto-char (point-min))
13164 (and (/= (point-min) (point-max))
13165 (let ((obarray gnus-active-hashtb
)) (read buf
))))
13167 ;; Now, the symbol we have read is either `options' or a group
13168 ;; name. If it is an options line, we just add it to a string.
13170 ((or (eq symbol options-symbol
)
13171 (eq symbol Options-symbol
))
13172 (setq gnus-newsrc-options
13173 ;; This concating is quite inefficient, but since our
13174 ;; thorough studies show that approx 99.37% of all
13175 ;; .newsrc files only contain a single options line, we
13176 ;; don't give a damn, frankly, my dear.
13177 (concat gnus-newsrc-options
13179 (gnus-point-at-bol)
13180 ;; Options may continue on the next line.
13181 (or (and (re-search-forward "^[^ \t]" nil
'move
)
13182 (progn (beginning-of-line) (point)))
13186 (or (boundp symbol
) (set symbol nil
))
13187 ;; It was a group name.
13188 (setq subscribed
(= (following-char) ?
:)
13189 group
(symbol-name symbol
)
13192 ;; If the line ends here, this is clearly a buggy line, so
13193 ;; we put point a the beginning of line and let the cond
13194 ;; below do the error handling.
13195 (beginning-of-line)
13196 ;; We skip to the beginning of the ranges.
13197 (skip-chars-forward "!: \t"))
13198 ;; We are now at the beginning of the list of read articles.
13199 ;; We read them range by range.
13202 ((looking-at "[0-9]+")
13203 ;; We narrow and read a number instead of buffer-substring/
13204 ;; string-to-int because it's faster. narrow/widen is
13205 ;; faster than save-restriction/narrow, and save-restriction
13206 ;; produces a garbage object.
13208 (narrow-to-region (match-beginning 0) (match-end 0))
13211 ;; If the next character is a dash, then this is a range.
13212 (if (= (following-char) ?-
)
13214 ;; We read the upper bound of the range.
13216 (if (not (looking-at "[0-9]+"))
13217 ;; This is a buggy line, by we pretend that
13218 ;; it's kinda OK. Perhaps the user should be
13220 (setq reads
(cons num1 reads
))
13225 (narrow-to-region (match-beginning 0)
13230 ;; It was just a simple number, so we add it to the
13232 (setq reads
(cons num1 reads
)))
13233 ;; If the next char in ?\n, then we have reached the end
13234 ;; of the line and return nil.
13235 (/= (following-char) ?
\n))
13236 ((= (following-char) ?
\n)
13237 ;; End of line, so we end.
13240 ;; Not numbers and not eol, so this might be a buggy
13243 ;; If it was eob instead of ?\n, we allow it.
13245 ;; The line was buggy.
13247 (gnus-message 3 "Mangled line: %s"
13248 (buffer-substring (gnus-point-at-bol)
13249 (gnus-point-at-eol)))
13253 ;; Skip past ", ". Spaces are illegal in these ranges, but
13254 ;; we allow them, because it's a common mistake to put a
13255 ;; space after the comma.
13256 (skip-chars-forward ", "))
13258 ;; We have already read .newsrc.eld, so we gently update the
13259 ;; data in the hash table with the information we have just
13263 (let ((info (nth 2 (gnus-gethash group gnus-newsrc-hashtb
)))
13266 ;; There is an entry for this file in the alist.
13268 (setcar (nthcdr 2 info
) (nreverse reads
))
13269 ;; We update the level very gently. In fact, we
13270 ;; only change it if there's been a status change
13271 ;; from subscribed to unsubscribed, or vice versa.
13272 (setq level
(nth 1 info
))
13273 (cond ((and (<= level gnus-level-subscribed
)
13275 (setq level
(if reads
13276 gnus-level-default-unsubscribed
13277 (1+ gnus-level-default-unsubscribed
))))
13278 ((and (> level gnus-level-subscribed
) subscribed
)
13279 (setq level gnus-level-default-subscribed
)))
13280 (setcar (cdr info
) level
))
13281 ;; This is a new group.
13282 (setq info
(list group
13284 gnus-level-default-subscribed
13286 (1+ gnus-level-subscribed
)
13287 gnus-level-default-unsubscribed
))
13288 (nreverse reads
))))
13289 (setq newsrc
(cons info newsrc
))))))
13292 (setq newsrc
(nreverse newsrc
))
13294 (if (not already-read
)
13296 ;; We now have two newsrc lists - `newsrc', which is what we
13297 ;; have read from .newsrc, and `gnus-newsrc-alist', which is
13298 ;; what we've read from .newsrc.eld. We have to merge these
13299 ;; lists. We do this by "attaching" any (foreign) groups in the
13300 ;; gnus-newsrc-alist to the (native) group that precedes them.
13301 (let ((rc (cdr gnus-newsrc-alist
))
13302 (prev gnus-newsrc-alist
)
13305 (or (null (nth 4 (car rc
))) ; It's a native group.
13306 (assoc (car (car rc
)) newsrc
) ; It's already in the alist.
13307 (if (setq entry
(assoc (car (car prev
)) newsrc
))
13308 (setcdr (setq mentry
(memq entry newsrc
))
13309 (cons (car rc
) (cdr mentry
)))
13310 (setq newsrc
(cons (car rc
) newsrc
))))
13314 (setq gnus-newsrc-alist newsrc
)
13315 ;; We make the newsrc hashtb.
13316 (gnus-make-hashtable-from-newsrc-alist)
13318 ;; Finally, if we read some options lines, we parse them.
13319 (or (string= gnus-newsrc-options
"")
13320 (gnus-newsrc-parse-options gnus-newsrc-options
))))
13322 ;; Parse options lines to find "options -n !all rec.all" and stuff.
13323 ;; The return value will be a list on the form
13324 ;; ((regexp1 . ignore)
13325 ;; (regexp2 . subscribe)...)
13326 ;; When handling new newsgroups, groups that match a `ignore' regexp
13327 ;; will be ignored, and groups that match a `subscribe' regexp will be
13328 ;; subscribed. A line like
13329 ;; options -n !all rec.all
13330 ;; will lead to a list that looks like
13331 ;; (("^rec\\..+" . subscribe)
13332 ;; ("^.+" . ignore))
13333 ;; So all "rec.*" groups will be subscribed, while all the other
13334 ;; groups will be ignored. Note that "options -n !all rec.all" is very
13335 ;; different from "options -n rec.all !all".
13336 (defun gnus-newsrc-parse-options (options)
13339 (gnus-set-work-buffer)
13340 (insert (regexp-quote options
))
13341 ;; First we treat all continuation lines.
13342 (goto-char (point-min))
13343 (while (re-search-forward "\n[ \t]+" nil t
)
13344 (replace-match " " t t
))
13345 ;; Then we transform all "all"s into ".+"s.
13346 (goto-char (point-min))
13347 (while (re-search-forward "\\ball\\b" nil t
)
13348 (replace-match ".+" t t
))
13349 (goto-char (point-min))
13350 ;; We remove all other options than the "-n" ones.
13351 (while (re-search-forward "[ \t]-[^n][^-]*" nil t
)
13352 (replace-match " ")
13354 (goto-char (point-min))
13356 ;; We are only interested in "options -n" lines - we
13357 ;; ignore the other option lines.
13358 (while (re-search-forward "[ \t]-n" nil t
)
13360 (or (save-excursion
13361 (and (re-search-forward "[ \t]-n" (gnus-point-at-eol) t
)
13363 (gnus-point-at-eol)))
13364 ;; Search for all "words"...
13365 (while (re-search-forward "[^ \t,\n]+" eol t
)
13366 (if (= (char-after (match-beginning 0)) ?
!)
13367 ;; If the word begins with a bang (!), this is a "not"
13368 ;; spec. We put this spec (minus the bang) and the
13369 ;; symbol `ignore' into the list.
13370 (setq out
(cons (cons (concat
13371 "^" (buffer-substring
13372 (1+ (match-beginning 0))
13375 ;; There was no bang, so this is a "yes" spec.
13376 (setq out
(cons (cons (concat
13377 "^" (buffer-substring (match-beginning 0)
13379 'subscribe
) out
)))))
13381 (setq gnus-newsrc-options-n out
))))
13384 (defun gnus-save-newsrc-file ()
13385 "Save .newsrc file."
13386 ;; Note: We cannot save .newsrc file if all newsgroups are removed
13387 ;; from the variable gnus-newsrc-alist.
13388 (and (or gnus-newsrc-alist gnus-killed-list
)
13389 gnus-current-startup-file
13391 (run-hooks 'gnus-save-newsrc-hook
)
13393 (if (and gnus-use-dribble-file
13394 (or (not gnus-dribble-buffer
)
13395 (not (buffer-name gnus-dribble-buffer
))
13396 (zerop (save-excursion
13397 (set-buffer gnus-dribble-buffer
)
13399 (gnus-message 4 "(No changes need to be saved)")
13400 (if gnus-save-newsrc-file
13402 (gnus-message 5 "Saving %s..." gnus-current-startup-file
)
13403 ;; Make backup file of master newsrc.
13404 (gnus-gnus-to-newsrc-format)
13405 (gnus-message 5 "Saving %s...done"
13406 gnus-current-startup-file
)))
13407 ;; Quickly loadable .newsrc.
13408 (set-buffer (get-buffer-create " *Gnus-newsrc*"))
13409 (setq buffer-file-name
(concat gnus-current-startup-file
".eld"))
13410 (gnus-add-current-to-buffer-list)
13411 (buffer-disable-undo (current-buffer))
13413 (gnus-message 5 "Saving %s.eld..." gnus-current-startup-file
)
13414 (gnus-gnus-to-quick-newsrc-format)
13416 (kill-buffer (current-buffer))
13417 (gnus-message 5 "Saving %s.eld...done" gnus-current-startup-file
)
13418 (gnus-dribble-delete-file))))))
13420 (defun gnus-gnus-to-quick-newsrc-format ()
13421 "Insert Gnus variables such as gnus-newsrc-alist in lisp format."
13422 (insert ";; Gnus startup file.\n")
13423 (insert ";; Never delete this file - touch .newsrc instead to force Gnus\n")
13424 (insert ";; to read .newsrc.\n")
13425 (insert "(setq gnus-newsrc-file-version "
13426 (prin1-to-string gnus-version
) ")\n")
13427 (let ((variables gnus-variable-list
)
13429 (gnus-newsrc-alist (cdr gnus-newsrc-alist
))
13431 ;; insert lisp expressions.
13432 (gnus-compress-newsrc-alist)
13434 (setq variable
(car variables
))
13435 (and (boundp variable
)
13436 (symbol-value variable
)
13437 (or gnus-save-killed-list
(not (eq variable
'gnus-killed-list
)))
13438 (insert "(setq " (symbol-name variable
) " '"
13439 (prin1-to-string (symbol-value variable
))
13441 (setq variables
(cdr variables
)))
13442 (gnus-uncompress-newsrc-alist)))
13445 (defun gnus-gnus-to-newsrc-format ()
13446 ;; Generate and save the .newsrc file.
13447 (let ((newsrc (cdr gnus-newsrc-alist
))
13450 (set-buffer (create-file-buffer gnus-current-startup-file
))
13451 (setq buffer-file-name gnus-current-startup-file
)
13452 (buffer-disable-undo (current-buffer))
13455 (if gnus-newsrc-options
(insert gnus-newsrc-options
))
13456 ;; Write subscribed and unsubscribed.
13458 (setq info
(car newsrc
))
13459 (if (not (nth 4 info
)) ;Don't write foreign groups to .newsrc.
13461 (insert (car info
) (if (> (nth 1 info
) gnus-level-subscribed
)
13463 (if (setq ranges
(nth 2 info
))
13466 (if (not (listp (cdr ranges
)))
13467 (if (= (car ranges
) (cdr ranges
))
13468 (insert (int-to-string (car ranges
)))
13469 (insert (int-to-string (car ranges
)) "-"
13470 (int-to-string (cdr ranges
))))
13472 (setq range
(car ranges
)
13473 ranges
(cdr ranges
))
13474 (if (or (atom range
) (= (car range
) (cdr range
)))
13475 (insert (int-to-string
13476 (or (and (atom range
) range
)
13478 (insert (int-to-string (car range
)) "-"
13479 (int-to-string (cdr range
))))
13480 (if ranges
(insert ","))))))
13482 (setq newsrc
(cdr newsrc
)))
13483 ;; It has been reported that sometime the modtime on the .newsrc
13484 ;; file seems to be off. We really do want to overwrite it, so
13485 ;; we clear the modtime here before saving. It's a bit odd,
13487 ;; sometimes the modtime clear isn't sufficient. most brute force:
13488 ;; delete the silly thing entirely first. but this fails to provide
13489 ;; such niceties as .newsrc~ creation.
13490 (if gnus-modtime-botch
13491 (delete-file gnus-startup-file
)
13492 (clear-visited-file-modtime))
13494 (kill-buffer (current-buffer)))))
13496 (defun gnus-read-all-descriptions-files ()
13497 (let ((methods (cons gnus-select-method gnus-secondary-select-methods
)))
13499 (gnus-read-descriptions-file (car methods
))
13500 (setq methods
(cdr methods
)))
13503 (defun gnus-read-descriptions-file (&optional method
)
13504 (let ((method (or method gnus-select-method
)))
13505 ;; We create the hashtable whether we manage to read the desc file
13506 ;; to avoid trying to re-read after a failed read.
13507 (or gnus-description-hashtb
13508 (setq gnus-description-hashtb
13509 (gnus-make-hashtable (length gnus-active-hashtb
))))
13510 ;; Mark this method's desc file as read.
13511 (gnus-sethash (gnus-group-prefixed-name "" method
) "Has read"
13512 gnus-description-hashtb
)
13514 (gnus-message 5 "Reading descriptions file via %s..." (car method
))
13516 ((not (gnus-check-server method
))
13517 (gnus-message 1 "Couldn't open server")
13519 ((not (gnus-request-list-newsgroups method
))
13520 (gnus-message 1 "Couldn't read newsgroups descriptions")
13526 (set-buffer nntp-server-buffer
)
13527 (goto-char (point-min))
13528 (if (or (search-forward "\n.\n" nil t
)
13529 (goto-char (point-max)))
13531 (beginning-of-line)
13532 (narrow-to-region (point-min) (point))))
13533 (goto-char (point-min))
13534 (while (not (eobp))
13535 ;; If we get an error, we set group to 0, which is not a
13539 (let ((obarray gnus-description-hashtb
))
13540 ;; Group is set to a symbol interned in this
13542 (read nntp-server-buffer
))
13544 (skip-chars-forward " \t")
13545 ;; ... which leads to this line being effectively ignored.
13546 (and (symbolp group
)
13547 (set group
(buffer-substring
13548 (point) (progn (end-of-line) (point)))))
13549 (forward-line 1))))
13550 (gnus-message 5 "Reading descriptions file...done")
13553 (defun gnus-group-get-description (group)
13554 ;; Get the description of a group by sending XGTITLE to the server.
13555 (and (gnus-request-group-description group
)
13557 (set-buffer nntp-server-buffer
)
13558 (goto-char (point-min))
13559 (and (looking-at "[^ \t]+[ \t]+\\(.*\\)")
13560 (buffer-substring (match-beginning 1) (match-end 1))))))
13566 (defvar gnus-server-mode-hook nil
13567 "Hook run in `gnus-server-mode' buffers.")
13569 (defconst gnus-server-line-format
" {%(%h:%w%)}\n"
13570 "Format of server lines.
13571 It works along the same lines as a normal formatting string,
13572 with some simple extensions.")
13574 (defvar gnus-server-mode-line-format
"Gnus List of servers"
13575 "The format specification for the server mode line.")
13577 (defconst gnus-server-line-format-alist
13578 (list (list ?h
'how ?s
)
13580 (list ?w
'where ?s
)
13583 (defconst gnus-server-mode-line-format-alist
13584 (list (list ?S
'news-server ?s
)
13585 (list ?M
'news-method ?s
)
13586 (list ?u
'user-defined ?s
)))
13588 (defvar gnus-server-line-format-spec nil
)
13589 (defvar gnus-server-mode-line-format-spec nil
)
13590 (defvar gnus-server-killed-servers nil
)
13592 (defvar gnus-server-mode-map nil
)
13593 (put 'gnus-server-mode
'mode-class
'special
)
13595 (if gnus-server-mode-map
13597 (setq gnus-server-mode-map
(make-sparse-keymap))
13598 (suppress-keymap gnus-server-mode-map
)
13599 (define-key gnus-server-mode-map
" " 'gnus-server-read-server
)
13600 (define-key gnus-server-mode-map
"\r" 'gnus-server-read-server
)
13601 (define-key gnus-server-mode-map gnus-mouse-2
'gnus-server-pick-server
)
13602 (define-key gnus-server-mode-map
"q" 'gnus-server-exit
)
13603 (define-key gnus-server-mode-map
"l" 'gnus-server-list-servers
)
13604 (define-key gnus-server-mode-map
"k" 'gnus-server-kill-server
)
13605 (define-key gnus-server-mode-map
"y" 'gnus-server-yank-server
)
13606 (define-key gnus-server-mode-map
"c" 'gnus-server-copy-server
)
13607 (define-key gnus-server-mode-map
"a" 'gnus-server-add-server
)
13608 (define-key gnus-server-mode-map
"e" 'gnus-server-edit-server
))
13610 (defun gnus-server-mode ()
13611 "Major mode for listing and editing servers.
13613 All normal editing commands are switched off.
13614 \\<gnus-server-mode-map>
13616 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
13618 The following commands are available:
13620 \\{gnus-server-mode-map}"
13622 (if gnus-visual
(gnus-server-make-menu-bar))
13623 (kill-all-local-variables)
13624 (gnus-simplify-mode-line)
13625 (setq major-mode
'gnus-server-mode
)
13626 (setq mode-name
"Server")
13627 ; (gnus-group-set-mode-line)
13628 (setq mode-line-process nil
)
13629 (use-local-map gnus-server-mode-map
)
13630 (buffer-disable-undo (current-buffer))
13631 (setq truncate-lines t
)
13632 (setq buffer-read-only t
)
13633 (run-hooks 'gnus-server-mode-hook
))
13635 (defun gnus-server-insert-server-line (sformat name method
)
13636 (let* ((sformat (or sformat gnus-server-line-format-spec
))
13638 (where (nth 1 method
))
13640 (beginning-of-line)
13642 ;; Insert the text.
13643 (insert (eval sformat
))
13644 (add-text-properties b
(1+ b
) (list 'gnus-server
(intern name
)))))
13646 (defun gnus-server-setup-buffer ()
13647 (if (get-buffer gnus-server-buffer
)
13650 (set-buffer (get-buffer-create gnus-server-buffer
))
13652 (and gnus-carpal
(gnus-carpal-setup-buffer 'server
)))))
13654 (defun gnus-server-prepare ()
13655 (setq gnus-server-mode-line-format-spec
13656 (gnus-parse-format gnus-server-mode-line-format
13657 gnus-server-mode-line-format-alist
))
13658 (setq gnus-server-line-format-spec
13659 (gnus-parse-format gnus-server-line-format
13660 gnus-server-line-format-alist
))
13661 (let ((alist gnus-server-alist
)
13662 (buffer-read-only nil
))
13665 (gnus-server-insert-server-line nil
(car (car alist
)) (cdr (car alist
)))
13666 (setq alist
(cdr alist
))))
13667 (goto-char (point-min))
13668 (gnus-server-position-cursor))
13670 (defun gnus-server-server-name ()
13671 (let ((server (get-text-property (gnus-point-at-bol) 'gnus-server
)))
13672 (and server
(symbol-name server
))))
13674 (defalias 'gnus-server-position-cursor
'gnus-goto-colon
)
13676 (defconst gnus-server-edit-buffer
"*Gnus edit server*")
13678 (defun gnus-server-update-server (server)
13680 (set-buffer gnus-server-buffer
)
13681 (let ((buffer-read-only nil
)
13682 (info (cdr (assoc server gnus-server-alist
))))
13683 (gnus-dribble-enter
13684 (concat "(gnus-server-set-info \"" server
"\" '"
13685 (prin1-to-string info
) ")"))
13686 ;; Buffer may be narrowed.
13689 (if (gnus-server-goto-server server
)
13690 (delete-region (progn (beginning-of-line) (point))
13691 (progn (forward-line 1) (point))))
13692 (let ((entry (assoc server gnus-server-alist
)))
13693 (gnus-server-insert-server-line nil
(car entry
) (cdr entry
))
13694 (gnus-server-position-cursor))))))
13696 (defun gnus-server-set-info (server info
)
13697 ;; Enter a select method into the virtual server alist.
13698 (gnus-dribble-enter
13699 (concat "(gnus-server-set-info \"" server
"\" '"
13700 (prin1-to-string info
) ")"))
13701 (let* ((server (nth 1 info
))
13702 (entry (assoc server gnus-server-alist
)))
13703 (if entry
(setcdr entry info
)
13704 (setq gnus-server-alist
13705 (nconc gnus-server-alist
(list (cons server info
)))))))
13707 (defun gnus-server-to-method (server)
13708 ;; Map virtual server names to select methods.
13709 (or (and (equal server
"native") gnus-select-method
)
13710 (cdr (assoc server gnus-server-alist
))))
13712 (defun gnus-server-extend-method (group method
)
13713 ;; This function "extends" a virtual server. If the server is
13714 ;; "hello", and the select method is ("hello" (my-var "something"))
13715 ;; in the group "alt.alt", this will result in a new virtual server
13716 ;; called "helly+alt.alt".
13718 (gnus-copy-sequence
13719 (if (equal (car method
) "native") gnus-select-method
13720 (cdr (assoc (car method
) gnus-server-alist
))))))
13721 (setcar (cdr entry
) (concat (nth 1 entry
) "+" group
))
13722 (nconc entry
(cdr method
))))
13724 (defun gnus-server-get-method (group method
)
13725 ;; Input either a server name, and extended server name, or a
13726 ;; select method, and return a select method.
13727 (cond ((stringp method
)
13728 (gnus-server-to-method method
))
13729 ((and (stringp (car method
)) group
)
13730 (gnus-server-extend-method group method
))
13732 (gnus-server-add-address method
))))
13734 (defun gnus-server-add-address (method)
13735 (let ((method-name (symbol-name (car method
))))
13736 (if (and (memq 'address
(assoc method-name gnus-valid-select-methods
))
13737 (not (assq (intern (concat method-name
"-address")) method
)))
13738 (append method
(list (list (intern (concat method-name
"-address"))
13742 (defun gnus-server-equal (s1 s2
)
13744 (and (= (length s1
) (length s2
))
13746 (while (and s1
(member (car s1
) s2
))
13747 (setq s1
(cdr s1
)))
13750 ;;; Interactive server functions.
13752 (defun gnus-server-kill-server (server)
13753 "Kill the server on the current line."
13754 (interactive (list (gnus-server-server-name)))
13755 (or (gnus-server-goto-server server
)
13756 (if server
(error "No such server: %s" server
)
13757 (error "No server on the current line")))
13758 (gnus-dribble-enter "")
13759 (let ((buffer-read-only nil
))
13760 (delete-region (progn (beginning-of-line) (point))
13761 (progn (forward-line 1) (point))))
13762 (setq gnus-server-killed-servers
13763 (cons (assoc server gnus-server-alist
) gnus-server-killed-servers
))
13764 (setq gnus-server-alist
(delq (car gnus-server-killed-servers
)
13765 gnus-server-alist
))
13766 (gnus-server-position-cursor))
13768 (defun gnus-server-yank-server ()
13769 "Yank the previously killed server."
13771 (or gnus-server-killed-servers
13772 (error "No killed servers to be yanked"))
13773 (let ((alist gnus-server-alist
)
13774 (server (gnus-server-server-name))
13775 (killed (car gnus-server-killed-servers
)))
13777 (setq gnus-server-alist
(nconc gnus-server-alist
(list killed
)))
13778 (if (string= server
(car (car gnus-server-alist
)))
13779 (setq gnus-server-alist
(cons killed gnus-server-alist
))
13780 (while (and (cdr alist
)
13781 (not (string= server
(car (car (cdr alist
))))))
13782 (setq alist
(cdr alist
)))
13783 (setcdr alist
(cons killed
(cdr alist
)))))
13784 (gnus-server-update-server (car killed
))
13785 (setq gnus-server-killed-servers
(cdr gnus-server-killed-servers
))
13786 (gnus-server-position-cursor)))
13788 (defun gnus-server-exit ()
13789 "Return to the group buffer."
13791 (kill-buffer (current-buffer))
13792 (switch-to-buffer gnus-group-buffer
))
13794 (defun gnus-server-list-servers ()
13795 "List all available servers."
13797 (let ((cur (gnus-server-server-name)))
13798 (gnus-server-prepare)
13799 (if cur
(gnus-server-goto-server cur
)
13800 (goto-char (point-max))
13802 (gnus-server-position-cursor)))
13804 (defun gnus-server-copy-server (from to
)
13807 (or (gnus-server-server-name)
13808 (error "No server on the current line"))
13809 (read-string "Copy to: ")))
13810 (or from
(error "No server on current line"))
13811 (or (and to
(not (string= to
""))) (error "No name to copy to"))
13812 (and (assoc to gnus-server-alist
) (error "%s already exists" to
))
13813 (or (assoc from gnus-server-alist
)
13814 (error "%s: no such server" from
))
13815 (let ((to-entry (gnus-copy-sequence (assoc from gnus-server-alist
))))
13816 (setcar to-entry to
)
13817 (setcar (nthcdr 2 to-entry
) to
)
13818 (setq gnus-server-killed-servers
13819 (cons to-entry gnus-server-killed-servers
))
13820 (gnus-server-yank-server)))
13822 (defun gnus-server-add-server (how where
)
13824 (list (intern (completing-read "Server method: "
13825 gnus-valid-select-methods nil t
))
13826 (read-string "Server name: ")))
13827 (setq gnus-server-killed-servers
13828 (cons (list where how where
) gnus-server-killed-servers
))
13829 (gnus-server-yank-server))
13831 (defun gnus-server-goto-server (server)
13832 "Jump to a server line."
13834 (list (completing-read "Goto server: " gnus-server-alist nil t
)))
13835 (let ((to (text-property-any (point-min) (point-max)
13836 'gnus-server
(intern server
))))
13840 (gnus-server-position-cursor)))))
13842 (defun gnus-server-edit-server (server)
13843 "Edit the server on the current line."
13844 (interactive (list (gnus-server-server-name)))
13846 (error "No server on current line"))
13847 (let ((winconf (current-window-configuration)))
13848 (get-buffer-create gnus-server-edit-buffer
)
13849 (gnus-configure-windows 'edit-server
)
13850 (gnus-add-current-to-buffer-list)
13852 (make-local-variable 'gnus-prev-winconf
)
13853 (setq gnus-prev-winconf winconf
)
13854 (use-local-map (copy-keymap (current-local-map)))
13855 (let ((done-func '(lambda ()
13856 "Exit editing mode and update the information."
13858 (gnus-server-edit-server-done 'group
))))
13859 (setcar (cdr (nth 4 done-func
)) server
)
13860 (local-set-key "\C-c\C-c" done-func
))
13862 (insert ";; Type `C-c C-c' after you have edited the server.\n\n")
13863 (insert (pp-to-string (cdr (assoc server gnus-server-alist
))))))
13865 (defun gnus-server-edit-server-done (server)
13867 (set-buffer (get-buffer-create gnus-server-edit-buffer
))
13868 (goto-char (point-min))
13869 (let ((form (read (current-buffer)))
13870 (winconf gnus-prev-winconf
))
13871 (gnus-server-set-info server form
)
13872 (kill-buffer (current-buffer))
13873 (and winconf
(set-window-configuration winconf
))
13874 (set-buffer gnus-server-buffer
)
13875 (gnus-server-update-server (gnus-server-server-name))
13876 (gnus-server-list-servers)
13877 (gnus-server-position-cursor)))
13879 (defun gnus-server-read-server (server)
13881 (interactive (list (gnus-server-server-name)))
13882 (gnus-browse-foreign-server (gnus-server-to-method server
) (current-buffer)))
13884 (defun gnus-mouse-pick-server (e)
13886 (mouse-set-point e
)
13887 (gnus-server-read-server (gnus-server-server-name)))
13890 ;;; entry points into gnus-score.el
13893 ;;; Finding score files.
13895 (defvar gnus-global-score-files nil
13896 "*List of global score files and directories.
13897 Set this variable if you want to use people's score files. One entry
13898 for each score file or each score file directory. Gnus will decide
13899 by itself what score files are applicable to which group.
13901 Say you want to use the single score file
13902 \"/ftp.ifi.uio.no@ftp:/pub/larsi/ding/score/soc.motss.SCORE\" and all
13903 score files in the \"/ftp.some-where:/pub/score\" directory.
13905 (setq gnus-global-score-files
13906 '(\"/ftp.ifi.uio.no:/pub/larsi/ding/score/soc.motss.SCORE\"
13907 \"/ftp.some-where:/pub/score\"))")
13909 (defun gnus-score-score-files (group)
13910 "Return a list of all possible score files."
13911 ;; Search and set any global score files.
13912 (and gnus-global-score-files
13913 (or gnus-internal-global-score-files
13914 (gnus-score-search-global-directories gnus-global-score-files
)))
13915 ;; Fix the kill-file dir variable.
13916 (setq gnus-kill-files-directory
13917 (file-name-as-directory
13918 (or gnus-kill-files-directory
"~/News/")))
13919 ;; If we can't read it, there are no score files.
13920 (if (not (file-exists-p (expand-file-name gnus-kill-files-directory
)))
13921 (setq gnus-score-file-list nil
)
13922 (if (gnus-use-long-file-name 'not-score
)
13923 ;; We want long file names.
13924 (if (or (not gnus-score-file-list
)
13925 (not (car gnus-score-file-list
))
13926 (gnus-file-newer-than gnus-kill-files-directory
13927 (car gnus-score-file-list
)))
13928 (setq gnus-score-file-list
13929 (cons (nth 5 (file-attributes gnus-kill-files-directory
))
13932 gnus-kill-files-directory t
13933 (gnus-score-file-regexp))))))
13934 ;; We do not use long file names, so we have to do some
13935 ;; directory traversing.
13936 (let ((mdir (length (expand-file-name gnus-kill-files-directory
)))
13937 (suffixes (list gnus-score-file-suffix gnus-adaptive-file-suffix
))
13940 (setq dir
(expand-file-name
13941 (concat gnus-kill-files-directory
13942 (gnus-replace-chars-in-string group ?. ?
/))))
13943 (setq dir
(gnus-replace-chars-in-string dir ?
: ?
/))
13944 (setq suffix
(car suffixes
)
13945 suffixes
(cdr suffixes
))
13946 (if (file-exists-p (concat dir
"/" suffix
))
13947 (setq files
(cons (concat dir
"/" suffix
) files
)))
13948 (while (>= (1+ (length dir
)) mdir
)
13949 (and (file-exists-p (concat dir
"/all/" suffix
))
13950 (setq files
(cons (concat dir
"/all/" suffix
) files
)))
13951 (string-match "/[^/]*$" dir
)
13952 (setq dir
(substring dir
0 (match-beginning 0)))))
13953 (setq gnus-score-file-list
13954 (cons nil
(nreverse files
)))))
13955 (cdr gnus-score-file-list
)))
13957 (defun gnus-score-file-regexp ()
13958 (concat "\\(" gnus-score-file-suffix
13959 "\\|" gnus-adaptive-file-suffix
"\\)$"))
13961 (defun gnus-score-find-bnews (group)
13962 "Return a list of score files for GROUP.
13963 The score files are those files in the ~/News directory which matches
13964 GROUP using BNews sys file syntax."
13965 (let* ((sfiles (append (gnus-score-score-files group
)
13966 gnus-internal-global-score-files
))
13967 (kill-dir (file-name-as-directory
13968 (expand-file-name gnus-kill-files-directory
)))
13969 (klen (length kill-dir
))
13970 ofiles not-match regexp
)
13972 (set-buffer (get-buffer-create "*gnus score files*"))
13973 (buffer-disable-undo (current-buffer))
13974 ;; Go through all score file names and create regexp with them
13978 (insert (car sfiles
))
13979 (goto-char (point-min))
13980 ;; First remove the suffix itself.
13981 (re-search-forward (concat "." (gnus-score-file-regexp)))
13982 (replace-match "" t t
)
13983 (goto-char (point-min))
13984 (if (looking-at (regexp-quote kill-dir
))
13985 ;; If the file name was just "SCORE", `klen' is one character
13987 (delete-char (min (1- (point-max)) klen
))
13988 (goto-char (point-max))
13989 (search-backward "/")
13990 (delete-region (1+ (point)) (point-min)))
13991 ;; If short file names were used, we have to translate slashes.
13992 (goto-char (point-min))
13993 (while (re-search-forward "[/:]" nil t
)
13994 (replace-match "." t t
))
13995 ;; Kludge to get rid of "nntp+" problems.
13996 (goto-char (point-min))
13997 (and (looking-at "nn[a-z]+\\+")
13999 (search-forward "+")
14002 ;; Translate ".all" to "[./].*";
14003 (while (search-forward ".all" nil t
)
14004 (replace-match "[./:].*" t t
))
14005 (goto-char (point-min))
14006 ;; Translate "all" to ".*".
14007 (while (search-forward "all" nil t
)
14008 (replace-match ".*" t t
))
14009 (goto-char (point-min))
14010 ;; Deal with "not."s.
14011 (if (looking-at "not.")
14014 (setq regexp
(buffer-substring 5 (point-max))))
14015 (setq regexp
(buffer-substring 1 (point-max)))
14016 (setq not-match nil
))
14017 ;; Finally - if this resulting regexp matches the group name,
14018 ;; we add this score file to the list of score files
14019 ;; applicable to this group.
14020 (if (or (and not-match
14021 (not (string-match regexp group
)))
14022 (and (not not-match
)
14023 (string-match regexp group
)))
14024 (setq ofiles
(cons (car sfiles
) ofiles
)))
14025 (setq sfiles
(cdr sfiles
)))
14026 (kill-buffer (current-buffer))
14027 ;; Slight kludge here - the last score file returned should be
14028 ;; the local score file, whether it exists or not. This is so
14029 ;; that any score commands the user enters will go to the right
14030 ;; file, and not end up in some global score file.
14033 (if (gnus-use-long-file-name 'not-score
)
14034 (concat gnus-kill-files-directory group
"."
14035 gnus-score-file-suffix
)
14036 (concat gnus-kill-files-directory
14037 (gnus-replace-chars-in-string group ?. ?
/ ?
: ?
/)
14038 "/" gnus-score-file-suffix
)))))
14039 ;; The local score file might already be there, but it's
14040 ;; supposed to be the very last file, so we delete it from the
14041 ;; list if it's already there, and add it to the head of the
14043 (setq ofiles
(cons localscore
(delete localscore ofiles
))))
14044 (nreverse ofiles
))))
14046 (defun gnus-score-find-single (group)
14047 "Return list containing the score file for GROUP."
14048 (list (gnus-score-file-name group gnus-adaptive-file-suffix
)
14049 (gnus-score-file-name group
)))
14051 (defun gnus-score-find-hierarchical (group)
14052 "Return list of score files for GROUP.
14053 This includes the score file for the group and all its parents."
14054 (let ((all (copy-sequence '(nil)))
14056 (while (string-match "\\." group
(1+ start
))
14057 (setq start
(match-beginning 0))
14058 (setq all
(cons (substring group
0 start
) all
)))
14059 (setq all
(cons group all
))
14061 (mapcar (lambda (newsgroup)
14062 (gnus-score-file-name newsgroup gnus-adaptive-file-suffix
))
14063 (setq all
(nreverse all
)))
14064 (mapcar 'gnus-score-file-name all
))))
14066 (defvar gnus-score-file-alist-cache nil
)
14068 (defun gnus-score-find-alist (group)
14069 "Return list of score files for GROUP.
14070 The list is determined from the variable gnus-score-file-alist."
14071 (let ((alist gnus-score-file-multiple-match-alist
)
14073 ;; if this group has been seen before, return the cached entry
14074 (if (setq score-files
(assoc group gnus-score-file-alist-cache
))
14075 (cdr score-files
) ;ensures caching groups with no matches
14076 ;; handle the multiple match alist
14078 (and (string-match (car (car alist
)) group
)
14080 (nconc score-files
(copy-sequence (cdr (car alist
))))))
14081 (setq alist
(cdr alist
)))
14082 (setq alist gnus-score-file-single-match-alist
)
14083 ;; handle the single match alist
14085 (and (string-match (car (car alist
)) group
)
14086 ;; progn used just in case ("regexp") has no files
14087 ;; and score-files is still nil. -sj
14088 ;; this can be construed as a "stop searching here" feature :>
14089 ;; and used to simplify regexps in the single-alist
14092 (nconc score-files
(copy-sequence (cdr (car alist
)))))
14094 (setq alist
(cdr alist
)))
14095 ;; cache the score files
14096 (setq gnus-score-file-alist-cache
14097 (cons (cons group score-files
) gnus-score-file-alist-cache
))
14101 (defun gnus-possibly-score-headers (&optional trace
)
14102 (let ((func gnus-score-find-score-files-function
)
14104 (and func
(not (listp func
))
14105 (setq func
(list func
)))
14106 ;; Go through all the functions for finding score files (or actual
14107 ;; scores) and add them to a list.
14108 (setq score-files
(gnus-score-find-alist gnus-newsgroup-name
))
14110 (and (symbolp (car func
))
14111 (fboundp (car func
))
14113 (nconc score-files
(funcall (car func
) gnus-newsgroup-name
))))
14114 (setq func
(cdr func
)))
14115 (if score-files
(gnus-score-headers score-files trace
))))
14117 (defun gnus-score-file-name (newsgroup &optional suffix
)
14118 "Return the name of a score file for NEWSGROUP."
14119 (let ((suffix (or suffix gnus-score-file-suffix
)))
14121 ((or (null newsgroup
)
14122 (string-equal newsgroup
""))
14123 ;; The global score file is placed at top of the directory.
14125 suffix
(or gnus-kill-files-directory
"~/News")))
14126 ((gnus-use-long-file-name 'not-score
)
14127 ;; Append ".SCORE" to newsgroup name.
14128 (expand-file-name (concat (gnus-newsgroup-savable-name newsgroup
)
14130 (or gnus-kill-files-directory
"~/News")))
14132 ;; Place "SCORE" under the hierarchical directory.
14133 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup
)
14135 (or gnus-kill-files-directory
"~/News"))))))
14137 (defun gnus-score-search-global-directories (files)
14138 "Scan all global score directories for score files."
14139 ;; Set the variable `gnus-internal-global-score-files' to all
14140 ;; available global score files.
14141 (interactive (list gnus-global-score-files
))
14144 (if (string-match "/$" (car files
))
14145 (setq out
(nconc (directory-files
14147 (concat (gnus-score-file-regexp) "$"))))
14148 (setq out
(cons (car files
) out
)))
14149 (setq files
(cdr files
)))
14150 (setq gnus-internal-global-score-files out
)))
14152 ;; Allow redefinition of Gnus functions.
14154 (gnus-ems-redefine)
14158 ;;; gnus.el ends here