Skip to content

Instantly share code, notes, and snippets.

@yurrriq
Forked from canweriotnow/eio.el
Created June 4, 2017 18:02
Show Gist options
  • Save yurrriq/f6322739573f1f0967d561a3e72a5fe6 to your computer and use it in GitHub Desktop.
Save yurrriq/f6322739573f1f0967d561a3e72a5fe6 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