13401
+ ��膩��� 1 ;;; nnmh.el --- mhspool access for Gnus
14169
+ ��膩��� 2
13401
+ ��膩��� 3 ;; Copyright (C) 1995 Free Software Foundation, Inc.
+ ��膩��� 4
+ ��膩��� 5 ;; Author: Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
+ ��膩��� 6 ;; Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
+ ��膩��� 7 ;; Keywords: news, mail
+ ��膩��� 8
+ ��膩��� 9 ;; This file is part of GNU Emacs.
+ ��膩��� 10
+ ��膩��� 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)
+ ��膩��� 14 ;; any later version.
+ ��膩��� 15
+ ��膩��� 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.
+ ��膩��� 20
+ ��膩��� 21 ;; You should have received a copy of the GNU General Public License
14169
+ ��膩��� 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.
13401
+ ��膩��� 25
+ ��膩��� 26 ;;; Commentary:
+ ��膩��� 27
+ ��膩��� 28 ;; Based on nnspool.el by Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>.
+ ��膩��� 29 ;; For an overview of what the interface functions do, please see the
+ ��膩��� 30 ;; Gnus sources.
+ ��膩��� 31
+ ��膩��� 32 ;;; Code:
+ ��膩��� 33
+ ��膩��� 34 (require 'nnheader)
+ ��膩��� 35 (require 'rmail)
+ ��膩��� 36 (require 'nnmail)
+ ��膩��� 37 (require 'gnus)
+ ��膩��� 38
+ ��膩��� 39 (defvar nnmh-directory "~/Mail/"
+ ��膩��� 40 "*Mail spool directory.")
+ ��膩��� 41
+ ��膩��� 42 (defvar nnmh-get-new-mail t
+ ��膩��� 43 "*If non-nil, nnmh will check the incoming mail file and split the mail.")
+ ��膩��� 44
+ ��膩��� 45 (defvar nnmh-prepare-save-mail-hook nil
+ ��膩��� 46 "*Hook run narrowed to an article before saving.")
+ ��膩��� 47
+ ��膩��� 48 (defvar nnmh-be-safe nil
+ ��膩��� 49 "*If non-nil, nnmh will check all articles to make sure whether they are new or not.")
+ ��膩��� 50
+ ��膩��� 51
+ ��膩��� 52
+ ��膩��� 53 (defconst nnmh-version "nnmh 1.0"
+ ��膩��� 54 "nnmh version.")
+ ��膩��� 55
+ ��膩��� 56 (defvar nnmh-current-directory nil
+ ��膩��� 57 "Current news group directory.")
+ ��膩��� 58
+ ��膩��� 59 (defvar nnmh-status-string "")
+ ��膩��� 60 (defvar nnmh-group-alist nil)
+ ��膩��� 61
+ ��膩��� 62
+ ��膩��� 63
+ ��膩��� 64 (defvar nnmh-current-server nil)
+ ��膩��� 65 (defvar nnmh-server-alist nil)
+ ��膩��� 66 (defvar nnmh-server-variables
+ ��膩��� 67 (list
+ ��膩��� 68 (list 'nnmh-directory nnmh-directory)
+ ��膩��� 69 (list 'nnmh-get-new-mail nnmh-get-new-mail)
+ ��膩��� 70 '(nnmh-current-directory nil)
+ ��膩��� 71 '(nnmh-status-string "")
+ ��膩��� 72 '(nnmh-group-alist)))
+ ��膩��� 73
+ ��膩��� 74
+ ��膩��� 75
+ ��膩��� 76 ;;; Interface functions.
+ ��膩��� 77
+ ��膩��� 78 (defun nnmh-retrieve-headers (sequence &optional newsgroup server)
+ ��膩��� 79 (save-excursion
+ ��膩��� 80 (set-buffer nntp-server-buffer)
+ ��膩��� 81 (erase-buffer)
+ ��膩��� 82 (let* ((file nil)
+ ��膩��� 83 (number (length sequence))
+ ��膩��� 84 (large (and (numberp nnmail-large-newsgroup)
+ ��膩��� 85 (> number nnmail-large-newsgroup)))
+ ��膩��� 86 (count 0)
+ ��膩��� 87 beg article)
+ ��膩��� 88 (nnmh-possibly-change-directory newsgroup)
+ ��膩��� 89 (if (stringp (car sequence))
+ ��膩��� 90 'headers
+ ��膩��� 91 (while sequence
+ ��膩��� 92 (setq article (car sequence))
+ ��膩��� 93 (setq file
+ ��膩��� 94 (concat nnmh-current-directory (int-to-string article)))
+ ��膩��� 95 (if (and (file-exists-p file)
+ ��膩��� 96 (not (file-directory-p file)))
+ ��膩��� 97 (progn
+ ��膩��� 98 (insert (format "221 %d Article retrieved.\n" article))
+ ��膩��� 99 (setq beg (point))
+ ��膩��� 100 (nnheader-insert-head file)
+ ��膩��� 101 (goto-char beg)
+ ��膩��� 102 (if (search-forward "\n\n" nil t)
+ ��膩��� 103 (forward-char -1)
+ ��膩��� 104 (goto-char (point-max))
+ ��膩��� 105 (insert "\n\n"))
+ ��膩��� 106 (insert ".\n")
+ ��膩��� 107 (delete-region (point) (point-max))))
+ ��膩��� 108 (setq sequence (cdr sequence))
+ ��膩��� 109 (setq count (1+ count))
+ ��膩��� 110
+ ��膩��� 111 (and large
+ ��膩��� 112 (zerop (% count 20))
+ ��膩��� 113 (message "nnmh: Receiving headers... %d%%"
+ ��膩��� 114 (/ (* count 100) number))))
+ ��膩��� 115
+ ��膩��� 116 (and large (message "nnmh: Receiving headers...done"))
+ ��膩��� 117
+ ��膩��� 118 ;; Fold continuation lines.
+ ��膩��� 119 (goto-char (point-min))
+ ��膩��� 120 (while (re-search-forward "\\(\r?\n[ \t]+\\)+" nil t)
+ ��膩��� 121 (replace-match " " t t))
+ ��膩��� 122 'headers))))
+ ��膩��� 123
+ ��膩��� 124 (defun nnmh-open-server (server &optional defs)
+ ��膩��� 125 (nnheader-init-server-buffer)
+ ��膩��� 126 (if (equal server nnmh-current-server)
+ ��膩��� 127 t
+ ��膩��� 128 (if nnmh-current-server
+ ��膩��� 129 (setq nnmh-server-alist
+ ��膩��� 130 (cons (list nnmh-current-server
+ ��膩��� 131 (nnheader-save-variables nnmh-server-variables))
+ ��膩��� 132 nnmh-server-alist)))
+ ��膩��� 133 (let ((state (assoc server nnmh-server-alist)))
+ ��膩��� 134 (if state
+ ��膩��� 135 (progn
+ ��膩��� 136 (nnheader-restore-variables (nth 1 state))
+ ��膩��� 137 (setq nnmh-server-alist (delq state nnmh-server-alist)))
+ ��膩��� 138 (nnheader-set-init-variables nnmh-server-variables defs)))
+ ��膩��� 139 (setq nnmh-current-server server)))
+ ��膩��� 140
+ ��膩��� 141 (defun nnmh-close-server (&optional server)
+ ��膩��� 142 t)
+ ��膩��� 143
+ ��膩��� 144 (defun nnmh-server-opened (&optional server)
+ ��膩��� 145 (and (equal server nnmh-current-server)
+ ��膩��� 146 nntp-server-buffer
+ ��膩��� 147 (buffer-name nntp-server-buffer)))
+ ��膩��� 148
+ ��膩��� 149 (defun nnmh-status-message (&optional server)
+ ��膩��� 150 nnmh-status-string)
+ ��膩��� 151
+ ��膩��� 152 (defun nnmh-request-article (id &optional newsgroup server buffer)
+ ��膩��� 153 (nnmh-possibly-change-directory newsgroup)
+ ��膩��� 154 (let ((file (if (stringp id)
+ ��膩��� 155 nil
+ ��膩��� 156 (concat nnmh-current-directory (int-to-string id))))
+ ��膩��� 157 (nntp-server-buffer (or buffer nntp-server-buffer)))
+ ��膩��� 158 (and (stringp file)
+ ��膩��� 159 (file-exists-p file)
+ ��膩��� 160 (not (file-directory-p file))
+ ��膩��� 161 (save-excursion (nnmail-find-file file)))))
+ ��膩��� 162
+ ��膩��� 163 (defun nnmh-request-group (group &optional server dont-check)
+ ��膩��� 164 (and nnmh-get-new-mail (or dont-check (nnmh-get-new-mail group)))
+ ��膩��� 165 (let ((pathname (nnmh-article-pathname group nnmh-directory))
+ ��膩��� 166 dir)
+ ��膩��� 167 (if (file-directory-p pathname)
+ ��膩��� 168 (progn
+ ��膩��� 169 (setq nnmh-current-directory pathname)
+ ��膩��� 170 (and nnmh-get-new-mail
+ ��膩��� 171 nnmh-be-safe
+ ��膩��� 172 (nnmh-update-gnus-unreads group))
+ ��膩��� 173 (or dont-check
+ ��膩��� 174 (progn
+ ��膩��� 175 (setq dir
+ ��膩��� 176 (sort
+ ��膩��� 177 (mapcar
+ ��膩��� 178 (function
+ ��膩��� 179 (lambda (name)
+ ��膩��� 180 (string-to-int name)))
+ ��膩��� 181 (directory-files pathname nil "^[0-9]+$" t))
+ ��膩��� 182 '<))
+ ��膩��� 183 (save-excursion
+ ��膩��� 184 (set-buffer nntp-server-buffer)
+ ��膩��� 185 (erase-buffer)
+ ��膩��� 186 (if dir
+ ��膩��� 187 (insert (format "211 %d %d %d %s\n" (length dir)
+ ��膩��� 188 (car dir)
+ ��膩��� 189 (progn (while (cdr dir)
+ ��膩��� 190 (setq dir (cdr dir)))
+ ��膩��� 191 (car dir))
+ ��膩��� 192 group))
+ ��膩��� 193 (insert (format "211 0 1 0 %s\n" group))))))
+ ��膩��� 194 t)
+ ��膩��� 195 (setq nnmh-status-string "No such group")
+ ��膩��� 196 nil)))
+ ��膩��� 197
+ ��膩��� 198 (defun nnmh-request-list (&optional server dir)
+ ��膩��� 199 (or dir
+ ��膩��� 200 (save-excursion
+ ��膩��� 201 (set-buffer nntp-server-buffer)
+ ��膩��� 202 (erase-buffer)
+ ��膩��� 203 (setq dir (file-truename (file-name-as-directory nnmh-directory)))))
+ ��膩��� 204 (setq dir (expand-file-name dir))
+ ��膩��� 205 ;; Recurse down all directories.
+ ��膩��� 206 (let ((dirs (and (file-readable-p dir)
+ ��膩��� 207 (> (nth 1 (file-attributes (file-chase-links dir))) 2)
+ ��膩��� 208 (directory-files dir t nil t))))
+ ��膩��� 209 (while dirs
+ ��膩��� 210 (if (and (not (string-match "/\\.\\.?$" (car dirs)))
+ ��膩��� 211 (file-directory-p (car dirs))
+ ��膩��� 212 (file-readable-p (car dirs)))
+ ��膩��� 213 (nnmh-request-list nil (car dirs)))
+ ��膩��� 214 (setq dirs (cdr dirs))))
+ ��膩��� 215 ;; For each directory, generate an active file line.
+ ��膩��� 216 (if (not (string= (expand-file-name nnmh-directory) dir))
+ ��膩��� 217 (let ((files (mapcar
+ ��膩��� 218 (lambda (name) (string-to-int name))
+ ��膩��� 219 (directory-files dir nil "^[0-9]+$" t))))
+ ��膩��� 220 (if (null files)
+ ��膩��� 221 ()
+ ��膩��� 222 (save-excursion
+ ��膩��� 223 (set-buffer nntp-server-buffer)
+ ��膩��� 224 (goto-char (point-max))
+ ��膩��� 225 (insert
+ ��膩��� 226 (format
+ ��膩��� 227 "%s %d %d y\n"
+ ��膩��� 228 (progn
+ ��膩��� 229 (string-match
+ ��膩��� 230 (file-truename (file-name-as-directory
+ ��膩��� 231 (expand-file-name nnmh-directory))) dir)
+ ��膩��� 232 (nnmail-replace-chars-in-string
+ ��膩��� 233 (substring dir (match-end 0)) ?/ ?.))
+ ��膩��� 234 (apply (function max) files)
+ ��膩��� 235 (apply (function min) files)))))))
+ ��膩��� 236 (setq nnmh-group-alist (nnmail-get-active))
+ ��膩��� 237 (and server nnmh-get-new-mail (nnmh-get-new-mail))
+ ��膩��� 238 t)
+ ��膩��� 239
+ ��膩��� 240 (defun nnmh-request-newgroups (date &optional server)
+ ��膩��� 241 (nnmh-request-list server))
+ ��膩��� 242
+ ��膩��� 243 (defun nnmh-request-post (&optional server)
+ ��膩��� 244 (mail-send-and-exit nil))
+ ��膩��� 245
+ ��膩��� 246 (defalias 'nnmh-request-post-buffer 'nnmail-request-post-buffer)
+ ��膩��� 247
+ ��膩��� 248 (defun nnmh-request-expire-articles (articles newsgroup &optional server force)
+ ��膩��� 249 (nnmh-possibly-change-directory newsgroup)
+ ��膩��� 250 (let* ((days (or (and nnmail-expiry-wait-function
+ ��膩��� 251 (funcall nnmail-expiry-wait-function newsgroup))
+ ��膩��� 252 nnmail-expiry-wait))
+ ��膩��� 253 (active-articles
+ ��膩��� 254 (mapcar
+ ��膩��� 255 (function
+ ��膩��� 256 (lambda (name)
+ ��膩��� 257 (string-to-int name)))
+ ��膩��� 258 (directory-files nnmh-current-directory nil "^[0-9]+$" t)))
+ ��膩��� 259 (max-article (and active-articles (apply 'max active-articles)))
+ ��膩��� 260 (is-old t)
+ ��膩��� 261 article rest mod-time)
+ ��膩��� 262 (nnmail-activate 'nnmh)
+ ��膩��� 263
+ ��膩��� 264 (while (and articles is-old)
+ ��膩��� 265 (setq article (concat nnmh-current-directory
+ ��膩��� 266 (int-to-string (car articles))))
+ ��膩��� 267 (if (setq mod-time (nth 5 (file-attributes article)))
+ ��膩��� 268 (if (and (or (not nnmail-keep-last-article)
+ ��膩��� 269 (not max-article)
+ ��膩��� 270 (not (= (car articles) max-article)))
+ ��膩��� 271 (not (equal mod-time '(0 0)))
+ ��膩��� 272 (or force
+ ��膩��� 273 (setq is-old
+ ��膩��� 274 (> (nnmail-days-between
+ ��膩��� 275 (current-time-string)
+ ��膩��� 276 (current-time-string mod-time))
+ ��膩��� 277 days))))
+ ��膩��� 278 (progn
+ ��膩��� 279 (and gnus-verbose-backends
+ ��膩��� 280 (message "Deleting article %s..." article))
+ ��膩��� 281 (condition-case ()
+ ��膩��� 282 (delete-file article)
+ ��膩��� 283 (file-error
+ ��膩��� 284 (setq rest (cons (car articles) rest)))))
+ ��膩��� 285 (setq rest (cons (car articles) rest))))
+ ��膩��� 286 (setq articles (cdr articles)))
+ ��膩��� 287 (message "")
+ ��膩��� 288 (nconc rest articles)))
+ ��膩��� 289
+ ��膩��� 290 (defun nnmh-close-group (group &optional server)
+ ��膩��� 291 t)
+ ��膩��� 292
+ ��膩��� 293 (defun nnmh-request-move-article
+ ��膩��� 294 (article group server accept-form &optional last)
+ ��膩��� 295 (let ((buf (get-buffer-create " *nnmh move*"))
+ ��膩��� 296 result)
+ ��膩��� 297 (and
+ ��膩��� 298 (nnmh-request-article article group server)
+ ��膩��� 299 (save-excursion
+ ��膩��� 300 (set-buffer buf)
+ ��膩��� 301 (insert-buffer-substring nntp-server-buffer)
+ ��膩��� 302 (setq result (eval accept-form))
+ ��膩��� 303 (kill-buffer (current-buffer))
+ ��膩��� 304 result)
+ ��膩��� 305 (condition-case ()
+ ��膩��� 306 (delete-file (concat nnmh-current-directory
+ ��膩��� 307 (int-to-string article)))
+ ��膩��� 308 (file-error nil)))
+ ��膩��� 309 result))
+ ��膩��� 310
+ ��膩��� 311 (defun nnmh-request-accept-article (group &optional last)
+ ��膩��� 312 (if (stringp group)
+ ��膩��� 313 (and
+ ��膩��� 314 (nnmail-activate 'nnmh)
+ ��膩��� 315 ;; We trick the choosing function into believing that only one
14040
+ ��膩��� 316 ;; group is available.
13401
+ ��膩��� 317 (let ((nnmail-split-methods (list (list group ""))))
+ ��膩��� 318 (car (nnmh-save-mail))))
+ ��膩��� 319 (and
+ ��膩��� 320 (nnmail-activate 'nnmh)
+ ��膩��� 321 (car (nnmh-save-mail)))))
+ ��膩��� 322
+ ��膩��� 323 (defun nnmh-request-replace-article (article group buffer)
+ ��膩��� 324 (nnmh-possibly-change-directory group)
+ ��膩��� 325 (save-excursion
+ ��膩��� 326 (set-buffer buffer)
+ ��膩��� 327 (nnmh-possibly-create-directory group)
+ ��膩��� 328 (condition-case ()
+ ��膩��� 329 (progn
+ ��膩��� 330 (write-region (point-min) (point-max)
+ ��膩��� 331 (concat nnmh-current-directory (int-to-string article))
+ ��膩��� 332 nil (if gnus-verbose-backends nil 'nomesg))
+ ��膩��� 333 t)
+ ��膩��� 334 (error nil))))
+ ��膩��� 335
+ ��膩��� 336
+ ��膩��� 337 ;;; Internal functions.
+ ��膩��� 338
+ ��膩��� 339 (defun nnmh-possibly-change-directory (newsgroup)
+ ��膩��� 340 (if newsgroup
+ ��膩��� 341 (let ((pathname (nnmh-article-pathname newsgroup nnmh-directory)))
+ ��膩��� 342 (if (file-directory-p pathname)
+ ��膩��� 343 (setq nnmh-current-directory pathname)
+ ��膩��� 344 (error "No such newsgroup: %s" newsgroup)))))
+ ��膩��� 345
+ ��膩��� 346 (defun nnmh-possibly-create-directory (group)
+ ��膩��� 347 (let (dir dirs)
+ ��膩��� 348 (setq dir (nnmh-article-pathname group nnmh-directory))
+ ��膩��� 349 (while (not (file-directory-p dir))
+ ��膩��� 350 (setq dirs (cons dir dirs))
+ ��膩��� 351 (setq dir (file-name-directory (directory-file-name dir))))
+ ��膩��� 352 (while dirs
+ ��膩��� 353 (if (make-directory (directory-file-name (car dirs)))
+ ��膩��� 354 (error "Could not create directory %s" (car dirs)))
+ ��膩��� 355 (and gnus-verbose-backends
+ ��膩��� 356 (message "Creating mail directory %s" (car dirs)))
+ ��膩��� 357 (setq dirs (cdr dirs)))))
+ ��膩��� 358
+ ��膩��� 359 (defun nnmh-save-mail ()
+ ��膩��� 360 "Called narrowed to an article."
+ ��膩��� 361 (let ((group-art (nreverse (nnmail-article-group 'nnmh-active-number))))
+ ��膩��� 362 (nnmail-insert-lines)
+ ��膩��� 363 (nnmail-insert-xref group-art)
+ ��膩��� 364 (run-hooks 'nnmh-prepare-save-mail-hook)
+ ��膩��� 365 (goto-char (point-min))
+ ��膩��� 366 (while (looking-at "From ")
+ ��膩��� 367 (replace-match "X-From-Line: ")
+ ��膩��� 368 (forward-line 1))
+ ��膩��� 369 ;; We save the article in all the newsgroups it belongs in.
+ ��膩��� 370 (let ((ga group-art)
+ ��膩��� 371 first)
+ ��膩��� 372 (while ga
+ ��膩��� 373 (nnmh-possibly-create-directory (car (car ga)))
+ ��膩��� 374 (let ((file (concat (nnmh-article-pathname
+ ��膩��� 375 (car (car ga)) nnmh-directory)
+ ��膩��� 376 (int-to-string (cdr (car ga))))))
+ ��膩��� 377 (if first
+ ��膩��� 378 ;; It was already saved, so we just make a hard link.
+ ��膩��� 379 (add-name-to-file first file t)
+ ��膩��� 380 ;; Save the article.
+ ��膩��� 381 (write-region (point-min) (point-max) file nil nil)
+ ��膩��� 382 (setq first file)))
+ ��膩��� 383 (setq ga (cdr ga))))
+ ��膩��� 384 group-art))
+ ��膩��� 385
+ ��膩��� 386 (defun nnmh-active-number (group)
+ ��膩��� 387 "Compute the next article number in GROUP."
+ ��膩��� 388 (let ((active (car (cdr (assoc group nnmh-group-alist)))))
+ ��膩��� 389 ;; The group wasn't known to nnmh, so we just create an active
+ ��膩��� 390 ;; entry for it.
+ ��膩��� 391 (or active
+ ��膩��� 392 (progn
+ ��膩��� 393 (setq active (cons 1 0))
+ ��膩��� 394 (setq nnmh-group-alist (cons (list group active) nnmh-group-alist))))
+ ��膩��� 395 (setcdr active (1+ (cdr active)))
+ ��膩��� 396 (while (file-exists-p
+ ��膩��� 397 (concat (nnmh-article-pathname group nnmh-directory)
+ ��膩��� 398 (int-to-string (cdr active))))
+ ��膩��� 399 (setcdr active (1+ (cdr active))))
+ ��膩��� 400 (cdr active)))
+ ��膩��� 401
+ ��膩��� 402 (defun nnmh-article-pathname (group mail-dir)
+ ��膩��� 403 "Make pathname for GROUP."
+ ��膩��� 404 (let ((mail-dir (file-name-as-directory (expand-file-name mail-dir))))
+ ��膩��� 405 (if (file-directory-p (concat mail-dir group))
+ ��膩��� 406 (concat mail-dir group "/")
+ ��膩��� 407 (concat mail-dir (nnmail-replace-chars-in-string group ?. ?/) "/"))))
+ ��膩��� 408
+ ��膩��� 409 (defun nnmh-get-new-mail (&optional group)
+ ��膩��� 410 "Read new incoming mail."
+ ��膩��� 411 (let* ((spools (nnmail-get-spool-files group))
+ ��膩��� 412 (group-in group)
+ ��膩��� 413 incoming incomings)
+ ��膩��� 414 (if (or (not nnmh-get-new-mail) (not nnmail-spool-file))
+ ��膩��� 415 ()
+ ��膩��� 416 ;; We first activate all the groups.
+ ��膩��� 417 (or nnmh-group-alist
+ ��膩��� 418 (nnmh-request-list))
+ ��膩��� 419 ;; The we go through all the existing spool files and split the
+ ��膩��� 420 ;; mail from each.
+ ��膩��� 421 (while spools
+ ��膩��� 422 (and
+ ��膩��� 423 (file-exists-p (car spools))
+ ��膩��� 424 (> (nth 7 (file-attributes (car spools))) 0)
+ ��膩��� 425 (progn
+ ��膩��� 426 (and gnus-verbose-backends
+ ��膩��� 427 (message "nnmh: Reading incoming mail..."))
+ ��膩��� 428 (if (not (setq incoming
+ ��膩��� 429 (nnmail-move-inbox
+ ��膩��� 430 (car spools)
+ ��膩��� 431 (concat (file-name-as-directory nnmh-directory)
+ ��膩��� 432 "Incoming"))))
+ ��膩��� 433 ()
+ ��膩��� 434 (setq incomings (cons incoming incomings))
+ ��膩��� 435 (setq group (nnmail-get-split-group (car spools) group-in))
+ ��膩��� 436 (nnmail-split-incoming incoming 'nnmh-save-mail nil group))))
+ ��膩��� 437 (setq spools (cdr spools)))
+ ��膩��� 438 ;; If we did indeed read any incoming spools, we save all info.
+ ��膩��� 439 (if incoming
+ ��膩��� 440 (message "nnmh: Reading incoming mail...done"))
+ ��膩��� 441 (while incomings
+ ��膩��� 442 (setq incoming (car incomings))
+ ��膩��� 443 (and nnmail-delete-incoming
+ ��膩��� 444 (file-exists-p incoming)
+ ��膩��� 445 (file-writable-p incoming)
+ ��膩��� 446 (delete-file incoming))
+ ��膩��� 447 (setq incomings (cdr incomings))))))
+ ��膩��� 448
+ ��膩��� 449
+ ��膩��� 450 (defun nnmh-update-gnus-unreads (group)
+ ��膩��� 451 ;; Go through the .nnmh-articles file and compare with the actual
+ ��膩��� 452 ;; articles in this folder. The articles that are "new" will be
+ ��膩��� 453 ;; marked as unread by Gnus.
+ ��膩��� 454 (let* ((dir nnmh-current-directory)
+ ��膩��� 455 (files (sort (mapcar (function (lambda (name) (string-to-int name)))
+ ��膩��� 456 (directory-files nnmh-current-directory
+ ��膩��� 457 nil "^[0-9]+$" t)) '<))
+ ��膩��� 458 (nnmh-file (concat dir ".nnmh-articles"))
+ ��膩��� 459 new articles)
+ ��膩��� 460 ;; Load the .nnmh-articles file.
+ ��膩��� 461 (if (file-exists-p nnmh-file)
+ ��膩��� 462 (setq articles
+ ��膩��� 463 (let (nnmh-newsgroup-articles)
+ ��膩��� 464 (condition-case nil (load nnmh-file nil t t) (error nil))
+ ��膩��� 465 nnmh-newsgroup-articles)))
+ ��膩��� 466 ;; Add all new articles to the `new' list.
+ ��膩��� 467 (let ((art files))
+ ��膩��� 468 (while art
+ ��膩��� 469 (if (not (assq (car art) articles)) (setq new (cons (car art) new)))
+ ��膩��� 470 (setq art (cdr art))))
+ ��膩��� 471 ;; Remove all deleted articles.
+ ��膩��� 472 (let ((art articles))
+ ��膩��� 473 (while art
+ ��膩��� 474 (if (not (memq (car (car art)) files))
+ ��膩��� 475 (setq articles (delq (car art) articles)))
+ ��膩��� 476 (setq art (cdr art))))
+ ��膩��� 477 ;; Check whether the highest-numbered articles really are the ones
+ ��膩��� 478 ;; that Gnus thinks they are by looking at the time-stamps.
+ ��膩��� 479 (let ((art articles))
+ ��膩��� 480 (while (and art
+ ��膩��� 481 (not (equal
+ ��膩��� 482 (nth 5 (file-attributes
+ ��膩��� 483 (concat dir (int-to-string (car (car art))))))
+ ��膩��� 484 (cdr (car art)))))
+ ��膩��� 485 (setq articles (delq (car art) articles))
+ ��膩��� 486 (setq new (cons (car (car art)) new))
+ ��膩��� 487 (setq art (cdr art))))
+ ��膩��� 488 ;; Go through all the new articles and add them, and their
+ ��膩��� 489 ;; time-stamps to the list.
+ ��膩��� 490 (let ((n new))
+ ��膩��� 491 (while n
+ ��膩��� 492 (setq articles
+ ��膩��� 493 (cons (cons
+ ��膩��� 494 (car n)
+ ��膩��� 495 (nth 5 (file-attributes
+ ��膩��� 496 (concat dir (int-to-string (car n))))))
+ ��膩��� 497 articles))
+ ��膩��� 498 (setq n (cdr n))))
+ ��膩��� 499 ;; Make Gnus mark all new articles as unread.
+ ��膩��� 500 (or (zerop (length new))
+ ��膩��� 501 (gnus-make-articles-unread
+ ��膩��� 502 (gnus-group-prefixed-name group (list 'nnmh ""))
+ ��膩��� 503 (setq new (sort new '<))))
+ ��膩��� 504 ;; Sort the article list with highest numbers first.
+ ��膩��� 505 (setq articles (sort articles (lambda (art1 art2)
+ ��膩��� 506 (> (car art1) (car art2)))))
+ ��膩��� 507 ;; Finally write this list back to the .nnmh-articles file.
+ ��膩��� 508 (save-excursion
+ ��膩��� 509 (set-buffer (get-buffer-create "*nnmh out*"))
+ ��膩��� 510 (insert ";; Gnus article active file for " group "\n\n")
+ ��膩��� 511 (insert "(setq nnmh-newsgroup-articles '")
+ ��膩��� 512 (insert (prin1-to-string articles) ")\n")
+ ��膩��� 513 (write-region (point-min) (point-max) nnmh-file nil 'nomesg)
+ ��膩��� 514 (kill-buffer (current-buffer)))))
+ ��膩��� 515
+ ��膩��� 516 (provide 'nnmh)
+ ��膩��� 517
+ ��膩��� 518 ;;; nnmh.el ends here