Changeset 3526 for branches/2.2/lisp/gnus/gnus-start.el
- Timestamp:
- 2004年10月31日 15時41分47秒 (4 years ago)
- Files:
-
- branches/2.2/lisp/gnus/gnus-start.el (modified) (67 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/2.2/lisp/gnus/gnus-start.el
r3505 r3526 1 1 ;;; gnus-start.el --- startup functions for Gnus 2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002 2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 3 3 ;; Free Software Foundation, Inc. 4 4 … … 33 33 (require 'gnus-range) 34 34 (require 'gnus-util) 35 (require 'message) 35 (autoload 'message-make-date "message") 36 (autoload 'gnus-agent-read-servers-validate "gnus-agent") 37 (autoload 'gnus-agent-possibly-alter-active "gnus-agent") 36 38 (eval-when-compile (require 'cl)) 37 39 … … 41 43 :group 'gnus-start 42 44 :type 'file) 45 46 (defcustom gnus-backup-startup-file 'never 47 "Whether to create backup files. 48 This variable takes the same values as the `version-control' 49 variable." 50 :version "21.4" 51 :group 'gnus-start 52 :type '(choice (const :tag "Never" never) 53 (const :tag "If existing" nil) 54 (other :tag "Always" t))) 55 56 (defcustom gnus-save-startup-file-via-temp-buffer t 57 "Whether to write the startup file contents to a buffer then save 58 the buffer or write directly to the file. The buffer is faster 59 because all of the contents are written at once. The direct write 60 uses considerably less memory." 61 :version "21.4" 62 :group 'gnus-start 63 :type '(choice (const :tag "Write via buffer" t) 64 (const :tag "Write directly to file" nil))) 43 65 44 66 (defcustom gnus-init-file (nnheader-concat gnus-home-directory ".gnus") … … 225 247 not match this regexp will be removed before saving the list." 226 248 :group 'gnus-newsrc 227 :type 'boolean) 249 :type '(radio (sexp :format "Non-nil\n" 250 :match (lambda (widget value) 251 (and value (not (stringp value)))) 252 :value t) 253 (const nil) 254 (regexp :format "%t: %v\n" :size 0))) 228 255 229 256 (defcustom gnus-ignored-newsgroups 230 257 (mapconcat 'identity 231 258 '("^to\\." ; not "real" groups 232 "^[0-9. \t]+ "; all digits in name259 "^[0-9. \t]+\\( \\|$\\)" ; all digits in name 233 260 "^[\"][]\"[#'()]" ; bogus characters 234 261 ) … … 242 269 243 270 (defcustom gnus-subscribe-newsgroup-method 'gnus-subscribe-zombies 244 "*Function called with a group name when new group is detected.271 "*Function(s) called with a group name when new group is detected. 245 272 A few pre-made functions are supplied: `gnus-subscribe-randomly' 246 273 inserts new groups at the beginning of the list of groups; … … 260 287 (function-item gnus-subscribe-zombies) 261 288 (function-item gnus-subscribe-topics) 262 function)) 289 function 290 (repeat function))) 291 292 (defcustom gnus-subscribe-newsgroup-hooks nil 293 "*Hooks run after you subscribe to a new group. 294 The hooks will be called with new group's name as argument." 295 :group 'gnus-group-new 296 :type 'hook) 263 297 264 298 (defcustom gnus-subscribe-options-newsgroup-method 265 299 'gnus-subscribe-alphabetically 266 "* This function iscalled to subscribe newsgroups mentioned on \"options -n\" lines.300 "*Function(s) called to subscribe newsgroups mentioned on \"options -n\" lines. 267 301 If, for instance, you want to subscribe to all newsgroups in the 268 302 \"no\" and \"alt\" hierarchies, you'd put the following in your … … 280 314 (function-item gnus-subscribe-killed) 281 315 (function-item gnus-subscribe-zombies) 282 function)) 316 (function-item gnus-subscribe-topics) 317 function 318 (repeat function))) 283 319 284 320 (defcustom gnus-subscribe-hierarchical-interactive nil … … 295 331 296 332 (defcustom gnus-auto-subscribed-groups 297 " nnml\\|^nnfolder\\|^nnmbox\\|^nnmh\\|^nnbabyl"333 "^nnml\\|^nnfolder\\|^nnmbox\\|^nnmh\\|^nnbabyl\\|^nnmaildir" 298 334 "*All new groups that match this regexp will be subscribed automatically. 299 335 Note that this variable only deals with new groups. It has no effect … … 355 391 :type 'hook) 356 392 357 (defcustom gnus-setup-news-hook nil 393 (defcustom gnus-setup-news-hook 394 '(gnus-fixup-nnimap-unread-after-getting-new-news) 358 395 "A hook after reading the .newsrc file, but before generating the buffer." 359 396 :group 'gnus-start 397 :type 'hook) 398 399 (defcustom gnus-get-top-new-news-hook nil 400 "A hook run just before Gnus checks for new news globally." 401 :group 'gnus-group-new 360 402 :type 'hook) 361 403 … … 366 408 367 409 (defcustom gnus-after-getting-new-news-hook 368 (when (gnus-boundp 'display-time-timer)369 '(display-time-event-handler))410 '(gnus-display-time-event-handler 411 gnus-fixup-nnimap-unread-after-getting-new-news) 370 412 "*A hook run after Gnus checks for new news when Gnus is already running." 371 413 :group 'gnus-group-new 414 :type 'hook) 415 416 (defcustom gnus-read-newsrc-el-hook nil 417 "A hook called after reading the newsrc.eld? file." 418 :group 'gnus-newsrc 372 419 :type 'hook) 373 420 … … 387 434 Can be used to turn version control on or off." 388 435 :group 'gnus-newsrc 436 :type 'hook) 437 438 (defcustom gnus-group-mode-hook nil 439 "Hook for Gnus group mode." 440 :group 'gnus-group-various 441 :options '(gnus-topic-mode) 389 442 :type 'hook) 390 443 … … 433 486 (load file nil t) 434 487 (error 435 (error "Error in %s: %s" file var)))))))))488 (error "Error in %s: %s" file (cadr var)))))))))) 436 489 437 490 ;; For subscribing new newsgroup … … 509 562 510 563 (defun gnus-subscribe-alphabetically (newgroup) 511 "Subscribe new NEW SGROUP and insert it in alphabetical order."564 "Subscribe new NEWGROUP and insert it in alphabetical order." 512 565 (let ((groups (cdr gnus-newsrc-alist)) 513 566 before) … … 519 572 520 573 (defun gnus-subscribe-hierarchically (newgroup) 521 "Subscribe new NEW SGROUP and insert it in hierarchical newsgroup order."574 "Subscribe new NEWGROUP and insert it in hierarchical newsgroup order." 522 575 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams) 523 576 (save-excursion 524 577 (set-buffer (nnheader-find-file-noselect gnus-current-startup-file)) 525 ( let ((groupkey newgroup)526 before)527 (while (and (not before) groupkey)528 (goto-char (point-min))529 (let ((groupkey-re530 (concat "^\\(" (regexp-quote groupkey) ".*\\)[!:]")))531 (while (and (re-search-forward groupkey-re nil t)532 (progn533 (setq before (match-string 1))534 (string< before newgroup)))))535 ;; Remove tail of newsgroup name (eg. a.b.c -> a.b)536 (setq groupkey537 (when (string-match "^\\(.*\\)\\.[^.]+$" groupkey)538 (substring groupkey (match-beginning 1) (match-end 1)))))539 (gnus-subscribe-newsgroup newgroup before))540 (kill-buffer (current-buffer))))578 (prog1 579 (let ((groupkey newgroup) before) 580 (while (and (not before) groupkey) 581 (goto-char (point-min)) 582 (let ((groupkey-re 583 (concat "^\\(" (regexp-quote groupkey) ".*\\)[!:]"))) 584 (while (and (re-search-forward groupkey-re nil t) 585 (progn 586 (setq before (match-string 1)) 587 (string< before newgroup))))) 588 ;; Remove tail of newsgroup name (eg. a.b.c -> a.b) 589 (setq groupkey 590 (when (string-match "^\\(.*\\)\\.[^.]+$" groupkey) 591 (substring groupkey (match-beginning 1) (match-end 1))))) 592 (gnus-subscribe-newsgroup newgroup before)) 593 (kill-buffer (current-buffer))))) 541 594 542 595 (defun gnus-subscribe-interactively (group) … … 567 620 gnus-level-killed (gnus-gethash (or next "dummy.group") 568 621 gnus-newsrc-hashtb)) 569 (gnus-message 5 "Subscribe newsgroup: %s" newsgroup))) 622 (gnus-message 5 "Subscribe newsgroup: %s" newsgroup) 623 (run-hook-with-args 'gnus-subscribe-newsgroup-hooks newsgroup) 624 t)) 570 625 571 626 (defun gnus-read-active-file-p () … … 576 631 577 632 ;; Silence byte-compiler. 578 (defvar gnus-current-headers) 579 (defvar gnus-thread-indent-array) 580 (defvar gnus-newsgroup-name) 581 (defvar gnus-newsgroup-headers) 582 (defvar gnus-group-list-mode) 583 (defvar gnus-group-mark-positions) 584 (defvar gnus-newsgroup-data) 585 (defvar gnus-newsgroup-unreads) 586 (defvar nnoo-state-alist) 587 (defvar gnus-current-select-method) 633 (eval-when-compile 634 (defvar gnus-current-headers) 635 (defvar gnus-thread-indent-array) 636 (defvar gnus-newsgroup-name) 637 (defvar gnus-newsgroup-headers) 638 (defvar gnus-group-list-mode) 639 (defvar gnus-group-mark-positions) 640 (defvar gnus-newsgroup-data) 641 (defvar gnus-newsgroup-unreads) 642 (defvar nnoo-state-alist) 643 (defvar gnus-current-select-method) 644 (defvar mail-sources) 645 (defvar nnmail-scan-directory-mail-source-once) 646 (defvar nnmail-split-history) 647 (defvar nnmail-spool-file)) 648 649 (defun gnus-close-all-servers () 650 "Close all servers." 651 (interactive) 652 (dolist (server gnus-opened-servers) 653 (gnus-close-server (car server)))) 588 654 589 655 (defun gnus-clear-system () 590 656 "Clear all variables and buffers." 591 657 ;; Clear Gnus variables. 592 (let ((variables gnus-variable-list))658 (let ((variables (remove 'gnus-format-specs gnus-variable-list))) 593 659 (while variables 594 660 (set (car variables) nil) … … 597 663 (setq gnus-list-of-killed-groups nil 598 664 gnus-have-read-active-file nil 665 gnus-agent-covered-methods nil 666 gnus-server-method-cache nil 599 667 gnus-newsrc-alist nil 600 668 gnus-newsrc-hashtb nil … … 631 699 (gnus-kill-buffer nntp-server-buffer) 632 700 ;; Kill Gnus buffers. 633 (let ((buffers (gnus-buffers))) 634 (when buffers 635 (mapcar 'kill-buffer buffers))) 701 (dolist (buffer (gnus-buffers)) 702 (gnus-kill-buffer buffer)) 636 703 ;; Remove Gnus frames. 637 704 (gnus-kill-gnus-frames)) … … 671 738 (setq gnus-slave slave) 672 739 (gnus-read-init-file) 740 (if gnus-agent 741 (gnus-agentize)) 673 742 674 743 (when gnus-simple-splash … … 708 777 709 778 ;; Do the actual startup. 779 (if gnus-agent 780 (gnus-request-create-group "queue" '(nndraft ""))) 781 (gnus-request-create-group "drafts" '(nndraft "")) 710 782 (gnus-setup-news nil level dont-connect) 711 783 (gnus-run-hooks 'gnus-setup-news-hook) … … 727 799 "nndraft:drafts" 'gnus-dummy '((gnus-draft-mode))))) 728 800 729 ;;;###autoload730 (defun gnus-unload ()731 "Unload all Gnus features.732 \(For some value of `all' or `Gnus'.) Currently, features whose names733 have prefixes `gnus-', `nn', `mm-' or `rfc' are unloaded. Use734 cautiously -- unloading may cause trouble."735 (interactive)736 (dolist (feature features)737 (if (string-match "^\\(gnus-\\|nn\\|mm-\\|rfc\\)" (symbol-name feature))738 (unload-feature feature 'force))))739 740 801 741 802 ;;; … … 764 825 (goto-char (point-max)) 765 826 (insert string "\n") 766 (set-window-point (get-buffer-window (current-buffer)) (point-max)) 827 ;; This has been commented by Josh Huber <huber@alum.wpi.edu> 828 ;; It causes problems with both XEmacs and Emacs 21, and doesn't 829 ;; seem to be of much value. (FIXME: remove this after we make sure 830 ;; it's not needed). 831 ;; (set-window-point (get-buffer-window (current-buffer)) (point-max)) 767 832 (bury-buffer gnus-dribble-buffer) 768 833 (save-excursion … … 790 855 (let ((auto (make-auto-save-file-name)) 791 856 (gnus-dribble-ignore t) 857 (purpose nil) 792 858 modes) 793 859 (when (or (file-exists-p auto) (file-exists-p dribble-file)) … … 805 871 (setq modes (file-modes gnus-current-startup-file))) 806 872 (set-file-modes dribble-file modes)) 873 (goto-char (point-min)) 874 (when (search-forward "Gnus was exited on purpose" nil t) 875 (setq purpose t)) 807 876 ;; Possibly eval the file later. 808 877 (when (or gnus-always-read-dribble-file 809 878 (gnus-y-or-n-p 810 "Gnus auto-save file exists. Do you want to read it? ")) 879 (if purpose 880 "Gnus exited on purpose without saving; read auto-save file anyway? " 881 "Gnus auto-save file exists. Do you want to read it? "))) 811 882 (setq gnus-dribble-eval-file t))))))) 812 883 … … 870 941 ;; Make sure the archive server is available to all and sundry. 871 942 (when gnus-message-archive-method 872 (setq gnus-server-alist (delq (assoc "archive" gnus-server-alist) 873 gnus-server-alist)) 874 (push (cons "archive" gnus-message-archive-method) 875 gnus-server-alist)) 943 (unless (assoc "archive" gnus-server-alist) 944 (push `("archive" 945 nnfolder 946 "archive" 947 (nnfolder-directory 948 ,(nnheader-concat message-directory "archive")) 949 (nnfolder-active-file 950 ,(nnheader-concat message-directory "archive/active")) 951 (nnfolder-get-new-mail nil) 952 (nnfolder-inhibit-expiry t)) 953 gnus-server-alist))) 876 954 877 955 ;; If we don't read the complete active file, we fill in the … … 880 958 (eq gnus-read-active-file 'some)) 881 959 (gnus-update-active-hashtb-from-killed)) 960 961 ;; Validate agent covered methods now that gnus-server-alist has 962 ;; been initialized. 963 ;; NOTE: This is here for one purpose only. By validating the 964 ;; agentized server's, it converts the old 5.10.3, and earlier, 965 ;; format to the current format. That enables the agent code 966 ;; within gnus-read-active-file to function correctly. 967 (if gnus-agent 968 (gnus-agent-read-servers-validate)) 882 969 883 970 ;; Read the active file and create `gnus-active-hashtb'. … … 909 996 ;; See whether we need to read the description file. 910 997 (when (and (boundp 'gnus-group-line-format) 998 (stringp gnus-group-line-format) 911 999 (let ((case-fold-search nil)) 912 1000 (string-match "%[-,0-9]*D" gnus-group-line-format)) … … 923 1011 (gnus-find-new-newsgroups)) 924 1012 1013 ;; Check and remove bogus newsgroups. 1014 (when (and init gnus-check-bogus-newsgroups 1015 gnus-read-active-file (not level) 1016 (gnus-server-opened gnus-select-method)) 1017 (gnus-check-bogus-newsgroups)) 1018 925 1019 ;; We might read in new NoCeM messages here. 926 1020 (when (and gnus-use-nocem … … 934 1028 ;; Find the number of unread articles in each non-dead group. 935 1029 (let ((gnus-read-active-file (and (not level) gnus-read-active-file))) 936 (gnus-get-unread-articles level)) 937 938 (when (and init gnus-check-bogus-newsgroups 939 gnus-read-active-file (not level) 940 (gnus-server-opened gnus-select-method)) 941 (gnus-check-bogus-newsgroups)))) 1030 (gnus-get-unread-articles level)))) 1031 1032 (defun gnus-call-subscribe-functions (method group) 1033 "Call METHOD to subscribe GROUP. 1034 If no function returns `non-nil', call `gnus-subscribe-zombies'." 1035 (unless (cond 1036 ((functionp method) 1037 (funcall method group)) 1038 ((listp method) 1039 (catch 'found 1040 (dolist (func method) 1041 (if (funcall func group) 1042 (throw 'found t))) 1043 nil)) 1044 (t nil)) 1045 (gnus-subscribe-zombies group))) 942 1046 943 1047 (defun gnus-find-new-newsgroups (&optional arg) … … 993 1097 (setq groups (1+ groups)) 994 1098 (gnus-sethash group group gnus-killed-hashtb) 995 (funcall gnus-subscribe-options-newsgroup-method group)) 1099 (gnus-call-subscribe-functions 1100 gnus-subscribe-options-newsgroup-method group)) 996 1101 ((eq do-sub 'ignore) 997 1102 nil) … … 1001 1106 (if gnus-subscribe-hierarchical-interactive 1002 1107 (push group new-newsgroups) 1003 (funcall gnus-subscribe-newsgroup-method group))))))) 1108 (gnus-call-subscribe-functions 1109 gnus-subscribe-newsgroup-method group))))))) 1004 1110 gnus-active-hashtb) 1005 1111 (when new-newsgroups … … 1086 1192 (incf groups) 1087 1193 (gnus-sethash group group gnus-killed-hashtb) 1088 (funcall gnus-subscribe-options-newsgroup-method group)) 1194 (gnus-call-subscribe-functions 1195 gnus-subscribe-options-newsgroup-method group)) 1089 1196 ((eq do-sub 'ignore) 1090 1197 nil) … … 1094 1201 (if gnus-subscribe-hierarchical-interactive 1095 1202 (push group new-newsgroups) 1096 (funcall gnus-subscribe-newsgroup-method group))))))) 1203 (gnus-call-subscribe-functions 1204 gnus-subscribe-newsgroup-method group))))))) 1097 1205 hashtb)) 1098 1206 (when new-newsgroups … … 1110 1218 ;; First check if any of the following files exist. If they do, 1111 1219 ;; it's not the first time the user has used Gnus. 1112 (dolist (file (list gnus-current-startup-file 1113 (concat gnus-current-startup-file ".el") 1220 (dolist (file (list (concat gnus-current-startup-file ".el") 1114 1221 (concat gnus-current-startup-file ".eld") 1115 gnus-startup-file1116 1222 (concat gnus-startup-file ".el") 1117 1223 (concat gnus-startup-file ".eld"))) … … 1127 1233 gnus-backup-default-subscribed-newsgroups)) 1128 1234 group) 1129 (when (eq groups t) 1130 ;; If t, we subscribe (or not) all groups as if they were new. 1131 (mapatoms 1132 (lambda (sym) 1133 (when (setq group (symbol-name sym)) 1134 (let ((do-sub (gnus-matches-options-n group))) 1135 (cond 1136 ((eq do-sub 'subscribe) 1137 (gnus-sethash group group gnus-killed-hashtb) 1138 (funcall gnus-subscribe-options-newsgroup-method group)) 1139 ((eq do-sub 'ignore) 1140 nil) 1141 (t 1142 (push group gnus-killed-list)))))) 1143 gnus-active-hashtb) 1235 (if (eq groups t) 1236 ;; If t, we subscribe (or not) all groups as if they were new. 1237 (mapatoms 1238 (lambda (sym) 1239 (when (setq group (symbol-name sym)) 1240 (let ((do-sub (gnus-matches-options-n group))) 1241 (cond 1242 ((eq do-sub 'subscribe) 1243 (gnus-sethash group group gnus-killed-hashtb) 1244 (gnus-call-subscribe-functions 1245 gnus-subscribe-options-newsgroup-method group)) 1246 ((eq do-sub 'ignore) 1247 nil) 1248 (t 1249 (push group gnus-killed-list)))))) 1250 gnus-active-hashtb) 1144 1251 (dolist (group groups) 1145 1252 ;; Only subscribe the default groups that are activated. … … 1149 1256 (save-excursion 1150 1257 (set-buffer gnus-group-buffer) 1151 (gnus-group-make-help-group)) 1258 ;; Don't error if the group already exists. This happens when a 1259 ;; first-time user types 'F'. -- didier 1260 (gnus-group-make-help-group t)) 1152 1261 (when gnus-novice-user 1153 1262 (gnus-message 7 "`A k' to list killed groups")))))) 1154 1263 1155 1264 (defun gnus-subscribe-group (group &optional previous method) 1156 "Sub cribe GROUP and put it after PREVIOUS."1265 "Subscribe GROUP and put it after PREVIOUS." 1157 1266 (gnus-group-change-level 1158 1267 (if method … … 1214 1323 (cond 1215 1324 ((>= oldlevel gnus-level-zombie) 1216 (if (= oldlevel gnus-level-zombie)1217 (setq gnus-zombie-list (delete group gnus-zombie-list))1218 (setq gnus-killed-list (delete group gnus-killed-list))))1325 ;; oldlevel could be wrong. 1326 (setq gnus-zombie-list (delete group gnus-zombie-list)) 1327 (setq gnus-killed-list (delete group gnus-killed-list))) 1219 1328 (t 1220 1329 (when (and (>= level gnus-level-zombie) … … 1239 1348 (if (= level gnus-level-zombie) 1240 1349 (push group gnus-zombie-list) 1241 (push group gnus-killed-list)))) 1350 (if (= oldlevel gnus-level-killed) 1351 ;; Remove from active hashtb. 1352 (unintern group gnus-active-hashtb) 1353 ;; Don't add it into killed-list if it was killed. 1354 (push group gnus-killed-list))))) 1242 1355 (t 1243 1356 ;; If the list is to be entered into the newsrc assoc, and … … 1307 1420 group (gnus-info-group info)) 1308 1421 (unless (or (gnus-active group) ; Active 1309 (gnus-info-method info)) ; Foreign 1422 (and (gnus-info-method info) 1423 (not (gnus-secondary-method-p 1424 (gnus-info-method info))))) ; Foreign 1310 1425 ;; Found a bogus newsgroup. 1311 1426 (push group bogus))) … … 1378 1493 (gnus-request-scan group method)) 1379 1494 t) 1380 ( condition-case ()1495 (if (or debug-on-error debug-on-quit) 1381 1496 (inline (gnus-request-group group dont-check method)) 1382 ;;(error nil) 1383 (quit 1384 (message "Quit activating %s" group) 1385 nil)) 1386 (setq active (gnus-parse-active)) 1387 ;; If there are no articles in the group, the GROUP 1388 ;; command may have responded with the `(0 . 0)'. We 1389 ;; ignore this if we already have an active entry 1390 ;; for the group. 1391 (if (and (zerop (car active)) 1392 (zerop (cdr active)) 1393 (gnus-active group)) 1394 (gnus-active group) 1395 (gnus-set-active group active) 1396 ;; Return the new active info. 1397 active)))) 1497 (condition-case nil 1498 (inline (gnus-request-group group dont-check method)) 1499 ;;(error nil) 1500 (quit 1501 (message "Quit activating %s" group) 1502 nil))) 1503 (unless dont-check 1504 (setq active (gnus-parse-active)) 1505 ;; If there are no articles in the group, the GROUP 1506 ;; command may have responded with the `(0 . 0)'. We 1507 ;; ignore this if we already have an active entry 1508 ;; for the group. 1509 (if (and (zerop (car active)) 1510 (zerop (cdr active)) 1511 (gnus-active group)) 1512 (gnus-active group) 1513 1514 (gnus-set-active group active) 1515 ;; Return the new active info. 1516 active))))) 1398 1517 1399 1518 (defun gnus-get-unread-articles-in-group (info active &optional update) … … 1412 1531 (inline (gnus-cache-possibly-alter-active 1413 1532 (gnus-info-group info) active))) 1533 1534 ;; If the agent is enabled, we may have to alter the active info. 1535 (when (and gnus-agent info) 1536 (gnus-agent-possibly-alter-active 1537 (gnus-info-group info) active)) 1538 1414 1539 ;; Modify the list of read articles according to what articles 1415 1540 ;; are available; then tally the unread articles and add the … … 1478 1603 (setq num (max 0 (- (cdr active) num))))) 1479 1604 ;; Set the number of unread articles. 1480 (when info 1605 (when (and info 1606 (gnus-gethash (gnus-info-group info) gnus-newsrc-hashtb)) 1481 1607 (setcar (gnus-gethash (gnus-info-group info) gnus-newsrc-hashtb) num)) 1482 1608 num))) … … 1485 1611 ;; and compute how many unread articles there are in each group. 1486 1612 (defun gnus-get-unread-articles (&optional level) 1613 (setq gnus-server-method-cache nil) 1487 1614 (let* ((newsrc (cdr gnus-newsrc-alist)) 1488 1615 (level (or level gnus-activate-level (1+ gnus-level-subscribed))) … … 1496 1623 (t 0)) 1497 1624 level)) 1498 scanned-methods info group active method retrievegroups) 1499 (gnus-message 5 "Checking new news...") 1625 (methods-cache nil) 1626 (type-cache nil) 1627 scanned-methods info group active method retrieve-groups cmethod 1628 method-type) 1629 (gnus-message 6 "Checking new news...") 1500 1630 1501 1631 (while newsrc … … 1515 1645 ;; t for unchecked foreign groups or bogus groups, or groups that can't 1516 1646 ;; be checked, for one reason or other. 1517 (if (and (setq method (gnus-info-method info)) 1518 (not (inline 1519 (gnus-server-equal 1520 gnus-select-method 1521 (setq method (gnus-server-get-method nil method))))) 1522 (not (gnus-secondary-method-p method))) 1647 (when (setq method (gnus-info-method info)) 1648 (if (setq cmethod (assoc method methods-cache)) 1649 (setq method (cdr cmethod)) 1650 (setq cmethod (inline (gnus-server-get-method nil method))) 1651 (push (cons method cmethod) methods-cache) 1652 (setq method cmethod))) 1653 (when (and method 1654 (not (setq method-type (cdr (assoc method type-cache))))) 1655 (setq method-type 1656 (cond 1657 ((gnus-secondary-method-p method) 1658 'secondary) 1659 ((inline (gnus-server-equal gnus-select-method method)) 1660 'primary) 1661 (t 1662 'foreign))) 1663 (push (cons method method-type) type-cache)) 1664 (if (and method 1665 (eq method-type 'foreign)) 1523 1666 ;; These groups are foreign. Check the level. 1524 1667 (when (and (<= (gnus-info-level info) foreign-level) 1525 (setq active (gnus-activate-group group 'scan)))1668 (setq active (gnus-activate-group group 'scan))) 1526 1669 ;; Let the Gnus agent save the active file. 1527 (when (and gnus-agent gnus-plugged active)1670 (when (and gnus-agent active (gnus-online method)) 1528 1671 (gnus-agent-save-group-info 1529 1672 method (gnus-group-real-name group) active)) … … 1543 1686 ;; if server support gnus-retrieve-groups we push 1544 1687 ;; the group onto retrievegroups for later checking 1545 (if (assoc method retrieve groups)1546 (setcdr (assoc method retrieve groups)1547 (cons group (cdr (assoc method retrieve groups))))1548 (push (list method group) retrieve groups))1688 (if (assoc method retrieve-groups) 1689 (setcdr (assoc method retrieve-groups) 1690 (cons group (cdr (assoc method retrieve-groups)))) 1691 (push (list method group) retrieve-groups)) 1549 1692 ;; hack: `nnmail-get-new-mail' changes the mail-source depending 1550 1693 ;; on the group, so we must perform a scan for every group … … 1564 1707 (setq active (gnus-activate-group group 'scan)) 1565 1708 (push method scanned-methods)) 1566 (when active1567 (gnus-close-group group))))))1709 (when active 1710 (gnus-close-group group)))))) 1568 1711 1569 1712 ;; Get the number of unread articles in the group. … … 1579 1722 (gnus-set-active group nil) 1580 1723 (let ((tmp (gnus-gethash group gnus-newsrc-hashtb))) 1581 (if tmp (setcar tmp t)))))) 1724 (when tmp 1725 (setcar tmp t)))))) 1582 1726 1583 1727 ;; iterate through groups on methods which support gnus-retrieve-groups 1584 1728 ;; and fetch a partial active file and use it to find new news. 1585 (while retrievegroups 1586 (let* ((mg (pop retrievegroups)) 1587 (method (or (car mg) gnus-select-method)) 1588 (groups (cdr mg))) 1729 (dolist (rg retrieve-groups) 1730 (let ((method (or (car rg) gnus-select-method)) 1731 (groups (cdr rg))) 1589 1732 (when (gnus-check-server method) 1590 ;; Request that the backend scan its incoming messages.1591 (when (gnus-check-backend-function 'request-scan (car method))1592 (gnus-request-scan nil method))1593 (gnus-read-active-file-2 (mapcar (lambda (group) 1594 (gnus-group-real-name group))1595 groups)method)1596 (dolist (group groups)1597 (cond1598 ((setq active (gnus-active (gnus-info-group1599 (setq info (gnus-get-info group)))))1600 (inline (gnus-get-unread-articles-in-group info active t)))1601 (t1602 ;; The group couldn't be reached, so we nix out the number of1603 ;; unread articles and stuff.1604 (gnus-set-active group nil)1605 (setcar (gnus-gethash group gnus-newsrc-hashtb) t)))))))1606 1607 (gnus-message 5"Checking new news...done")))1733 ;; Request that the backend scan its incoming messages. 1734 (when (gnus-check-backend-function 'request-scan (car method)) 1735 (gnus-request-scan nil method)) 1736 (gnus-read-active-file-2 1737 (mapcar (lambda (group) (gnus-group-real-name group)) groups) 1738 method) 1739 (dolist (group groups) 1740 (cond 1741 ((setq active (gnus-active (gnus-info-group 1742 (setq info (gnus-get-info group))))) 1743 (inline (gnus-get-unread-articles-in-group info active t))) 1744 (t 1745 ;; The group couldn't be reached, so we nix out the number of 1746 ;; unread articles and stuff. 1747 (gnus-set-active group nil) 1748 (setcar (gnus-gethash group gnus-newsrc-hashtb) t))))))) 1749 1750 (gnus-message 6 "Checking new news...done"))) 1608 1751 1609 1752 ;; Create a hash table out of the newsrc alist. The `car's of the … … 1665 1808 (push article news))) 1666 1809 (when news 1810 ;; Enter this list into the group info. 1667 1811 (gnus-info-set-read 1668 1812 info (gnus-remove-from-range (gnus-info-read info) (nreverse news))) 1813 1814 ;; Set the number of unread articles in gnus-newsrc-hashtb. 1815 (gnus-get-unread-articles-in-group info (gnus-active group)) 1816 1817 ;; Insert the change into the group buffer and the dribble file. 1818 (gnus-group-update-group group t)))) 1819 1820 (defun gnus-make-ascending-articles-unread (group articles) 1821 "Mark ascending ARTICLES in GROUP as unread." 1822 (let* ((entry (or (gnus-gethash group gnus-newsrc-hashtb) 1823 (gnus-gethash (gnus-group-real-name group) 1824 gnus-newsrc-hashtb))) 1825 (info (nth 2 entry)) 1826 (ranges (gnus-info-read info)) 1827 (r ranges) 1828 modified) 1829 1830 (while articles 1831 (let ((article (pop articles))) ; get the next article to remove from ranges 1832 (while (let ((range (car ranges))) ; note the current range 1833 (if (atom range) ; single value range 1834 (cond ((not range) 1835 ;; the articles extend past the end of the ranges 1836 ;; OK - I'm done 1837 (setq articles nil)) 1838 ((< range article) 1839 ;; this range preceeds the article. Leave the range unmodified. 1840 (pop ranges) 1841 ranges) 1842 ((= range article) 1843 ;; this range exactly matches the article; REMOVE THE RANGE. 1844 ;; NOTE: When the range being removed is the last range, the list is corrupted by inserting null at its end. 1845 (setcar ranges (cadr ranges)) 1846 (setcdr ranges (cddr ranges)) 1847 (setq modified (if (car ranges) t 'remove-null)) 1848 nil)) 1849 (let ((min (car range)) 1850 (max (cdr range))) 1851 ;; I have a min/max range to consider 1852 (cond ((> min max) ; invalid range introduced by splitter 1853
