]> code.delx.au - gnu-emacs/blobdiff - lisp/gnus/nnmaildir.el
(nnheader-init-server-buffer): Use with-current-buffer.
[gnu-emacs] / lisp / gnus / nnmaildir.el
index bfb55db30a9d8680e8dab6202f8e01c88619bc8c..05c19c27ee15c242c42f34aad4303065fb29d7b1 100644 (file)
@@ -6,6 +6,21 @@
 
 ;; This file is part of GNU Emacs.
 
+;; GNU Emacs is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 3, or (at your option)
+;; any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs; see the file COPYING.  If not, write to the
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
+
 ;;; Commentary:
 
 ;; Maildir format is documented at <URL:http://cr.yp.to/proto/maildir.html>
    )
 ]
 
+;; For Emacs < 22.2.
+(eval-and-compile
+  (unless (fboundp 'declare-function) (defmacro declare-function (&rest r))))
+
 (eval-and-compile
   (require 'nnheader)
   (require 'gnus)
@@ -869,7 +888,9 @@ by nnmaildir-request-article.")
                        pgname (nnmaildir--pgname nnmaildir--cur-server pgname)
                        group (symbol-value group)
                        ro (nnmaildir--param pgname 'read-only))
-                 (insert (nnmaildir--grp-name group) " ")
+                 (insert (gnus-replace-in-string
+                          (nnmaildir--grp-name group) " " "\\ " t)
+                         " ")
                   (princ (nnmaildir--group-maxnum nnmaildir--cur-server group)
                         nntp-server-buffer)
                  (insert " ")
@@ -896,14 +917,17 @@ by nnmaildir-request-article.")
          (insert " ")
          (princ (nnmaildir--group-maxnum nnmaildir--cur-server group)
                 nntp-server-buffer)
-         (insert " " gname "\n")))))
+         (insert " "
+                 (gnus-replace-in-string gname " " "\\ " t)
+                 "\n")))))
   'group)
 
 (defun nnmaildir-request-update-info (gname info &optional server)
   (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)
@@ -951,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))
@@ -984,7 +1009,7 @@ by nnmaildir-request-article.")
        (insert " ")
        (princ (nnmaildir--group-maxnum nnmaildir--cur-server group)
               nntp-server-buffer)
-       (insert " " gname "\n")
+       (insert " " (gnus-replace-in-string gname " " "\\ " t) "\n")
        t))))
 
 (defun nnmaildir-request-create-group (gname &optional server args)
@@ -1146,7 +1171,7 @@ by nnmaildir-request-article.")
              (insert "\t" (nnmaildir--nov-get-beg nov) "\t"
                      (nnmaildir--art-msgid article) "\t"
                      (nnmaildir--nov-get-mid nov) "\tXref: nnmaildir "
-                     gname ":")
+                     (gnus-replace-in-string gname " " "\\ " t) ":")
              (princ num nntp-server-buffer)
              (insert "\t" (nnmaildir--nov-get-end nov) "\n"))))
     (catch 'return
@@ -1418,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))