1 ;;; fuel-scaffold.el -- interaction with tools.scaffold
3 ;; Copyright (C) 2009 Jose Antonio Ortega Ruiz
4 ;; See http://factorcode.org/license.txt for BSD license.
6 ;; Author: Jose Antonio Ortega Ruiz <jao@gnu.org>
7 ;; Keywords: languages, fuel, factor
8 ;; Start date: Sun Jan 11, 2009 18:40
12 ;; Utilities for creating new vocabulary files and other boilerplate.
13 ;; Mainly, an interface to Factor's tools.scaffold.
19 (require 'fuel-syntax)
25 (defgroup fuel-scaffold nil
26 "Options for FUEL's scaffolding."
29 (defcustom fuel-scaffold-developer-name nil
30 "The name to be inserted as yours in scaffold templates."
32 (const :tag "Factor's value for developer-name" nil))
33 :group 'fuel-scaffold)
36 ;;; Auxiliary functions:
38 (defun fuel-scaffold--vocab-roots ()
39 (let ((cmd '(:fuel* (vocab-roots get :get) "fuel")))
40 (fuel-eval--retort-result (fuel-eval--send/wait cmd))))
45 (defun fuel-scaffold-vocab (&optional other-window name-hint root-hint)
46 "Creates a directory in the given root for a new vocabulary and
47 adds source, tests and authors.txt files.
49 You can configure `fuel-scaffold-developer-name' (set by default to
50 `user-full-name') for the name to be inserted in the generated files."
52 (let* ((name (read-string "Vocab name: " name-hint))
53 (root (completing-read "Vocab root: "
54 (fuel-scaffold--vocab-roots)
55 nil t (or root-hint "resource:")))
56 (cmd `(:fuel* ((,root ,name ,fuel-scaffold-developer-name)
57 (fuel-scaffold-vocab)) "fuel"))
58 (ret (fuel-eval--send/wait cmd))
59 (file (fuel-eval--retort-result ret)))
61 (error "Error creating vocab (%s)" (car (fuel-eval--retort-error ret))))
62 (if other-window (find-file-other-window file) (find-file file))
63 (goto-char (point-max))
66 (defun fuel-scaffold-help (&optional arg)
67 "Creates, if it does not already exist, a help file with
68 scaffolded help for each word in the current vocabulary.
70 With prefix argument, ask for the vocabulary name.
71 You can configure `fuel-scaffold-developer-name' (set by default to
72 `user-full-name') for the name to be inserted in the generated file."
74 (let* ((vocab (or (and (not arg) (fuel-syntax--current-vocab))
75 (fuel-completion--read-vocab nil)))
76 (cmd `(:fuel* (,vocab ,fuel-scaffold-developer-name fuel-scaffold-help)
78 (ret (fuel-eval--send/wait cmd))
79 (file (fuel-eval--retort-result ret)))
81 (error "Error creating help file" (car (fuel-eval--retort-error ret))))
85 (provide 'fuel-scaffold)
86 ;;; fuel-scaffold.el ends here