* Q: prevent Emacs from sending mail with no subject
@ 2003-12-23 16:44 Eric Pement
2003-12-23 17:26 ` Kin Cho
2003-12-23 18:51 ` Kevin Rodgers
0 siblings, 2 replies; 3+ messages in thread
From: Eric Pement @ 2003-12-23 16:44 UTC (permalink / raw)
I would like to know how to prevent Emacs from sending email with no
subject (or with a subject line that contains only whitespace). I've
accidentally sent a couple of messages this way, and I think Emacs
converted the subject line to "(unknown)" for me, but I'm not sure. At
any rate, I want Emacs to not send the message if the subject line is
empty, but to prompt me to enter the missing subject.
I've already checked the FAQ, the Customization menu, "Learning GNU
Emacs" and searched the Google archives for this issue, but I can't
seem to find the answer. Any help would be appreciated.
--
Eric Pement
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Q: prevent Emacs from sending mail with no subject
2003-12-23 16:44 Q: prevent Emacs from sending mail with no subject Eric Pement
@ 2003-12-23 17:26 ` Kin Cho
2003-12-23 18:51 ` Kevin Rodgers
1 sibling, 0 replies; 3+ messages in thread
From: Kin Cho @ 2003-12-23 17:26 UTC (permalink / raw)
Try this bit of elisp:
(defadvice mail-send (before check-for-null-subject activate)
(or (mail-subject) (error "No subject!"))
(or (string-match "^.+?:[ \t]*[^ \t]+"
(buffer-substring-no-properties
(progn (beginning-of-line) (point))
(progn (end-of-line) (point))))
(error "No subject!")))
-kin
pemente@northpark.edu (Eric Pement) writes:
> I would like to know how to prevent Emacs from sending email with no
> subject (or with a subject line that contains only whitespace). I've
> accidentally sent a couple of messages this way, and I think Emacs
> converted the subject line to "(unknown)" for me, but I'm not sure. At
> any rate, I want Emacs to not send the message if the subject line is
> empty, but to prompt me to enter the missing subject.
>
> I've already checked the FAQ, the Customization menu, "Learning GNU
> Emacs" and searched the Google archives for this issue, but I can't
> seem to find the answer. Any help would be appreciated.
>
> --
> Eric Pement
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Q: prevent Emacs from sending mail with no subject
2003-12-23 16:44 Q: prevent Emacs from sending mail with no subject Eric Pement
2003-12-23 17:26 ` Kin Cho
@ 2003-12-23 18:51 ` Kevin Rodgers
1 sibling, 0 replies; 3+ messages in thread
From: Kevin Rodgers @ 2003-12-23 18:51 UTC (permalink / raw)
Eric Pement wrote:
> I would like to know how to prevent Emacs from sending email with no
> subject (or with a subject line that contains only whitespace). I've
> accidentally sent a couple of messages this way, and I think Emacs
> converted the subject line to "(unknown)" for me, but I'm not sure. At
> any rate, I want Emacs to not send the message if the subject line is
> empty, but to prompt me to enter the missing subject.
>
> I've already checked the FAQ, the Customization menu, "Learning GNU
> Emacs" and searched the Google archives for this issue, but I can't
> seem to find the answer. Any help would be appreciated.
Emacs is not changing your Subject header (I just checked the lisp/mail/*.el
files distributed with Emacs 21.3). It is probably your site's MTA -- are
you using sendmail.el or smtpmail.el, or something else?
In any case, you probably want to add the check for an empty Subject header
to mail-send-hook:
(defun mail-send-check-subject ()
(save-excursion
;; see mail-position-on-field:
(goto-char (point-min))
(let ((case-fold-search t))
(if (re-search-forward "^Subject:[ \t]*" (mail-header-end))
;; else signal an error
(if (eolp)
(insert (read-string "Subject: ")))))))
(add-hook 'mail-send-hook 'mail-send-check-subject)
--
Kevin Rodgers
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2003-12-23 18:51 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-12-23 16:44 Q: prevent Emacs from sending mail with no subject Eric Pement
2003-12-23 17:26 ` Kin Cho
2003-12-23 18:51 ` Kevin Rodgers
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 read-only IMAP folder(s) and NNTP newsgroup(s).