Skip to content

Instantly share code, notes, and snippets.

@canweriotnow
Created June 6, 2015 01:34
Show Gist options
  • Save canweriotnow/0aed2a2009e8cae06de3 to your computer and use it in GitHub Desktop.
Save canweriotnow/0aed2a2009e8cae06de3 to your computer and use it in GitHub Desktop.
elisp exercise helper
;;; eio.el --- Support for creating Elisp exercises
;; Author: Jason Lewis
;; Created: 5 June 2015
;; This file is not part of GNU Emacs.
;;; Commentary:
;;
;; Provides utility functions for stubbing elisp exercises
;;; Code:
(defun stub-exercise (exercise)
"Create the stub for EXERCISE."
(let ((human-name (lisp-to-human exercise)))
(concat ";;; " exercise ".el --- " human-name "Exercise (exercism)\n"
"\n"
";;; Commentary:\n"
"\n"
";;; Code:\n"
"\n"
"\n"
"(provide '" exercise ")\n"
";;; " exercise ".el ends here")))
(defun stub-test (exercise)
"Stubs the test for EXERCISE."
(let ((human-name (lisp-to-human exercise)))
(concat ";;; " exercise "-test.el --- " human-name "Test (exercism)\n"
"\n"
";;; Commentary:\n"
"\n"
";;; Code:\n"
"(load-file \"" exercise ".el\")\n"
"\n"
"\n"
"\n"
"(provide '" exercise "-test)\n"
";;; " exercise ".el ends here")))
(defun lisp-to-human (title)
"Takes a kebab-case TITLE and humanizes it. E.g., hello-world -> Hello World."
(mapconcat 'identity
(mapcar #'capitalize
(split-string title "-")) " "))
(provide 'eio)
;;; eio.el ends here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment