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

_______________________________________________
info-gnus-english mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/info-gnus-english

Reply via email to