* nnmaildir.el (nnmaildir--parse-filename, nnmaildir--sort-files,
authorPaul Jarc <prj@po.cwru.edu>
Wed, 12 Mar 2003 17:58:28 +0000 (17:58 +0000)
committerPaul Jarc <prj@po.cwru.edu>
Wed, 12 Mar 2003 17:58:28 +0000 (17:58 +0000)
nnmaildir--scan, nnmaildir-request-accept-article): Changes for
the recent filename uniqueness discussion.

lisp/ChangeLog
lisp/nnmaildir.el

index f6baefa..a9c6ea1 100644 (file)
@@ -1,3 +1,9 @@
+2003-03-12  Paul Jarc  <prj@po.cwru.edu>
+
+       * nnmaildir.el (nnmaildir--parse-filename, nnmaildir--sort-files,
+       nnmaildir--scan, nnmaildir-request-accept-article): Changes for
+       the recent filename uniqueness discussion.
+
 2003-03-12  Katsumi Yamaoka  <yamaoka@jpl.org>
 
        * mm-view.el (mm-inline-image-emacs): Make it delete an excessive
@@ -37,7 +43,7 @@
        overhead of optional messages. Reversed message levels to
        emphasize percent completion messages.  Detailed messages of
        little use except when debugging code.
-       
+
 2003-03-08  Teodor Zlatanov  <tzz@lifelogs.com>
 
        * spam.el (spam-ham-move-routine): use
@@ -50,7 +56,6 @@
        (spam-setup-widening): use
        nnimap-split-download-body-default instead of
        nnimap-split-download-body which is a user-customizable variable
-        
 
 2003-03-07  Simon Josefsson  <jas@extundo.com>
 
        parameters when calling gnus-summary-find-prev.
        (gnus-summary-find-next,gnus-summary-find-prev): Apply
        gnus-auto-goto-ignores to filter out unacceptable articles.
