Expression evaluation

Much of the power of &dactyl.appName; lies in its scriptable expression evaluation. &dactyl.appName; understands two kinds of expressions: ex commands, and JavaScript. Ex commands are simple, easy to type, and readily accessible from the command-line. They form a core part of the user interface. JavaScript, on the other hand, is much less straightforward, but allows for any number of complex actions to be executed, with full access to all of the internals of &dactyl.appName; and &dactyl.host;. Both expression evaluation methods support sophisticated expression completion, including option lists and descriptions thereof, along with paren matching and syntax error highlighting.

:ec :echo :echo expr

Echo a JavaScript expression. expr may be a simple quoted string, in which case it is shown in the statusline, or any arbitrary JavaScript expression. If the expression results in anything other than a string, it is pretty-printed in a multiline frame just above the command-line. The output depends on the type of object. Functions display their source, DOM nodes display the pretty-printed XML of the top-level node, XML literals are rendered as page content, and all other objects display their string representation and all of their enumerable properties.

See also :javascript

:echoe :echoerr :echoerr expr

Echo the expression as an error message. Just like :echo but echoes the result highlighted as ErrorMsg and saves it to the message history.

:echom :echomsg :echomsg expr

Echo the expression as an informational message. Just like :echo but also saves the message in the message history.

:exe :execute :execute expr

Execute the ex command string that results from the evaluation of the JavaScript expression expr. For example,

:execute "open " + content.location.host

opens the homepage of the currently opened site.

Unlike Vim this only supports a single argument.
:js :javas :javascript :javascript cmd :javascript <<endpattern\ncmd\nendpattern :javascript!

Evaluates the given cmd as JavaScript. Behaves exactly as :echo, except that the result is not printed. Any exception raised by the evaluation will, however, be displayed as an error message and appended to :messages.

:javascript alert(Hello world) will open a dialog window with the message Hello world.

Moreover, multiline scripts can be executed with shell-like here document syntax. For example, the following,

:javascript <<EOF for each (var tab in tabs.visibleTabs) tab.linkedBrowser.reload(); EOF

will reload all visible tabs.

Moreover, sophisticated, context-sensitive completion is available for JavaScript code, which extends to property names, object keys, and programmable completion for string function arguments. The completion code is designed to be both as safe and as powerful as possible. Expressions in a given command-line session will only be evaluated once, and, with autocompletion turned on, any completion which requires a function to be executed requires an explicit press to commence.

The special version :javascript! opens the JavaScript console of &dactyl.host;.

:let :let var-name [+-.]= expr1 :let var-name :let

Sets or lists a variable. Sets the variable var-name to the value of the expression expr1. If no expression is given, the value of the variable is displayed. Without arguments, displays a list of all variables. This functionality has few useful applications and so is deprecated.

:unl :unlet :unlet! name

Deletes the named variables. When ! is given, no error message is output for non-existing variables.