X-Git-Url: http://cgit.sxemacs.org/?a=blobdiff_plain;f=lisp%2Fgnus-diary.el;h=655d652ba27a626f911a5068f58738adb989104a;hb=cd75bce75b753994058f9a74a476d9dfaf11e264;hp=9425ef3b26086e0f319c7e0ddd3e696b2fdcb02b;hpb=125d88b46ad2efa065f06d5dac37a245b488985a;p=gnus diff --git a/lisp/gnus-diary.el b/lisp/gnus-diary.el index 9425ef3b2..655d652ba 100644 --- a/lisp/gnus-diary.el +++ b/lisp/gnus-diary.el @@ -1,7 +1,7 @@ -;;; gnus-diary.el --- Wrapper around the NNDiary Gnus backend +;;; gnus-diary.el --- Wrapper around the NNDiary Gnus back end -;; Copyright (c) 2001, 2002, 2003 Free Software Foundation, Inc. -;; Copyright (C) 1999, 2000, 2001 Didier Verna. +;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, +;; 2006, 2007 Free Software Foundation, Inc. ;; Author: Didier Verna ;; Maintainer: Didier Verna @@ -12,8 +12,8 @@ ;; 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. +;; 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 @@ -21,8 +21,9 @@ ;; 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. +;; 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: @@ -32,63 +33,8 @@ ;; 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 ": ") 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: -;; -;; : -;; -;; 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: @@ -102,7 +48,9 @@ (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." @@ -111,14 +59,14 @@ :group 'gnus-summary-format) (defcustom gnus-diary-time-format "%a, %b %e %y, %H:%M" - "*Time format to display appointements in nndiary summary buffers. + "*Time format to display appointments in nndiary summary buffers. Please refer to `format-time-string' for information on possible values." :type 'string :group 'gnus-diary) (defcustom gnus-diary-delay-format-function 'gnus-diary-delay-format-english "*Function called to format a diary delay string. -It is passed two arguments. The first one is non nil if the delay is in +It is passed two arguments. The first one is non-nil if the delay is in the past. The second one is of the form ((NUM . UNIT) ...) where NUM is an integer and UNIT is one of 'year 'month 'week 'day 'hour or 'minute. It should return strings like \"In 2 months, 3 weeks\", \"3 hours, @@ -133,7 +81,7 @@ 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 ================================================== @@ -210,6 +158,7 @@ There are currently two built-in format functions: ;; #### NOTE: Gnus sometimes gives me a HEADER not corresponding to any ;; message, with all fields set to nil here. I don't know what it is for, and ;; I just ignore it. +;;;###autoload (defun gnus-user-format-function-d (header) ;; Returns an aproximative delay string for the next occurence of this ;; message. The delay is given only in the first non zero unit. @@ -246,6 +195,7 @@ There are currently two built-in format functions: ;; #### NOTE: Gnus sometimes gives me a HEADER not corresponding to any ;; message, with all fields set to nil here. I don't know what it is for, and ;; I just ignore it. +;;;###autoload (defun gnus-user-format-function-D (header) ;; Returns a formatted time string for the next occurence of this message. (let* ((extras (mail-header-extra header)) @@ -274,7 +224,7 @@ There are currently two built-in format functions: (gnus-thread-header h2))) (defun gnus-summary-sort-by-schedule (&optional reverse) - "Sort nndiary summary buffers by schedule of appointements. + "Sort nndiary summary buffers by schedule of appointments. Optional prefix (or REVERSE argument) means sort in reverse order." (interactive "P") (gnus-summary-sort 'schedule reverse)) @@ -301,35 +251,35 @@ Optional prefix (or REVERSE argument) means sort in reverse order." ;; - a nice summary line format ;; - NNDiary specific sorting by schedule functions ;; In general, try not to mess with what the user might have modified. - (let ((posting-style (gnus-group-get-parameter group 'posting-style t))) - ;; Posting style: - (mapcar (lambda (elt) - (let ((header (format "X-Diary-%s" (car elt)))) - (unless (assoc header posting-style) - (setq posting-style (append posting-style - `((,header "*"))))) - )) - nndiary-headers) - (gnus-group-set-parameter group 'posting-style posting-style) - ;; Summary line format: - (unless (gnus-group-get-parameter group 'gnus-summary-line-format t) - (gnus-group-set-parameter group 'gnus-summary-line-format - `(,gnus-diary-summary-line-format))) - ;; Sorting by schedule: - (unless (gnus-group-get-parameter group 'gnus-article-sort-functions) - (gnus-group-set-parameter group 'gnus-article-sort-functions - '((append gnus-article-sort-functions - (list - 'gnus-article-sort-by-schedule))))) - (unless (gnus-group-get-parameter group 'gnus-thread-sort-functions) - (gnus-group-set-parameter group 'gnus-thread-sort-functions - '((append gnus-thread-sort-functions - (list - 'gnus-thread-sort-by-schedule))))) - )) + + ;; Posting style: + (let ((posting-style (gnus-group-get-parameter group 'posting-style t)) + (headers nndiary-headers) + header) + (while headers + (setq header (format "X-Diary-%s" (caar headers)) + headers (cdr headers)) + (unless (assoc header posting-style) + (setq posting-style (append posting-style (list (list header "*")))))) + (gnus-group-set-parameter group 'posting-style posting-style)) + ;; Summary line format: + (unless (gnus-group-get-parameter group 'gnus-summary-line-format t) + (gnus-group-set-parameter group 'gnus-summary-line-format + `(,gnus-diary-summary-line-format))) + ;; Sorting by schedule: + (unless (gnus-group-get-parameter group 'gnus-article-sort-functions) + (gnus-group-set-parameter group 'gnus-article-sort-functions + '((append gnus-article-sort-functions + (list + 'gnus-article-sort-by-schedule))))) + (unless (gnus-group-get-parameter group 'gnus-thread-sort-functions) + (gnus-group-set-parameter group 'gnus-thread-sort-functions + '((append gnus-thread-sort-functions + (list + 'gnus-thread-sort-by-schedule)))))) ;; 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) @@ -447,7 +397,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))