-       
+
 2003-03-04  Jesper Harder  <harder@ifa.au.dk>
 
        * mail-source.el (mail-source-read-passwd): Remove. `read-passwd'
        read-passwd.
 
        * pgg.el (pgg-read-passphrase): Simplify.
-       
+
 2003-03-04  Kevin Greiner  <kgreiner@xpediantsolutions.com>
 
        * gnus-agent.el (gnus-agent-mode): Fixed the mode line reports
        (gnus-category-read): Ignore nil values when converting an
        old-format category so that the new-format category will default
        those attributes to the global variables.
-       
+
 2003-03-03  Reiner Steib  <Reiner.Steib@gmx.de>
 
        * mail-source.el (mail-source-delete-old-incoming-confirm): Fixed
        `gnus-point-at-bol' and `gnus-point-at-eol' instead of
        `(progn (beginning-of-line) (point))'.  It's shorter, faster,
        and makes it clear that we don't need the side effect.
-       * gnus-util.el (gnus-delete-line): do.  
+       * gnus-util.el (gnus-delete-line): do.
        * gnus-xmas.el (gnus-group-add-icon): do.
        * nnmail.el (nnmail-article-group, nnmail-cache-fetch-group): do.
        * nntp.el (nntp-send-authinfo-from-file): do.
        * nnml.el (nnml-header-value): do.
        * nnheader.el (nnheader-insert-references): do.
-       * gnus-cite.el (gnus-article-highlight-citation) 
+       * gnus-cite.el (gnus-article-highlight-citation)
        (gnus-cite-parse): do.
        * gnus-score.el (gnus-score-followup): do.
        * gnus-draft.el (gnus-draft-send): do.
        (nnfolder-request-article): do.
        * gnus-art.el (article-hide-boring-headers)
        (gnus-article-hide-header): do.
-       
+
        * nnheader.el (nnheader-find-nov-line): Use gnus-delete-line.
        * nnml.el (nnml-request-replace-article): do.
        * nnmbox.el (nnmbox-request-move-article, nnmbox-delete-mail): do.
        * gnus-art.el (gnus-mm-display-part): do.
 
        * gnus-art.el (gnus-article-goto-part): Use gnus-goto-char.
-       
+
 2003-03-02  Kevin Greiner  <kgreiner@xpediantsolutions.com>
 
        * nntp.el (nntp-possibly-change-group): Avoid calling
        (gnus-request-head, gnus-request-body): Conditional checks
        surrounding gnus-agent-request-article removed; now performed by
        gnus-agent-request-article.
-       
+
        * gnus-start.el (): Added defvar statements to resolve compilation
        warnings.
        (gnus-long-file-names): New function. Isolates platform dependent
        * pgg-gpg.el (pgg-gpg-process-region): Insert process status into
        errors-buffer. This produces a nicer error message in case of
        problems.
-       
+
 2003-03-01  Teodor Zlatanov  <tzz@lifelogs.com>
 
        * spam.el (spam-maybe-spam-stat-load, spam-maybe-spam-stat-load):
 
 2003-03-01  Lars Magne Ingebrigtsen  <larsi@gnus.org>
 
-       * message.el (message-make-fqdn): Protect against nil user-mail. 
+       * message.el (message-make-fqdn): Protect against nil user-mail.
 
 2003-02-28  Vasily Korytov <deskpot@myrealbox.com>
 
        * gnus-art.el (gnus-boring-article-headers): New values:
        'to-list and 'cc-list.
-       
+
 2003-02-28  Teodor Zlatanov  <tzz@lifelogs.com>
 
        * spam.el (spam-setup-widening): new function to set
        provide a separate single group expiration function.
        (gnus-agent-regenerate-group): Now clears the message buffer when
        finished.
-       
+
 2003-02-23  Kai Gro\e,A_\e(Bjohann  <kai.grossjohann@uni-duisburg.de>
 
        * gnus.el (gnus-agent-target-move-group-header): New variable.
 2003-02-23  Lars Magne Ingebrigtsen  <larsi@gnus.org>
 
        * gnus-art.el (gnus-mime-action-on-part): Require a match
-       interactively. 
+       interactively.
 
        * gnus-start.el (gnus-save-newsrc-file): Use
-       gnus-backup-startup-file. 
+       gnus-backup-startup-file.
        (gnus-backup-startup-file): New variable.
 
 2003-02-22  Lars Magne Ingebrigtsen  <larsi@gnus.org>
 
-       * gnus.el (gnus-summary-buffer-name): Moved function here. 
+       * gnus.el (gnus-summary-buffer-name): Moved function here.
 
        * gnus-draft.el (defun): Remove debug.
 
        (gnus-summary-expire-articles): send data header for article, not
        just article ID
 
-       * gnus-registry.el (gnus-registry-hashtb, gnus-register-action) 
+       * gnus-registry.el (gnus-registry-hashtb, gnus-register-action)
        (gnus-register-spool-action): added hashtable of message ID keys
        with message motion data
 
        insert-string which is obsolete in Emacs 21.4.
 
        * message.el (message-cross-post-followup-to-header): do.
-       
+
        * spam.el (spam-ifile-register-with-ifile)
        (spam-stat-register-spam-routine)
        (spam-stat-register-ham-routine)
 
 2003-02-18  Teodor Zlatanov  <tzz@lifelogs.com>
 
-       * spam.el (spam-ham-move-routine) 
+       * spam.el (spam-ham-move-routine)
        (spam-mark-spam-as-expired-and-move-routine): use
        gnus-summary-kill-process-mark and gnus-summary-yank-process-mark
        around process-mark manipulation on the group
 2003-02-14  ShengHuo ZHU  <zsh@cs.rochester.edu>
 
        * mm-uu.el (mm-uu-uu-filename): Fix use of character constant.
-       
+
 2003-02-11  Stefan Monnier  <monnier@cs.yale.edu>
-      
+
        * nntp.el (nntp-accept-process-output): Don't use point-max to get
-        the buffer's size.
+       the buffer's size.
 
 2003-01-31  Joe Buehler  <jhpb@draco.hekimian.com>
 
        * nnheader.el: Added cygwin to system-type comparisons.
-       
+
 2003-01-27  Juanma Barranquero  <lektu@terra.es>
 
        * imap.el (imap-mailbox-status): Fix typo.
 
 2003-02-13  Teodor Zlatanov  <tzz@lifelogs.com>
 
-       * spam.el (spam-ham-move-routine) 
+       * spam.el (spam-ham-move-routine)
        (spam-mark-spam-as-expired-and-move-routine): made the article
        move conditional, so it's not called even if there's nothing to move
 
        the current LINE.
        (gnus-agent-summary-fetch-group): Minimized the number of times
        that the article is updated in the buffer.
-       
+
 2003-02-11  Teodor Zlatanov  <tzz@lifelogs.com>
 
        * spam.el (spam-ham-move-routine): use the process-mark instead of
        less than 10 digits to avoid overflow errors.  Fixed logic error
        when ensuring that the final article ID is present in the new
        alist.
-       
+
 2003-02-09  Lars Magne Ingebrigtsen  <larsi@gnus.org>
 
        * gnus-topic.el (gnus-topic-goto-missing-topic): Just move to the
        * gnus-registry.el (regtest-nnmail): use
        gnus-internal-registry-spool-current-method
 
-       
-
 2003-02-07  Lars Magne Ingebrigtsen  <larsi@gnus.org>
 
        * mail-source.el (mail-source-fetch): Typo fix.
        (gnus-group-full-name): always get a group's full name
        (gnus-group-guess-full-name): shortcut, using just the group name
 
-       * gnus-sum.el (gnus-summary-article-move-hook) 
-       (gnus-summary-article-delete-hook) 
+       * gnus-sum.el (gnus-summary-article-move-hook)
+       (gnus-summary-article-delete-hook)
        (gnus-summary-article-expire-hook): new hooks
-       (gnus-summary-move-article, gnus-summary-expire-articles) 
+       (gnus-summary-move-article, gnus-summary-expire-articles)
        (gnus-summary-delete-article): invoke the new hooks
 
 2003-02-07  Frank Weinberg  <frank@usenet-rundfahrt.de>
 
-        * gnus-art.el (gnus-article-refer-article): Strip leading "news:"
-          from message-ID
+       * gnus-art.el (gnus-article-refer-article): Strip leading "news:"
+       from message-ID
 
 2003-02-07  Jesper Harder  <harder@ifa.au.dk>
 
        (mail-source-ignore-errors): New variable.
 
        * gnus-sum.el (gnus-summary-refer-thread): Don't re-fetch current
-       articles. 
+       articles.
 
        * gnus-msg.el (gnus-version-expose-system): Change default.
 
        "delete-if" is misleading because it isn't actually destructive.
 
        * gnus-topic.el (gnus-group-prepare-topics): Use new name.
-       
+
        * nnmail.el (nnmail-purge-split-history): do.
 
        * gnus-win.el (gnus-get-buffer-window): do.
-       
+
        * gnus-sum.el (gnus-simplify-whitespace): Remove unnecessary
        let-binding.
        (gnus-simplify-all-whitespace): do.
        * gnus.el: Use gnus-prin1-to-string throughout.
 
        * gnus-util.el (gnus-prin1-to-string): Bind print-length and
-       print-level. 
+       print-level.
 
        * gnus-art.el (article-display-x-face): Removed grey x-face stuff.
        (gnus-treat-display-grey-xface): Removed.
 
 2003-01-27  Teodor Zlatanov  <tzz@lifelogs.com>
 
-       * spam.el (spam-check-blackholes) 
+       * spam.el (spam-check-blackholes)
        (spam-blackhole-good-server-regex): new variable to skip some IPs
        when checking blackholes; use it
-       (spam-check-bogofilter-headers) 
+       (spam-check-bogofilter-headers)
        (spam-bogofilter-bogosity-positive-spam-header): new variable, in
        case more X-Bogosity is used than just "Yes/No"
        (spam-ham-move-routine): semi-fixed, only first article is
 
        * gnus-util.el (gnus-kill-buffer): Remove buffer from gnus-buffers
        as well.
-       
+
        * gnus-sum.el (gnus-select-newsgroup): Use gnus-kill-buffer.
-       
+
        * gnus-score.el (gnus-score-headers, gnus-score-find-bnews): do.
-       
+
        * gnus-start.el (gnus-save-newsrc-file, gnus-clear-system): do.
-       
+
        * gnus-bcklg.el (gnus-backlog-shutdown): do.
-       
+
        * gnus-srvr.el (gnus-server-exit, gnus-browse-exit): do.
 
 2003-01-26  Lars Magne Ingebrigtsen  <larsi@gnus.org>
        * gnus-fun.el (gnus-face-encode): New function.
        (gnus-convert-png-to-face): Use it.
 
-       * gnus-sum.el (gnus-summary-make-menu-bar): Added M-& to marks. 
+       * gnus-sum.el (gnus-summary-make-menu-bar): Added M-& to marks.
 
 2003-01-26  Jesper Harder  <harder@ifa.au.dk>
 
 2003-01-24  Lars Magne Ingebrigtsen  <larsi@gnus.org>
 
        * nnheader.el (nnheader-directory-separator-character): New
-       variable. 
+       variable.
 
 2003-01-24  Kai Gro\e,A_\e(Bjohann  <kai.grossjohann@uni-duisburg.de>
 
        (gnus-agent-regenerate-group): Reformat to keep under eighty
        columns.  Reword docstrings so that first line is under eighty
        chars and a complete sentence.  Still need to work on the rear
-       end of the file, in particular gnus-agent-expire.       
+       end of the file, in particular gnus-agent-expire.
 
 2003-01-24  Lars Magne Ingebrigtsen  <larsi@gnus.org>
 
 
 2003-01-24  Teodor Zlatanov  <tzz@lifelogs.com>
 
-       * spam.el (spam-check-blackholes, spam-split) 
+       * spam.el (spam-check-blackholes, spam-split)
        (spam-mark-junk-as-spam-routine, spam-summary-prepare-exit): added
        gnus-message calls to show to users what spam.el is doing
 
 2003-01-24  Lars Magne Ingebrigtsen  <larsi@gnus.org>
 
        * gnus-art.el (gnus-mime-security-show-details): Toggle showing
-       details. 
+       details.
 
 2003-01-23  Lars Magne Ingebrigtsen  <larsi@gnus.org>
 
        * gnus-sum.el (gnus-summary-force-verify-and-decrypt): Doc fix.
 
        * gnus-async.el (gnus-async-wait-for-article): Don't use a
-       timeout. 
+       timeout.
 
-       * nntp.el (nntp-accept-process-output): Removed timeout. 
+       * nntp.el (nntp-accept-process-output): Removed timeout.
        (nntp-read-timeout): New variable.
        (nntp-accept-process-output): Use it.
 
 
 2003-01-23  Teodor Zlatanov  <tzz@lifelogs.com>
 
-       * spam.el (spam-check-regex-headers, spam-list-of-checks) 
+       * spam.el (spam-check-regex-headers, spam-list-of-checks)
        (spam-regex-headers-spam, spam-regex-headers-ham): added spam/ham
        checks of incoming mail based on simple header regexp matching
 
        gnus-summary-first-subject call to match new API.
        (gnus-summary-first-unseen-or-unread-subject): Ditto.
        (gnus-summary-catchup): Do not mark unfetched articles as read.
-       
+
 2003-01-22  Jesper Harder  <harder@ifa.au.dk>
 
        * gnus-art.el (gnus-treat-strip-pgp, gnus-article-hide-pgp-hook):
        * gnus-sum.el (gnus-summary-update-article-line): Fixed
        calculation of net characters added for use in the gnus-data
        structure.
-       
+
 2003-01-18  Kai Gro\e,A_\e(Bjohann  <kai.grossjohann@uni-duisburg.de>
 
        * nnmail.el (nnmail-process-unix-mail-format): Improve error
 
 2003-01-17  Lars Magne Ingebrigtsen  <larsi@gnus.org>
 
-       * gnus-art.el (gnus-article-followup-with-original): Clean up. 
+       * gnus-art.el (gnus-article-followup-with-original): Clean up.
        (gnus-article-reply-with-original): Ditto.
 
        * gnus-sum.el (gnus-summary-catchup): Make sure downloadable,
 
 2003-01-17  Simon Josefsson  <jas@extundo.com>
 
-       * gnus-fun.el (gnus-x-face-from-file): 
+       * gnus-fun.el (gnus-x-face-from-file):
        (gnus-face-from-file): Suggest image format in minibuffer prompt.
 
        * gnus-fun.el (gnus-convert-image-to-x-face-command)
 
 2003-01-16  Simon Josefsson  <jas@extundo.com>
 
-       * gnus-fun.el (gnus-convert-image-to-x-face-command) 
-       (gnus-convert-image-to-face-command, gnus-x-face-from-file) 
+       * gnus-fun.el (gnus-convert-image-to-x-face-command)
+       (gnus-convert-image-to-face-command, gnus-x-face-from-file)
        (gnus-face-from-file): Doc fix; don't mention image format.
 
 2003-01-16  Teodor Zlatanov  <tzz@lifelogs.com>
        (spam-summary-prepare-exit): fixed bug, noticed by Malcolm Purvis
 
 2003-01-15  ShengHuo ZHU  <zsh@cs.rochester.edu>
+
        * gnus-agent.el: Don't use `path'.
        From the GNU coding standards:
