X-Git-Url: https://www.fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=blobdiff_plain;f=vm;h=f1968967ca9942409e3f33099e6a6db69cbd3290;hb=1d49667604d56dec160ba3fbe612fcec52e7e5e6;hp=f700c990792644f75b2799a7b5655705e19a8822;hpb=db114167e8e2c85fe63ab00fb9472df35666b10b;p=elisp.git diff --git a/vm b/vm index f700c99..f196896 100644 --- a/vm +++ b/vm @@ -14,9 +14,23 @@ ;; along with this program. If not, see . ;; ;; ;; ;; Written by and Copyright (C) Francois Fleuret ;; -;; Contact < francois@fleuret.org > for comments & bug reports ;; +;; Contact for comments & bug reports ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; A fast indexed / search in mbox +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; This is one of my own things, check my web page to get it + +(when (ff/load-or-alert "~/sources/gpl/mymail/mymail-vm.el") + + (define-key vm-summary-mode-map "\\" 'mymail/vm-visit-folder) + (define-key global-map [S-f7] 'mymail/vm-visit-folder) + (setq mymail/default-search-request "today" + mymail/default-additional-search-requests "!s ^\\[SPAM\\],!s \\] STATUS,") + (add-to-list 'recentf-exclude "/tmp/mymail-vm-.*\.mbox") +) + (setq-default vm-summary-show-threads t) ;; (setq vm-preview-lines nil) @@ -27,77 +41,71 @@ (setq vm-auto-displayed-mime-content-types '( "text" - "image/jpeg" - "image/png" + ;; "image/jpeg" + ;; "image/png" "multipart" "message/rfc822" )) -(setq vm-startup-message-displayed t ;; Yes, we already saw it, no need to insist - vm-use-menus nil - vm-skip-deleted-messages nil - vm-skip-read-messages nil - vm-use-toolbar nil +(setq + ;; browse-url-mozilla-program "iceweasel" + ;; mail-complete-style nil + ;; mail-from-style nil + ;; vm-coding-system-priorities '(utf-8) + ;; vm-highlighted-header-regexp "From:\\|Subject:\\|Cc:\\|To:\\|Bcc:\\|Reply-To:" + ;; vm-included-text-attribution-format "\nOn %w, %m %d, at %H, you wrote:\n\n" ;; vm-jump-to-new-messages nil - vm-startup-with-summary t + ;; vm-mime-7bit-composition-charset "latin-1" + ;; vm-mime-8bit-composition-charset "utf-8" ;; vm-preview-read-messages t - vm-preview-lines nil - vm-auto-get-new-mail t - vm-circular-folders nil - vm-confirm-new-folders t - vm-mutable-windows t - vm-mutable-frames nil - vm-summary-thread-indent-level 1 + ;; vm-summary-format " %*%A %-3.3m %2d %5US %I%UA %s\n" ;; vm-summary-uninteresting-senders-arrow "->" - vm-summary-uninteresting-senders-arrow "►" + ;; vm-summary-uninteresting-senders-arrow "►" ;; vm-summary-uninteresting-senders-arrow "➔" ;; vm-summary-uninteresting-senders-arrow "➤" - vm-summary-arrow "> " - vm-included-text-prefix " > " - vm-forwarding-digest-type "mime" - vm-mime-attachment-save-directory "~/misc/attachments" - vm-use-toolbar nil - vm-frame-per-folder nil - vm-frame-per-summary nil - vm-mime-yank-attachments nil - - ;; vm-mime-7bit-composition-charset "latin-1" - vm-mime-8bit-composition-charset "iso-8859-1" - ;; vm-mime-8bit-composition-charset "utf-8" - ;; browse-url-mozilla-program "iceweasel" - vm-netscape-program browse-url-mozilla-program - ;; vm-coding-system-priorities '(utf-8) - ;; mail-from-style nil - ;; mail-complete-style nil - - ;; vm-summary-format " %*%A %-3.3m %2d %5US %I%UA %s\n" - vm-summary-format " %*%a %-3.3m %2d %5US %I%UA %s\n" - ;; vm-highlighted-header-regexp "From:\\|Subject:\\|Cc:\\|To:\\|Bcc:\\|Reply-To:" - vm-highlighted-header-regexp "From:\\|Subject:" - + bbdb-send-mail-style 'vm + bbdb/mail-auto-create-p nil + mail-signature t + mail-specify-envelope-from t vm-auto-folder-case-fold-search t - - vm-keep-sent-messages nil - vm-delete-after-saving t + vm-auto-get-new-mail t + vm-circular-folders nil + vm-confirm-new-folders t vm-delete-after-archiving t - + vm-delete-after-saving t + vm-forwarding-digest-type "mime" vm-forwarding-subject-format "(forwarded from %F) %s" + vm-frame-per-folder nil + vm-frame-per-summary nil + vm-highlighted-header-regexp "From:\\|Subject:\\|Reply-To:" vm-in-reply-to-format nil vm-included-text-attribution-format "\nOn %w, %m %d, %y (%h), %F wrote:\n\n" - ;; vm-included-text-attribution-format "\nOn %w, %m %d, at %H, you wrote:\n\n" + vm-included-text-prefix " > " + vm-keep-sent-messages nil + vm-mime-8bit-composition-charset "iso-8859-1" + vm-mime-attachment-save-directory "~/misc/attachments" + vm-mime-yank-attachments nil + vm-mutable-frames nil + vm-mutable-windows t + vm-netscape-program browse-url-mozilla-program + vm-preview-lines nil vm-reply-subject-prefix "Re: " - - mail-signature t - mail-specify-envelope-from t - - bbdb/mail-auto-create-p nil - bbdb-send-mail-style 'vm - + vm-skip-deleted-messages nil + vm-skip-read-messages nil + vm-startup-message-displayed t + vm-startup-with-summary t + vm-summary-arrow "> " + vm-summary-format " %*%a %-3.3m %2d %5US %I%UA %s\n" + vm-summary-thread-indent-level 1 + vm-summary-uninteresting-senders-arrow ">" + vm-use-menus nil + vm-use-toolbar nil + vm-use-toolbar nil ) ;; (add-to-list 'vm-visible-headers "From " t) -;; (add-to-list 'vm-visible-headers "Reply-To:" t) +(add-to-list 'vm-visible-headers "Reply-To:" t) ;; (add-to-list 'vm-visible-headers "X-Mailer:" t) ;; (add-to-list 'vm-visible-headers "X-from-in-bbdb:" t) ;; (add-to-list 'vm-visible-headers "Return-Path:") @@ -107,10 +115,6 @@ (setq - ;; vm-auto-displayed-mime-content-types '("text/plain" "text" "image" "multipart") - ;; vm-display-using-mime t - ;; vm-coding-system-priorities '(iso-8859-1 iso-8859-15 utf-8) - vm-infer-mime-types t vm-mime-use-image-strips nil vm-mime-base64-decoder-program "base64" @@ -118,15 +122,6 @@ vm-mime-base64-encoder-program "base64" vm-mime-base64-encoder-switches '() - ;; vm-auto-displayed-mime-content-types '( - ;; ;; "plain text" - ;; "text" - ;; "multipart" - ;; "image/xpm" - ;; ) - - ;; vm-auto-displayed-mime-content-type-exceptions '("text/html") - vm-mime-internal-content-types '( "multipart" "text" @@ -136,26 +131,36 @@ ) ;; To force it to be converted to plain text - vm-mime-internal-content-type-exceptions '("text/html") + ;; vm-mime-internal-content-type-exceptions '("text/html") vm-mime-external-content-types-alist '( ("application/x-dvi" "xdvi") ("image/postscript" "gv") ("application/pdf" "xpdf") - ;; ("application/pdf" "epdfview") ("application/postscript" "gv") - ;;("image" "feh") + ("image" "pho") ("video" "mplayer") - ;; ("text/html" "iceweasel") + ;; ("text/html" "firefox") + ;; ("application/pdf" "epdfview") ) ) (require 'vm-rfaddons) +;; The two following lines deal with windows-1252 buggy encoding + +;;**;; ;; First, don't display iso-8859-1 as-is in default face +;;**;; (delete "iso-8859-1" vm-mime-default-face-charsets) +;;**;; ;; Then substitute windows-1252 for iso-8859-1 +;;**;; (add-to-list 'vm-mime-mule-charset-to-coding-alist '("iso-8859-1" windows-1252)) + +;; (setq vm-mime-default-face-charsets t) + ;; (add-to-list 'vm-mime-default-face-charsets "utf-8") -(add-to-list 'vm-mime-default-face-charsets "iso-8859-1") +;; (add-to-list 'vm-mime-default-face-charsets "iso-8859-1") +;; (add-to-list 'vm-mime-default-face-charsets "Windows-1251") ;; (add-hook 'vm-mail-send-hook 'ff/vm-remove-non-7bits-in-headers) (add-hook 'vm-mail-send-hook 'vm-mime-encode-headers) (add-hook 'vm-mail-send-hook 'vm-mail-check-recipients) @@ -176,10 +181,10 @@ ;; "html2text -style pretty -nobs" ;; )) -(add-to-list 'vm-mime-type-converter-alist - '("text/html" "text/plain" - "html2text.sh" - )) +;; (add-to-list 'vm-mime-type-converter-alist + ;; '("text/html" "text/plain" + ;; "html2text.sh" + ;; )) (add-to-list 'vm-mime-type-converter-alist '("image" "image/xpm" @@ -275,7 +280,9 @@ attachement from mail." (defun vm-summary-function-S (&optional message) (let ((s (string-to-int (vm-su-byte-count message)))) (if (> s 32768) - (propertize (concat (int-to-string (/ s 1024)) "k") 'face 'bold) + (propertize (concat (int-to-string (/ s 1024)) "k") + 'face 'italic + ) ""))) (defun ff/vm-delete-and-go-down () (interactive) @@ -283,7 +290,10 @@ attachement from mail." (vm-delete-message 1) (condition-case nil (vm-next-message-no-skip 1) (error nil))) -(add-hook 'vm-quit-hook 'vm-expunge-folder) +(defun ff/vm-expunge-folder () + (unless vm-folder-read-only (vm-expunge-folder))) + +(add-hook 'vm-quit-hook 'ff/vm-expunge-folder) (add-hook 'vm-quit-hook 'bbdb-save-db) (add-hook 'vm-retrieved-spooled-mail-hook 'display-time-update) @@ -303,6 +313,7 @@ attachement from mail." (flyspell-mode) (auto-fill-mode) (mail-abbrevs-setup) + (yas/minor-mode) ;; (setq fill-paragraph-function 'mail-mode-fill-paragraph) @@ -325,7 +336,8 @@ attachement from mail." ;; To have a slightly darker background for headers (ff/configure-faces - '((ff/mail-header-face :background "#c8c8ff")) + ;; '((ff/mail-header-face :background "#c8c8ff")) + '((ff/mail-header-face :foreground "blue4")) ) (defun ff/colorize-headers () (interactive) @@ -535,15 +547,22 @@ an attachment") (add-hook 'vm-mail-send-hook 'flyspell-mode-off) ;; Append so that it happens after the mime encoding ;; (add-hook 'vm-mail-send-hook 'ff/check-badly-encoded-address t) + ;; Append this hook so that it runs after all other checks (add-hook 'vm-mail-send-hook 'ff/dissociate-file-from-vm-mail-buffer t) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; If we can, encrypt! +(add-hook 'vm-mode-hook 'mc-install-read-mode) +(add-hook 'vm-summary-mode-hook 'mc-install-read-mode) +(add-hook 'vm-virtual-mode-hook 'mc-install-read-mode) +(add-hook 'vm-mail-mode-hook 'mc-install-write-mode) +(add-hook 'vm-presentation-mode-hook 'mc-install-read-mode) + ;; (defun ff/encrypt-mail-if-possible () (interactive) -;; (condition-case nil (mc-encrypt) -;; (error nil))) + ;; (condition-case nil (mc-encrypt-message) + ;; (error nil))) ;; (add-hook 'vm-mail-send-hook 'ff/encrypt-mail-if-possible t) @@ -556,7 +575,8 @@ an attachment") (defun ff/goto-next-mail-field () (interactive) (let ((field (save-excursion (end-of-line) - (re-search-backward (concat "\\(^[a-zA-Z\-]*: \\|^" mail-header-separator "$\\)") nil t) + (re-search-backward + (concat "\\(^[a-zA-Z\-]*: \\|^" mail-header-separator "$\\)") nil t) (match-string 1)))) (cond ((string= field "To: ") @@ -591,6 +611,7 @@ an attachment") t) (substitute-key-definition 'next-line 'mail-abbrev-next-line vm-mail-mode-map global-map) + (substitute-key-definition 'end-of-buffer 'mail-abbrev-end-of-buffer vm-mail-mode-map global-map) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -625,9 +646,6 @@ is t." (when (load "bbdb-vm" t) - ;; (defadvice define-mail-abbrev (before ff/remove-explicit-name (name definition &optional from-mailrc-file) activate) - ;; (message "%s -> %s" name definition)) - (defun ff/mail-aliases-from-bbdb () "Creates automatically mail aliases from the bbdb records. For instance, someone in bbdb named \"Paul Smith\" would generate an alias @@ -638,7 +656,8 @@ instance, someone in bbdb named \"Paul Smith\" would generate an alias (let* ((record (car records)) (name (concat (elt record 0) " " (elt record 1))) (email (car (elt record 6))) - (alias (downcase (replace-regexp-in-string "\\([a-zA-Z]?\\)[^- ]*[- ]*" "\\1" name)))) + (alias (downcase (replace-regexp-in-string + "\\([a-zA-Z]?\\)[^- ]*[- ]*" "\\1" name)))) (if (and (> (length alias) 1) ;; Do not overwrite an existing alias (not (and mail-abbrevs (intern-soft alias mail-abbrevs)))) @@ -649,3 +668,15 @@ instance, someone in bbdb named \"Paul Smith\" would generate an alias (bbdb-insinuate-vm) (ff/mail-aliases-from-bbdb)) ) + +(defun ff/pipe-to-tmp () (interactive) + (let ((link "/tmp/attach") + (dir (format-time-string "/tmp/attach-%Y%m%d-%H%M%S" (current-time)))) + (mkdir dir) + (when (file-symlink-p link) (delete-file link)) + (unless (file-exists-p link) + (make-symbolic-link dir "/tmp/attach" 1)) + (vm-pipe-message-to-command (concat "munpack -C " dir)) + (message "Wrote files to %s" dir) + ) + )