From 1c90c19f62f97354f5b7c57ad131d4501c639ec0 Mon Sep 17 00:00:00 2001 From: rhysd Date: Sun, 23 Jun 2019 19:25:19 +0900 Subject: vim-patch:8.1.1539: not easy to define a variable and lock it Problem: Not easy to define a variable and lock it. Solution: Add ":const". https://github.com/vim/vim/commit/9937a055437ef67b57a1bdec8f0799b669c9dbf0 --- runtime/doc/eval.txt | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 4eaa72ee68..6649bebedb 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -9629,8 +9629,31 @@ This does NOT work: > No error message is given for a non-existing variable, also without !. If the system does not support deleting an environment - variable, it is made emtpy. - + variable, it is made empty. + + *:cons* *:const* *E996* +:cons[t] {var-name} = {expr1} +:cons[t] [{name1}, {name2}, ...] = {expr1} +:cons[t] [{name1}, {name2}, ...] .= {expr1} +:cons[t] [{name}, ..., ; {lastname}] = {expr1} +:cons[t] {var-name} =<< [trim] {marker} +text... +text... +{marker} + Similar to |:let|, but additionally lock the variable + after setting the value. This is the same as locking + the variable with |:lockvar| just after |:let|, thus: > + :const x = 1 +< is equivalent to: > + :let x = 1 + :lockvar 1 x +< This is useful if you want to make sure the variable + is not modified. + *E995* + |:const| does not allow to for changing a variable. > + :let x = 1 + :const x = 2 " Error! +< :lockv[ar][!] [depth] {name} ... *:lockvar* *:lockv* Lock the internal variable {name}. Locking means that it can no longer be changed (until it is unlocked). -- cgit From 3d5a800278aacce3cf332e2e416975905881b8f6 Mon Sep 17 00:00:00 2001 From: rhysd Date: Sun, 23 Jun 2019 21:04:51 +0900 Subject: vim-patch:8.1.1554: docs and tests for :const can be improved Problem: Docs and tests for :const can be improved. Solution: Improve documentation, add a few more tests. (Ryuichi Hayashida, closes vim/vim#4551) https://github.com/vim/vim/commit/1c196e7b1742c1a50ce0d74190721acaad087f81 --- runtime/doc/eval.txt | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 6649bebedb..a17808e298 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -9631,15 +9631,10 @@ This does NOT work: > If the system does not support deleting an environment variable, it is made empty. - *:cons* *:const* *E996* + *:cons* *:const* :cons[t] {var-name} = {expr1} :cons[t] [{name1}, {name2}, ...] = {expr1} -:cons[t] [{name1}, {name2}, ...] .= {expr1} :cons[t] [{name}, ..., ; {lastname}] = {expr1} -:cons[t] {var-name} =<< [trim] {marker} -text... -text... -{marker} Similar to |:let|, but additionally lock the variable after setting the value. This is the same as locking the variable with |:lockvar| just after |:let|, thus: > @@ -9653,7 +9648,11 @@ text... |:const| does not allow to for changing a variable. > :let x = 1 :const x = 2 " Error! -< +< *E996* + Note that environment variables, option values and + register values cannot be used here, since they cannot + be locked. + :lockv[ar][!] [depth] {name} ... *:lockvar* *:lockv* Lock the internal variable {name}. Locking means that it can no longer be changed (until it is unlocked). -- cgit