-       
+
            Please do not use the term ``pathname'' that is used in Unix
            documentation; use ``file name'' (two words) instead.  We use
            the term ``path'' only for search paths, which are lists of
            directory names.
 
        * nnsoup.el (nnsoup-file-name): Ditto.
+
        * nnmail.el (nnmail-pathname-coding-system): Ditto.
-               (nnmail-group-pathname): Ditto.
+       (nnmail-group-pathname): Ditto.
+
        * nnimap.el (nnimap-group-overview-filename): Ditto.
+
        * nnheader.el (nnheader-pathname-coding-system): Ditto.
        (nnheader-group-pathname): Ditto.
+
        * nnfolder.el (nnfolder-group-pathname): Ditto.
+
        * gnus.el (gnus-home-directory): Ditto.
+
        * gnus-group.el (gnus-group-icon-list): Ditto.
+
 2003-01-16  Jesper Harder  <harder@ifa.au.dk>
 
        * gnus-art.el (gnus-mime-print-part): Use mm-handle-media-type.
 
 2003-01-15  Teodor Zlatanov  <tzz@lifelogs.com>
 
-       * spam.el (spam-use-bogofilter-headers, spam-bogofilter-header) 
+       * spam.el (spam-use-bogofilter-headers, spam-bogofilter-header)
        (spam-bogofilter-database-directory): new variables
