Remove nnml-retrieve-groups that is unnecessary and somewhat problematic
[gnus] / lisp / gnus-diary.el
index 4dc1050..0f5c613 100644 (file)
@@ -1,7 +1,6 @@
 ;;; gnus-diary.el --- Wrapper around the NNDiary Gnus back end
 
-;; Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
-;; Copyright (C) 1999, 2000, 2001 Didier Verna.
+;; Copyright (C) 1999-2015 Free Software Foundation, Inc.
 
 ;; Author:        Didier Verna <didier@xemacs.org>
 ;; Maintainer:    Didier Verna <didier@xemacs.org>
 
 ;; 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 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 3 of the License, 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.
+;; 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., 51 Franklin Street, Fifth Floor, Boston,
-;; MA 02110-1301, USA.
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
 
 
 ;;; Commentary:
   :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,
@@ -160,7 +157,7 @@ There are currently two built-in format functions:
 ;; I just ignore it.
 ;;;###autoload
 (defun gnus-user-format-function-d (header)
-  ;; Returns an aproximative delay string for the next occurence of this
+  ;; Return an approximate delay string for the next occurrence of this
   ;; message. The delay is given only in the first non zero unit.
   ;; Code partly stolen from article-make-date-line
   (let* ((extras (mail-header-extra header))
@@ -197,7 +194,7 @@ There are currently two built-in format functions:
 ;; I just ignore it.
 ;;;###autoload
 (defun gnus-user-format-function-D (header)
-  ;; Returns a formatted time string for the next occurence of this message.
+  ;; Returns a formatted time string for the next occurrence of this message.
   (let* ((extras (mail-header-extra header))
         (sched (gnus-diary-header-schedule extras))
         (occur (nndiary-next-occurence sched (current-time))))
@@ -224,7 +221,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))
@@ -251,47 +248,47 @@ 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 back end function.
-;; Thus, `nndiary-request-create-group-hooks' is inoperative.
+;; Thus, `nndiary-request-create-group-functions' is inoperative.
 (defun gnus-diary-maybe-update-group-parameters (group)
   (when (eq (car (gnus-find-method-for-group group)) 'nndiary)
     (gnus-diary-update-group-parameters group)))
 
-(add-hook 'nndiary-request-create-group-hooks
+(add-hook 'nndiary-request-create-group-functions
          'gnus-diary-update-group-parameters)
-;; Now that we have `gnus-subscribe-newsgroup-hooks', this is not needed
+;; Now that we have `gnus-subscribe-newsgroup-functions', this is not needed
 ;; anymore. Maybe I should remove this completely.
-(add-hook 'nndiary-request-update-info-hooks
+(add-hook 'nndiary-request-update-info-functions
          'gnus-diary-update-group-parameters)
-(add-hook 'gnus-subscribe-newsgroup-hooks
+(add-hook 'gnus-subscribe-newsgroup-functions
          'gnus-diary-maybe-update-group-parameters)
 
 
@@ -353,7 +350,7 @@ If ARG (or prefix) is non-nil, force prompting for all fields."
             (condition-case ()
                 (nndiary-parse-schedule-value value
                                               (nth 1 head) (nth 2 head))
-              (t
+              (error
                (setq invalid t)))
             ;; #### NOTE: this (along with the `gnus-diary-add-header'
             ;; function) could be rewritten in a better way, in particular
@@ -370,28 +367,28 @@ If ARG (or prefix) is non-nil, force prompting for all fields."
                                 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-completing-read prompt (cons "*" (mapcar 'car (nth 1 head)))
+                                             t value
+                                             '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 ()
               (nndiary-parse-schedule-value value
                                             (nth 1 head) (nth 2 head))
-            (t
+            (error
              (setq invalid t))))
         (gnus-diary-add-header (concat header ": " value))
         ))
      nndiary-headers)
     ))
 
-(add-hook 'nndiary-request-accept-article-hooks
+(add-hook 'nndiary-request-accept-article-functions
          (lambda () (gnus-diary-check-message nil)))
 
-(define-key message-mode-map "\C-cDc" 'gnus-diary-check-message)
-(define-key gnus-article-edit-mode-map "\C-cDc" 'gnus-diary-check-message)
+(define-key message-mode-map "\C-c\C-fd" 'gnus-diary-check-message)
+(define-key gnus-article-edit-mode-map "\C-c\C-fd" 'gnus-diary-check-message)
 
 
 ;; The end ==================================================================
@@ -401,11 +398,6 @@ If ARG (or prefix) is non-nil, force prompting for all fields."
   (interactive)
   (message "NNDiary version %s" nndiary-version))
 
-(define-key message-mode-map "\C-cDv" 'gnus-diary-version)
-(define-key gnus-article-edit-mode-map "\C-cDv" 'gnus-diary-version)
-
-
 (provide 'gnus-diary)
 
-;;; arch-tag: 98467e70-337e-4ddc-b92d-45d403ff1b4b
 ;;; gnus-diary.el ends here