- (gnus-activate-group "nndraft:queue")
- (save-excursion
- (let ((articles (nndraft-articles))
- (unsendable (gnus-uncompress-range
- (cdr (assq 'unsend
- (gnus-info-marks
- (gnus-get-info "nndraft:queue"))))))
- article)
- (while (setq article (pop articles))
- (unless (memq article unsendable)
- (gnus-draft-send article))))))
-
-;;; Utility functions
-
-;;;!!!If this is byte-compiled, it fails miserably.
-;;;!!!I have no idea why.
-
-(progn
-(defun gnus-draft-setup (narticle group)
- (gnus-setup-message 'forward
- (let ((article narticle))
- (message-mail)
- (erase-buffer)
- (if (not (gnus-request-restore-buffer article group))
- (error "Couldn't restore the article")
- ;; Insert the separator.
- (goto-char (point-min))
- (search-forward "\n\n")
- (forward-char -1)
- (insert mail-header-separator)
- (forward-line 1)
- (message-set-auto-save-file-name))))))
+ (when (or gnus-plugged
+ (not gnus-agent-prompt-send-queue)
+ (gnus-y-or-n-p "Gnus is unplugged; really send queue? "))
+ (gnus-activate-group "nndraft:queue")
+ (save-excursion
+ (let* ((articles (nndraft-articles))
+ (unsendable (gnus-uncompress-range
+ (cdr (assq 'unsend
+ (gnus-info-marks
+ (gnus-get-info "nndraft:queue"))))))
+ (gnus-posting-styles nil)
+ message-send-mail-partially-limit
+ (total (length articles))
+ article)
+ (while (setq article (pop articles))
+ (unless (memq article unsendable)
+ (let ((message-sending-message
+ (format "Sending message %d of %d..."
+ (- total (length articles)) total)))
+ (gnus-draft-send article))))))
+ (gnus-group-refresh-group "nndraft:queue")))
+
+;;;###autoload
+(defun gnus-draft-reminder ()
+ "Reminder user if there are unsent drafts."
+ (interactive)
+ (if (gnus-alive-p)
+ (let (active)
+ (catch 'continue
+ (dolist (group '("nndraft:drafts" "nndraft:queue"))
+ (setq active (gnus-activate-group group))
+ (if (and active (>= (cdr active) (car active)))
+ (if (y-or-n-p "There are unsent drafts. Confirm to exit? ")
+ (throw 'continue t)
+ (error "Stop!"))))))))
+
+(defcustom gnus-draft-setup-hook nil
+ "Hook run after setting up a draft buffer."
+ :group 'gnus-message
+ :version "23.1" ;; No Gnus
+ :type 'hook)
+
+
+(defun gnus-draft-setup (narticle group &optional restore dont-pop)
+ "Setup a mail draft buffer.
+If DONT-POP is nil, display the buffer after setting it up."
+ (let (ga)
+ (gnus-setup-message 'forward
+ (let ((article narticle))
+ (message-mail nil nil nil nil
+ (if dont-pop
+ (lambda (buf) (set-buffer (get-buffer-create buf)))))
+ (let ((inhibit-read-only t))
+ (erase-buffer))
+ (if (not (gnus-request-restore-buffer article group))
+ (error "Couldn't restore the article")
+ (when (and restore
+ (equal group "nndraft:queue"))
+ (mime-to-mml))
+ ;; Insert the separator.
+ (goto-char (point-min))
+ (search-forward "\n\n")
+ (forward-char -1)
+ (save-restriction
+ (narrow-to-region (point-min) (point))
+ (setq ga
+ (message-fetch-field gnus-draft-meta-information-header)))
+ (insert mail-header-separator)
+ (forward-line 1)
+ (message-set-auto-save-file-name))))
+ (gnus-backlog-remove-article group narticle)
+ (when (and ga
+ (ignore-errors (setq ga (car (read-from-string ga)))))
+ (setq gnus-newsgroup-name
+ (if (equal (car ga) "") nil (car ga)))
+ (gnus-configure-posting-styles)
+ (setq gnus-message-group-art (cons gnus-newsgroup-name (cadr ga)))
+ (setq message-post-method
+ `(lambda (arg)
+ (gnus-post-method arg ,(car ga))))
+ (unless (equal (cadr ga) "")
+ (dolist (article (cdr ga))
+ (message-add-action
+ `(progn
+ (gnus-add-mark ,(car ga) 'replied ,article)
+ (gnus-request-set-mark ,(car ga) (list (list (list ,article)
+ 'add '(reply)))))
+ 'send))))
+ (run-hooks 'gnus-draft-setup-hook)))