Mercurial > emacs
comparison lisp/gnus/gnus-cache.el @ 88155:d7ddb3e565de
sync with trunk
author | Henrik Enberg <henrik.enberg@telia.com> |
---|---|
date | Mon, 16 Jan 2006 00:03:54 +0000 |
parents | 0d8b17d428b5 |
children |
comparison
equal
deleted
inserted
replaced
88154:8ce476d3ba36 | 88155:d7ddb3e565de |
---|---|
1 ;;; gnus-cache.el --- cache interface for Gnus | 1 ;;; gnus-cache.el --- cache interface for Gnus |
2 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000 | 2 |
3 ;; Free Software Foundation, Inc. | 3 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, |
4 ;; 2004, 2005 Free Software Foundation, Inc. | |
4 | 5 |
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org> | 6 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org> |
6 ;; Keywords: news | 7 ;; Keywords: news |
7 | 8 |
8 ;; This file is part of GNU Emacs. | 9 ;; This file is part of GNU Emacs. |
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
18 ;; GNU General Public License for more details. | 19 ;; GNU General Public License for more details. |
19 | 20 |
20 ;; You should have received a copy of the GNU General Public License | 21 ;; You should have received a copy of the GNU General Public License |
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the | 22 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
23 ;; Boston, MA 02111-1307, USA. | 24 ;; Boston, MA 02110-1301, USA. |
24 | 25 |
25 ;;; Commentary: | 26 ;;; Commentary: |
26 | 27 |
27 ;;; Code: | 28 ;;; Code: |
28 | 29 |
31 (require 'gnus) | 32 (require 'gnus) |
32 (require 'gnus-int) | 33 (require 'gnus-int) |
33 (require 'gnus-range) | 34 (require 'gnus-range) |
34 (require 'gnus-start) | 35 (require 'gnus-start) |
35 (eval-when-compile | 36 (eval-when-compile |
37 (if (not (fboundp 'gnus-agent-load-alist)) | |
38 (defun gnus-agent-load-alist (group))) | |
36 (require 'gnus-sum)) | 39 (require 'gnus-sum)) |
37 | 40 |
38 (defcustom gnus-cache-active-file | 41 (defcustom gnus-cache-active-file |
39 (expand-file-name "active" gnus-cache-directory) | 42 (expand-file-name "active" gnus-cache-directory) |
40 "*The cache active file." | 43 "*The cache active file." |
121 (when gnus-cache-buffer | 124 (when gnus-cache-buffer |
122 (let ((buffer (cdr gnus-cache-buffer)) | 125 (let ((buffer (cdr gnus-cache-buffer)) |
123 (overview-file (gnus-cache-file-name | 126 (overview-file (gnus-cache-file-name |
124 (car gnus-cache-buffer) ".overview"))) | 127 (car gnus-cache-buffer) ".overview"))) |
125 ;; write the overview only if it was modified | 128 ;; write the overview only if it was modified |
126 (when (buffer-modified-p buffer) | 129 (when (and (buffer-live-p buffer) (buffer-modified-p buffer)) |
127 (save-excursion | 130 (with-current-buffer buffer |
128 (set-buffer buffer) | |
129 (if (> (buffer-size) 0) | 131 (if (> (buffer-size) 0) |
130 ;; Non-empty overview, write it to a file. | 132 ;; Non-empty overview, write it to a file. |
131 (let ((coding-system-for-write | 133 (let ((coding-system-for-write |
132 gnus-cache-overview-coding-system)) | 134 gnus-cache-overview-coding-system)) |
133 (gnus-write-buffer overview-file)) | 135 (gnus-write-buffer overview-file)) |
158 (setq group (car result) | 160 (setq group (car result) |
159 number (cdr result)))) | 161 number (cdr result)))) |
160 (when (and number | 162 (when (and number |
161 (> number 0) ; Reffed article. | 163 (> number 0) ; Reffed article. |
162 (or force | 164 (or force |
163 (and (or (not gnus-cacheable-groups) | 165 (and (gnus-cache-fully-p group) |
164 (string-match gnus-cacheable-groups group)) | |
165 (or (not gnus-uncacheable-groups) | |
166 (not (string-match | |
167 gnus-uncacheable-groups group))) | |
168 (gnus-cache-member-of-class | 166 (gnus-cache-member-of-class |
169 gnus-cache-enter-articles ticked dormant unread))) | 167 gnus-cache-enter-articles ticked dormant unread))) |
170 (not (file-exists-p (setq file (gnus-cache-file-name | 168 (not (file-exists-p (setq file (gnus-cache-file-name |
171 group number))))) | 169 group number))))) |
172 ;; Possibly create the cache directory. | 170 ;; Possibly create the cache directory. |
181 (gnus-article-decode-hook nil)) | 179 (gnus-article-decode-hook nil)) |
182 (gnus-request-article-this-buffer number group)) | 180 (gnus-request-article-this-buffer number group)) |
183 (when (> (buffer-size) 0) | 181 (when (> (buffer-size) 0) |
184 (let ((coding-system-for-write gnus-cache-coding-system)) | 182 (let ((coding-system-for-write gnus-cache-coding-system)) |
185 (gnus-write-buffer file)) | 183 (gnus-write-buffer file)) |
186 (setq headers (nnheader-parse-head t)) | 184 (nnheader-remove-body) |
185 (setq headers (nnheader-parse-naked-head)) | |
187 (mail-header-set-number headers number) | 186 (mail-header-set-number headers number) |
188 (gnus-cache-change-buffer group) | 187 (gnus-cache-change-buffer group) |
189 (set-buffer (cdr gnus-cache-buffer)) | 188 (set-buffer (cdr gnus-cache-buffer)) |
190 (goto-char (point-max)) | 189 (goto-char (point-max)) |
191 (forward-line -1) | 190 (forward-line -1) |
207 (forward-line 1)) | 206 (forward-line 1)) |
208 (beginning-of-line) | 207 (beginning-of-line) |
209 (nnheader-insert-nov headers) | 208 (nnheader-insert-nov headers) |
210 ;; Update the active info. | 209 ;; Update the active info. |
211 (set-buffer gnus-summary-buffer) | 210 (set-buffer gnus-summary-buffer) |
212 (gnus-cache-update-active group number) | 211 (gnus-cache-possibly-update-active group (cons number number)) |
213 (push article gnus-newsgroup-cached) | 212 (setq gnus-newsgroup-cached |
213 (gnus-add-to-sorted-list gnus-newsgroup-cached article)) | |
214 (gnus-summary-update-secondary-mark article)) | 214 (gnus-summary-update-secondary-mark article)) |
215 t)))))) | 215 t)))))) |
216 | 216 |
217 (defun gnus-cache-enter-remove-article (article) | 217 (defun gnus-cache-enter-remove-article (article) |
218 "Mark ARTICLE for later possible removal." | 218 "Mark ARTICLE for later possible removal." |
233 (gnus-cache-possibly-remove-articles-1))))) | 233 (gnus-cache-possibly-remove-articles-1))))) |
234 (setq gnus-cache-removable-articles nil))) | 234 (setq gnus-cache-removable-articles nil))) |
235 | 235 |
236 (defun gnus-cache-possibly-remove-articles-1 () | 236 (defun gnus-cache-possibly-remove-articles-1 () |
237 "Possibly remove some of the removable articles." | 237 "Possibly remove some of the removable articles." |
238 (unless (eq gnus-use-cache 'passive) | 238 (when (gnus-cache-fully-p gnus-newsgroup-name) |
239 (let ((articles gnus-cache-removable-articles) | 239 (let ((articles gnus-cache-removable-articles) |
240 (cache-articles gnus-newsgroup-cached) | 240 (cache-articles gnus-newsgroup-cached) |
241 article) | 241 article) |
242 (gnus-cache-change-buffer gnus-newsgroup-name) | 242 (gnus-cache-change-buffer gnus-newsgroup-name) |
243 (while articles | 243 (while articles |
281 (if (not cached) | 281 (if (not cached) |
282 ;; No cached articles here, so we just retrieve them | 282 ;; No cached articles here, so we just retrieve them |
283 ;; the normal way. | 283 ;; the normal way. |
284 (let ((gnus-use-cache nil)) | 284 (let ((gnus-use-cache nil)) |
285 (gnus-retrieve-headers articles group fetch-old)) | 285 (gnus-retrieve-headers articles group fetch-old)) |
286 (let ((uncached-articles (gnus-sorted-intersection | 286 (let ((uncached-articles (gnus-sorted-difference articles cached)) |
287 (gnus-sorted-complement articles cached) | |
288 articles)) | |
289 (cache-file (gnus-cache-file-name group ".overview")) | 287 (cache-file (gnus-cache-file-name group ".overview")) |
290 type) | 288 type) |
291 ;; We first retrieve all the headers that we don't have in | 289 ;; We first retrieve all the headers that we don't have in |
292 ;; the cache. | 290 ;; the cache. |
293 (let ((gnus-use-cache nil)) | 291 (let ((gnus-use-cache nil)) |
333 (gnus-summary-remove-process-mark article) | 331 (gnus-summary-remove-process-mark article) |
334 (if (natnump article) | 332 (if (natnump article) |
335 (when (gnus-cache-possibly-enter-article | 333 (when (gnus-cache-possibly-enter-article |
336 gnus-newsgroup-name article | 334 gnus-newsgroup-name article |
337 nil nil nil t) | 335 nil nil nil t) |
336 (setq gnus-newsgroup-undownloaded (delq article gnus-newsgroup-undownloaded)) | |
338 (push article out)) | 337 (push article out)) |
339 (gnus-message 2 "Can't cache article %d" article)) | 338 (gnus-message 2 "Can't cache article %d" article)) |
339 (gnus-summary-update-download-mark article) | |
340 (gnus-summary-update-secondary-mark article)) | 340 (gnus-summary-update-secondary-mark article)) |
341 (gnus-summary-next-subject 1) | 341 (gnus-summary-next-subject 1) |
342 (gnus-summary-position-point) | 342 (gnus-summary-position-point) |
343 (nreverse out))) | 343 (nreverse out))) |
344 | 344 |
345 (defun gnus-cache-remove-article (n) | 345 (defun gnus-cache-remove-article (&optional n) |
346 "Remove the next N articles from the cache. | 346 "Remove the next N articles from the cache. |
347 If not given a prefix, use the process marked articles instead. | 347 If not given a prefix, use the process marked articles instead. |
348 Returns the list of articles removed." | 348 Returns the list of articles removed." |
349 (interactive "P") | 349 (interactive "P") |
350 (gnus-cache-change-buffer gnus-newsgroup-name) | 350 (gnus-cache-change-buffer gnus-newsgroup-name) |
352 article out) | 352 article out) |
353 (while articles | 353 (while articles |
354 (setq article (pop articles)) | 354 (setq article (pop articles)) |
355 (gnus-summary-remove-process-mark article) | 355 (gnus-summary-remove-process-mark article) |
356 (when (gnus-cache-possibly-remove-article article nil nil nil t) | 356 (when (gnus-cache-possibly-remove-article article nil nil nil t) |
357 (when gnus-newsgroup-agentized | |
358 (let ((alist (gnus-agent-load-alist gnus-newsgroup-name))) | |
359 (unless (cdr (assoc article alist)) | |
360 (setq gnus-newsgroup-undownloaded | |
361 (gnus-add-to-sorted-list | |
362 gnus-newsgroup-undownloaded article))))) | |
357 (push article out)) | 363 (push article out)) |
364 (gnus-summary-update-download-mark article) | |
358 (gnus-summary-update-secondary-mark article)) | 365 (gnus-summary-update-secondary-mark article)) |
359 (gnus-summary-next-subject 1) | 366 (gnus-summary-next-subject 1) |
360 (gnus-summary-position-point) | 367 (gnus-summary-position-point) |
361 (nreverse out))) | 368 (nreverse out))) |
362 | 369 |
365 (memq article gnus-newsgroup-cached)) | 372 (memq article gnus-newsgroup-cached)) |
366 | 373 |
367 (defun gnus-summary-insert-cached-articles () | 374 (defun gnus-summary-insert-cached-articles () |
368 "Insert all the articles cached for this group into the current buffer." | 375 "Insert all the articles cached for this group into the current buffer." |
369 (interactive) | 376 (interactive) |
370 (let ((cached (sort (copy-sequence gnus-newsgroup-cached) '>)) | 377 (let ((gnus-verbose (max 6 gnus-verbose))) |
371 (gnus-verbose (max 6 gnus-verbose))) | 378 (if (not gnus-newsgroup-cached) |
372 (unless cached | 379 (gnus-message 3 "No cached articles for this group") |
373 (gnus-message 3 "No cached articles for this group")) | 380 (gnus-summary-goto-subjects gnus-newsgroup-cached)))) |
374 (while cached | 381 |
375 (gnus-summary-goto-subject (pop cached) t)))) | 382 (defun gnus-summary-limit-include-cached () |
376 | 383 "Limit the summary buffer to articles that are cached." |
377 (defalias 'gnus-summary-limit-include-cached | 384 (interactive) |
378 'gnus-summary-insert-cached-articles) | 385 (let ((gnus-verbose (max 6 gnus-verbose))) |
386 (if gnus-newsgroup-cached | |
387 (progn | |
388 (gnus-summary-limit gnus-newsgroup-cached) | |
389 (gnus-summary-position-point)) | |
390 (gnus-message 3 "No cached articles for this group")))) | |
379 | 391 |
380 ;;; Internal functions. | 392 ;;; Internal functions. |
381 | 393 |
382 (defun gnus-cache-change-buffer (group) | 394 (defun gnus-cache-change-buffer (group) |
383 (and gnus-cache-buffer | 395 (and gnus-cache-buffer |
408 (and dormant (memq 'dormant class)) | 420 (and dormant (memq 'dormant class)) |
409 (and unread (memq 'unread class)) | 421 (and unread (memq 'unread class)) |
410 (and (not unread) (not ticked) (not dormant) (memq 'read class)))) | 422 (and (not unread) (not ticked) (not dormant) (memq 'read class)))) |
411 | 423 |
412 (defun gnus-cache-file-name (group article) | 424 (defun gnus-cache-file-name (group article) |
425 (setq group (gnus-group-decoded-name group)) | |
413 (expand-file-name | 426 (expand-file-name |
414 (if (stringp article) article (int-to-string article)) | 427 (if (stringp article) article (int-to-string article)) |
415 (file-name-as-directory | 428 (file-name-as-directory |
416 (expand-file-name | 429 (expand-file-name |
417 (nnheader-translate-file-chars | 430 (nnheader-translate-file-chars |
420 (let ((group (nnheader-replace-duplicate-chars-in-string | 433 (let ((group (nnheader-replace-duplicate-chars-in-string |
421 (nnheader-replace-chars-in-string group ?/ ?_) | 434 (nnheader-replace-chars-in-string group ?/ ?_) |
422 ?. ?_))) | 435 ?. ?_))) |
423 ;; Translate the first colon into a slash. | 436 ;; Translate the first colon into a slash. |
424 (when (string-match ":" group) | 437 (when (string-match ":" group) |
425 (aset group (match-beginning 0) ?/)) | 438 (setq group (concat (substring group 0 (match-beginning 0)) |
439 "/" (substring group (match-end 0))))) | |
426 (nnheader-replace-chars-in-string group ?. ?/))) | 440 (nnheader-replace-chars-in-string group ?. ?/))) |
427 t) | 441 t) |
428 gnus-cache-directory)))) | 442 gnus-cache-directory)))) |
429 | 443 |
430 (defun gnus-cache-update-article (group article) | 444 (defun gnus-cache-update-article (group article) |
458 (set-buffer (cdr gnus-cache-buffer)) | 472 (set-buffer (cdr gnus-cache-buffer)) |
459 (goto-char (point-min)) | 473 (goto-char (point-min)) |
460 (when (or (looking-at (concat (int-to-string number) "\t")) | 474 (when (or (looking-at (concat (int-to-string number) "\t")) |
461 (search-forward (concat "\n" (int-to-string number) "\t") | 475 (search-forward (concat "\n" (int-to-string number) "\t") |
462 (point-max) t)) | 476 (point-max) t)) |
463 (delete-region (progn (beginning-of-line) (point)) | 477 (gnus-delete-line))) |
464 (progn (forward-line 1) (point))))) | 478 (unless (setq gnus-newsgroup-cached |
465 (setq gnus-newsgroup-cached | 479 (delq article gnus-newsgroup-cached)) |
466 (delq article gnus-newsgroup-cached)) | 480 (gnus-sethash gnus-newsgroup-name nil gnus-cache-active-hashtb) |
481 (setq gnus-cache-active-altered t)) | |
467 (gnus-summary-update-secondary-mark article) | 482 (gnus-summary-update-secondary-mark article) |
468 t))) | 483 t))) |
469 | 484 |
470 (defun gnus-cache-articles-in-group (group) | 485 (defun gnus-cache-articles-in-group (group) |
471 "Return a sorted list of cached articles in GROUP." | 486 "Return a sorted list of cached articles in GROUP." |
472 (let ((dir (file-name-directory (gnus-cache-file-name group 1))) | 487 (let ((dir (file-name-directory (gnus-cache-file-name group 1))) |
473 articles) | 488 articles) |
474 (when (file-exists-p dir) | 489 (when (file-exists-p dir) |
475 (setq articles | 490 (setq articles |
476 (sort (mapcar (lambda (name) (string-to-int name)) | 491 (sort (mapcar (lambda (name) (string-to-number name)) |
477 (directory-files dir nil "^[0-9]+$" t)) | 492 (directory-files dir nil "^[0-9]+$" t)) |
478 '<)) | 493 '<)) |
479 ;; Update the cache active file, just to synch more. | 494 ;; Update the cache active file, just to synch more. |
480 (when articles | 495 (if articles |
481 (gnus-cache-update-active group (car articles) t) | 496 (progn |
482 (gnus-cache-update-active group (car (last articles)))) | 497 (gnus-cache-update-active group (car articles) t) |
498 (gnus-cache-update-active group (car (last articles)))) | |
499 (when (gnus-gethash group gnus-cache-active-hashtb) | |
500 (gnus-sethash group nil gnus-cache-active-hashtb) | |
501 (setq gnus-cache-active-altered t))) | |
483 articles))) | 502 articles))) |
484 | 503 |
485 (defun gnus-cache-braid-nov (group cached &optional file) | 504 (defun gnus-cache-braid-nov (group cached &optional file) |
486 (let ((cache-buf (gnus-get-buffer-create " *gnus-cache*")) | 505 (let ((cache-buf (gnus-get-buffer-create " *gnus-cache*")) |
487 beg end) | 506 beg end) |
501 (while cached | 520 (while cached |
502 (while (and (not (eobp)) | 521 (while (and (not (eobp)) |
503 (< (read (current-buffer)) (car cached))) | 522 (< (read (current-buffer)) (car cached))) |
504 (forward-line 1)) | 523 (forward-line 1)) |
505 (beginning-of-line) | 524 (beginning-of-line) |
506 (save-excursion | 525 (set-buffer cache-buf) |
507 (set-buffer cache-buf) | 526 (if (search-forward (concat "\n" (int-to-string (car cached)) "\t") |
508 (if (search-forward (concat "\n" (int-to-string (car cached)) "\t") | 527 nil t) |
509 nil t) | 528 (setq beg (gnus-point-at-bol) |
510 (setq beg (progn (beginning-of-line) (point)) | 529 end (progn (end-of-line) (point))) |
511 end (progn (end-of-line) (point))) | 530 (setq beg nil)) |
512 (setq beg nil))) | 531 (set-buffer nntp-server-buffer) |
513 (when beg | 532 (when beg |
514 (insert-buffer-substring cache-buf beg end) | 533 (insert-buffer-substring cache-buf beg end) |
515 (insert "\n")) | 534 (insert "\n")) |
516 (setq cached (cdr cached))) | 535 (setq cached (cdr cached))) |
517 (kill-buffer cache-buf))) | 536 (kill-buffer cache-buf))) |
529 (< (progn (goto-char (match-beginning 1)) | 548 (< (progn (goto-char (match-beginning 1)) |
530 (read (current-buffer))) | 549 (read (current-buffer))) |
531 (car cached))) | 550 (car cached))) |
532 (search-forward "\n.\n" nil 'move)) | 551 (search-forward "\n.\n" nil 'move)) |
533 (beginning-of-line) | 552 (beginning-of-line) |
534 (save-excursion | 553 (set-buffer cache-buf) |
535 (set-buffer cache-buf) | 554 (erase-buffer) |
536 (erase-buffer) | 555 (let ((coding-system-for-read |
537 (let ((coding-system-for-read | 556 gnus-cache-coding-system)) |
538 gnus-cache-coding-system)) | 557 (insert-file-contents (gnus-cache-file-name group (car cached)))) |
539 (insert-file-contents (gnus-cache-file-name group (car cached)))) | 558 (goto-char (point-min)) |
540 (goto-char (point-min)) | 559 (insert "220 ") |
541 (insert "220 ") | 560 (princ (car cached) (current-buffer)) |
542 (princ (car cached) (current-buffer)) | 561 (insert " Article retrieved.\n") |
543 (insert " Article retrieved.\n") | 562 (search-forward "\n\n" nil 'move) |
544 (search-forward "\n\n" nil 'move) | 563 (delete-region (point) (point-max)) |
545 (delete-region (point) (point-max)) | 564 (forward-char -1) |
546 (forward-char -1) | 565 (insert ".") |
547 (insert ".")) | 566 (set-buffer nntp-server-buffer) |
548 (insert-buffer-substring cache-buf) | 567 (insert-buffer-substring cache-buf) |
549 (setq cached (cdr cached))) | 568 (setq cached (cdr cached))) |
550 (kill-buffer cache-buf))) | 569 (kill-buffer cache-buf))) |
551 | 570 |
552 ;;;###autoload | 571 ;;;###autoload |
602 gnus-cache-active-altered)) | 621 gnus-cache-active-altered)) |
603 (gnus-write-active-file gnus-cache-active-file gnus-cache-active-hashtb t) | 622 (gnus-write-active-file gnus-cache-active-file gnus-cache-active-hashtb t) |
604 ;; Mark the active hashtb as unaltered. | 623 ;; Mark the active hashtb as unaltered. |
605 (setq gnus-cache-active-altered nil))) | 624 (setq gnus-cache-active-altered nil))) |
606 | 625 |
626 (defun gnus-cache-possibly-update-active (group active) | |
627 "Update active info bounds of GROUP with ACTIVE if necessary. | |
628 The update is performed if ACTIVE contains a higher or lower bound | |
629 than the current." | |
630 (let ((lower t) (higher t)) | |
631 (if gnus-cache-active-hashtb | |
632 (let ((cache-active (gnus-gethash group gnus-cache-active-hashtb))) | |
633 (when cache-active | |
634 (unless (< (car active) (car cache-active)) | |
635 (setq lower nil)) | |
636 (unless (> (cdr active) (cdr cache-active)) | |
637 (setq higher nil)))) | |
638 (gnus-cache-read-active)) | |
639 (when lower | |
640 (gnus-cache-update-active group (car active) t)) | |
641 (when higher | |
642 (gnus-cache-update-active group (cdr active))))) | |
643 | |
607 (defun gnus-cache-update-active (group number &optional low) | 644 (defun gnus-cache-update-active (group number &optional low) |
608 "Update the upper bound of the active info of GROUP to NUMBER. | 645 "Update the upper bound of the active info of GROUP to NUMBER. |
609 If LOW, update the lower bound instead." | 646 If LOW, update the lower bound instead." |
610 (let ((active (gnus-gethash group gnus-cache-active-hashtb))) | 647 (let ((active (gnus-gethash group gnus-cache-active-hashtb))) |
611 (if (null active) | 648 (if (null active) |
639 nums alphs) | 676 nums alphs) |
640 (when top | 677 (when top |
641 (gnus-message 5 "Generating the cache active file...") | 678 (gnus-message 5 "Generating the cache active file...") |
642 (setq gnus-cache-active-hashtb (gnus-make-hashtable 123))) | 679 (setq gnus-cache-active-hashtb (gnus-make-hashtable 123))) |
643 (when (string-match "^\\(nn[^_]+\\)_" group) | 680 (when (string-match "^\\(nn[^_]+\\)_" group) |
644 (setq group (replace-match "\\1:" t t group))) | 681 (setq group (replace-match "\\1:" t nil group))) |
645 ;; Separate articles from all other files and directories. | 682 ;; Separate articles from all other files and directories. |
646 (while files | 683 (while files |
647 (if (string-match "^[0-9]+$" (file-name-nondirectory (car files))) | 684 (if (string-match "^[0-9]+$" (file-name-nondirectory (car files))) |
648 (push (string-to-int (file-name-nondirectory (pop files))) nums) | 685 (push (string-to-number (file-name-nondirectory (pop files))) nums) |
649 (push (pop files) alphs))) | 686 (push (pop files) alphs))) |
650 ;; If we have nums, then this is probably a valid group. | 687 ;; If we have nums, then this is probably a valid group. |
651 (when (setq nums (sort nums '<)) | 688 (when (setq nums (sort nums '<)) |
652 (gnus-sethash group (cons (car nums) (gnus-last-element nums)) | 689 (gnus-sethash group (cons (car nums) (gnus-last-element nums)) |
653 gnus-cache-active-hashtb)) | 690 gnus-cache-active-hashtb)) |
668 (defun gnus-cache-generate-nov-databases (dir) | 705 (defun gnus-cache-generate-nov-databases (dir) |
669 "Generate NOV files recursively starting in DIR." | 706 "Generate NOV files recursively starting in DIR." |
670 (interactive (list gnus-cache-directory)) | 707 (interactive (list gnus-cache-directory)) |
671 (gnus-cache-close) | 708 (gnus-cache-close) |
672 (let ((nnml-generate-active-function 'identity)) | 709 (let ((nnml-generate-active-function 'identity)) |
673 (nnml-generate-nov-databases-1 dir))) | 710 (nnml-generate-nov-databases-1 dir)) |
711 (gnus-cache-open)) | |
674 | 712 |
675 (defun gnus-cache-move-cache (dir) | 713 (defun gnus-cache-move-cache (dir) |
676 "Move the cache tree to somewhere else." | 714 "Move the cache tree to somewhere else." |
677 (interactive "FMove the cache tree to: ") | 715 (interactive "FMove the cache tree to: ") |
678 (rename-file gnus-cache-directory dir)) | 716 (rename-file gnus-cache-directory dir)) |
679 | 717 |
718 (defun gnus-cache-fully-p (&optional group) | |
719 "Returns non-nil if the cache should be fully used. | |
720 If GROUP is non-nil, also cater to `gnus-cacheable-groups' and | |
721 `gnus-uncacheable-groups'." | |
722 (and gnus-use-cache | |
723 (not (eq gnus-use-cache 'passive)) | |
724 (if (null group) | |
725 t | |
726 (and (or (not gnus-cacheable-groups) | |
727 (string-match gnus-cacheable-groups group)) | |
728 (or (not gnus-uncacheable-groups) | |
729 (not (string-match gnus-uncacheable-groups group))))))) | |
730 | |
731 ;;;###autoload | |
732 (defun gnus-cache-rename-group (old-group new-group) | |
733 "Rename OLD-GROUP as NEW-GROUP. | |
734 Always updates the cache, even when disabled, as the old cache | |
735 files would corrupt Gnus when the cache was next enabled. It | |
736 depends on the caller to determine whether group renaming is | |
737 supported." | |
738 (let ((old-dir (gnus-cache-file-name old-group "")) | |
739 (new-dir (gnus-cache-file-name new-group ""))) | |
740 (gnus-rename-file old-dir new-dir t)) | |
741 | |
742 (let ((no-save gnus-cache-active-hashtb)) | |
743 (unless gnus-cache-active-hashtb | |
744 (gnus-cache-read-active)) | |
745 (let* ((old-group-hash-value | |
746 (gnus-gethash old-group gnus-cache-active-hashtb)) | |
747 (new-group-hash-value | |
748 (gnus-gethash new-group gnus-cache-active-hashtb)) | |
749 (delta | |
750 (or old-group-hash-value new-group-hash-value))) | |
751 (gnus-sethash new-group old-group-hash-value gnus-cache-active-hashtb) | |
752 (gnus-sethash old-group nil gnus-cache-active-hashtb) | |
753 | |
754 (if no-save | |
755 (setq gnus-cache-active-altered delta) | |
756 (gnus-cache-write-active delta))))) | |
757 | |
758 ;;;###autoload | |
759 (defun gnus-cache-delete-group (group) | |
760 "Delete GROUP from the cache. | |
761 Always updates the cache, even when disabled, as the old cache | |
762 files would corrupt gnus when the cache was next enabled. | |
763 Depends upon the caller to determine whether group deletion is | |
764 supported." | |
765 (let ((dir (gnus-cache-file-name group ""))) | |
766 (gnus-delete-directory dir)) | |
767 | |
768 (let ((no-save gnus-cache-active-hashtb)) | |
769 (unless gnus-cache-active-hashtb | |
770 (gnus-cache-read-active)) | |
771 (let* ((group-hash-value (gnus-gethash group gnus-cache-active-hashtb))) | |
772 (gnus-sethash group nil gnus-cache-active-hashtb) | |
773 | |
774 (if no-save | |
775 (setq gnus-cache-active-altered group-hash-value) | |
776 (gnus-cache-write-active group-hash-value))))) | |
777 | |
680 (provide 'gnus-cache) | 778 (provide 'gnus-cache) |
681 | 779 |
780 ;;; arch-tag: 05a79442-8c58-4e65-bd0a-3cbb1b89a33a | |
682 ;;; gnus-cache.el ends here | 781 ;;; gnus-cache.el ends here |