* lpath.el: Fbind string-as-multibyte for XEmacs.
[gnus] / lisp / gnus-diary.el
index 98ef4e0..f49f5b4 100644 (file)
@@ -1,30 +1,29 @@
-;;; gnus-diary.el --- Wrapper around the NNDiary Gnus backend
+;;; gnus-diary.el --- Wrapper around the NNDiary Gnus back end
 
-;; Copyright (C) 1999-2001 Didier Verna.
-
-;; PRCS: $Id: gnus-diary.el 1.17 Wed, 12 Sep 2001 15:54:36 +0200 didier $
+;; Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+;; Copyright (C) 1999, 2000, 2001 Didier Verna.
 
 ;; Author:        Didier Verna <didier@xemacs.org>
 ;; Maintainer:    Didier Verna <didier@xemacs.org>
-;; Created:       Tue Jul 20 10:42:55 1999 under XEmacs 21.2 (beta 18)
-;; Last Revision: Wed Sep 12 12:31:09 2001
+;; Created:       Tue Jul 20 10:42:55 1999
 ;; 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
-;; 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.
+;; 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,
-;; 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.
+;; 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 this program; if not, write to the Free Software
-;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+;; MA 02110-1301, USA.
 
 
 ;;; Commentary:
 ;; Description:
 ;; ===========
 
-;; Gnus-Diary is a wrapper around the NNDiary Gnus backend.  It is here to
-;; make your nndiary-user life easier in different ways.  So, you don't have
-;; to use it if you don't want to.  But, really, you should.
-
-;; Gnus-Diary offers the following features on top of the NNDiary backend:
-
-;;  - A nice summary line format:
-;;    Displaying diary messages in standard summary line format (usually
-;;    something like "<From Joe>: <Subject>") is pretty useless.  Most of the
-;;    time, you're the one who wrote the message, and you mostly want to see
-;;    the event's date.  Gnus-Diary offers you a nice summary line format
-;;    which will do this.  By default, a summary line will appear like this:
-;;
-;;     <Event Date>: <Subject> <Remaining time>
-;;
-;;   for example, here's how Joe's birthday is displayed in my
-;;   "nndiary:birhdays" summary buffer (the message is expirable, but will
-;;   never be deleted, as it specifies a regular event):
-;;
-;;   E  Sat, Sep 22 01, 12:00: Joe's birthday (in 6 months, 1 week)
-
-;;  - More article sorting functions:
-;;    Gnus-Diary adds a new sorting function called
-;;    `gnus-summary-sort-by-schedule'.  This function lets you organize your
-;;    diary summary buffers from the closest event to the farthest one.
-
-;;  - Automatic generation of diary group parameters:
-;;    When you create a new diary group, or visit one, Gnus-Diary checks your
-;;    group parameters, and if needed, sets the summary line format to the
-;;    diary-specific value, adds the diary-specific sorting functions, and
-;;    also adds the different `X-Diary-*' headers to the group's
-;;    posting-style.  It is then easier to send a diary message, because if
-;;    you use `C-u a' or `C-u m' on a diary group to prepare a message, these
-;;    headers will be inserted automatically (but not filled with proper
-;;    values yet).
-
-;;  - An interactive mail-to-diary convertion function:
-;;    The function `gnus-diary-check-message' ensures that the current message
-;;    contains all the required diary headers, and prompts you for values /
-;;    correction if needed.  This function is hooked in the nndiary backend so
-;;    that moving an article to an nndiary group will trigger it
-;;    automatically.  It is also bound to `C-c D c' in message-mode and
-;;    article-edit-mode in order to ease the process of converting a usual
-;;    mail to a diary one.  This function takes a prefix argument which will
-;;    force prompting of all diary headers, regardless of their
-;;    presence/validity.  That way, you can very easily reschedule a diary
-;;    message for instance.
-
-
-;; Usage:
-;; =====
-
-;; 0/ Don't use any `gnus-user-format-function-[d|D]'.  Gnus-Diary provides
-;;    both of these (sorry if you used them before).
-;; 1/ Add '(require 'gnus-diary) to your gnusrc file.
-;; 2/ Customize your gnus-diary options to suit your needs.
-
+;; gnus-diary is a utility toolkit used on top of the nndiary back end. It is
+;; now fully documented in the Gnus manual.
 
 
 ;; Bugs / Todo:
 (require 'gnus-art)
 
 (defgroup gnus-diary nil
-  "Utilities on top of the nndiary backend for Gnus.")
+  "Utilities on top of the nndiary back end for Gnus."
+  :version "22.1"
+  :group 'gnus)
 
 (defcustom gnus-diary-summary-line-format "%U%R%z %uD: %(%s%) (%ud)\n"
   "*Summary line format for nndiary groups."
@@ -135,7 +81,18 @@ There are currently two built-in format functions:
   :group 'gnus-diary)
 
 (defconst gnus-diary-version nndiary-version
-  "Current Diary backend version.")
+  "Current Diary back end version.")
+
+
+;; Compatibility functions ==================================================
+
+(eval-and-compile
+  (if (fboundp 'kill-entire-line)
+      (defalias 'gnus-diary-kill-entire-line 'kill-entire-line)
+    (defun gnus-diary-kill-entire-line ()
+      (beginning-of-line)
+      (let ((kill-whole-line t))
+       (kill-line)))))
 
 
 ;; Summary line format ======================================================
@@ -144,7 +101,7 @@ There are currently two built-in format functions:
   (if (null delay)
       "maintenant!"
     ;; Keep only a precision of two degrees
-    (and (> (length delay) 1) (setf (nthcdr 2 delay) nil))
+    (and (> (length delay) 1) (setcdr (cdr delay) nil))
     (concat (if past "il y a " "dans ")
            (let ((str "")
                  del)
@@ -174,7 +131,7 @@ There are currently two built-in format functions:
   (if (null delay)
       "now!"
     ;; Keep only a precision of two degrees
-    (and (> (length delay) 1) (setf (nthcdr 2 delay) nil))
+    (and (> (length delay) 1) (setcdr (cdr delay) nil))
     (concat (unless past "in ")
            (let ((str "")
                  del)
@@ -195,7 +152,7 @@ There are currently two built-in format functions:
      (let ((head (cdr (assoc (intern (format "X-Diary-%s" (car elt)))
                             headers))))
        (when head
-        (nndiary-parse-schedule-value head (cadr elt) (caddr elt)))))
+        (nndiary-parse-schedule-value head (cadr elt) (car (cddr elt))))))
    nndiary-headers))
 
 ;; #### NOTE: Gnus sometimes gives me a HEADER not corresponding to any
@@ -256,7 +213,7 @@ There are currently two built-in format functions:
         (o1 (nndiary-next-occurence s1 now))
         (o2 (nndiary-next-occurence s2 now)))
     (if (and (= (car o1) (car o2)) (= (cadr o1) (cadr o2)))
-        (< (mail-header-number h1) (mail-header-number h2))
+       (< (mail-header-number h1) (mail-header-number h2))
       (time-less-p o1 o2))))
 
 
