kakoune/doc/pages/scopes.asciidoc

72 lines
2.2 KiB
Plaintext
Raw Normal View History

= Scopes
== Description
Scopes are groups in which a particular Kakoune object can have different
values depending on the group the value was declared in.
These scoped objects are:
- aliases (See <<commands#, `:doc commands`>>)
- faces (See <<faces#, `:doc faces`>>)
- highlighters (See <<highlighters#, `:doc highlighters`>>)
- hooks (See <<hooks#, `:doc hooks`>>)
- keymaps (See <<mapping#, `:doc mapping`>>)
- options (See <<options#, `:doc options`>>)
== Names and hierarchy
Scopes are named as follows:
*window*::
2017-11-02 10:37:39 +01:00
context linked to the window displaying a buffer
*buffer*::
2017-11-02 10:37:39 +01:00
context linked directly to the buffer
*global*::
2017-11-02 10:37:39 +01:00
global context linked to the instance of Kakoune
The following order of priority applies to the above scopes:
--------------------------
window ]> buffer ]> global
--------------------------
The above priority line implies that objects can have individual values that
will be resolved first in the *window* scope (highest priority), then in
the *buffer* scope, and finally in the *global* scope (lowest priority).
The `set-option` and `unset-option` commands also accept *current* as
a valid scope name. It refers to the narrowest scope the option is set in.
== Uses
The scope paradigm is very useful as it allows the user to customize the
behavior of the editor without modifying the configuration globally, as
is the case with other editors who only have a single *global* scope by
default.
Examples:
*filetype*::
2017-11-02 10:37:39 +01:00
A single buffer opened in two separate windows can have different
2017-11-06 10:08:59 +01:00
filetypes declared in the *window* scope with 'set'.
(See <<options#,`:doc options`>>)
*status line*::
2017-11-02 10:37:39 +01:00
All the buffers of the current session can have the same information
displayed in the status line, except for a specific buffer (the
'modelinefmt' option can be declared in the *global* scope, and
2017-11-06 10:08:59 +01:00
customized in the *buffer* scope with 'set'.
(See <<options#,`:doc options`>>)
== Execution context
Some commands work in a specific context that might exclude one or
several scopes altogether, consequently ignoring some values of a given
object.
Example: the *window* scope is never considered when resolving the
values of options when writing a buffer (e.g. 'BOM', 'eolformat').