massar@godot.UUCP (J.P. Massar) (02/19/85)
Here is an enhancement to Emacs / Elisp that allows M-X Mail Buffer to be given string arguments representing To: CC: and Subject: fields. Previously, Emacs would always prompt you for these fields. This is extremely useful in that now one can write Elisp functions which automatically create and send mail messages. The changes are to the 'mailbuf' routine in the file e_cmds.c. Here are the diffs: *** oldcmds.c Sun Feb 17 14:39:29 1985 --- e_cmds.c Mon Feb 18 16:48:28 1985 *************** *** 1055,1061 /* Mail Buffer */ ! mailbuf() { register char *to, *cc, *subject; register pid; --- 1055,1065 ----- /* Mail Buffer */ ! mailbuf (arg,c,to,cc,subject) ! ! int arg,c; ! char *to,*cc,*subject; ! { register pid; register FILE *mailin, *mailout; *************** *** 1057,1063 mailbuf() { - register char *to, *cc, *subject; register pid; register FILE *mailin, *mailout; char outf = 0; --- 1061,1066 ----- char *to,*cc,*subject; { register pid; register FILE *mailin, *mailout; char outf = 0; *************** *** 1069,1075 char *mailtemp; #endif ! if (!(to = getstr("To: ", 0)) || !*to) return(1); #if vms strcpy(addressee, to); --- 1072,1078 ----- char *mailtemp; #endif ! if (!to && !(to = getstr("To: ", 0)) || !*to) return(1); #if vms strcpy(addressee, to); *************** *** 1085,1091 unlink(mailtemp); echo1("Message sent"); #else ! if (!(pid = filter("mail", "mail", pi, po, to, 0, 0))) return(1); mailin = fdopen(&mailbfr[0], pi[1], "w"); mailout = fdopen(&mailbfr[1], po[0], "r"); --- 1088,1094 ----- unlink(mailtemp); echo1("Message sent"); #else ! if (!(pid = filter("/usr/ucb/mail","/usr/ucb/mail",pi,po,to,0,0))) return(1); mailin = fdopen(&mailbfr[0], pi[1], "w"); mailout = fdopen(&mailbfr[1], po[0], "r"); *************** *** 1089,1095 return(1); mailin = fdopen(&mailbfr[0], pi[1], "w"); mailout = fdopen(&mailbfr[1], po[0], "r"); ! cc = getstr("Cc: ", 0); if (!cc) { kill(pid, SIGKILL); fclose(mailin); --- 1092,1098 ----- return(1); mailin = fdopen(&mailbfr[0], pi[1], "w"); mailout = fdopen(&mailbfr[1], po[0], "r"); ! if (!cc) cc = getstr("Cc: ", 0); if (!cc) { kill(pid, SIGKILL); fclose(mailin); *************** *** 1099,1105 } if (cc && *cc) fprintf(mailin, "~c %s\n", cc); ! subject = getstr("Subject: ", 0); if (!subject) { kill(pid, SIGKILL); fclose(mailin); --- 1102,1108 ----- } if (cc && *cc) fprintf(mailin, "~c %s\n", cc); ! if (!subject) subject = getstr("Subject: ", 0); if (!subject) { kill(pid, SIGKILL); fclose(mailin); --------------------------------------------------------------------------- There are almost certainly a number of other functions which could be made to operate in this manner (i.e., accept string arguments instead of necessarily prompting). It's an easy fix -- if someone does fix any more please post the fix. -- -- JP Massar, Thinking Machines Corporation, Cambridge, MA -- ihnp4!godot!massar -- massar@cca-unix