Announcements and discussions for Gnus, the GNU Emacs Usenet newsreader
 help / color / mirror / Atom feed
From: "François Fleuret" <francois.fleuret@epfl.ch>
Subject: Checking attachments are actually attached
Date: Sat, 08 Apr 2006 12:34:21 +0200	[thread overview]
Message-ID: <87fykoe4pe.fsf@fleuret.homeunix.org> (raw)

Dear all,

I wrote this, which may be of interest for others:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Checks that the mail contains an attached file if the body refers
;; to such an attachment. The idea comes from
;; http://home.cc.gatech.edu/eaganj/MailApp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defcustom check-no-missing-attachment-regexp "attach"
  "*A mail whose body matches this regular expression should contain
an attachment")

(defun contains-attachment (l)
  (and l (or (and
              (eq (car (car l)) 'part)
              (string= "attachment" (cdr (assoc 'disposition (cdr (car l))))))
             (contains-attachment (cdr l)))))

(defun check-no-missing-attachment ()
  "Checks the mail contains an attached file if the body refers to such an attachment"
  (message-goto-body)
  (and (re-search-forward check-no-missing-attachment-regexp nil t)
       (not (contains-attachment (mml-parse)))
       (not (y-or-n-p "An attachment seems to be missing, send message ? "))
       (error "You refer to an unexisting attachment.")))

(add-hook 'message-send-hook 'check-no-missing-attachment)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Comments are of course welcome.

Cheers,

-- 
François Fleuret                          http://cvlab.epfl.ch/~fleuret

                 reply	other threads:[~2006-04-08 10:34 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87fykoe4pe.fsf@fleuret.homeunix.org \
    --to=francois.fleuret@epfl.ch \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).