From: yoichi Date: Fri, 26 Nov 2004 03:59:38 +0000 (+0000) Subject: * wl-util.el (toplevel): Don't check existence of `timer-activate'. X-Git-Tag: wl-2_12-root~31 X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=2bb4f7f07e9a3c68756ca19bd22bfb1d2ef13238;p=elisp%2Fwanderlust.git * wl-util.el (toplevel): Don't check existence of `timer-activate'. * wl-util.el (wl-save-drafts): Moved from sample setting. (wl-set-save-drafts): New function to set idle timer. * wl-draft.el (wl-draft): Call it. * wl-vars.el (wl-auto-save-drafts-interval): New variable. --- diff --git a/samples/en/dot.wl b/samples/en/dot.wl index 73fa9c7..038ba0a 100644 --- a/samples/en/dot.wl +++ b/samples/en/dot.wl @@ -205,16 +205,6 @@ ; 'wl-generate-user-agent-string-1) -;; Automatically save modified draft buffers in every 20 seconds. -;(defun my-wl-auto-save-draft-buffers () -; (let ((buffers (wl-collect-draft))) -; (save-excursion -; (while buffers -; (set-buffer (car buffers)) -; (if (buffer-modified-p) (wl-draft-save)) -; (setq buffers (cdr buffers)))))) -;(run-with-idle-timer 20 t 'my-wl-auto-save-draft-buffers) - ;; When you encrypt message by PGP, include your public key. ;; (to make the message visible from yourself) ;(setq pgg-encrypt-for-me t) diff --git a/samples/ja/dot.wl b/samples/ja/dot.wl index 47d4437..57577a7 100644 --- a/samples/ja/dot.wl +++ b/samples/ja/dot.wl @@ -204,17 +204,6 @@ ;(setq wl-generate-mailer-string-function ; 'wl-generate-user-agent-string-1) - -;; 変更されたドラフトがあれば 20 秒ごとに自動保存する。 -;(defun my-wl-auto-save-draft-buffers () -; (let ((buffers (wl-collect-draft))) -; (save-excursion -; (while buffers -; (set-buffer (car buffers)) -; (if (buffer-modified-p) (wl-draft-save)) -; (setq buffers (cdr buffers)))))) -;(run-with-idle-timer 20 t 'my-wl-auto-save-draft-buffers) - ;; PGP で暗号化する時に自分の公開鍵も含める。 ;; (そのメッセージを自分でも読めるように) ;(setq pgg-encrypt-for-me t) diff --git a/wl/ChangeLog b/wl/ChangeLog index 44e4a09..e6e9711 100644 --- a/wl/ChangeLog +++ b/wl/ChangeLog @@ -1,3 +1,12 @@ +2004-11-26 Yoichi NAKAYAMA + + * wl-util.el (toplevel): Don't check existence of `timer-activate'. + + * wl-util.el (wl-save-drafts): Moved from sample setting. + (wl-set-save-drafts): New function to set idle timer. + * wl-draft.el (wl-draft): Call it. + * wl-vars.el (wl-auto-save-drafts-interval): New variable. + 2004-11-23 Yuuichi Teranishi * wl-util.el (wl-current-message-buffer): Fixed bug when yank from diff --git a/wl/wl-draft.el b/wl/wl-draft.el index 643d907..7367f20 100644 --- a/wl/wl-draft.el +++ b/wl/wl-draft.el @@ -1645,7 +1645,7 @@ If KILL-WHEN-DONE is non-nil, current draft buffer is killed" (let (wl-demo) (wl-init)) ; returns immediately if already initialized. - + (wl-set-save-drafts) (let (buffer header-alist-internal) (setq buffer (wl-draft-create-buffer parent-folder)) (unless (cdr (assq 'From header-alist)) diff --git a/wl/wl-util.el b/wl/wl-util.el index 9b4eb20..c4f8c26 100644 --- a/wl/wl-util.el +++ b/wl/wl-util.el @@ -578,6 +578,14 @@ that `read' can handle, whenever this is possible." (buffer-list)) result)) +(defun wl-save-drafts () + (let ((buffers (wl-collect-draft))) + (save-excursion + (while buffers + (set-buffer (car buffers)) + (if (buffer-modified-p) (wl-draft-save)) + (setq buffers (cdr buffers)))))) + (static-if (fboundp 'read-directory-name) (defun wl-read-directory-name (prompt dir) (read-directory-name prompt dir dir)) @@ -707,6 +715,34 @@ that `read' can handle, whenever this is possible." (set-window-hscroll (get-buffer-window (current-buffer) t) 0)) max)))) +;; Draft auto-save +(static-cond + (wl-on-xemacs + (defvar wl-save-drafts-timer-name "wl-save-drafts") + + (defun wl-set-save-drafts () + (if (numberp wl-auto-save-drafts-interval) + (unless (get-itimer wl-save-drafts-timer-name) + (start-itimer wl-save-drafts-timer-name 'wl-save-drafts + wl-save-drafts-interval wl-save-drafts-interval + t)) + (when (get-itimer wl-save-drafts-timer-name) + (delete-itimer wl-save-drafts-timer-name))))) + (t + (defun wl-set-save-drafts () + (if (numberp wl-auto-save-drafts-interval) + (progn + (require 'timer) + (if (get 'wl-save-drafts 'timer) + (progn (timer-set-idle-time (get 'wl-save-drafts 'timer) + wl-auto-save-drafts-interval t) + (timer-activate-when-idle (get 'wl-save-drafts 'timer))) + (put 'wl-save-drafts 'timer + (run-with-idle-timer + wl-auto-save-drafts-interval t 'wl-save-drafts)))) + (when (get 'wl-save-drafts 'timer) + (cancel-timer (get 'wl-save-drafts 'timer))))))) + ;; Biff (static-cond (wl-on-xemacs @@ -723,9 +759,7 @@ that `read' can handle, whenever this is possible." wl-biff-check-interval wl-biff-check-interval wl-biff-use-idle-timer)))) - ((and (condition-case nil (require 'timer) (error nil));; FSFmacs 19+ - (fboundp 'timer-activate)) - + (t (defun wl-biff-stop () (when (get 'wl-biff 'timer) (cancel-timer (get 'wl-biff 'timer)))) @@ -811,10 +845,7 @@ This function is imported from Emacs 20.7." (timer-set-time timer (timer-next-integral-multiple-of-time current wl-biff-check-interval) wl-biff-check-interval) - (timer-activate timer)))))) - (t - (fset 'wl-biff-stop 'ignore) - (fset 'wl-biff-start 'ignore))) + (timer-activate timer))))))) (defsubst wl-biff-notify (new-mails notify-minibuf) (when (and (not wl-modeline-biff-status) (> new-mails 0)) diff --git a/wl/wl-vars.el b/wl/wl-vars.el index 59da329..1f91f9c 100644 --- a/wl/wl-vars.el +++ b/wl/wl-vars.el @@ -1964,6 +1964,13 @@ This wrapper is generated by the mail system when rejecting a letter." :type 'regexp :group 'wl-draft) +(defcustom wl-auto-save-drafts-interval 1 + "Idle interval in seconds to save draft buffers automatically. +If you don't want to use this feature, set this to nil." + :type '(choice (const :tag "Don't use this feature" nil) + (number :tag "Secs")) + :group 'wl-draft) + (defcustom wl-draft-preview-attributes t "Non-nil forces to preview the attributes in the `wl-draft-preview-message'. Attributes specified in the `wl-draft-preview-attributes-list' are displayed."