Revision: miles@gnu.org--gnu-2005/gnus--devo--0--patch-37
[gnus] / lisp / nndiary.el
index f94bfe3..3a35379 100644 (file)
@@ -1,23 +1,21 @@
 ;;; nndiary.el --- A diary backend for Gnus
 
-;; Copyright (C) 1999-2001 Didier Verna.
-
-;; PRCS: $Id: nndiary.el 1.26 Wed, 12 Sep 2001 15:23:27 +0200 didier $
+;; Copyright (C) 1999, 2000, 2001, 2003
+;;        Free Software Foundation, Inc.
 
 ;; Author:        Didier Verna <didier@xemacs.org>
 ;; Maintainer:    Didier Verna <didier@xemacs.org>
 ;; Created:       Fri Jul 16 18:55:42 1999
-;; Last Revision: Wed Aug  8 17:36:21 2001
 ;; Keywords:      calendar mail news
 
-;; This file is part of NNDiary.
+;; This file is part of GNU Emacs.
 
-;; NNDiary is free software; you can redistribute it and/or modify
+;; 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 2 of the License, or
 ;; (at your option) any later version.
 
-;; NNDiary is distributed in the hope that it will be useful,
+;; 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.
 
 ;; Compatibility Functions  =================================================
 
-(if (fboundp 'signal-error)
+(eval-and-compile
+  (if (fboundp 'signal-error)
+      (defun nndiary-error (&rest args)
+       (apply #'signal-error 'nndiary args))
     (defun nndiary-error (&rest args)
-      (apply #'signal-error 'nndiary args))
-  (defun nndiary-error (&rest args)
-    (apply #'error args)))
+      (apply #'error args))))
 
 
 ;; Backend behavior customization ===========================================
 
 (defgroup nndiary nil
   "The Gnus Diary backend."
+  :version "22.1"
   :group 'gnus-diary)
 
 (defcustom nndiary-mail-sources
@@ -365,25 +365,7 @@ all.  This may very well take some time.")
 
 \f
 
-;; $Format: "(defconst nndiary-prcs-major-version \"$ProjectMajorVersion$\")"$
-(defconst nndiary-prcs-major-version "branch-0-2")
-;; $Format: "(defconst nndiary-prcs-minor-version \"$ProjectMinorVersion$\")"$
-(defconst nndiary-prcs-minor-version "13")
-(defconst nndiary-version
-  (let ((level nndiary-prcs-minor-version)
-       major minor status)
-    (string-match "\\(branch\\|version\\)-\\([0-9]+\\)-\\([0-9]+\\)"
-                 nndiary-prcs-major-version)
-    (setq major (match-string 2 nndiary-prcs-major-version)
-         minor (match-string 3 nndiary-prcs-major-version)
-         status (match-string 1 nndiary-prcs-major-version))
-    (cond ((string= status "version")
-          (setq level (int-to-string (1- (string-to-int level))))
-          (if (eq level 0)
-              (concat major "." minor)
-            (concat major "." minor "." level)))
-         ((string= status "branch")
-          (concat major "." minor "-b" level))))
+(defconst nndiary-version "0.2-b14"
   "Current Diary backend version.")
 
 (defun nndiary-version ()
@@ -391,7 +373,6 @@ all.  This may very well take some time.")
   (interactive)
   (message "NNDiary version %s" nndiary-version))
 
-
 (defvoo nndiary-nov-file-name ".overview")
 
 (defvoo nndiary-current-directory nil)
@@ -499,6 +480,19 @@ all.  This may very well take some time.")
   ;; the (relative) number of seconds ahead GMT.
   )
 
+(defsubst nndiary-schedule ()
+  (let (head)
+    (condition-case arg
+       (mapcar
+        (lambda (elt)
+          (setq head (nth 0 elt))
+          (nndiary-parse-schedule (nth 0 elt) (nth 1 elt) (nth 2 elt)))
+        nndiary-headers)
+      (t
+       (nnheader-report 'nndiary "X-Diary-%s header parse error: %s."
+                       head (cdr arg))
+       nil))
+    ))
 
 ;;; Interface functions =====================================================
 
@@ -711,7 +705,8 @@ all.  This may very well take some time.")
              (with-temp-buffer
                (nndiary-request-article number group server (current-buffer))
                (let ((nndiary-current-directory nil))
-                 (nnmail-expiry-target-group nnmail-expiry-target group))))
+                 (nnmail-expiry-target-group nnmail-expiry-target group)))
+             (nndiary-possibly-change-directory group server))
            (nnheader-message 5 "Deleting article %s in %s" number group)
            (condition-case ()
                (funcall nnmail-delete-file-function article)
@@ -765,7 +760,9 @@ all.  This may very well take some time.")
   (when (nndiary-schedule)
     (let (result)
       (when nnmail-cache-accepted-message-ids
-       (nnmail-cache-insert (nnmail-fetch-field "message-id")))
+       (nnmail-cache-insert (nnmail-fetch-field "message-id")
+                            group
+                            (nnmail-fetch-field "subject")))
       (if (stringp group)
          (and
           (nnmail-activate 'nndiary)
@@ -996,7 +993,7 @@ all.  This may very well take some time.")
                  (search-forward id nil t)) ; We find the ID.
        ;; And the id is in the fourth field.
        (if (not (and (search-backward "\t" nil t 4)
-                     (not (search-backward"\t" (gnus-point-at-bol) t))))
+                     (not (search-backward"\t" (point-at-bol) t))))
            (forward-line 1)
          (beginning-of-line)
          (setq found t)
@@ -1129,13 +1126,7 @@ all.  This may very well take some time.")
        (narrow-to-region
         (goto-char (point-min))
         (if (search-forward "\n\n" nil t) (1- (point)) (point-max))))
-      ;; Fold continuation lines.
-      (goto-char (point-min))
-      (while (re-search-forward "\\(\r?\n[ \t]+\\)+" nil t)
-       (replace-match " " t t))
-      ;; Remove any tabs; they are too confusing.
-      (subst-char-in-region (point-min) (point-max) ?\t ? )
-      (let ((headers (nnheader-parse-head t)))
+      (let ((headers (nnheader-parse-naked-head)))
        (mail-header-set-chars headers chars)
        (mail-header-set-number headers number)
        headers))))
@@ -1223,9 +1214,7 @@ all.  This may very well take some time.")
     (push (list group
                (cons (or (caar files) (1+ last))
                      (max last
-                          (or (let ((f files))
-                                (while (cdr f) (setq f (cdr f)))
-                                (caar f))
+                          (or (caar (last files))
                               0))))
          nndiary-group-alist)))
 
@@ -1357,20 +1346,6 @@ all.  This may very well take some time.")
       (nndiary-parse-schedule-value (match-string 1) min-or-values max))
     ))
 
-(defsubst nndiary-schedule ()
-  (let (head)
-    (condition-case arg
-       (mapcar
-        (lambda (elt)
-          (setq head (nth 0 elt))
-          (nndiary-parse-schedule (nth 0 elt) (nth 1 elt) (nth 2 elt)))
-        nndiary-headers)
-      (t
-       (nnheader-report 'nndiary "X-Diary-%s header parse error: %s."
-                       head (cdr arg))
-       nil))
-    ))
-
 (defun nndiary-max (spec)
   ;; Returns the max of specification SPEC, or nil for permanent schedules.
   (unless (null spec)
@@ -1436,7 +1411,7 @@ all.  This may very well take some time.")
                      (nth 6 date-elts))))
         reminder res)
     ;; remove the DOW and DST entries
-    (setf (nthcdr 6 date-elts) (nthcdr 8 date-elts))
+    (setcdr (nthcdr 5 date-elts) (nthcdr 8 date-elts))
     (while (setq reminder (pop reminders))
       (push
        (cond ((eq (cdr reminder) 'minute)
@@ -1732,4 +1707,5 @@ all.  This may very well take some time.")
 (provide 'nndiary)
 
 
+;;; arch-tag: 9c542b95-92e7-4ace-a038-330ab296e203
 ;;; nndiary.el ends here