From 7ae3ca83f008262d7e625886f114fca094313452 Mon Sep 17 00:00:00 2001 From: yamaoka Date: Thu, 30 Aug 2001 22:16:46 +0000 Subject: [PATCH] Synch with Oort Gnus. --- lisp/ChangeLog | 42 ++++++++++++++++++++++ lisp/mail-source.el | 14 ++++++-- lisp/mm-decode.el | 7 ++-- lisp/nndoc.el | 6 ++-- lisp/nnheader.el | 5 ++- lisp/nnml.el | 96 ++++++++++++++++++++++++++++++++++++--------------- 6 files changed, 133 insertions(+), 37 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 31b796e..9f296a6 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,45 @@ +2001-08-30 13:00:00 ShengHuo ZHU + + * nndoc.el (nndoc-forward-type-p): It is not a digest. + +2001-08-30 11:00:00 ShengHuo ZHU + + * nnml.el (nnml-check-directory-twice): Remove. + (nnml-retrieve-headers): Ditto. + (nnml-article-to-file): Use nnheader-directory-files-is-safe. + +2001-08-30 Andrew Innes + + * nnheader.el (nnheader-directory-files-is-safe): No need to read + directory twice on Windows, or on GNU Emacs-21. + +2001-08-30 Andrew Innes + + * nnml.el (nnml-request-article): Use nnml-article-to-file-alist. + (nnml-request-rename-group): Ditto. + (nnml-active-number): Ditto. + (nnml-request-create-group): Use nnml-directory-articles. + (nnml-request-expire-articles): Use nnml-directory-articles, which + gets list from nov database if available. + (nnml-get-nov-buffer): New function. + (nnml-open-nov): Use it. + (nnml-update-file-alist): Use nnml-article-to-file-alist, which + gets alist from nov database if available. + (nnml-directory-articles): New function. + (nnml-article-to-file-alist): New function. + +2001-08-30 Andrew Innes + + * mm-decode.el (mm-display-external): Use `name' as filename, if + `filename' attribute is not present. + +2001-08-30 Andrew Innes + + * mail-source.el (mail-source-flash): New defcustom. + (mail-source-new-mail-p): Ring visible bell if appropriate. + (mail-source-start-idle-timer): Use unwind-protect to ensure idle + timer is cleared even if mail check signals an error. + 2001-08-29 10:00:00 ShengHuo ZHU * gnus-sum.el (gnus-summary-move-article): Only update marks of diff --git a/lisp/mail-source.el b/lisp/mail-source.el index 89116f4..136704c 100644 --- a/lisp/mail-source.el +++ b/lisp/mail-source.el @@ -224,6 +224,11 @@ If non-nil, this maildrop will be checked periodically for new mail." :group 'mail-source :type 'sexp) +(defcustom mail-source-flash t + "*If non-nil, flash periodically when mail is available." + :group 'mail-source + :type 'boolean) + (defcustom mail-source-crash-box "~/.emacs-mail-crash-box" "File where mail will be stored while processing it." :group 'mail-source @@ -751,6 +756,10 @@ If ARGS, PROMPT is used as an argument to `format'." (defun mail-source-new-mail-p () "Handler for `display-time' to indicate when new mail is available." + ;; Flash (ie. ring the visible bell) if mail is available. + (if (and mail-source-flash mail-source-new-mail-available) + (let ((visible-bell t)) + (ding))) ;; Only report flag setting; flag is updated on a different schedule. mail-source-new-mail-available) @@ -773,8 +782,9 @@ If ARGS, PROMPT is used as an argument to `format'." mail-source-idle-time-delay nil (lambda () - (mail-source-check-pop mail-source-primary-source) - (setq mail-source-report-new-mail-idle-timer nil)))) + (unwind-protect + (mail-source-check-pop mail-source-primary-source) + (setq mail-source-report-new-mail-idle-timer nil))))) ;; Since idle timers created when Emacs is already in the idle ;; state don't get activated until Emacs _next_ becomes idle, we ;; need to force our timer to be considered active now. We do diff --git a/lisp/mm-decode.el b/lisp/mm-decode.el index 7975fae..d300c6e 100644 --- a/lisp/mm-decode.el +++ b/lisp/mm-decode.el @@ -625,8 +625,11 @@ external if displayed external." (mm-insert-part handle) (let* ((dir (make-temp-name (expand-file-name "emm." mm-tmp-directory))) - (filename (mail-content-type-get - (mm-handle-disposition handle) 'filename)) + (filename (or + (mail-content-type-get + (mm-handle-disposition handle) 'filename) + (mail-content-type-get + (mm-handle-type handle) 'name))) (mime-info (mailcap-mime-info (mm-handle-media-type handle) t)) (needsterm (or (assoc "needsterm" mime-info) diff --git a/lisp/nndoc.el b/lisp/nndoc.el index 7dd8d94..5c115b7 100644 --- a/lisp/nndoc.el +++ b/lisp/nndoc.el @@ -225,7 +225,7 @@ from the document.") (set-buffer buffer) (erase-buffer) (when entry - (cond + (cond ((stringp article) nil) (nndoc-generate-article-function (funcall nndoc-generate-article-function article)) @@ -459,9 +459,7 @@ from the document.") (defun nndoc-forward-type-p () (when (and (re-search-forward "^-+ \\(Start of \\)?forwarded message.*\n+" nil t) - (not (re-search-forward "^Subject:.*digest" nil t)) - (not (re-search-backward "^From:" nil t 2)) - (not (re-search-forward "^From:" nil t 2))) + (looking-at "[\r\n]*[a-zA-Z][a-zA-Z0-9-]*:")) t)) (defun nndoc-rfc934-type-p () diff --git a/lisp/nnheader.el b/lisp/nnheader.el index 1fe79ca..466d701 100644 --- a/lisp/nnheader.el +++ b/lisp/nnheader.el @@ -818,7 +818,10 @@ list of headers that match SEQUENCE (see `nntp-retrieve-headers')." (string-match nnheader-numerical-short-files file) (string-to-int (match-string 0 file)))) -(defvar nnheader-directory-files-is-safe nil +(defvar nnheader-directory-files-is-safe + (or (eq system-type 'windows-nt) + (and (not (featurep 'xemacs)) + (> emacs-major-version 20))) "If non-nil, Gnus believes `directory-files' is safe. It has been reported numerous times that `directory-files' fails with an alarming frequency on NFS mounted file systems. If it is nil, diff --git a/lisp/nnml.el b/lisp/nnml.el index 6a928a0..7a527e6 100644 --- a/lisp/nnml.el +++ b/lisp/nnml.el @@ -116,9 +116,6 @@ This variable is a virtual server slot. See the Gnus manual for details.") (defvoo nnml-generate-active-function 'nnml-generate-active-info) (defvar nnml-nov-buffer-file-name nil) -(defvar nnml-check-directory-twice t - "If t, to make sure nothing went wrong when reading over NFS -- -check twice.") (defvoo nnml-file-coding-system nnmail-file-coding-system) @@ -140,12 +137,7 @@ check twice.") (count 0) (file-name-coding-system nnmail-pathname-coding-system) (pathname-coding-system nnmail-pathname-coding-system) - beg article - (nnml-check-directory-twice - (and nnml-check-directory-twice - ;; To speed up, disable it in some case. - (or (not (numberp nnmail-large-newsgroup)) - (<= number nnmail-large-newsgroup))))) + beg article) (if (stringp (car sequence)) 'headers (if (nnml-retrieve-headers-with-nov sequence fetch-old) @@ -212,7 +204,7 @@ check twice.") (when (and (setq group-num (nnml-find-group-number id)) (cdr (assq (cdr group-num) - (nnheader-article-to-file-alist + (nnml-article-to-file-alist (setq gpath (nnmail-group-pathname (car group-num) @@ -286,7 +278,7 @@ check twice.") nnml-group-alist) (nnml-possibly-create-directory group) (nnml-possibly-change-directory group server) - (let ((articles (nnheader-directory-articles nnml-current-directory))) + (let ((articles (nnml-directory-articles nnml-current-directory))) (when articles (setcar active (apply 'min articles)) (setcdr active (apply 'max articles)))) @@ -312,7 +304,7 @@ check twice.") (deffoo nnml-request-expire-articles (articles group &optional server force) (nnml-possibly-change-directory group server) (let ((active-articles - (nnheader-directory-articles nnml-current-directory)) + (nnml-directory-articles nnml-current-directory)) (is-old t) article rest mod-time number) (nnmail-activate 'nnml) @@ -493,7 +485,7 @@ check twice.") ;; We move the articles file by file instead of renaming ;; the directory -- there may be subgroups in this group. ;; One might be more clever, I guess. - (let ((files (nnheader-article-to-file-alist old-dir))) + (let ((files (nnml-article-to-file-alist old-dir))) (while files (rename-file (concat old-dir (cdar files)) @@ -539,7 +531,7 @@ check twice.") (let (file) (if (setq file (cdr (assq article nnml-article-file-alist))) (expand-file-name file nnml-current-directory) - (if nnml-check-directory-twice + (if (not nnheader-directory-files-is-safe) ;; Just to make sure nothing went wrong when reading over NFS -- ;; check once more. (when (file-exists-p @@ -688,7 +680,7 @@ check twice.") (unless nnml-article-file-alist (setq nnml-article-file-alist (sort - (nnheader-article-to-file-alist nnml-current-directory) + (nnml-article-to-file-alist nnml-current-directory) 'car-less-than-car))) (setq active (if nnml-article-file-alist @@ -733,18 +725,22 @@ check twice.") (mail-header-set-number headers number) headers)))) +(defun nnml-get-nov-buffer (group) + (let ((buffer (get-buffer-create (format " *nnml overview %s*" group)))) + (save-excursion + (set-buffer buffer) + (set (make-local-variable 'nnml-nov-buffer-file-name) + (expand-file-name + nnml-nov-file-name + (nnmail-group-pathname group nnml-directory))) + (erase-buffer) + (when (file-exists-p nnml-nov-buffer-file-name) + (nnheader-insert-file-contents nnml-nov-buffer-file-name))) + buffer)) + (defun nnml-open-nov (group) (or (cdr (assoc group nnml-nov-buffer-alist)) - (let ((buffer (get-buffer-create (format " *nnml overview %s*" group)))) - (save-excursion - (set-buffer buffer) - (set (make-local-variable 'nnml-nov-buffer-file-name) - (expand-file-name - nnml-nov-file-name - (nnmail-group-pathname group nnml-directory))) - (erase-buffer) - (when (file-exists-p nnml-nov-buffer-file-name) - (nnheader-insert-file-contents nnml-nov-buffer-file-name))) + (let ((buffer (nnml-get-nov-buffer group))) (push (cons group buffer) nnml-nov-buffer-alist) buffer))) @@ -879,7 +875,51 @@ check twice.") (when (or (not nnml-article-file-alist) force) (setq nnml-article-file-alist - (nnheader-article-to-file-alist nnml-current-directory)))) + (nnml-article-to-file-alist nnml-current-directory)))) + +(defun nnml-directory-articles (dir) + "Return a list of all article files in a directory. +Use the nov database for that directory if available." + (if (or gnus-nov-is-evil nnml-nov-is-evil + (not (file-exists-p + (expand-file-name nnml-nov-file-name dir)))) + (nnheader-directory-articles dir) + ;; build list from .overview if available + ;; We would use nnml-open-nov, except that nnml-nov-buffer-alist is + ;; defvoo'd, and we might get called when it hasn't been swapped in. + (save-excursion + (let ((list nil) + art + (buffer (nnml-get-nov-buffer nnml-current-group))) + (set-buffer buffer) + (goto-char (point-min)) + (while (not (eobp)) + (setq art (read (current-buffer))) + (push art list) + (forward-line 1)) + list)))) + +(defun nnml-article-to-file-alist (dir) + "Return an alist of article/file pairs in DIR. +Use the nov database for that directory if available." + (if (or gnus-nov-is-evil nnml-nov-is-evil + (not (file-exists-p + (expand-file-name nnml-nov-file-name + nnml-current-directory)))) + (nnheader-article-to-file-alist nnml-current-directory) + ;; build list from .overview if available + (save-excursion + (let ((alist nil) + art + (buffer (nnml-get-nov-buffer nnml-current-group))) + (set-buffer buffer) + (goto-char (point-min)) + (while (not (eobp)) + (setq art (read (current-buffer))) + ;; assume file name is unadorned (ie. not compressed etc) + (push (cons art (int-to-string art)) alist) + (forward-line 1)) + alist)))) (deffoo nnml-request-set-mark (group actions &optional server) (nnml-possibly-change-directory group server) @@ -940,8 +980,8 @@ check twice.") (error "Cannot write to %s (%s)" err)))))) (defun nnml-open-marks (group server) - (let ((file (expand-file-name - nnml-marks-file-name + (let ((file (expand-file-name + nnml-marks-file-name (nnmail-group-pathname group nnml-directory)))) (if (file-exists-p file) (setq nnml-marks (condition-case err -- 1.7.10.4