#ifndef REMIND_MACROS
#define REMIND_MACROS

/*
 * a set of macros to aid in creating beautiful reminders with remind(1)
 * 
 *	some points to note -
 *
 *	    getting certain characters into the final output is hard -
 *		instead, use the following substitutions
 *		    for '	    use  ( character \001 )
 *		    for ;	    use  ( character \002 )
 *		    for \	    use  ( character \003 )
 *		    for newline	    use ;
 *
 *	    use DOSHOWTIME to incorporate the output of a command
 *		executed at the time the reminder appears on the screen
 *	    use DOPOSTTIME for commands to be executed at the time
 *		"remind" is run
 *
 *	    HEAD centers the text, and underlines it with **'s
 *	    COMMENT is useful for text that should not appear in the
 *		reminder, but is needed to flag a time or date
 *	    PAD fills the remainder of the line with spaces, so that the
 *		dialog will in fact be the right width - use it at least
 *		once if using centered text
 *
 *	    NL causes a new line
 *	    RMARG, LMARG and MARGINS set the margin positions
 *
 *	    use ;; for a new paragraph
 */

/* some (nroff) formatting macros */

#define RMARG(r).ll r/**/m
#define LMARG(l).in l
#define MARGINS(l,r)LMARG(l);RMARG(r)
#define NL .br
#define LINES(count).br;.sp count
#define LINE LINES(1)
#define PAD \\l|\\n(.lu\\ 
#define RAGGED .na
#define CENTRE .ad c
#define FILL .ad b
#define LEFT .ad l
#define RIGHT .ad r
#define COMMENT(text).\\" text "
#define HEAD(text).ce;text;.ce;\\l\\n(.nu\\&*;PAD

/* macros which will cause commands to be executed at various times */

#define date /bin/date
#define awk /bin/awk
#define cat /bin/cat

#define DOPOSTTIME(command)'`command`'
#define DOSHOWTIME(command)'"\'\`command\`\'"'
#define DATE DOSHOWTIME((date | awk '{OFS=\" \";print \$1,\$2,\$3}'))
#define TIME DOSHOWTIME((date | awk '{split(\$4,time,\":\");print time[1] \":\" time[2];}'))
#define INCLUDE(name)DOSHOWTIME(cat name)

/* these simplify regular postings */

#define DAILY(time)COMMENT(every day time)
#define MONDAYS(time)COMMENT(every Mon time)
#define TUESDAYS(time)COMMENT(every Tue time)
#define WEDNESDAYS(time)COMMENT(every Wed time)
#define THURSDAYS(time)COMMENT(every Thu time)
#define FRIDAYS(time)COMMENT(every Fri time)
#define SATURDAYS(time)COMMENT(every Sat time)
#define SUNDAYS(time)COMMENT(every Sun time)

#endif
