]> git.donarmstrong.com Git - dactyl.git/blob - common/locale/en-US/repeat.xml
f977e0cb24a6453aee2a2b7e650c41addfb0da08
[dactyl.git] / common / locale / en-US / repeat.xml
1 <?xml version="1.0" encoding="UTF-8"?>
2 <?xml-stylesheet type="text/xsl" href="dactyl://content/help.xsl"?>
3
4 <!DOCTYPE document SYSTEM "dactyl://content/dtd">
5
6 <document
7     name="repeat"
8     title="&dactyl.appName; Repeating Commands"
9     xmlns="&xmlns.dactyl;"
10     xmlns:html="&xmlns.html;">
11
12 <h1 tag="repeating">Repeating commands</h1>
13 <toc start="2"/>
14
15 <p>
16     &dactyl.appName; can repeat commands in a number of ways, from repeating
17     the last command, to recording and playing macros, to saving its state and
18     executing scripts.
19 </p>
20
21 <h2 tag="single-repeat">Single repeats</h2>
22
23 <item>
24     <tags>&lt;repeat-key> .</tags>
25     <strut/>
26     <spec><oa>count</oa>.</spec>
27     <description>
28         <p>
29             Repeat the last keyboard mapping <oa>count</oa> times. Note that,
30             unlike in Vim, this also applies to other than editing commands.
31         </p>
32     </description>
33 </item>
34
35 <item>
36     <tags>@:</tags>
37     <strut/>
38     <spec><oa>count</oa>@:</spec>
39     <description>
40         <p>Repeat the last Ex command <oa>count</oa> times.</p>
41     </description>
42 </item>
43
44 <h2 tag="macros complex-repeat">Macros</h2>
45
46 <item>
47     <tags>&lt;record-macro> q</tags>
48     <strut/>
49     <spec>q<a>0-9a-zA-Z</a></spec>
50     <description>
51         <p>
52             Record a key sequence as a macro. Available macros are
53             <a>0-9a-zA-Z</a>. If the macro is an uppercase letter, the
54             recorded keys are appended to the lowercase macro of the same
55             name. Typing <k>q</k> again stops the recording.
56         </p>
57     </description>
58 </item>
59
60 <item>
61     <tags>:macros</tags>
62     <spec>:mac<oa>ros</oa> <oa>pat</oa></spec>
63     <description>
64         <p>
65             List recorded macros matching the optional regular expression
66             <oa>pat</oa>. If no regexp is given, list all macros.
67         </p>
68     </description>
69 </item>
70
71 <item>
72     <tags>:delmac :delmacros</tags>
73     <spec>:delmac<oa>ros</oa> <a>pat</a></spec>
74     <spec>:delmac<oa>ros</oa>!</spec>
75     <description>
76         <p>
77             Delete recorded macros matching the regular expression
78             <a>pat</a>. If <em>!</em> is given, all macros are deleted.
79         </p>
80     </description>
81 </item>
82
83 <item>
84     <tags>&lt;play-macro> @</tags>
85     <spec><oa>count</oa>@<a>a-z0-9</a></spec>
86     <description>
87         <p>
88             Plays the contents of macro with name <a>a-z0-9</a> <oa>count</oa>
89             times.
90         </p>
91     </description>
92 </item>
93
94 <item>
95     <tags>@@</tags>
96     <spec><oa>count</oa>@@</spec>
97     <description short="true">
98         <p>Replay the last executed macro <oa>count</oa> times.</p>
99     </description>
100 </item>
101
102 <h2 tag="macro-utilities">Macro utilities</h2>
103
104 <p>
105     The following key bindings facilitate the recording of efficient
106     macros. They have no effect when typed normally, but are
107     recorded and take effect during macro playback.
108 </p>
109
110 <item>
111     <tags><![CDATA[<sleep> <A-m>s]]></tags>
112     <spec><a>count</a><![CDATA[<A-m>s]]></spec>
113     <description short="true">
114         <p>
115             Sleep for <a>count</a> milliseconds before resuming playback.
116         </p>
117     </description>
118 </item>
119
120 <item>
121     <tags><![CDATA[<wait-for-page-load> <A-m>l]]></tags>
122     <strut/>
123     <spec><oa>count</oa><![CDATA[<A-m>l]]></spec>
124     <description>
125         <p>
126             Wait for the current page to finish loading before resuming
127             playback. If <oa>count</oa> is given, wait no more than
128             <oa>count</oa> seconds. Otherwise wait no more than 25 seconds.
129         </p>
130     </description>
131 </item>
132
133
134 <h2 tag="group groups">Groups</h2>
135
136 <p>
137     In order to facilitate script writing, especially scripts which only
138     apply to certain web sites, many types of commands and mappings can
139     be assigned to a named group. In addition to helping identify the
140     source of such mappings in listings, and aiding in the cleanup of
141     scripts, these groups can be configured to apply only to certain web
142     sites.
143 </p>
144
145 <item>
146     <tags>:gr :group</tags>
147     <spec>:gr<oa>oup</oa></spec>
148     <description>
149         <p>List all active <t>groups</t>.</p>
150     </description>
151 </item>
152
153 <item>
154     <spec>:gr<oa>oup</oa><oa>!</oa> <a>group</a> …</spec>
155     <description>
156         <p>
157             Select, create, or modify a <t>group</t>. After invocation,
158             <a>group</a> becomes the default group for all further commands
159             issued in the current script. If <oa>!</oa> is given the group is
160             cleared of all mappings, commands, and any other entries bound to
161             it before making the specified additions (if any).
162         </p>
163
164         <p>The following <a>group</a> names have special meanings:</p>
165
166         <dl>
167             <dt>builtin</dt> <dd>The default group for builtin items. Can not be modified in any way by scripts.</dd>
168             <dt>default</dt> <dd>The default group for the script containing this <tt>:group</tt> command.</dd>
169             <dt>user</dt> <dd>The default group for the command line and <t>&dactyl.name;rc</t>.</dd>
170         </dl>
171
172         <p>The following arguments are available:</p>
173
174         <dl>
175             <dt>-args=<a>javascript</a></dt> <dd>JavaScript Object which
176                 augments the arguments passed to commands, mappings, and
177                 autocommands, e.g., given <str delim="">{ foo: "bar" }</str>,
178                 <tt>foo</tt> (<tt>&lt;foo></tt> if the Ex syntax is used) will
179                 be replaced by <str delim="">bar</str> inside the definitions
180                 (short name: <em>-a</em>)</dd>
181             <dt>-description</dt> <dd>A description of this group (short names: <em>-desc</em>, <em>-d</em>)</dd>
182             <dt>-locations=<a>filters</a></dt> <dd>The URLs for which this
183                 group should be active. See <t>site-filters</t> (short names:
184                 <em>-locs</em>, <em>-loc</em>, <em>-l</em>)</dd>
185             <dt>-nopersist</dt> <dd>Do not save this group to an auto-generated RC file (short name: <em>-n</em>)</dd>
186         </dl>
187     </description>
188 </item>
189
190 <item>
191     <tags>:delgr :delgroup</tags>
192     <spec>:delgr<oa>oup</oa> <a>group</a></spec>
193     <spec>:delgr<oa>oup</oa>!</spec>
194     <description>
195         <p>
196             Delete the specified <a>group</a>. With <oa>!</oa> delete all
197             user groups.
198         </p>
199     </description>
200 </item>
201
202 <h2 tag="site-filter site-filters">Site Filters</h2>
203
204 <p>
205     Many &dactyl.appName; commands accept filters so that they may be applied
206     only to specific sites. Most of these commands accept filters in any of the
207     following formats:
208 </p>
209
210 <dl>
211     <dt>domain</dt>
212     <dd>
213         Any filter which is a valid domain name will match any site on that
214         domain or any sub-domain thereof. These filters may contain any letter
215         of the Roman alphabet, Arabic numerals, hyphens, and full stops.
216         Non-Latin domain names must be punycode encoded.
217     </dd>
218
219     <dt>URL prefix</dt>
220     <dd>
221         Any URL beginning with a valid protocol name and ending with a
222         <tt>*</tt> is treated as a URL prefix. It will match any URL which
223         begins with the given filter sans the trailing asterisk.
224     </dd>
225
226     <dt>Full URL</dt>
227     <dd>
228         Any URL beginning with a valid protocol name and not ending with an
229         asterisk is treated as a full URL match. It will match any page which
230         has a URL identical to the filter.
231     </dd>
232
233     <dt>Regular expression</dt>
234     <dd>
235         Any filter which does not fall into one of the above categories is
236         treated as a case-sensitive regular expression.
237     </dd>
238 </dl>
239
240 <p>
241     In most cases, any of the above may be prefixed with a <tt>!</tt> character
242     to exclude matching sites.
243 </p>
244
245 <h2 tag="using-scripts">Using scripts</h2>
246
247 <item>
248     <tags>:so :source</tags>
249     <spec>:so<oa>urce</oa><oa>!</oa> <a>file</a></spec>
250     <description>
251         <p>
252             Read Ex commands, JavaScript, or CSS from <a>file</a>. Files are
253             interpreted based on their extensions. Files which end in
254             <em>.js</em> are executed as JavaScript, while those ending in
255             <em>.css</em> are loaded as Cascading Stylesheets, and anything
256             else is interpreted as Ex commands. In normal cases, any errors
257             generated by the execution or non-existence of <a>file</a> are
258             printed to the <t>command-line</t> area.  When <oa>!</oa> is
259             provided, these are suppressed.
260         </p>
261
262         <p>
263             Environment variables in <a>file</a> are expanded to their current
264             value, and the prefix <em>~</em> is replaced with the value of
265             <em>$HOME</em>. See <t>expand-env</t> and <t>initialization</t>
266             for more information.
267         </p>
268
269         <h3 tag=":source-contexts">Script Contexts</h3>
270
271         <p>
272             Each script executes in its own JavaScript context. This means that
273             any global variable or function, including those defined by
274             <ex>:javascript</ex> and the <tt>-javascript</tt> flag of
275             <ex>:map</ex>, <ex>:command</ex>, and <ex>:autocmd</ex>,
276             is directly available only within the current script. Outside of the
277             current script, they can only be accessed as properties of the
278             script's global object, which is stored in the <tt>plugins</tt>
279             global under the script's full path.
280         </p>
281
282         <h3 tag=":source-groups">Script Groups</h3>
283
284         <p>
285             In addition to its own JavaScript context, each script is executed
286             with its own default <link topic="groups">group</link> into which
287             its styles, mappings, commands, and autocommands are placed. This
288             means that commands such as <ex>:delcommand!</ex> can be issued
289             without fear of trampling other user-defined mappings. The command
290             <ex>:group! default</ex> can be issued to clear all such items at
291             once, and should be placed at the head of most scripts to prevent
292             the accumulation of stale items when the script is re-sourced.
293         </p>
294
295         <h3 tag=":source-css">Cascading Stylesheets</h3>
296
297         <p>
298             When a CSS file is sourced, its contents are applied to every web
299             page and every chrome document, including all browser windows and
300             dialogs. If the same file is sourced more than once, its previous
301             rules are cleared before it is applied again. Rules can be
302             restricted to specific documents by enclosing them in
303             <link topic="https://developer.mozilla.org/en/CSS/@-moz-document">@-moz-document</link>
304             blocks.
305         </p>
306
307         <h3 tag=":source-javascript">JavaScript</h3>
308
309         <p>
310             JavaScript files are executed with full chrome privileges in their
311             own global namespaces. These namespaces are stored as objects in
312             the <em>plugins</em> object, in the property named after the full
313             path of the sourced file. This means that any variables or
314             functions created by your script are stored as properties of that
315             object. Additionally, all properties of the global <em>window</em>
316             and <em>modules</em> objects are accessible to your script as
317             global variables.
318         </p>
319
320         <p>
321             Files in <em>~/.&dactyl.name;/plugins</em> may additionally be
322             accessed in <em>plugins.<a>filename</a></em> where <a>filename</a>
323             is the last component of the file's path stripped of any
324             extensions, with all hyphens stripped and any letter following a
325             hyphen capitalized.  So, the file
326             <em>~/.&dactyl.name;/plugins/foo-bar.js</em> may be accessed as
327             <em>plugins.fooBar</em>. See also <t>writing-plugins</t>.
328         </p>
329
330         <h3 tag=":source-ex">Ex commands</h3>
331
332         <p>
333             Ex command files are executed as if each line were entered into
334             the &tag.command-line; individually.
335             Additionally, certain commands support the same ‘here document’
336             syntax supported by most Unix shells and by the &tag.command-line;.
337             So, to execute a JavaScript statement which does not comfortably fit
338             on a single line, you can use:
339         </p>
340
341         <code><ex>:js</ex> &lt;&lt;<em>EOF</em>
342 <kwd><hl key="Object">var</hl></kwd> hello = <kwd>function</kwd> () {
343     alert(<str>Hello world</str>);
344 }
345 <em>EOF</em></code>
346
347         <p>See also <t>ex-scripts</t> below.</p>
348     </description>
349 </item>
350
351
352 <item>
353     <tags>:lpl :loadplugins</tags>
354     <strut/>
355     <spec>:loadplugins[!] <oa>pattern</oa> …</spec>
356     <description>
357         <p>
358             Immediately load all plugins which have yet to be loaded. Because
359             plugins are not automatically loaded until after <tt><t>&dactyl.name;rc</t></tt>
360             is sourced, this command must be placed early in the
361             <tt>&dactyl.name;rc</tt> file if <tt>&dactyl.name;rc</tt> uses commands or options
362             which are defined by plugins. Additionally, this command allows
363             newly installed plugins to be easily loaded without restarting
364             &dactyl.appName;. See also <o>loadplugins</o>.
365         </p>
366         <p>
367             If <oa>pattern</oa>s are provided, the given regular expressions are
368             used as filters rather than those in <o>loadplugins</o>.
369         </p>
370         <p>
371             If <oa>!</oa> is given the plugins are forcibly loaded.
372         </p>
373     </description>
374 </item>
375
376 <item>
377     <tags>:runt :runtime</tags>
378     <spec>:runt<oa>ime</oa><oa>!</oa> <a>file</a> …</spec>
379     <description>
380         <p>
381             Source the specified file from the first directory in
382             <o>runtimepath</o> in which it exists. When <oa>!</oa> is given,
383             source the file from all directories in <o>runtimepath</o> in
384             which it exists.
385         </p>
386         <example><ex>:runtime plugins/foobar.js</ex></example>
387     </description>
388 </item>
389
390 <item>
391     <tags>:scrip :scriptnames</tags>
392     <spec>:scrip<oa>tnames</oa></spec>
393     <description>
394         <p>List all sourced script names, in the order they were first sourced.</p>
395     </description>
396 </item>
397
398 <item>
399     <tags>:fini :finish</tags>
400     <strut/>
401     <spec>:fini<oa>sh</oa></spec>
402     <description>
403         <p>
404             Stop sourcing a script file. This can only be called from within a
405             &dactyl.appName; script file.
406         </p>
407     </description>
408 </item>
409
410 <h3 tag="ex-scripts">Ex Command Scripts</h3>
411
412 <p>
413     Ex command scripts are similar to both entering commands on the
414     &tag.command-line; and to Vim
415     scripts, but with some notable differences.
416 </p>
417
418 <p tag="multiline-commands">
419     Commands in Ex command scripts can span multiple lines by
420     prefixing the second and further lines with a <em>\</em>
421     character. For instance, the following all define commands whose
422     definitions span multiple lines.
423 </p>
424
425 <code><ex>:command!</ex> <str delim="">foo</str>
426         \ <em>-description</em> <str>A command that frobs bars</str>
427         \ <ex>:javascript</ex> frob(content.bar)</code>
428
429 <code><ex>:style</ex> <em>-name</em> <str delim="'">foo</str>
430      \ <str delim="'">foobar.com</str>
431      \ p<str delim="">:first-line</str> { <em>font-variant</em>: <str delim="">small-caps</str>; }
432      \ div<em>#side-bar</em> > <str delim="">:first-child</str> { <em>display</em>: <str delim="">none</str>; }</code>
433
434 <code><ex>:command!</ex> <str delim="">do-some-stuff</str>
435         \ <em>-description</em> <str>A command which does some stuff in JavaScript</str>
436         \ <ex>:javascript</ex> &lt;&lt;<em>EOF</em>
437         \     window.do(<str>some</str>);
438         \     window.do(<str>stuff</str>);
439         \<em>EOF</em></code>
440
441 <code><ex>:command!</ex> <str delim="">do-some-stuff</str>
442         \ <em>-description</em> <str>A command which does some stuff in JavaScript</str>
443         \ <ex>:javascript</ex>
444         \\    window.do(<str>some</str>);
445         \\    window.do(<str>stuff</str>);</code>
446
447 <p tag="comments">
448     Lines may be commented out by prefixing them with a <em>"</em>
449     character. Comments and commands cannot both occur in a single command
450     line.
451 </p>
452
453 <code>            <hl style="color: #444">" This is a comment</hl>
454     foo bar " This is a syntax error
455             <str> This is not a comment</str>
456     foo bar <str> This is not a comment</str>
457 </code>
458
459 <h2 tag="profile profiling">Profiling</h2>
460
461 <item>
462     <tags>:time</tags>
463     <spec>:<oa>count</oa>time<oa>!</oa> <a>code|:command</a></spec>
464     <description>
465         <p>
466             Profile a piece of JavaScript code or an Ex command. Run
467             <a>code</a> <oa>count</oa> times and print the elapsed time.
468             If <a>code</a> begins with a <ex>:</ex>, it is executed as an Ex
469             command. Otherwise, it is executed as JavaScript, in which case it
470             is evaluated only once and stored as a function which is executed
471             <oa>count</oa> times.
472         </p>
473
474         <p>
475             When <oa>!</oa> is given, <a>code</a> is executed <oa>count</oa>
476             times, but no statistics are printed.
477         </p>
478     </description>
479 </item>
480
481 </document>
482
483 <!-- vim:se sts=4 sw=4 et: -->