tcd: doc, error messages

This commit is contained in:
Justin M. Keyes
2016-04-21 03:04:10 -04:00
parent ec71d87b81
commit 89e6973fe2
4 changed files with 56 additions and 68 deletions

View File

@@ -1216,20 +1216,18 @@ use has("browsefilter"): >
============================================================================== ==============================================================================
7. The current directory *current-directory* 7. The current directory *current-directory*
You may use the |:cd|, |:tcd| and |:lcd| commands to change to another You can use |:cd|, |:tcd| and |:lcd| to change to another directory, so you
directory, so you will not have to type that directory name in front of the will not have to type that directory name in front of the file names. It also
file names. It also makes a difference for executing external commands, e.g. makes a difference for executing external commands, e.g. ":!ls" or ":te ls".
":!ls".
There are three levels of working directories: global, tab and window. The There are three current-directory "scopes": global, tab and window. The
local working directory of the current window takes precedence over the local window-local working directory takes precedence over the tab-local
working directory of the tab, which in turn takes precedence over the global working directory, which in turn takes precedence over the global
working directory. If a local working directory, tab or window, does not working directory. If a local working directory (tab or window) does not
exist, the next one in the hierarchy applies. exist, the next-higher scope in the hierarchy applies.
All commands for changing the working directory can be suffixed with an Commands for changing the working directory can be suffixed with a bang "!"
exclamation mark (e.g. |:cd!|). This is for compatibility with Vim and will be (e.g. |:cd!|) which is ignored, for compatibility with Vim.
ignored by Neovim.
*:cd* *E747* *E472* *:cd* *E747* *E472*
:cd[!] On non-Unix systems: Print the current directory :cd[!] On non-Unix systems: Print the current directory
@@ -1256,9 +1254,8 @@ ignored by Neovim.
*:tc* *:tcd* *E5000* *E5001* *E5002* *:tc* *:tcd* *E5000* *E5001* *E5002*
:tc[d][!] {path} Like |:cd|, but set the current directory for the :tc[d][!] {path} Like |:cd|, but set the current directory for the
current tab. The current directory for other tabs current tab and window. The current directory for
or the local directory of windows in this tab is not other tabs and windows is not changed.
changed, except for the current window.
*:tcd-* *:tcd-*
:tcd[!] - Change to the previous current directory (before the :tcd[!] - Change to the previous current directory (before the
@@ -1284,19 +1281,20 @@ ignored by Neovim.
Also see |getcwd()|. Also see |getcwd()|.
So long as no |:tcd| or |:lcd| command has been used, all windows share the So long as no |:tcd| or |:lcd| command has been used, all windows share the
same current directory. Using a command to jump to another window doesn't same "current directory". Using a command to jump to another window doesn't
change anything for the current directory. change anything for the current directory.
When a |:lcd| command has been used for a window, the specified directory
becomes the current directory for that window. Windows where the |:lcd| When |:lcd| has been used for a window, the specified directory becomes the
command has not been used stick to the tab- or global current directory. When current directory for that window. Windows where the |:lcd| command has not
jumping to another window the current directory will become the last specified been used stick to the global or tab-local directory. When jumping to another
local current directory. If none was specified, the tab- or global current window the current directory will become the last specified local current
directory is used. directory. If none was specified, the global or tab-local directory is used.
When changing tabs the same behaviour applies. If the current tab has no When changing tabs the same behaviour applies. If the current tab has no
local working directory the global working directory is used. When a |:cd| local working directory the global working directory is used. When a |:cd|
command is used, the current window and tab will lose their local current command is used, the current window and tab will lose their local current
directories and will use the global current directory from now on. When a directories and will use the global current directory from now on. When
|:tcd| command is used, only the current window will lose its local working a |:tcd| command is used, only the current window will lose its local working
directory. directory.
After using |:cd| the full path name will be used for reading and writing After using |:cd| the full path name will be used for reading and writing
@@ -1346,9 +1344,7 @@ There are a few things to remember when editing binary files:
9. Encryption *encryption* 9. Encryption *encryption*
*:X* *E817* *E818* *E819* *E820* *:X* *E817* *E818* *E819* *E820*
Support for editing encrypted files has been removed, but may be added back in Support for editing encrypted files has been removed.
the future. See the following discussions for more information:
https://github.com/neovim/neovim/issues/694 https://github.com/neovim/neovim/issues/694
https://github.com/neovim/neovim/issues/701 https://github.com/neovim/neovim/issues/701

View File

@@ -3560,20 +3560,16 @@ getcurpos() Get the position of the cursor. This is like getpos('.'), but
call setpos('.', save_cursor) call setpos('.', save_cursor)
< <
getcwd([{window}[, {tab}]]) *getcwd()* getcwd([{window}[, {tab}]]) *getcwd()*
With no argument the result is a String, which is the name of the With no arguments the result is a String, which is the name of
current effective working directory. If an arguments are provided for a the current effective working directory. With {window} or
window or a tabpage the working directory of that scope is returned. {tab} the working directory of that scope is returned.
Tabs and windows are identified by their respective numbers,
Tabs and windows are identified using their respective number. If a 0 means current tab or window. Missing argument implies 0.
number is 0 the current tab or window is implied. If one is not given Thus the following are equivalent: >
it defaults to 0. Thus
getcwd() getcwd()
getcwd(0) getcwd(0)
getcwd(0, 0) getcwd(0, 0)
< If {window} is -1 it is ignored, only the tab is resolved.
are all equal. If {window} is -1 it will be ignored and only the tab
will be looked at.
getfsize({fname}) *getfsize()* getfsize({fname}) *getfsize()*
@@ -3910,19 +3906,17 @@ has_key({dict}, {key}) *has_key()*
an entry with key {key}. Zero otherwise. an entry with key {key}. Zero otherwise.
haslocaldir([{window}[, {tab}]]) *haslocaldir()* haslocaldir([{window}[, {tab}]]) *haslocaldir()*
The result is a Number, which is 1 when the specified tabpage or window The result is a Number, which is 1 when the specified tabpage
has a local path set via |:lcd| or |:tcd|, and 0 otherwise. or window has a local path set via |:lcd| or |:tcd|, and
0 otherwise.
Tabs and windows are identified using their respective number. If a
number is 0 the current tab or window is implied. If one is not given
it defaults to 0. Thus
Tabs and windows are identified by their respective numbers,
0 means current tab or window. Missing argument implies 0.
Thus the following are equivalent: >
haslocaldir() haslocaldir()
haslocaldir(0) haslocaldir(0)
haslocaldir(0, 0) haslocaldir(0, 0)
< If {window} is -1 it is ignored, only the tab is resolved.
are all equal. If {window} is -1 it will be ignored and only the tab
will be looked at.
hasmapto({what} [, {mode} [, {abbr}]]) *hasmapto()* hasmapto({what} [, {mode} [, {abbr}]]) *hasmapto()*
The result is a Number, which is 1 if there is a mapping that The result is a Number, which is 1 if there is a mapping that

View File

@@ -9826,7 +9826,7 @@ static void f_getcwd(typval_T *argvars, typval_T *rettv)
} }
} }
// It the deepest scope number is `-1` advance the scope by one. // If the deepest scope number is `-1` advance the scope.
if (scope_number[scope] < 0) { if (scope_number[scope] < 0) {
scope++; scope++;
} }
@@ -9847,8 +9847,7 @@ static void f_getcwd(typval_T *argvars, typval_T *rettv)
win = NULL; win = NULL;
} else if (scope_number[kCdScopeWindow] >= 0) { } else if (scope_number[kCdScopeWindow] >= 0) {
if (!tp) { if (!tp) {
EMSG(_("E5001: A higher-level scope cannot be -1 if a lower-level" EMSG(_("E5001: Higher scope cannot be -1 if lower scope is >= 0."));
" scope is >= 0."));
goto end; goto end;
} }
@@ -10782,8 +10781,7 @@ static void f_haslocaldir(typval_T *argvars, typval_T *rettv)
win = NULL; win = NULL;
} else if (scope_number[kCdScopeWindow] >= 0) { } else if (scope_number[kCdScopeWindow] >= 0) {
if (!tp) { if (!tp) {
EMSG(_("E5001: A higher-level scope cannot be -1 if a lower-level" EMSG(_("E5001: Higher scope cannot be -1 if lower scope is >= 0."));
" scope is >= 0."));
return; return;
} }

View File

@@ -110,31 +110,31 @@ end
-- Test legal parameters for 'getcwd' and 'haslocaldir' -- Test legal parameters for 'getcwd' and 'haslocaldir'
for _, cmd in ipairs {'getcwd', 'haslocaldir'} do for _, cmd in ipairs {'getcwd', 'haslocaldir'} do
describe('getcwd()', function() describe(cmd..'()', function()
-- Test invalid argument types -- Test invalid argument types
local expected = 'Vim(call):E474: Invalid argument' local expected = 'Vim(call):E474: Invalid argument'
it('fails to parse a string', function() it('fails on string', function()
eq(expected, exc_exec('call ' .. cmd .. '("some string")')) eq(expected, exc_exec('call ' .. cmd .. '("some string")'))
end) end)
it('fails to parse a float', function() it('fails on float', function()
eq(expected, exc_exec('call ' .. cmd .. '(1.0)')) eq(expected, exc_exec('call ' .. cmd .. '(1.0)'))
end) end)
it('fails to parse a list', function() it('fails on list', function()
eq(expected, exc_exec('call ' .. cmd .. '([1, 2])')) eq(expected, exc_exec('call ' .. cmd .. '([1, 2])'))
end) end)
it('fails to parse a dictionary', function() it('fails on dictionary', function()
eq(expected, exc_exec('call ' .. cmd .. '({"key": "value"})')) eq(expected, exc_exec('call ' .. cmd .. '({"key": "value"})'))
end) end)
it('fails to parse a funcref', function() it('fails on funcref', function()
eq(expected, exc_exec('call ' .. cmd .. '(function("tr"))')) eq(expected, exc_exec('call ' .. cmd .. '(function("tr"))'))
end) end)
-- Test invalid numbers -- Test invalid numbers
it('fails to parse number less than -1', function() it('fails on number less than -1', function()
eq(expected, exc_exec('call ' .. cmd .. '(-2)')) eq(expected, exc_exec('call ' .. cmd .. '(-2)'))
end) end)
local expected = 'Vim(call):E5001: A higher-level scope cannot be -1 if a lower-level scope is >= 0.' local expected = 'Vim(call):E5001: Higher scope cannot be -1 if lower scope is >= 0.'
it('fails to parse arument -1 when previous arg was greater than -1', function() it('fails on -1 if previous arg is >=0', function()
eq(expected, exc_exec('call ' .. cmd .. '(0, -1)')) eq(expected, exc_exec('call ' .. cmd .. '(0, -1)'))
end) end)