Merge from emacs--devo--0
[gnus] / lisp / nnmaildir.el
index 7a268f2..05c19c2 100644 (file)
@@ -1,5 +1,6 @@
 ;;; nnmaildir.el --- maildir backend for Gnus
-;; Public domain.
+
+;; This file is in the public domain.
 
 ;; Author: Paul Jarc <prj@po.cwru.edu>
 
    )
 ]
 
+;; For Emacs < 22.2.
+(eval-and-compile
+  (unless (fboundp 'declare-function) (defmacro declare-function (&rest r))))
+
 (eval-and-compile
   (require 'nnheader)
   (require 'gnus)
@@ -921,7 +926,8 @@ by nnmaildir-request-article.")
   (let ((group (nnmaildir--prepare server gname))
        pgname flist always-marks never-marks old-marks dotfile num dir
        markdirs marks mark ranges markdir article read end new-marks ls
-       old-mmth new-mmth mtime mark-sym existing missing deactivate-mark)
+       old-mmth new-mmth mtime mark-sym existing missing deactivate-mark
+       article-list)
     (catch 'return
       (unless group
        (setf (nnmaildir--srv-error nnmaildir--cur-server)
@@ -969,12 +975,13 @@ by nnmaildir-request-article.")
            (setq ranges (assq mark-sym old-marks))
            (if ranges (setq ranges (cdr ranges)))
            (throw 'got-ranges nil))
+         (setq article-list nil)
          (dolist (prefix (funcall ls markdir nil "\\`[^.]" 'nosort))
            (setq article (nnmaildir--flist-art flist prefix))
            (if article
-               (setq ranges
-                     (gnus-add-to-range ranges
-                                        `(,(nnmaildir--art-num article)))))))
+               (setq article-list
+                     (cons (nnmaildir--art-num article) article-list))))
+         (setq ranges (gnus-add-to-range ranges (sort article-list '<))))
        (if (eq mark-sym 'read) (setq read ranges)
          (if ranges (setq marks (cons (cons mark-sym ranges) marks)))))
       (gnus-info-set-read info (gnus-range-add read missing))
@@ -1436,6 +1443,8 @@ by nnmaildir-request-article.")
 (defun nnmaildir-active-number (gname)
   0)
 
+(declare-function gnus-group-mark-article-read "gnus-group" (group article))
+
 (defun nnmaildir-request-expire-articles (ranges &optional gname server force)
   (let ((no-force (not force))
        (group (nnmaildir--prepare server gname))