That is is brilliant!
Emacs 23 .. wow you like retro! If you ever feel like upgraded, it would be great to have another users on the reborn VM. Yeechang Lee <[email protected]> writes: > A way to avoid sending a message that mentions an attachment but does not > have one. It is based on VM 8.2.0b and Emacs 23 (yes, really). I offer it to > the community hoping that others will find it useful, and for feedback. > > ;; Require confirmation to send message that mentions attachment > ;; without attachment > > (defun my-vm-get-current-body-text () > "Return the body text of the mail message in the current > buffer. Based on `vmpc-get-current-body-text'." > (save-excursion > (goto-char (point-min)) > (let ((start (re-search-forward > (concat "^" (regexp-quote mail-header-separator) "$"))) > (end (point-max))) > (buffer-substring start end)))) > > (defcustom my-vm-check-for-attachment-regexp "attach" > "In VM, ask to confirm sending message if it mentions > attachment without having one. Non-nil (default is 'attach') is > what `my-vm-check-for-attachment' looks for when scanning the > message. Set to nil to never ask.") > > (defun my-vm-check-for-attachment () > "In VM, ask to confirm sending message if it mentions > attachment without having one. Set > `my-vm-check-for-attachment-regexp' to modify how VM checks for > the mention, or to nil to never ask." > > > (when my-vm-check-for-attachment-regexp ; Is function enabled? Put > ; another way, is there > ; something to look for? > > ; Get content of Subject: > ; header. Does using > ; `vm-get-header-contents' > ; make a difference here? > (let ((subject (vm-mail-get-header-contents "Subject:")) > > ; Get content of message > ; body. We could use > ; `vmpc-get-current-body-text', > ; but can't be sure > ; Personality Crisis is > ; enabled. > (body (my-vm-get-current-body-text)) > > ; VM's atachment tag, evidence > ; that message has > ; attachment. Taken from > ; `vm-attach-file'. > (attachment-regexp (regexp-quote "[ATTACHMENT "))) > > (when > (or ; Does subject line or body mention attachment? > (string-match-p my-vm-check-for-attachment-regexp subject) > (string-match-p my-vm-check-for-attachment-regexp body)) > > ; Yes, message mentions > ; attachment. Does message > ; actually have attachment? > (unless (string-match-p attachment-regexp body) > > ; No attachment found. Confirm > ; before sending > ; message. Prompting with > ; `my-vm-check-for-attachment-regexp' > ; helps identify false > ; positive. > (when (not (y-or-n-p > (concat "Message mentions '" > my-vm-check-for-attachment-regexp > "' but has no attachment. Send? "))) > (error "Message not sent"))))))) > > (add-hook 'vm-mail-send-hook 'my-vm-check-for-attachment) >
