Use windows-1252 encoding for stdin/stdout on Windows
[factor/jcg.git] / misc / fuel / fuel-scaffold.el
blob05d825593c56612b40fcdd669613111f803ea019
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
10 ;;; Comentary:
12 ;; Utilities for creating new vocabulary files and other boilerplate.
13 ;; Mainly, an interface to Factor's tools.scaffold.
15 ;;; Code:
17 (require 'fuel-eval)
18 (require 'fuel-edit)
19 (require 'fuel-syntax)
20 (require 'fuel-base)
23 ;;; Customisation:
25 (defgroup fuel-scaffold nil
26 "Options for FUEL's scaffolding."
27 :group 'fuel)
29 (defcustom fuel-scaffold-developer-name user-full-name
30 "The name to be inserted as yours in scaffold templates."
31 :type 'string
32 :group 'fuel-scaffold)
35 ;;; Auxiliary functions:
37 (defun fuel-scaffold--vocab-roots ()
38 (let ((cmd '(:fuel* (vocab-roots get :get) "fuel")))
39 (fuel-eval--retort-result (fuel-eval--send/wait cmd))))
42 ;;; User interface:
44 (defun fuel-scaffold-vocab (&optional other-window name-hint root-hint)
45 "Creates a directory in the given root for a new vocabulary and
46 adds source, tests and authors.txt files.
48 You can configure `fuel-scaffold-developer-name' (set by default to
49 `user-full-name') for the name to be inserted in the generated files."
50 (interactive)
51 (let* ((name (read-string "Vocab name: " name-hint))
52 (root (completing-read "Vocab root: "
53 (fuel-scaffold--vocab-roots)
54 nil t (or root-hint "resource:")))
55 (cmd `(:fuel* ((,root ,name ,fuel-scaffold-developer-name)
56 (fuel-scaffold-vocab)) "fuel"))
57 (ret (fuel-eval--send/wait cmd))
58 (file (fuel-eval--retort-result ret)))
59 (unless file
60 (error "Error creating vocab (%s)" (car (fuel-eval--retort-error ret))))
61 (if other-window (find-file-other-window file) (find-file file))
62 (goto-char (point-max))
63 name))
65 (defun fuel-scaffold-help (&optional arg)
66 "Creates, if it does not already exist, a help file with
67 scaffolded help for each word in the current vocabulary.
69 With prefix argument, ask for the vocabulary name.
70 You can configure `fuel-scaffold-developer-name' (set by default to
71 `user-full-name') for the name to be inserted in the generated file."
72 (interactive "P")
73 (let* ((vocab (or (and (not arg) (fuel-syntax--current-vocab))
74 (fuel-edit--read-vocabulary-name nil)))
75 (cmd `(:fuel* (,vocab ,fuel-scaffold-developer-name fuel-scaffold-help)
76 "fuel"))
77 (ret (fuel-eval--send/wait cmd))
78 (file (fuel-eval--retort-result ret)))
79 (unless file
80 (error "Error creating help file" (car (fuel-eval--retort-error ret))))
81 (find-file file)))
84 (provide 'fuel-scaffold)
85 ;;; fuel-scaffold.el ends here