info-gnus-english
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

delayed sending of mail


From: Kevin Brubeck Unhammer
Subject: delayed sending of mail
Date: Wed, 22 Aug 2012 15:06:26 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1 (gnu/linux)

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: pgpf4Os_2lsMl.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]