-       (spam-check-bogofilter-headers, spam-check-bogofilter) 
-       (spam-bogofilter-register-with-bogofilter) 
-       (spam-bogofilter-register-spam-routine) 
-       (spam-bogofilter-register-ham-routine) 
+       (spam-check-bogofilter-headers, spam-check-bogofilter)
+       (spam-bogofilter-register-with-bogofilter)
+       (spam-bogofilter-register-spam-routine)
+       (spam-bogofilter-register-ham-routine)
        (spam-group-ham-processor-bogofilter-p): new functions for the new
        Bogofilter interface
        (spam-summary-prepare-exit): use the new Bogofilter functions
 2003-01-15  Lars Magne Ingebrigtsen  <larsi@gnus.org>
 
        * message.el (message-send): Don't warn about duplicates when
-       superseding. 
+       superseding.
 
 2003-01-15  Simon Josefsson  <jas@extundo.com>
 
 
 2003-01-14  Lars Magne Ingebrigtsen  <larsi@gnus.org>
 
-       * gnus-audio.el (gnus-audio-au-player): Use executable-find. 
+       * gnus-audio.el (gnus-audio-au-player): Use executable-find.
 
 2003-01-13  Jhair Tocancipa Triana <jhair_tocancipa@@gmx.net>
 
        * gnus-audio.el (gnus-audio-au-player, gnus-audio-wav-player): Use
