Skip to content

Instantly share code, notes, and snippets.

@tkych
Created May 28, 2013 03:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tkych/5660296 to your computer and use it in GitHub Desktop.
Save tkych/5660296 to your computer and use it in GitHub Desktop.
Template for lisp file
;;;; Last modified : 2013-05-28 12:08:22 tkych
;;====================================================================
;; Template for Lisp File
;;====================================================================
(in-package :cl-user)
(ql:quickload :simple-date-time)
(defpackage #:template
(:nicknames :tp)
(:use :cl)
(:export #:gen-lisp-file))
(in-package #:template)
;;--------------------------------------------------------------------
;; gen-lisp-file
;;--------------------------------------------------------------------
(defparameter *nickname* "tkych")
(defun now ()
(let ((now (simple-date-time:now)))
(replace (simple-date-time:|yyyy-mm-dd hh:mm:ss| now)
(simple-date-time:yyyy-mm-dd now))))
(defun write-file-header (stream)
(format stream ";;;; Last modified : ~A ~A~3%" (now) *nickname*))
(defun write-line* (n char stream)
(format stream (format nil "~~~D,,,'~AA" n char) char))
(defun write-commented-line (char stream)
(format stream "~&;;")
(write-line* 68 char stream)
(terpri))
(defun write-title (stream title)
(write-commented-line #\= stream)
(format stream ";; ~A~%" title)
(write-commented-line #\= stream))
(defun write-subtitle (stream)
(write-commented-line #\- stream)
(format stream "~%;; ~%")
(write-commented-line #\- stream))
(defun gen-lisp-file (file-spec &optional (title ""))
(with-open-file (out (format nil "~A.lisp" file-spec)
:direction :output
:external-format :utf-8
:if-does-not-exist :create
:if-exists :error)
(write-file-header out)
(write-title out title)
(format out "~5%")
(write-subtitle out)
(format out "~10%")
(write-commented-line #\= out)))
;;====================================================================
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment