|
|
Hi again,
I'm hoping this letter will reach Robert (newsspam5REMOVETHIS@xxxxxxx)
because this question is a follow up to something he helped me on. But if
anyone else can answer my questions, I would appreciate it!
My project is to clip unwanted attachments out of emails. I am able to do
so using the function vm-mime-action-on-all-attachments from
vm-rfaddons.el. At this time, I run my function interactively rather than
by a hook. Here is the code:
(setq jjf-vm-mime-cut-list '("IMSTP.gif"))
(defun jjf-vm-cut-unwanted-mime-objects ()
(interactive)
(vm-mime-action-on-all-attachments
nil 'jjf-vm-cut-unwanted-mime-objects-internal '("image")))
(defun jjf-vm-cut-unwanted-mime-objects-internal (layout type file)
(when (member file jjf-vm-mime-cut-list)
(message "%s is a member of jjf-vm-mime-cut-list" file)
(let ((buf (marker-buffer (vm-mm-layout-body-start layout)))
(header-start (vm-mm-layout-header-start layout))
(header-end (vm-mm-layout-header-end layout))
(body-start (vm-mm-layout-body-start layout))
(body-end (vm-mm-layout-body-end layout)))
(with-current-buffer buf
(toggle-read-only)
(save-restriction
(widen)
(delete-region header-start header-end)
(delete-region body-start body-end)
(message "header: %s %s body: %s %s" header-start header-end
body-start body-end)
(message "%s" (buffer-substring header-start header-end))
)
(toggle-read-only)
))))
This code works, and I am able to cut a named mime object out of an email.
What it does not do, is refresh the presentation buffer. The presentation
buffer is left with a non-functioning mime-button.
Next question: I want to be able to use other criteria in the cut-list, for
instance, the Sender, or maybe an md5 sum of the unwanted object. That
would eliminate false positives. Can I access the Sender field from the
scope of my function? Does emacs have an md5sum or similar hash-key
generator that would be apt for matching content?
This message is getting long so I will leave it there. Any suggestions for
improvement in the code are welcome--I am an elisp novice.
Last question: is it just my news client or do the messages in this
newsgroup expire fast?
Thanks!
John Foerch
|
|