+
+(defun ff/pipe-to-tmp (universal)
+ (interactive "P")
+
+ (if universal (vm-pipe-message-to-command)
+
+ (let ((link "/tmp/at")
+ (dir (format-time-string "/tmp/at-%Y%m%d-%H%M%S" (current-time))))
+ (mkdir dir)
+
+ (when (file-symlink-p (concat link "~~"))
+ (delete-file (concat link "~~")))
+
+ (when (and (file-symlink-p (concat link "~"))
+ (not (file-exists-p (concat link "~~"))))
+ (rename-file (concat link "~") (concat link "~~")))
+
+ (when (and (file-symlink-p link)
+ (not (file-exists-p (concat link "~"))))
+ (file-symlink-p link) (rename-file link (concat link "~")))
+
+ (unless (file-exists-p link)
+ (make-symbolic-link dir link 1))
+
+ ;; (vm-pipe-message-to-command (concat "munpack -C " dir))
+
+ (vm-pipe-message-to-command (concat "munpack -t -C " dir))
+ (message "Wrote files to %s" dir)
+ )
+ )
+ )
+
+(define-key vm-mode-pipe-map "\\" 'ff/pipe-to-tmp)
+
+(defun ff/make-nonexisting-filename (filename)
+ (let ((root filename)
+ (extension "")
+ (result filename))
+ (when (file-exists-p result)
+ (when (string-match "^\\(.*\\)\\(\\.[^\\.]*\\)$" filename)
+ (setq root (match-string 1 filename)
+ extension (match-string 2 filename)))
+ (let ((n 0))
+ (while (file-exists-p (setq result (format "%s_%03d%s" root n extension)))
+ (setq n (+ n 1)))))
+ result))
+
+(defun ff/vm-mime-save-all-attachments (&optional count
+ directory
+ no-delete-after-saving)
+ "Save all attachments in the next COUNT messages or marked
+messages. For the purpose of this function, an \"attachment\" is
+a mime part part which has \"attachment\" as its disposition or
+simply has an associated filename. Any mime types that match
+`vm-mime-savable-types' but not `vm-mime-savable-type-exceptions'
+are also included.
+
+The attachments are saved to the specified DIRECTORY. The
+variables `vm-all-attachments-directory' or
+`vm-mime-attachment-save-directory' can be used to set the
+default location. When directory does not exist it will be
+created."
+ (interactive
+ (list current-prefix-arg
+ (vm-read-file-name
+ "Attachment directory: "
+ (or vm-mime-all-attachments-directory
+ vm-mime-attachment-save-directory
+ default-directory)
+ (or vm-mime-all-attachments-directory
+ vm-mime-attachment-save-directory
+ default-directory)
+ nil nil
+ vm-mime-save-all-attachments-history)))
+
+ (vm-check-for-killed-summary)
+ (if (interactive-p) (vm-follow-summary-cursor))
+
+ (let ((n 0))
+ (vm-mime-action-on-all-attachments
+ count
+ ;; the action to be performed BEGIN
+ (lambda (msg layout type file)
+ (let ((directory (if (functionp directory)
+ (funcall directory msg)
+ directory)))
+ (setq file
+ (if file
+ (expand-file-name (file-name-nondirectory file) directory)
+ (vm-read-file-name
+ (format "Save %s to file: " type)
+ (or directory
+ vm-mime-all-attachments-directory
+ vm-mime-attachment-save-directory)
+ (or directory
+ vm-mime-all-attachments-directory
+ vm-mime-attachment-save-directory)
+ nil nil
+ vm-mime-save-all-attachments-history)
+ ))
+
+ (setq file (ff/make-nonexisting-filename file))
+
+ (when file
+ (message "Saving `%s%s" type (if file (format " (%s)" file) ""))
+ (make-directory (file-name-directory file) t)
+ (vm-mime-send-body-to-file layout file file)
+ (if vm-mime-delete-after-saving
+ (let ((vm-mime-confirm-delete nil))
+ (vm-mime-discard-layout-contents
+ layout (expand-file-name file))))
+ (setq n (+ 1 n)))))
+ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; the action to be performed END
+ ;; attachment filters
+ vm-mime-savable-types
+ vm-mime-savable-type-exceptions)
+
+ (when (interactive-p)
+ (vm-discard-cached-data)
+ (vm-preview-current-message))
+
+ (if (> n 0)
+ (message "%d attachment%s saved" n (if (= n 1) "" "s"))
+ (message "No attachments to be saved!"))))
+
+(define-key vm-summary-mode-map [(control c) (control s)] 'ff/vm-mime-save-all-attachments)
+
+;; I do not like relief
+
+(ff/configure-faces
+ '(
+
+ ;; (vm-highlight-url :weight 'bold :foreground "#0000f0" :box nil)
+ (vm-highlight-url :underline nil :foreground "#0000f0" :box nil)
+ ;; (vm-highlight-url :background "white" :foreground "#0000f0" :box nil)
+ (vm-highlighted-header :box nil) ;; :weight 'bold :background "white")
+
+ (vm-attachment-button :background "#f0d0d0" :box nil)
+ (vm-attachment-button-mouse :background "#f0d0d0" :box nil)
+ (vm-attachment-button-pressed-face :background "#f0d0d0" :box nil)
+ (vm-mime-button :background "#f0d0d0" :box nil)
+ (vm-mime-button-mouse :background "#f0d0d0" :box nil)
+ (vm-mime-button-pressed-face :background "#f0d0d0" :box nil)
+ ))