From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.user/15740 Path: news.gmane.org!not-for-mail From: Kevin Brubeck Unhammer Newsgroups: gmane.emacs.gnus.user Subject: Re: delayed sending of mail Date: Thu, 23 Aug 2012 11:04:08 +0200 Message-ID: <87y5l6ughj.fsf@fsfe.org> References: <87harvnkj1.fsf@fsfe.org> <87fw7e4p7e.fsf@topper.koldfront.dk> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============3435900012466453047==" X-Trace: ger.gmane.org 1345712682 22606 80.91.229.3 (23 Aug 2012 09:04:42 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 23 Aug 2012 09:04:42 +0000 (UTC) To: info-gnus-english@gnu.org Original-X-From: info-gnus-english-bounces+gegu-info-gnus-english=m.gmane.org@gnu.org Thu Aug 23 11:04:43 2012 Return-path: Envelope-to: gegu-info-gnus-english@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1T4TLF-0003gk-FS for gegu-info-gnus-english@m.gmane.org; Thu, 23 Aug 2012 11:04:41 +0200 Original-Received: from localhost ([::1]:51236 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T4TLD-00022L-Lp for gegu-info-gnus-english@m.gmane.org; Thu, 23 Aug 2012 05:04:39 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:58771) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T4TL6-000221-Fl for info-gnus-english@gnu.org; Thu, 23 Aug 2012 05:04:38 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T4TKz-0005nE-MA for info-gnus-english@gnu.org; Thu, 23 Aug 2012 05:04:32 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:41473) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T4TKz-0005n3-Bi for info-gnus-english@gnu.org; Thu, 23 Aug 2012 05:04:25 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1T4TKx-0003IT-JS for info-gnus-english@gnu.org; Thu, 23 Aug 2012 11:04:23 +0200 Original-Received: from cde31bf51.dhcp.as2116.net ([81.191.49.222]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 23 Aug 2012 11:04:23 +0200 Original-Received: from unhammer by cde31bf51.dhcp.as2116.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 23 Aug 2012 11:04:23 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 139 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: cde31bf51.dhcp.as2116.net User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1 (gnu/linux) Cancel-Lock: sha1:GvSdYSxG5lNgSekbdMbLUAd6XgY= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: info-gnus-english@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Announcements and discussions for GNUS, the GNU Emacs Usenet newsreader \(in English\)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: info-gnus-english-bounces+gegu-info-gnus-english=m.gmane.org@gnu.org Original-Sender: info-gnus-english-bounces+gegu-info-gnus-english=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.gnus.user:15740 Archived-At: --===============3435900012466453047== Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable asjo@koldfront.dk (Adam Sj=C3=B8gren) writes: > On Wed, 22 Aug 2012 15:06:26 +0200, Kevin wrote: > >> someone on IRC asked about how to make a function that delays sending of >> email, so as to have a chance to edit/cancel within 2 minutes or so. > > When I want delayed sending of an email/article, instead of using C-c > C-c to send it, I go C-c C-j (which is bound to gnus-delay-article). > > Then I am prompted about how long to delay it, or when to send it. After > answering that, the email shows up in nndraft:delayed until the set > time, when it is sent. > > In my .gnus I have these things to make it work: > > ; Activate delayed messages: > (gnus-delay-initialize) > > ; Show X-Now-Playing and X-Gnus-Delayed header: > (setq gnus-visible-headers (concat gnus-visible-headers "\\|^X-Now-Pl= aying:\\|X-Gnus-Delayed:")) > > ; Remove date, so delayed messages (C-c C-j) don't get a date until > ; sent : > (setq message-draft-headers '(References From)) > > Only the first one is essential, I think. Oh, and the documentation of > gnus-delay-article says that delayed messages are sent after new news is > fetched, which means that these lines in my .gnus: > > ; Demon to fetch email every 5 minutes when Emacs has been idle for 5= minutes: > (gnus-demon-add-handler 'gnus-demon-scan-news 5 5) > (gnus-demon-init) > > probably are essential as well. (And sending is potentially ~5 minutes > off.) > > Maybe you can build upon gnus-delay-article if you want a fixed delay? Thanks, Adam and Reiner, I should've guessed it was solved already :) I prefer a shorter demon timeout for this purpose, but I don't need the full news scan, so I used (gnus-demon-add-handler 'gnus-delay-send-queue 1 nil) ; call every othe= r minute regardless of idleness (gnus-demon-init) And for the actual sending, in case anyone's interested: (defvar message-delayed-send-default-minutes 2 "Default delay in minutes before delayed-sending with `message-delaye= d-send-and-exit'") (defun message-delayed-send-and-exit () "Use `gnus-delay-article' to send after `message-delayed-send-default-minutes' minutes." (interactive) (message "Sending in %s minutes" message-delayed-send-default-minutes) (gnus-delay-article (format "%sm" message-delayed-send-default-minute= s))) (define-key message-mode-map (kbd "C-c C-c") 'message-delayed-send-and-= exit) And in case I exit gnus before it's sent, I added: (defun gnus-delay-send-queue-hurry () "As `gnus-delay-send-queue, but also send anything that is to be sent within `message-delayed-send-default-minutes minutes." (interactive) (save-excursion (let* ((group (format "nndraft:%s" gnus-delay-group)) (message-send-hook (copy-sequence message-send-hook)) articles article deadline) (when (gnus-group-entry group) (gnus-activate-group group) (add-hook 'message-send-hook (lambda () (message-remove-header gnus-delay-header))) (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))) ;; The difference: (setq deadline (time-subtract deadline (seconds-to-time (* 60 message-delayed-send-default-minutes)))) (setq deadline (time-since deadline)) (when (and (>=3D (nth 0 deadline) 0) (>=3D (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))))))) =20=20=20=20 (add-hook 'gnus-exit-gnus-hook 'gnus-delay-send-queue-hurry) (I guess another possibility would be to first go through nndraft and alter the header, then call `gnus-delay-send-queue', but most of that function consists of finding delayed articles anyway =E2=80=A6) =2D-=20 Kevin Brubeck Unhammer GPG: 0x766AC60C --=-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iQEcBAEBAgAGBQJQNfIIAAoJEHQmBt52asYMsAEH/2jBLAEFHdHc2L5vH06yjFI/ aftTpEMRVyQxftXuHdCItAzt4y83zPb3rmDIejnDvm4IBZsXxw5vHR+ON80DSVGd ItVR1LECh07S+i9+eZbvsrloT0Z1OgowCNC0W7i7FGby8Tum2V753va9pb1BImSL ONWfcTC53/Q4/g9XkUtHJA/Py5dggp+4igxN17M8LPlx4k2OOKmvwjsC5xE9ojqG 6Rf2TLqgfi1ozucRAFwFvAV4iByM62ctC9dqPce/ikr0sMC3jouHdJZKj2JlMUEj Tkivr5xsXqUlI0PxpUUOZqmWAxl76RvORavhJ4R56cQI1SAK4zoakJslzrQhff8= =uY9X -----END PGP SIGNATURE----- --=-=-=-- --===============3435900012466453047== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ info-gnus-english mailing list info-gnus-english@gnu.org https://lists.gnu.org/mailman/listinfo/info-gnus-english --===============3435900012466453047==--