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 user-full-name
30 "The name to be inserted as yours in scaffold templates."
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
))))
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."
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
)))
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))
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."
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
)
77 (ret (fuel-eval--send/wait cmd
))
78 (file (fuel-eval--retort-result ret
)))
80 (error "Error creating help file" (car (fuel-eval--retort-error ret
))))
84 (provide 'fuel-scaffold
)
85 ;;; fuel-scaffold.el ends here