Announcements and discussions for Gnus, the GNU Emacs Usenet newsreader
 help / color / mirror / Atom feed
From: Kevin Brubeck Unhammer <unhammer@fsfe.org>
To: info-gnus-english@gnu.org
Subject: delayed sending of mail
Date: Wed, 22 Aug 2012 15:06:26 +0200	[thread overview]
Message-ID: <87harvnkj1.fsf@fsfe.org> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 1400 bytes --]

Hi, 

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. I
came up with

  (defun message-wait-send-and-exit (&optional arg)
    "Bury the buffer and wait a bit, then send message like
  `message-send-and-exit'."
    (interactive "P")
    (let ((timeout "2 minutes")
          (buf (current-buffer)))
      (message "Sending %s in %s" buf timeout)
      (bury-buffer)
      (run-at-time timeout
  		 nil
  		 (lambda (arg buf)
  		   (when (buffer-live-p buf)
  		     (with-current-buffer buf
  		       (let ((inhibit-quit nil)) ; avoid hang if e.g. server is slow/down
  		                                 ; though this makes C-g dangerous
  			 (message-send-and-exit arg)))))
  		 arg
  		 buf)))
  
but I know it's fraught with problems (missing headers cause
interactive questions to pop up out of nowhere, a C-g at the wrong
moment will cancel sending).

Has anyone attempted something like this before? I guess to avoid the
problem of interactive questions you'd have to write your own version of
`message-send' and do the `run-at-time' there. Perhaps `with-timeout'
could be used along with inhibit-quit to avoid stray C-g's while still
not hanging on server trouble? (Or is this a much bigger project than
that?)

-- 
Kevin Brubeck Unhammer

GPG: 0x766AC60C

[-- Attachment #1.2: Type: application/pgp-signature, Size: 489 bytes --]

[-- Attachment #2: Type: text/plain, Size: 162 bytes --]

_______________________________________________
info-gnus-english mailing list
info-gnus-english@gnu.org
https://lists.gnu.org/mailman/listinfo/info-gnus-english

             reply	other threads:[~2012-08-22 13:06 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-22 13:06 Kevin Brubeck Unhammer [this message]
2012-08-22 21:00 ` Adam Sjøgren
2012-08-22 21:04   ` Adam Sjøgren
2012-08-23  9:04   ` Kevin Brubeck Unhammer
2012-08-23 10:25     ` Adam Sjøgren
2012-08-22 21:01 ` Reiner Steib

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87harvnkj1.fsf@fsfe.org \
    --to=unhammer@fsfe.org \
    --cc=info-gnus-english@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).