* message.el (message-mode-map): Keybinding for `gnus-delay-article'.
authorKai Grossjohann <kgrossjo@eu.uu.net>
Sat, 29 Sep 2001 19:25:32 +0000 (19:25 +0000)
committerKai Grossjohann <kgrossjo@eu.uu.net>
Sat, 29 Sep 2001 19:25:32 +0000 (19:25 +0000)
(message-mode-menu): Menu item for same.

* gnus-group.el (gnus-group-make-menu-bar): Menu item for sending
delayed articles.

* gnus-delay.el (gnus-delay-send-drafts): Do nothing if
nndraft:delayed does not exist.
(gnus-delay-initialize): Don't set up keymap, that's done from
message.el now.
(gnus-delay, gnus-delay-group, gnus-delay-header)
(gnus-delay-default-delay, gnus-delay-default-hour): Customize.

lisp/ChangeLog
lisp/gnus-delay.el
lisp/gnus-group.el
lisp/message.el

index c568b0b..002d772 100644 (file)
@@ -1,3 +1,18 @@
+2001-09-29  Kai Gro\e,A_\e(Bjohann  <Kai.Grossjohann@CS.Uni-Dortmund.DE>
+
+       * message.el (message-mode-map): Keybinding for `gnus-delay-article'.
+       (message-mode-menu): Menu item for same.
+
+       * gnus-group.el (gnus-group-make-menu-bar): Menu item for sending
+       delayed articles.
+
+       * gnus-delay.el (gnus-delay-send-drafts): Do nothing if
+       nndraft:delayed does not exist.
+       (gnus-delay-initialize): Don't set up keymap, that's done from
+       message.el now.
+       (gnus-delay, gnus-delay-group, gnus-delay-header) 
+       (gnus-delay-default-delay, gnus-delay-default-hour): Customize.
+
 2001-09-29  Simon Josefsson  <jas@extundo.com>
 
        * mm-util.el (mm-mime-mule-charset-alist): Encode mule-utf-8 as
index 8232b9a..449f9cb 100644 (file)
 
 ;; Provide delayed posting of articles.
 