@@ -270,6 +227,7 @@ Optional prefix (or REVERSE argument) means sort in reverse order."
   (interactive "P")
   (gnus-summary-sort 'schedule reverse))
 
+(defvar gnus-summary-misc-menu) ;; Avoid byte compiler warning.
 (add-hook 'gnus-summary-menu-hook
          (lambda ()
            (easy-menu-add-item gnus-summary-misc-menu
@@ -319,7 +277,7 @@ Optional prefix (or REVERSE argument) means sort in reverse order."
     ))
 
 ;; Called when a group is subscribed. This is needed because groups created
-;; because of mail splitting are *not* created with the backend function.
+;; because of mail splitting are *not* created with the back end function.
 ;; Thus, `nndiary-request-create-group-hooks' is inoperative.
 (defun gnus-diary-maybe-update-group-parameters (group)
   (when (eq (car (gnus-find-method-for-group group)) 'nndiary)
@@ -337,15 +295,6 @@ Optional prefix (or REVERSE argument) means sort in reverse order."
 
 ;; Diary Message Checking ===================================================
 
-(if (fboundp 'kill-entire-line)
-    (defun gnus-diary-kill-entire-line ()
-      (kill-entire-line))
-  (defun gnus-diary-kill-entire-line ()
-    (beginning-of-line)
-    (let ((kill-whole-line t))
-      (kill-line)))
-  )
-
 (defvar gnus-diary-header-value-history nil
   ;; History variable for header value prompting
   )
@@ -416,16 +365,14 @@ If ARG (or prefix) is non-nil, force prompting for all fields."
           (let ((prompt (concat (and invalid
                                      (prog1 "(current value invalid) "
                                        (beep)))
-                                header
-                                (and (not value) " (defaults to `*')")
-                                ": ")))
+                                header ": ")))
             (setq value
                   (if (listp (nth 1 head))
                       (completing-read prompt (cons '("*" nil) (nth 1 head))
                                        nil t value
-                                       gnus-diary-header-value-history "*")
+                                       gnus-diary-header-value-history)
                     (read-string prompt value
-                                 gnus-diary-header-value-history "*"))))
+                                 gnus-diary-header-value-history))))
           (setq ask nil)
           (setq invalid nil)
           (condition-case ()
@@ -448,7 +395,7 @@ If ARG (or prefix) is non-nil, force prompting for all fields."
 ;; The end ==================================================================
 
 (defun gnus-diary-version ()
-  "Current Diary backend version."
+  "Current Diary back end version."
   (interactive)
   (message "NNDiary version %s" nndiary-version))
 
@@ -458,4 +405,5 @@ If ARG (or prefix) is non-nil, force prompting for all fields."
 
 (provide 'gnus-diary)
 
+;;; arch-tag: 98467e70-337e-4ddc-b92d-45d403ff1b4b
 ;;; gnus-diary.el ends here