blob: 2524c0b1d4c4909d07db6ae297c45e2a630ac69e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="chrome://liberator/content/help.xsl"?>
<!DOCTYPE document SYSTEM "chrome://liberator/content/liberator.dtd">
<document
name="autocommands"
title="&liberator.appname; Autocommands"
xmlns="http://vimperator.org/namespaces/liberator"
xmlns:html="http://www.w3.org/1999/xhtml">
<h2 tag="autocommands">Automatic commands</h2>
<p>
Autocommands are a way to automatically execute code when
certain events happen.
</p>
<item>
<tags>:au :autocmd</tags>
<spec>:au[tocmd]</spec>
<description>
<p>Execute commands automatically on events.</p>
<p><ex>:au[tocmd]</ex> <a>event</a> <a>pat</a> <a>cmd</a></p>
<p>
If the <em>-javascript</em> (short name <em>-js</em>)
option is specified, <a>cmd</a> is executed as JavaScript
code, with any supplied arguments available as
variables.
</p>
<p>Add <a>cmd</a> to the list of commands Vimperator will execute on <a>event</a> for a URL matching <a>pat</a>:</p>
<ul>
<li><ex>:autocmd[!]</ex> <a>events</a> <a>pat</a>: list/remove autocommands filtered by <a>events</a> and <a>pat</a></li>
<li><ex>:autocmd[!]</ex> <a>events</a>: list/remove autocommands matching <a>events</a></li>
<li><ex>:autocmd[!]</ex> <a>pat</a>: list/remove autocommands matching <a>pat</a></li>
<li><ex>:autocmd[!]</ex>: list/remove all autocommands</li>
</ul>
<p>Available <a>events</a>:</p>
<dl>
<dt>BookmarkAdd</dt> <dd>Triggered after a page is bookmarked</dd>
<dt>ColorScheme</dt> <dd>Triggered after a color scheme has been loaded</dd>
<dt>DOMLoad</dt> <dd>Triggered when a page's DOM content has fully loaded</dd>
<dt>DownloadPost</dt> <dd>Triggered when a download has completed</dd>
<dt>Fullscreen</dt> <dd>Triggered when the browser's fullscreen state changes</dd>
<dt>LocationChange</dt> <dd>Triggered when changing tabs or when navigating to a new location</dd>
<dt>PageLoadPre</dt> <dd>Triggered after a page load is initiated</dd>
<dt>PageLoad</dt> <dd>Triggered when a page gets (re)loaded/opened</dd>
<dt>PrivateMode</dt> <dd>Triggered when private mode is activated or deactivated</dd>
<dt>Sanitize</dt> <dd>Triggered when privata data are sanitized</dd>
<dt>ShellCmdPost</dt> <dd>Triggered after executing a shell command with <ex>:!</ex><a>cmd</a></dd>
<dt>VimperatorEnter</dt> <dd>Triggered after Firefox starts</dd>
<dt>VimperatorLeavePre</dt><dd>Triggered before exiting Firefox, just before destroying each module</dd>
<dt>VimperatorLeave</dt> <dd>Triggered before exiting Firefox</dd>
</dl>
<p><a>pat</a> is a regular expression, use .* if you want to match all URLs.</p>
<note>This differs from Vim which uses a glob rather than a regex for <a>pat</a>.</note>
<p>The following keywords are available where relevant:</p>
<dl>
<dt><url></dt> <dd>The URL against which the event was selected.</dd>
<dt><title></dt> <dd>The page, bookmark or download title.</dd>
<dt><doc></dt> <dd>The document for which the event occurred. Only for <em>DOMLoad</em>, <em>PageLoad</em> and <em>PageLoadPre</em>.</dd>
<dt><tab></dt> <dd>The tab in which the event occurred. Only for <em>DOMLoad</em>, <em>PageLoad</em> and <em>PageLoadPre</em>.</dd>
<dt><tags></dt> <dd>The tags applied to <url>. Only for <em>BookmarkAdd</em>.</dd>
<dt><keyword></dt> <dd>The keywords applied to the bookmark. Only for <em>BookmarkAdd</em>.</dd>
<dt><icon></dt> <dd>The icon associated with <url>. Only for <em>BookmarkAdd</em>.</dd>
<dt><size></dt> <dd>The size of a downloaded file. Only for <em>DownloadPost</em>.</dd>
<dt><file></dt> <dd>The target destination of a download. Only for <em>DownloadPost</em>.</dd>
<dt><state></dt> <dd>The new state. Only for "Fullscreen" and <em>PrivateMode</em>.</dd>
<dt><name></dt> <dd>The name of the item. Only for <em>ColorScheme</em> and <em>Sanitize</em>.</dd>
</dl>
</description>
</item>
<item>
<tags>:doautoa :doautoall</tags>
<spec>:doautoa[ll] <a>event</a> <oa>url</oa></spec>
<description>
<p>
Apply the autocommands matching the specified URL to all buffers. If no
<oa>url</oa> is specified use the current URL.
</p>
</description>
</item>
<item>
<tags>:do :doautocmd</tags>
<spec>:do[autocmd] <a>event</a> <oa>url</oa></spec>
<description>
<p>
Apply the autocommands matching the specified URL to the current buffer. If no
<oa>url</oa> is specified use the current URL.
</p>
</description>
</item>
<h2 tag="autocmd-examples">Examples</h2>
<p>Enable <em>passthrough</em> mode on all Google sites:</p>
<p>
<ex>:autocmd LocationChange .* js modes.passAllKeys = /google\.com/.test(buffer.URL)</ex>
</p>
<p>Enable <em>passthrough</em> mode on *some* Google sites:</p>
<p>
<ex>:autocmd LocationChange .* js modes.passAllKeys = /(www|mail)\.google\.com/.test(buffer.URL)</ex>
</p>
<p>
Set the filetype to mail when editing email at Gmail:
</p>
<p>
<ex>:autocmd LocationChange .* :set editor=<str>gvim -f</str></ex>
</p>
<p>
<ex>:autocmd LocationChange mail\\.google\\.com :set editor=<str>gvim -f -c 'set ft=mail'</str></ex>
</p>
</document>
<!-- vim:se sts=4 sw=4 et: -->
|