(%include environment)
(%include lisp_dcls)
(%include e-macros)
(lisp-need-at-run-time format)
(declare (defpl1 decode_clock_value_ "" (bit (36.))	;clock value
	       (return fixed bin)		;month
	       (return fixed bin)		;day of month
	       (return fixed bin)		;year
	       (return ignore fixed bin (35.))	;time
	       (return ignore fixed bin)	;weekday
	       (return ignore char (3))))	;zone

(declare (defpl1 convert_date_to_binary_ "" (char (*)) ;date_time_string
	       (return fixed bin (35.))	;binary date-time
	       (return fixed bin (35.))))	;code

(declare (special fpathname)
         (*expr text-mode find-file-subr read-in-file
	      word-abbreviation-mode empty-buffer-p))

(defvar *minutes-file-suffix* "sipb_minutes")
(defvar *minutes-dir* ">udd>sipb>secretary")
(defvar *minutes-format* "minutes-form.text")

(defun sipb_minutes-mode ()
       (text-mode)
       (word-abbreviation-mode 'on))

(defun make-minutes-entryname (dy mo yr)
       (format nil "~2,'0d.~2,'0d.~d.~a"
	     dy mo yr *minutes-file-suffix*))

(defprop word-abbreviation-mode ">udd>m>wmy>ed>emacs_word_abbrev_" autoload)

(set-perm-key '^Z^M 'minutes)
(defcom minutes
        &doc "Starts a new SIPB minutes.  Prompts for the date (hit carriage
return for the current date).  If starting new minutes, reads in the
minutes format."
        &args ((date-string &prompt "Minutes date (RETURN for today): "))
        (let ((datelist (decode_clock_value_
		      (car (convert_date_to_binary_ date-string)))))
	   (find-file-subr
	     (catenate *minutes-dir* ">"
		     (make-minutes-entryname
		       (cadr datelist)
		       (car datelist)
		       (caddr datelist)))))
        (cond ((empty-buffer-p current-buffer)
	     (let ((fpathname))
		(read-in-file (catenate *minutes-dir* ">"
				    *minutes-format*))))))
