Added command that checks if contact can receive encrypted emails, changed citation...
authorGabriel Pérez-Cerezo <gabriel@gpcf.eu>
Tue, 15 Dec 2015 16:03:26 +0000 (17:03 +0100)
committerGabriel Pérez-Cerezo <gabriel@gpcf.eu>
Tue, 15 Dec 2015 16:03:26 +0000 (17:03 +0100)
.wl

diff --git a/.wl b/.wl
index 3a6c6be..552d6ed 100644 (file)
--- a/.wl
+++ b/.wl
@@ -1,4 +1,4 @@
-;; mode: -*-emacs-lisp-*-
+; mode: -*-emacs-lisp-*-
 ;
 (load "silly-mail" nil t)
 (setq wl-stay-folder-window t
@@ -14,7 +14,6 @@
       signature-insert-at-eof t
       signature-delete-blank-lines-at-eof t
       wl-draft-send-mail-function 'wl-draft-send-mail-with-sendmail
-      sendmail-program (expand-file-name "~/software/mail/savemail.py")
       default-mime-charset 'utf8
       wl-fcc-force-as-read t
       wl-interactive-send nil
@@ -46,7 +45,7 @@
                                         (interactive)
                                         (mime-preview-quit)
                                         (wl-summary-forward)))
-
+            (local-set-key (kbd "K") 'extract-gpg-key)
             ))
 (setq mime-edit-insert-user-agent-field nil)
 
             (local-set-key "X" '(lambda ()
                                        ; checks for mail remotely using rsync.
                                   (interactive)
-                                  (shell-command 
-                                  (concat (expand-file-name "~/software/mail/getmail.sh") " > /dev/null 2>&1"))
-                                  (wl-summary-incorporate)
-                                  ))
+                                  (if (= (shell-command 
+                                          (concat (expand-file-name "~/software/mail/getmail.sh") " > /dev/null 2>&1")) 0 )
+                                      (wl-summary-incorporate)
+                                    (error "Fetching mail failed")
+                                    )))
 ))
 (defun gpcf-decrypt-mail ()
   "Decrypts mail in MIME preview buffer. Works with both PGP/MIME
@@ -149,20 +149,14 @@ message is sent, it adds the user's signature."
        (sm-add-microsoft)
        (sm-add-emacs-name)
        (sm-put-header "X-PGP-Key" "http://en.gpcf.eu/key.asc") 
-       (local-set-key (kbd "C-c e") '(lambda () 
-                                       (interactive)
-                                       (mime-edit-set-encrypt t)
-                                       (mime-edit-set-sign t)                                
-                                       (message 
-                                        "This message will be signed and encrypted") 
-                                       (face-remap-remove-relative enc-color)
-                                       ))
+       (local-set-key (kbd "C-c e") 'mime-edit-set-sign-and-encrypt)
        (local-set-key (kbd "C-c s") 'ispell-message)
        (local-set-key (kbd "C-c m s") 'wl-display-math)
        (local-set-key (kbd "C-c m h") 'wl-hide-math)
        (local-set-key (kbd "C-c c") '(lambda ()
                                      ;;; save email to queue and send it using SSH.
                                        (interactive)
+                                       (check-encryption-capabilities)
                                        (wl-draft-send-and-exit)
                                        (call-process-shell-command 
                                         (concat (expand-file-name "~/software/mail/sendmail.sh") "&") 
@@ -171,7 +165,32 @@ message is sent, it adds the user's signature."
        (delete-other-windows))
     (mail-signature) ;; add signature
     ))
-
+(defun mime-edit-set-sign-and-encrypt ()
+  (interactive)
+  (mime-edit-set-encrypt t)
+  (mime-edit-set-sign t)                                     
+  (message 
+   "This message will be signed and encrypted") 
+  (face-remap-remove-relative enc-color)
+)                                      
+(defun check-encryption-capabilities ()
+  "Checks if the recipient can receive encrypted e-mail, based on whether they have sent you encrypted e-mail before or not"
+  (interactive)
+  (save-excursion
+    (beginning-of-buffer)
+    (unless (search-forward-regexp "^To: .* <\\(.*\\)>$" nil t)
+      (unless (search-forward-regexp "^To: \\(.*\\)$" nil t)
+       (error "No To: address specified"))
+    ))
+  (when (and (not (memq 'encrypt mime-edit-pgp-processing))
+            (= (shell-command
+                ;; this person sent you encrypted email
+                (concat "mu find flag:encrypted from:" (match-string 1) " > /dev/null 2>&1")) 0 )
+            )
+    (when (yes-or-no-p "Do you want to encrypt and sign this message? ")
+      (mime-edit-set-sign-and-encrypt)
+      ))
+)
 (add-hook 'mime-edit-mode-hook 'gpcf-setup-mail)
 ; single window mode.
 (setq wl-stay-folder-window nil
@@ -202,6 +221,9 @@ message is sent, it adds the user's signature."
 (defadvice wl-summary-prev (after wl-summary-prev activate)
   (wl-delete-other-windows)
   )
+;; (defadvice wl-summary-incorporate (after wl-summary-incorporate activate)
+;;   (call-process-shell-command "mu index >/dev/null 2>/dev/null" nil 0)
+;;   )
 (defun wl-next-message ()
   "Jump to next message and open it"
   (interactive)
@@ -209,6 +231,7 @@ message is sent, it adds the user's signature."
       (mime-preview-quit))
       (wl-summary-next)
       (wl-summary-click-on-message))
+
 (defun wl-prev-message ()
   "Jump to previous message and open it"
   (interactive)
@@ -216,4 +239,35 @@ message is sent, it adds the user's signature."
       (mime-preview-quit))
   (wl-summary-prev)
   (wl-summary-click-on-message))
+
+;; Changes: removed newline
+(defun wl-default-draft-cite ()
+  (let ((mail-yank-ignored-headers "[^:]+:")
+       (mail-yank-prefix "> ")
+       date from cite-title)
+    (save-restriction
+      (if (< (mark t) (point))
+         (exchange-point-and-mark))
+      (narrow-to-region (point)(point-max))
+      (setq date (std11-field-body "date")
+           from (std11-field-body "from")))
+    (when (or date from)
+      (insert (format "On %s, %s wrote:\n"
+                     (or date "some time ago")
+                     (if wl-default-draft-cite-decorate-author
+                         (funcall wl-summary-from-function
+                                  (or from "you"))
+                       (or from "you")))))
+    (mail-indent-citation)))
+;; mu-find search
+(require 'elmo-search)
+(elmo-search-register-engine
+ 'mu 'local-file
+ :prog "/usr/bin/mu" ;; or wherever you've installed it
+ :args '("find" pattern "--fields" "l") :charset 'utf-8)
+
+(setq elmo-search-default-engine 'mu)
+;; for when you type "g" in folder or summary.
+(setq wl-default-spec "[")
+
 (load "~/.emacs.d/lisp/latex-math-preview.el")