+;;; Todo:
+
+;; * `gnus-delay-send-drafts' barfs when group does not exist.
+;; * Integrate gnus-delay.el into the rest of Gnus automatically.  How
+;;   should this be done?  Basically, we need to do what
+;;   `gnus-delay-initialize' does.  But in which files?
+
 ;;; Code:
 
 (require 'nndraft)
 (require 'gnus-draft)
 
-(defvar gnus-delay-group "delayed"
-  "Group name for storing delayed articles.")
-
-(defvar gnus-delay-header "X-Gnus-Delayed"
-  "Header name for storing info about delayed articles.")
-
-(defvar gnus-delay-default-delay "3d"
-  "*Default length of delay.")
-
-(defvar gnus-delay-default-hour 8
-  "*If deadline is given as date, then assume this time of day.")
+;;;###autoload
+(defgroup gnus-delay nil
+  "Arrange for sending postings later."
+  :group 'gnus)
+
+(defcustom gnus-delay-group "delayed"
+  "Group name for storing delayed articles."
+  :type 'string
+  :group 'gnus-delay)
+
+(defcustom gnus-delay-header "X-Gnus-Delayed"
+  "Header name for storing info about delayed articles."
+  :type 'string
+  :group 'gnus-delay)
+
+(defcustom gnus-delay-default-delay "3d"
+  "*Default length of delay."
+  :type 'string
+  :group 'gnus-delay)
+
+(defcustom gnus-delay-default-hour 8
+  "*If deadline is given as date, then assume this time of day."
+  :type 'integer
+  :group 'gnus-delay)
 
+;;;###autoload
 (defun gnus-delay-article (delay)
   "Delay this article by some time.
 DELAY is a string, giving the length of the time.  Possible values are:
@@ -116,6 +137,7 @@ DELAY is a string, giving the length of the time.  Possible values are:
   (kill-buffer (current-buffer))
   (message-do-actions message-postpone-actions))
 
+;;;###autoload
 (defun gnus-delay-send-drafts ()
   "Send all the delayed messages that are due now."
   (interactive)
@@ -123,25 +145,27 @@ DELAY is a string, giving the length of the time.  Possible values are:
     (let* ((group (format "nndraft:%s" gnus-delay-group))
           articles
           article deadline)
-      (gnus-activate-group group)
-      (setq articles (nndraft-articles))
-      (while (setq article (pop articles))
-       (gnus-request-head article group)
-       (set-buffer nntp-server-buffer)
-       (goto-char (point-min))
-       (if (re-search-forward
-            (concat "^" (regexp-quote gnus-delay-header) ":\\s-+")
-            nil t)
-           (progn
-             (setq deadline (nnheader-header-value))
-             (setq deadline (apply 'encode-time (parse-time-string deadline)))
-             (setq deadline (time-since deadline))
-             (when (and (>= (nth 0 deadline) 0)
-                        (>= (nth 1 deadline) 0))
-               (message "Sending delayed article %d" article)
-               (gnus-draft-send article group)
-               (message "Sending delayed article %d...done" article)))
-         (message "Delay header missing for article %d" article))))))
+      (when (gnus-gethash group gnus-newsrc-hashtb)
+       (gnus-activate-group group)
+       (setq articles (nndraft-articles))
+       (while (setq article (pop articles))
+         (gnus-request-head article group)
+         (set-buffer nntp-server-buffer)
+         (goto-char (point-min))
+         (if (re-search-forward
+              (concat "^" (regexp-quote gnus-delay-header) ":\\s-+")
+              nil t)
+             (progn
+               (setq deadline (nnheader-header-value))
+               (setq deadline (apply 'encode-time
+                                     (parse-time-string deadline)))
+               (setq deadline (time-since deadline))
+               (when (and (>= (nth 0 deadline) 0)
+                          (>= (nth 1 deadline) 0))
+                 (message "Sending delayed article %d" article)
+                 (gnus-draft-send article group)
+                 (message "Sending delayed article %d...done" article)))
+           (message "Delay header missing for article %d" article)))))))
 
 ;;;###autoload
 (defun gnus-delay-initialize (&optional no-keymap no-check)
@@ -149,11 +173,8 @@ DELAY is a string, giving the length of the time.  Possible values are:
 This sets up a key binding in `message-mode' to delay a message.
 This tells Gnus to look for delayed messages after getting new news.
 
-Key binding is skipped if optional arg NO-KEYMAP is non-nil.
+The optional arg NO-KEYMAP is ignored.
 Checking delayed messages is skipped if optional arg NO-CHECK is non-nil."
-  (unless no-keymap
-    (require 'message)
-    (define-key message-mode-map "\C-c\n" 'gnus-delay-article))
   (unless no-check
     (add-hook 'gnus-get-new-news-hook 'gnus-delay-send-drafts)))
 
index c3264be..d2f9403 100644 (file)
@@ -863,6 +863,10 @@ simple manner.")
        ,@(if (featurep 'xemacs) '(t)
            '(:help "Get newly arrived articles"))
        ]
+       ["Send delayed articles" gnus-delay-send-drafts
+       ,@(if (featurep 'xemacs) '(t)
+           '(:help "Send all articles that are scheduled to be sent now"))
+       ]
        ["Activate all groups" gnus-activate-all-groups t]
        ["Restart Gnus" gnus-group-restart t]
        ["Read init file" gnus-group-read-init-file t]
index 01abb3e..53055bf 100644 (file)
@@ -1487,6 +1487,7 @@ Point is left at the beginning of the narrowed-to region."
   (define-key message-mode-map "\C-c\C-s" 'message-send)
   (define-key message-mode-map "\C-c\C-k" 'message-kill-buffer)
   (define-key message-mode-map "\C-c\C-d" 'message-dont-send)
+  (define-key message-mode-map "\C-c\n" 'gnus-delay-article)
 
   (define-key message-mode-map "\C-c\C-e" 'message-elide-region)
   (define-key message-mode-map "\C-c\C-v" 'message-delete-not-region)
@@ -1523,6 +1524,9 @@ Point is left at the beginning of the narrowed-to region."
     ["Postpone Message" message-dont-send
      ,@(if (featurep 'xemacs) '(t)
         '(:help "File this draft message and exit"))]
+    ["Send at Specific Time" gnus-delay-article
+     ,@(if (featurep 'xemacs) '(t)
+        '(:help "Ask, then arrange to send message at that time"))]
     ["Kill Message" message-kill-buffer
      ,@(if (featurep 'xemacs) '(t)
         '(:help "Delete this message without sending"))]))