* delayed sending of mail @ 2012-08-22 13:06 Kevin Brubeck Unhammer 2012-08-22 21:00 ` Adam Sjøgren 2012-08-22 21:01 ` Reiner Steib 0 siblings, 2 replies; 6+ messages in thread From: Kevin Brubeck Unhammer @ 2012-08-22 13:06 UTC (permalink / raw) To: info-gnus-english [-- 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 ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: delayed sending of mail 2012-08-22 13:06 delayed sending of mail Kevin Brubeck Unhammer @ 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-22 21:01 ` Reiner Steib 1 sibling, 2 replies; 6+ messages in thread From: Adam Sjøgren @ 2012-08-22 21:00 UTC (permalink / raw) To: info-gnus-english 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-Playing:\\|X-Gnus-Delayed:")) ; Remove date, so delayed messages (C-c C-j) don't get a date until ; sent <mailman.1180.1266014215.14305.info-gnus-english@gnu.org>: (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? Best regards, Adam -- "A cat has nine lives, but a bullfrog croaks Adam Sjøgren every day." asjo@koldfront.dk ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: delayed sending of mail 2012-08-22 21:00 ` Adam Sjøgren @ 2012-08-22 21:04 ` Adam Sjøgren 2012-08-23 9:04 ` Kevin Brubeck Unhammer 1 sibling, 0 replies; 6+ messages in thread From: Adam Sjøgren @ 2012-08-22 21:04 UTC (permalink / raw) To: info-gnus-english On Wed, 22 Aug 2012 23:00:21 +0200, Adam wrote: > Maybe you can build upon gnus-delay-article if you want a fixed delay? I should have offered a link to the manual as well, it has more detail: * http://gnus.org/manual/gnus_75.html Best regards, Adam -- "A cat has nine lives, but a bullfrog croaks Adam Sjøgren every day." asjo@koldfront.dk ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: delayed sending of mail 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 1 sibling, 1 reply; 6+ messages in thread From: Kevin Brubeck Unhammer @ 2012-08-23 9:04 UTC (permalink / raw) To: info-gnus-english [-- Attachment #1.1: Type: text/plain, Size: 4469 bytes --] asjo@koldfront.dk (Adam Sjøgren) 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-Playing:\\|X-Gnus-Delayed:")) > > ; Remove date, so delayed messages (C-c C-j) don't get a date until > ; sent <mailman.1180.1266014215.14305.info-gnus-english@gnu.org>: > (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 other 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-delayed-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-minutes))) (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 (>= (nth 0 deadline) 0) (>= (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))))))) (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 …) -- 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 ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: delayed sending of mail 2012-08-23 9:04 ` Kevin Brubeck Unhammer @ 2012-08-23 10:25 ` Adam Sjøgren 0 siblings, 0 replies; 6+ messages in thread From: Adam Sjøgren @ 2012-08-23 10:25 UTC (permalink / raw) To: info-gnus-english On Thu, 23 Aug 2012 11:04:08 +0200, Kevin wrote: > 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 other minute regardless of idleness > (gnus-demon-init) Ah, cool, I will steal that - thanks for sharing (this and the rest)! Best regards, Adam -- "A cat has nine lives, but a bullfrog croaks Adam Sjøgren every day." asjo@koldfront.dk ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: delayed sending of mail 2012-08-22 13:06 delayed sending of mail Kevin Brubeck Unhammer 2012-08-22 21:00 ` Adam Sjøgren @ 2012-08-22 21:01 ` Reiner Steib 1 sibling, 0 replies; 6+ messages in thread From: Reiner Steib @ 2012-08-22 21:01 UTC (permalink / raw) To: info-gnus-english On Wed, Aug 22 2012, Kevin Brubeck Unhammer 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. See (info "(gnus)Delayed Articles") Bye, Reiner. -- ,,, (o o) ---ooO-(_)-Ooo--- | PGP key available | http://rsteib.home.pages.de/ ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2012-08-23 10:25 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2012-08-22 13:06 delayed sending of mail Kevin Brubeck Unhammer 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
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).