summaryrefslogtreecommitdiffstats
path: root/runtime
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-06-15 17:12:48 +0200
committerBram Moolenaar <Bram@vim.org>2019-06-15 17:12:48 +0200
commitd7c968794710f338d491072171df48f96612cf72 (patch)
treed5edca7e09283ff5c345d8e113a10829a70412a2 /runtime
parentbffc50494d52a3690cbbc5c7b34a835f9153184e (diff)
patch 8.1.1542: an OptionSet autocommand does not get enough infov8.1.1542
Problem: An OptionSet autocommand does not get enough info. Solution: Add v:option_command, v:option_oldlocal and v:option_oldglobal. (Latrice Wilgus, closes #4118)
Diffstat (limited to 'runtime')
-rw-r--r--runtime/doc/autocmd.txt38
-rw-r--r--runtime/doc/eval.txt21
-rw-r--r--runtime/doc/version8.txt3
3 files changed, 51 insertions, 11 deletions
diff --git a/runtime/doc/autocmd.txt b/runtime/doc/autocmd.txt
index c82669514a..c922df18ac 100644
--- a/runtime/doc/autocmd.txt
+++ b/runtime/doc/autocmd.txt
@@ -1,4 +1,4 @@
-*autocmd.txt* For Vim version 8.1. Last change: 2019 Jun 02
+*autocmd.txt* For Vim version 8.1. Last change: 2019 Jun 15
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -873,15 +873,33 @@ MenuPopup Just before showing the popup menu (under the
*OptionSet*
OptionSet After setting an option. The pattern is
matched against the long option name.
- The |v:option_old| variable indicates the
- old option value, |v:option_new| variable
- indicates the newly set value, the
- |v:option_type| variable indicates whether
- it's global or local scoped and |<amatch>|
- indicates what option has been set.
-
- Is not triggered on startup and for the 'key'
- option for obvious reasons.
+ |<amatch>| indicates what option has been set.
+
+ |v:option_type| indicates whether it's global
+ or local scoped
+ |v:option_command| indicates what type of
+ set/let command was used (follow the tag to
+ see the table).
+ |v:option_new| indicates the newly set value.
+ |v:option_oldlocal| hass the old local value.
+ |v:option_oldglobal| hass the old global
+ value
+ |v:option_old| indicates the old option value.
+
+ |v:option_oldlocal| is only set when |:set|
+ or |:setlocal| or a |modeline| was used to set
+ the option. Similarly |v:option_oldglobal| is
+ only set when |:set| or |:setglobal| was used.
+
+ Note that when setting a |global-local| string
+ option with |:set|, then |v:option_old| is the
+ old global value. However, for all other kinds
+ of options (local string options, global-local
+ number options, ...) it is the old local
+ value.
+
+ OptionSet is not triggered on startup and for
+ the 'key' option for obvious reasons.
Usage example: Check for the existence of the
directory in the 'backupdir' and 'undodir'
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
index ca3f4ca065..83a89957f2 100644
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -1943,10 +1943,29 @@ v:option_new New value of the option. Valid while executing an |OptionSet|
autocommand.
*v:option_old*
v:option_old Old value of the option. Valid while executing an |OptionSet|
- autocommand.
+ autocommand. Depending on the command used for setting and the
+ kind of option this is either the local old value or the
+ global old value.
+ *v:option_oldlocal*
+v:option_oldlocal
+ Old local value of the option. Valid while executing an
+ |OptionSet| autocommand.
+ *v:option_oldglobal*
+v:option_oldglobal
+ Old global value of the option. Valid while executing an
+ |OptionSet| autocommand.
*v:option_type*
v:option_type Scope of the set command. Valid while executing an
|OptionSet| autocommand. Can be either "global" or "local"
+ *v:option_command*
+v:option_command
+ Command used to set the option. Valid while executing an
+ |OptionSet| autocommand.
+ value option was set via ~
+ "setlocal" |:setlocal| or ":let l:xxx"
+ "setglobal" |:setglobal| or ":let g:xxx"
+ "set" |:set| or |:let|
+ "modeline" |modeline|
*v:operator* *operator-variable*
v:operator The last operator given in Normal mode. This is a single
character except for commands starting with <g> or <z>,
diff --git a/runtime/doc/version8.txt b/runtime/doc/version8.txt
index 1dcef7efed..73db5f05b4 100644
--- a/runtime/doc/version8.txt
+++ b/runtime/doc/version8.txt
@@ -336,7 +336,10 @@ New Vim variables: ~
|v:null| an empty String, used for JSON
|v:option_new| new value of the option, used by |OptionSet|
|v:option_old| old value of the option, used by |OptionSet|
+|v:option_oldlocal| old local value of the option, used by |OptionSet|
+|v:option_oldglobal| old global value of the option, used by |OptionSet|
|v:option_type| scope of the set command, used by |OptionSet|
+|v:option_command| command used to set the option, used by |OptionSet|
|v:progpath| the command with which Vim was invoked
|v:t_bool| value of Boolean type
|v:t_channel| value of Channel type