]> gitweb.factorcode.org Git - factor.git/blob - misc/fuel/README.md
0f9a0a92943f2d78cefead9a60a79c6be9ac17bb
[factor.git] / misc / fuel / README.md
1 FUEL, Factor's Ultimate Emacs Library
2 -------------------------------------
3
4 FUEL provides a complete environment for your Factor coding pleasure
5 inside Emacs, including source code edition and interaction with a
6 Factor listener instance running within Emacs.
7
8 FUEL was started by Jose A Ortega as an extension to Eduardo Cavazos'
9 original factor.el code. Eduardo is also responsible of naming the
10 beast.
11
12 # Installation
13
14 FUEL can be installed from [MELPA](http://melpa.milkbox.net/).
15
16 Alternatively, FUEL comes bundled with Factor's distribution.
17 The folder misc/fuel can be added to your load path:
18
19     (add-to-list 'load-path "<path/to/factor/installation>/misc/fuel")
20
21 The factor-mode major mode provides basic fontification and indentation
22 without connecting to a running Factor image:
23
24     (require 'factor-mode)
25
26 The fuel-mode minor mode provides interaction with a running Factor instance:
27
28     (require 'fuel-mode)
29
30 To use FUEL, you must set `fuel-factor-root-dir` to the root directory
31 of your Factor installation:
32
33     (setq fuel-factor-root-dir "<path/to/factor/installation>")
34
35 # Basic usage
36 ## Running the listener
37
38 If you're using the default Factor binary and images locations inside
39 the Factor's source tree, that should be enough to start using FUEL.
40 Editing any file with the extension `.factor` will put you in
41 factor-mode; try `C-hm` for a summary of available commands.
42
43 To start the listener, try `M-x run-factor`.
44
45 By default, FUEL will try to use the binary and image files in the
46 factor installation directory. You can customize them with:
47
48     (setq fuel-listener-factor-binary <full path to factor>)
49     (setq fuel-listener-factor-image <full path to factor image>)
50
51 Many aspects of the environment can be customized:
52 `M-x customize-group fuel` will show you how many.
53
54 ### Faster listener startup
55
56 On startup, `run-factor` loads the fuel vocabulary, which can take a
57 while. If you want to speedup the load process, type `save` in the
58 listener prompt just after invoking `run-factor`. This will save a
59 Factor image (overwriting the current one) with all the needed
60 vocabs.
61
62 Alternatively, you can add the following line to your
63 `.factor-boot-rc` file:
64
65     "fuel" require
66
67 This will ensure that the image generated while bootstrapping
68 Factor contains fuel and the vocabularies it depends on.
69
70 ### Connecting to a running Factor
71
72 `run-factor` starts a new factor listener process managed by Emacs.
73 If you prefer to start Factor externally, you can also connect
74 remotely from Emacs. Here's how to proceed:
75
76 - In the factor listener, run `"fuel.remote" run`. This will start a server
77 listener in port 9000.
78 - Switch to Emacs and issue the command `M-x connect-to-factor`.
79
80 That's it; you should be up and running. See the help for
81 `connect-to-factor` for how to use a different port.
82
83 ### Vocabulary creation
84
85 FUEL offers a basic interface to Factor's scaffolding utilities.
86 To create a new vocabulary directory and associated files:
87
88     M-x fuel-scaffold-vocab
89
90 and when in a vocab file, to create a docs file with boilerplate
91 for each word:
92
93     M-x fuel-scaffold-help
94
95 # Quick key reference
96
97   Triple chords ending in a single letter <x> accept also C-<x> (e.g.
98   C-c C-e C-r is the same as C-c C-e r).
99
100 ### In factor source files:
101
102 Commands in parenthesis can be invoked interactively with
103 M-x <command>, not necessarily in a factor buffer.
104
105     |--------------------+------------------------------------------------------------|
106     | C-c C-z            | switch to listener (run-factor)                            |
107     | C-c C-o            | cycle between code, tests and docs files                   |
108     | C-c C-t            | run the unit tests for a vocabulary                        |
109     | C-c C-r            | switch to listener and refresh all loaded vocabs           |
110     | C-c C-s            | switch to other factor buffer (fuel-switch-to-buffer)      |
111     | C-x 4 s            | switch to other factor buffer in other window              |
112     | C-x 5 s            | switch to other factor buffer in other frame               |
113     |--------------------+------------------------------------------------------------|
114     | M-.                | edit word at point in Emacs (fuel-edit-word)               |
115     | M-,                | go back to where M-. was last invoked                      |
116     | M-TAB              | complete word at point                                     |
117     | C-c C-e u          | update USING: line (fuel-update-usings)                    |
118     | C-c C-e v          | edit vocabulary (fuel-edit-vocabulary)                     |
119     | C-c C-e w          | edit word (fuel-edit-word-at-point)                        |
120     | C-c C-e d          | edit word's doc (C-u M-x fuel-edit-word-doc-at-point)      |
121     | C-c C-e l          | load vocabs in USING: form                                 |
122     |--------------------+------------------------------------------------------------|
123     | C-c C-e r          | eval region                                                |
124     | C-M-r, C-c C-e e   | eval region, extending it to definition boundaries         |
125     | C-M-x, C-c C-e x   | eval definition around point                               |
126     | C-c C-k, C-c C-e k | run file (fuel-run-file)                                   |
127     |--------------------+------------------------------------------------------------|
128     | C-c C-d a          | toggle autodoc mode (fuel-autodoc-mode)                    |
129     | C-c C-d d          | help for word at point (fuel-help)                         |
130     | C-c C-d e          | show stack effect of current sexp (with prefix, region)    |
131     | C-c C-d p          | find words containing given substring (fuel-apropos)       |
132     | C-c C-d v          | show words in current file (with prefix, ask for vocab)    |
133     |--------------------+------------------------------------------------------------|
134     | C-c M-<            | show callers of word or vocabulary at point                |
135     |                    | (fuel-show-callers, fuel-vocab-usage)                      |
136     | C-c M->            | show callees of word or vocabulary at point                |
137     |                    | (fuel-show-callees, fuel-vocab-uses)                       |
138     |--------------------+------------------------------------------------------------|
139     | C-c C-x s          | extract innermost sexp (up to point) as a separate word    |
140     |                    | (fuel-refactor-extract-sexp)                               |
141     | C-c C-x r          | extract region as a separate word                          |
142     |                    | (fuel-refactor-extract-region)                             |
143     | C-c C-x v          | extract region as a separate vocabulary                    |
144     |                    | (fuel-refactor-extract-vocab)                              |
145     | C-c C-x i          | replace word by its definition (fuel-refactor-inline-word) |
146     | C-c C-x w          | rename all uses of a word (fuel-refactor-rename-word)      |
147     | C-c C-x a          | extract region as a separate ARTICLE: form                 |
148     | C-c C-x g          | convert current word definition into GENERIC + method      |
149     |                    | (fuel-refactor-make-generic)                               |
150     |--------------------+------------------------------------------------------------|
151
152 ### In the listener:
153
154     |---------+----------------------------------------------------------|
155     | TAB     | complete word at point                                   |
156     | M-.     | edit word at point in Emacs                              |
157     | C-c C-r | refresh all loaded vocabs                                |
158     | C-c C-a | toggle autodoc mode                                      |
159     | C-c C-p | find words containing given substring (M-x fuel-apropos) |
160     | C-c C-s | toggle stack mode                                        |
161     | C-c C-v | edit vocabulary                                          |
162     | C-c C-w | help for word at point                                   |
163     | C-c C-k | run file                                                 |
164     |---------+----------------------------------------------------------|
165
166 ### In the debugger (it pops up upon eval/compilation errors):
167
168     |---------+-------------------------------------|
169     | g       | go to error                         |
170     | <digit> | invoke nth restart                  |
171     | w/e/l   | invoke :warnings, :errors, :linkage |
172     | q       | bury buffer                         |
173     |---------+-------------------------------------|
174
175 ### In the help browser:
176
177     |-----------+----------------------------------------------------------|
178     | h         | help for word at point                                   |
179     | v         | help for a vocabulary                                    |
180     | a         | find words containing given substring (M-x fuel-apropos) |
181     | e         | edit current article                                     |
182     | b a       | bookmark current page                                    |
183     | b b       | display bookmarks                                        |
184     | b d       | delete bookmark at point                                 |
185     | n/p       | next/previous page                                       |
186     | l         | previous page                                            |
187     | SPC/S-SPC | scroll up/down                                           |
188     | TAB/S-TAB | next/previous link                                       |
189     | k         | kill current page and go to previous or next             |
190     | r         | refresh page                                             |
191     | c         | clean browsing history                                   |
192     | M-.       | edit word at point in Emacs                              |
193     | C-c C-z   | switch to listener                                       |
194     | q         | bury buffer                                              |
195     |-----------+----------------------------------------------------------|
196
197 ### In crossref buffers
198
199     |-----------------+-----------------------------|
200     | TAB/BACKTAB     | navigate links              |
201     | RET/mouse click | follow link                 |
202     | h               | show help for word at point |
203     | q               | bury buffer                 |
204     |-----------------+-----------------------------|