-         /usr/bin/play as default player. 
+         /usr/bin/play as default player.
          (gnus-audio-play): Added ARG-DESCRIPTOR to prompt for a file to play.
 
 2003-01-14  Katsumi Yamaoka  <yamaoka@jpl.org>
        * gnus-agent.el (gnus-agent-get-undownloaded-list): Include the
        fictious headers generated by nnagent (ie. Undownloaded Article
        ####) in the list of articles that have not been downloaded.
-       
+
        * gnus-int.el (): Added require declarations to resolve
        compile-time warnings.
        (gnus-open-server): If the server status is set to offline,
 
 2003-01-13  Romain FRANCOISE  <romain@orebokech.com>
 
-       * gnus-fun.el (gnus-x-face-from-file): Quote file name. 
+       * gnus-fun.el (gnus-x-face-from-file): Quote file name.
        (gnus-face-from-file): Ditto.
 
 2003-01-13  Lars Magne Ingebrigtsen  <larsi@gnus.org>
 
        * gnus-sum.el (gnus-articles-to-read): Don't just apply
-       gnus-alter-articles-to-read-function to the unread articles. 
+       gnus-alter-articles-to-read-function to the unread articles.
 
 2003-01-13  Reiner Steib  <Reiner.Steib@gmx.de>
 
 2003-01-12  Fran\e,Ag\e(Bois-David Collin  <Francois-David.Collin@curie.fr>
 
        * mm-decode.el (mm-get-part): Use mm-with-unibyte-current-buffer.
-       
+
 2003-01-12  Lars Magne Ingebrigtsen  <larsi@gnus.org>
 
        * gnus-fun.el (gnus-face-from-file): Autoload.
        marks from articles that are already stored in the agent.
        (gnus-agent-backup-overview-buffer): New debug tool.  Creates a
        backup copy of an invalid .overview file for later analysis.
-       
+
 2003-01-12  Gregorio Gervasio, Jr.  <gtgj@pacbell.net>
 
        * gnus-sum.el (gnus-summary-exit): Reverse change to make group
 2003-01-11  Lars Magne Ingebrigtsen  <larsi@gnus.org>
 
        * gnus-art.el (gnus-display-mime): Use the mime emulation
-       variable. 
+       variable.
 
        * gnus-sum.el (gnus-article-emulate-mime): New variable.
 
 2003-01-10  Teodor Zlatanov  <tzz@lifelogs.com>
 
        * spam.el (spam-use-stat): new variable
-       (spam-group-spam-processor-stat-p) 
+       (spam-group-spam-processor-stat-p)
        (spam-group-ham-processor-stat-p): new convenience functions
        (spam-summary-prepare-exit): add spam/ham processors to sequence
        (spam-list-of-checks): add spam-use-stat to list of checks
        * gnus-sum.el (t): Add gnus-group-fetch-charter and
        gnus-group-fetch-control to summary key map and menu.
 
-
 2002-10-03  Paul Jarc  <prj@po.cwru.edu>
 
        * nnmaildir.el (nnmaildir--group-maxnum-art): fix maximum article
index dff0443..53bb2d1 100644 (file)
 ;;   copying, restoring, etc.
 ;;
 ;; Todo:
-;; * Merge the information from <URL:http://multivac.cwru.edu./nnmaildir/>
-;;   into the Gnus manual.
-;; * Allow create-directory = ".", and configurable prefix of maildir names,
-;;   stripped off to produce group names.
+;; * Artificially add nonexistent article to the 'read range, to fix the
+;;   wrong-count problem.
+;; * Replace create-directory with target-prefix, so the maildirs can be in
+;;   the same directory as the symlinks, starting with, e.g., ".".
 ;; * Add a hook for when moving messages from new/ to cur/, to support
 ;;   nnmail's duplicate detection.
 ;; * Allow each mark directory in a group to have its own inode for mark
 ;;   files, to accommodate AFS.
 ;; * Improve generated Xrefs, so crossposts are detectable.
-;; * Improve readability.
+;; * Improve code readability.
 
 ;;; Code:
 
@@ -86,8 +86,8 @@ by nnmaildir-request-article.")
 
 ;; Variables to generate filenames of messages being delivered:
 (defvar   nnmaildir--delivery-time "")
-(defconst nnmaildir--delivery-pid  (number-to-string (emacs-pid)))
-(defvar   nnmaildir--delivery-ct   nil)
+(defconst nnmaildir--delivery-pid (concat "P" (number-to-string (emacs-pid))))
+(defvar   nnmaildir--delivery-count nil)
 
 ;; An obarry containing symbols whose names are server names and whose values
 ;; are servers:
@@ -620,17 +620,13 @@ by nnmaildir-request-article.")
 (defun nnmaildir--parse-filename (file)
   (let ((prefix (car file))
        timestamp len)
-    (if (string-match
-        "\\`\\([0-9]+\\)\\.\\([0-9]+\\)\\(_\\([0-9]+\\)\\)?\\(\\..*\\)\\'"
-        prefix)
+    (if (string-match "\\`\\([0-9]+\\)\\(\\..*\\)\\'" prefix)
        (progn
          (setq timestamp (concat "0000" (match-string 1 prefix))
                len (- (length timestamp) 4))
          (vector (string-to-number (substring timestamp 0 len))
                  (string-to-number (substring timestamp len))
-                 (string-to-number (match-string 2 prefix))
-                 (string-to-number (or (match-string 4 prefix) "-1"))
-                 (match-string 5 prefix)
+                 (match-string 2 prefix)
                  file))
       file)))
 
@@ -643,11 +639,7 @@ by nnmaildir-request-article.")
     (if (> (aref a 0) (aref b 0)) (throw 'return nil))
     (if (< (aref a 1) (aref b 1)) (throw 'return t))
     (if (> (aref a 1) (aref b 1)) (throw 'return nil))
-    (if (< (aref a 2) (aref b 2)) (throw 'return t))
-    (if (> (aref a 2) (aref b 2)) (throw 'return nil))
-    (if (< (aref a 3) (aref b 3)) (throw 'return t))
-    (if (> (aref a 3) (aref b 3)) (throw 'return nil))
-    (string-lessp (aref a 4) (aref b 4))))
+    (string-lessp (aref a 2) (aref b 2))))
 
 (defun nnmaildir--scan (gname scan-msgs groups method srv-dir srv-ls)
   (catch 'return
@@ -703,7 +695,9 @@ by nnmaildir-request-article.")
        (when (or isnew nattr)
          (mapcar
           (lambda (file)
-            (rename-file (concat ndir file) (concat cdir file ":2,")))
+            (let ((path (concat ndir file)))
+              (and (time-less-p (nth 5 (file-attributes path)) (current-time))
+                   (rename-file path (concat cdir file ":2,")))))
           (funcall ls ndir nil "\\`[^.]" 'nosort))
          (setf (nnmaildir--grp-new group) nattr))
        (setq cattr (nth 5 (file-attributes cdir)))
@@ -751,7 +745,7 @@ by nnmaildir-request-article.")
            files (sort files 'nnmaildir--sort-files))
       (mapcar
        (lambda (file)
-        (setq file (if (consp file) file (aref file 5))
+        (setq file (if (consp file) file (aref file 3))
               x (make-nnmaildir--art :prefix (car file) :suffix (cdr file)))
         (nnmaildir--grp-add-art nnmaildir--cur-server group x))
        files)
@@ -1265,7 +1259,7 @@ by nnmaildir-request-article.")
        (coding-system-for-write nnheader-file-coding-system)
        (buffer-file-coding-system nil)
        (file-coding-system-alist nil)
-       srv-dir dir file tmpfile curfile 24h article)
+       srv-dir dir file time tmpfile curfile 24h article)
     (catch 'return
       (unless group
        (setf (nnmaildir--srv-error nnmaildir--cur-server)
@@ -1279,15 +1273,17 @@ by nnmaildir-request-article.")
        (throw 'return nil))
       (setq srv-dir (nnmaildir--srv-dir nnmaildir--cur-server)
            dir (nnmaildir--srvgrp-dir srv-dir gname)
-           file (format-time-string "%s" nil))
+           time (current-time)
+           file (format-time-string "%s." time))
       (unless (string-equal nnmaildir--delivery-time file)
        (setq nnmaildir--delivery-time file
-             nnmaildir--delivery-ct 0))
-      (setq file (concat file "." nnmaildir--delivery-pid))
-      (unless (zerop nnmaildir--delivery-ct)
-       (setq file (concat file "_"
-                          (number-to-string nnmaildir--delivery-ct))))
-      (setq file (concat file "." (system-name))
+             nnmaildir--delivery-count 0))
+      (when (and (consp (cdr time))
+                (consp (cddr time)))
+       (setq file (concat file "M" (number-to-string (caddr time)))))
+      (setq file (concat file nnmaildir--delivery-pid)
+           file (concat file "Q" (number-to-string nnmaildir--delivery-count))
+           file (concat file "." (system-name)) ;;;; FIXME: encode / and :
            tmpfile (concat (nnmaildir--tmp dir) file)
            curfile (concat (nnmaildir--cur dir) file ":2,"))
       (when (file-exists-p tmpfile)
@@ -1298,7 +1294,7 @@ by nnmaildir-request-article.")
        (setf (nnmaildir--srv-error nnmaildir--cur-server)
              (concat "File exists: " curfile))
        (throw 'return nil))
-      (setq nnmaildir--delivery-ct (1+ nnmaildir--delivery-ct)
+      (setq nnmaildir--delivery-count (1+ nnmaildir--delivery-count)
            24h (run-with-timer 86400 nil
                                (lambda ()
                                  (nnmaildir--unlink tmpfile)