Added support for saving messages into ham and spam folders master
authorGabriel Pérez-Cerezo <gabriel@gpcf.eu>
Mon, 28 Dec 2015 12:22:31 +0000 (13:22 +0100)
committerGabriel Pérez-Cerezo <gabriel@gpcf.eu>
Mon, 28 Dec 2015 12:22:31 +0000 (13:22 +0100)
.wl

diff --git a/.wl b/.wl
index 552d6ed..5316506 100644 (file)
--- a/.wl
+++ b/.wl
@@ -99,6 +99,8 @@
                                       (wl-summary-incorporate)
                                     (error "Fetching mail failed")
                                     )))
                                       (wl-summary-incorporate)
                                     (error "Fetching mail failed")
                                     )))
+            (local-set-key (kbd "Y s") 'wl-send-to-spam-folder)
+            (local-set-key (kbd "Y h") 'wl-send-to-ham-folder)
 ))
 (defun gpcf-decrypt-mail ()
   "Decrypts mail in MIME preview buffer. Works with both PGP/MIME
 ))
 (defun gpcf-decrypt-mail ()
   "Decrypts mail in MIME preview buffer. Works with both PGP/MIME
@@ -271,3 +273,30 @@ message is sent, it adds the user's signature."
 (setq wl-default-spec "[")
 
 (load "~/.emacs.d/lisp/latex-math-preview.el")    
 (setq wl-default-spec "[")
 
 (load "~/.emacs.d/lisp/latex-math-preview.el")    
+(defun wl-send-to-ham-folder ()
+  (interactive)
+  (wl-summary-auto-save "~/Maildir/ham/")
+  )
+(defun wl-send-to-spam-folder ()
+  (interactive)
+  (wl-summary-auto-save "~/Maildir/spam/")
+  )
+(defun wl-summary-auto-save (wl-save-dir)
+  "Save current message to disk."
+  (interactive)
+  (let ((filename)
+       (num (wl-summary-message-number)))
+    (unless wl-save-dir
+      (setq wl-save-dir wl-temporary-file-directory))
+    (if num
+       (save-excursion
+         (setq filename (concat wl-save-dir (number-to-string num) wl-summary-save-file-suffix))
+         (wl-summary-set-message-buffer-or-redisplay)
+         (set-buffer (wl-message-get-original-buffer))
+         ;(while (not (file-exists-p filename))
+         ;  (setq filename (concat (number-to-string (+ num 1)) wl-summary-save-file-suffix)))
+         (write-region-as-binary (point-min) (point-max) filename))
+    (message "No message to save."))
+    num)
+    )
+