Pentadactyl can repeat commands in a number of ways, from repeating the last command, to recording and playing macros, to saving its state and executing scripts.
Repeat the last keyboard mapping [count] times. Note that, unlike in Vim, this does not apply solely to editing commands, mainly because Pentadactyl doesn't have them.
Record a key sequence as a macro. Available macros are {0-9a-zA-Z}. If the macro is an uppercase letter, the recorded keys are appended to the lowercase macro of the same name. Typing q again stops the recording.
List recorded macros matching the optional regular expression [pat]. If no regexp is given, list all macros.
Delete recorded macros matching the regular expression {pat}. If ! is given, all macros are deleted.
The following key bindings facilitate the recording of efficient macros. They have no effect when typed normally, but are recorded and take effect during macro playback.
Wait for the current page to finish loading before resuming playback. If [count] is given, wait no more than [count] seconds. Otherwise wait no more than 25 seconds.
In order to facilitate script writing, especially scripts which only apply to certain web sites, many types of commands and mappings can be assigned to a named group. In addition to helping identify the source of such mappings in listings, and aiding in the cleanup of scripts, these groups can be configured to apply only to certain web sites.
Select, create, or modify a group. After invocation, {group} becomes the default group for all further commands issued in the current script. If [!] is given the group is cleared of all mappings, commands, and any other entries bound to it before making the specified additions (if any).
The following {group} names have special meanings:
The following arguments are available:
Delete the specified {group}. With [!] delete all user groups.
Many Pentadactyl commands accept filters so that they may be applied only to specific sites. Most of these commands accept filters in any of the following formats:
In most cases, any of the above may be prefixed with a ! character to exclude matching sites.
Read Ex commands, JavaScript, or CSS from {file}. Files are interpreted based on their extensions. Files which end in .js are executed as JavaScript, while those ending in .css are loaded as Cascading Stylesheets, and anything else is interpreted as Ex commands. In normal cases, any errors generated by the execution or non-existence of {file} are printed to the command-line area. When [!] is provided, these are suppressed.
Environment variables in {file} are expanded to their current value, and the prefix ~ is replaced with the value of $HOME. See expand-env and initialization for more information.
Each script executes in its own JavaScript context. This means that any global variable or function, including those defined by :javascript and the -javascript flag of :map, :command, and :autocmd, is directly available only within the current script. Outside of the current script, they can only be accessed as properties of the script's global object, which is stored in the plugins global under the script's full path.
In addition to its own JavaScript context, each script is executed with its own default group into which its styles, mappings, commands, and autocommands are placed. This means that commands such as :delcommand! can be issued without fear of trampling other user-defined mappings. The command :group! default can be issued to clear all such items at once, and should be placed at the head of most scripts to prevent the accumulation of stale items when the script is re-sourced.
When a CSS file is sourced, its contents are applied to every web page and every chrome document, including all browser windows and dialogs. If the same file is sourced more than once, its previous rules are cleared before it is applied again. Rules can be restricted to specific documents by enclosing them in @-moz-document blocks.
JavaScript files are executed with full chrome privileges in their own global namespaces. These namespaces are stored as objects in the plugins object, in the property named after the full path of the sourced file. This means that any variables or functions created by your script are stored as properties of that object. Additionally, all properties of the global window and modules objects are accessible to your script as global variables.
Files in ~/.pentadactyl/plugins may additionally be accessed in plugins.{filename} where {filename} is the last component of the file's path stripped of any extensions, with all hyphens stripped and any letter following a hyphen capitalized. So, the file ~/.pentadactyl/plugins/foo-bar.js may be accessed as plugins.fooBar. See also writing-plugins.
Ex command files are executed as if each line were entered into the command line individually. Additionally, certain commands support the same ‘here document’ syntax supported by most Unix shells and by the command line. So, to execute a JavaScript statement which does not comfortably fit on a single line, you can use:
:js <<EOF var hello = function () { alert(Hello world); } EOF
See also ex-scripts below.
Immediately load all plugins which have yet to be loaded. Because plugins are not automatically loaded until after pentadactylrc is sourced, this command must be placed early in the pentadactylrc file if pentadactylrc uses commands or options which are defined by plugins. Additionally, this command allows newly installed plugins to be easily loaded without restarting Pentadactyl. See also 'loadplugins'.
If [pattern]s are provided, the given regular expressions are used as filters rather than those in 'loadplugins'.
Source the specified file from the first directory in 'runtimepath' in which it exists. When [!] is given, source the file from all directories in 'runtimepath' in which it exists.
List all sourced script names, in the order they were first sourced.
Stop sourcing a script file. This can only be called from within a Pentadactyl script file.
Ex command scripts are similar to both entering commands on the command line and to Vim scripts, but with some notable differences.
Commands in Ex command scripts can span multiple lines by prefixing the second and further lines with a \ character. For instance, the following all define commands whose definitions span multiple lines.:command! foo \ -description A command that frobs bars \ :javascript frob(content.bar)
:style -name foo \ foobar.com \ p:first-line { font-variant: small-caps; } \ div#side-bar > :first-child { display: none; }
:command! do-some-stuff \ -description A command which does some stuff in JavaScript \ :javascript <<EOF \ window.do(some); \ window.do(stuff); \EOF
:command! do-some-stuff \ -description A command which does some stuff in JavaScript \ :javascript \\ window.do(some); \\ window.do(stuff);Lines may be commented out by prefixing them with a " character. Comments and commands cannot both occur in a single command line.
" This is a comment foo bar " This is a syntax error This is not a comment foo bar This is not a comment
Profile a piece of JavaScript code or an Ex command. Run {code} [count] times and print the elapsed time. If {code} begins with a :, it is executed as an Ex command. Otherwise, it is executed as JavaScript, in which case it is evaluated only once and stored as a function which is executed [count] times.
When [!] is given, {code} is executed [count] times, but no statistics are printed.