From ec71d87b8140ae097158f7e219b26701aed8158e Mon Sep 17 00:00:00 2001 From: HiPhish Date: Mon, 24 Aug 2015 12:58:28 +0200 Subject: Implement tab-local working directory feature. New ex commands: 'tcd', 'tchdir' Changed Vimscript functions: 'haslocaldir', 'getcwd' The ex-commands ':tcd' and ':tchdir' are the tab-local equivalents of ':lcd' and ':lchdir'. There are no new Vimscript functions introduced, instead the functions 'haslocaldir' and 'getcwd' take in optional arguments. See the documentation for details Since there is now different levels of local directory a simple boolean at source level is no longer sufficient; a new enumeration type is used for the scope-level from now on. The documentation has been accommodated for these new commands and functional tests have been written to test the feature. --- runtime/doc/editing.txt | 59 ++++++++++++++++++++++++++++++++++++------------- runtime/doc/eval.txt | 38 +++++++++++++++++++++++++------ 2 files changed, 75 insertions(+), 22 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/editing.txt b/runtime/doc/editing.txt index d2b9374143..ebf524fdbb 100644 --- a/runtime/doc/editing.txt +++ b/runtime/doc/editing.txt @@ -1216,12 +1216,20 @@ use has("browsefilter"): > ============================================================================== 7. The current directory *current-directory* -You may use the |:cd| and |:lcd| commands to change to another directory, so -you will not have to type that directory name in front of the file names. It -also makes a difference for executing external commands, e.g. ":!ls". +You may use the |:cd|, |:tcd| and |:lcd| commands to change to another +directory, so you will not have to type that directory name in front of the +file names. It also makes a difference for executing external commands, e.g. +":!ls". -Changing directory fails when the current buffer is modified, the '.' flag is -present in 'cpoptions' and "!" is not used in the command. +There are three levels of working directories: global, tab and window. The +local working directory of the current window takes precedence over the local +working directory of the tab, which in turn takes precedence over the global +working directory. If a local working directory, tab or window, does not +exist, the next one in the hierarchy applies. + +All commands for changing the working directory can be suffixed with an +exclamation mark (e.g. |:cd!|). This is for compatibility with Vim and will be +ignored by Neovim. *:cd* *E747* *E472* :cd[!] On non-Unix systems: Print the current directory @@ -1246,29 +1254,50 @@ present in 'cpoptions' and "!" is not used in the command. *:chd* *:chdir* :chd[ir][!] [path] Same as |:cd|. + *:tc* *:tcd* *E5000* *E5001* *E5002* +:tc[d][!] {path} Like |:cd|, but set the current directory for the + current tab. The current directory for other tabs + or the local directory of windows in this tab is not + changed, except for the current window. + + *:tcd-* +:tcd[!] - Change to the previous current directory (before the + previous ":tcd {path}" command). + + *:tch* *:tchdir* +:tch[dir][!] Same as |:tcd|. + *:lc* *:lcd* :lc[d][!] {path} Like |:cd|, but only set the current directory for the current window. The current directory for other - windows is not changed. + windows or any tabs is not changed. *:lch* *:lchdir* :lch[dir][!] Same as |:lcd|. + *:lcd-* +:lcd[!] - Change to the previous current directory (before the + previous ":tcd {path}" command). + *:pw* *:pwd* *E187* :pw[d] Print the current directory name. Also see |getcwd()|. -So long as no |:lcd| command has been used, all windows share the same current -directory. Using a command to jump to another window doesn't change anything -for the current directory. +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 +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| -command has not been used stick to the global current directory. When jumping -to another window the current directory will become the last specified local -current directory. If none was specified, the global current directory is -used. -When a |:cd| command is used, the current window will lose his local current -directory and will use the global current directory from now on. +command has not been used stick to the tab- or global current directory. When +jumping to another window the current directory will become the last specified +local current directory. If none was specified, the tab- or global current +directory is used. +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| +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 +|:tcd| command is used, only the current window will lose its local working +directory. After using |:cd| the full path name will be used for reading and writing files. On some networked file systems this may cause problems. The result of diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 476ab71461..3e1281a021 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -1886,7 +1886,7 @@ getcmdpos() Number return cursor position in command-line getcmdtype() String return current command-line type getcmdwintype() String return current command-line window type getcurpos() List position of the cursor -getcwd() String the current working directory +getcwd( [{scope}]) String the current working directory getfontname( [{name}]) String name of font being used getfperm( {fname}) String file permissions of file {fname} getfsize( {fname}) Number size in bytes of file {fname} @@ -3559,9 +3559,22 @@ getcurpos() Get the position of the cursor. This is like getpos('.'), but MoveTheCursorAround call setpos('.', save_cursor) < - *getcwd()* -getcwd() The result is a String, which is the name of the current - working directory. +getcwd([{window}[, {tab}]]) *getcwd()* + With no argument the result is a String, which is the name of the + current effective working directory. If an arguments are provided for a + window or a tabpage the working directory of that scope is returned. + + 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 + + getcwd() + getcwd(0) + getcwd(0, 0) + + are all equal. If {window} is -1 it will be ignored and only the tab + will be looked at. + getfsize({fname}) *getfsize()* The result is a Number, which is the size in bytes of the @@ -3896,9 +3909,20 @@ has_key({dict}, {key}) *has_key()* The result is a Number, which is 1 if |Dictionary| {dict} has an entry with key {key}. Zero otherwise. -haslocaldir() *haslocaldir()* - The result is a Number, which is 1 when the current - window has set a local path via |:lcd|, and 0 otherwise. +haslocaldir([{window}[, {tab}]]) *haslocaldir()* + The result is a Number, which is 1 when the specified tabpage 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 + + haslocaldir() + haslocaldir(0) + haslocaldir(0, 0) + + are all equal. If {window} is -1 it will be ignored and only the tab + will be looked at. hasmapto({what} [, {mode} [, {abbr}]]) *hasmapto()* The result is a Number, which is 1 if there is a mapping that -- cgit From 89e6973fe2b57316817877f64f0be5ebc5a25b7f Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Thu, 21 Apr 2016 03:04:10 -0400 Subject: tcd: doc, error messages --- runtime/doc/editing.txt | 52 +++++++++++++++++++++++-------------------------- runtime/doc/eval.txt | 42 +++++++++++++++++---------------------- 2 files changed, 42 insertions(+), 52 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/editing.txt b/runtime/doc/editing.txt index ebf524fdbb..0ad917006f 100644 --- a/runtime/doc/editing.txt +++ b/runtime/doc/editing.txt @@ -1216,20 +1216,18 @@ use has("browsefilter"): > ============================================================================== 7. The current directory *current-directory* -You may use the |:cd|, |:tcd| and |:lcd| commands to change to another -directory, so you will not have to type that directory name in front of the -file names. It also makes a difference for executing external commands, e.g. -":!ls". +You can use |:cd|, |:tcd| and |:lcd| to change to another directory, so you +will not have to type that directory name in front of the file names. It also +makes a difference for executing external commands, e.g. ":!ls" or ":te ls". -There are three levels of working directories: global, tab and window. The -local working directory of the current window takes precedence over the local -working directory of the tab, which in turn takes precedence over the global -working directory. If a local working directory, tab or window, does not -exist, the next one in the hierarchy applies. +There are three current-directory "scopes": global, tab and window. The +window-local working directory takes precedence over the tab-local +working directory, which in turn takes precedence over the global +working directory. If a local working directory (tab or window) does not +exist, the next-higher scope in the hierarchy applies. -All commands for changing the working directory can be suffixed with an -exclamation mark (e.g. |:cd!|). This is for compatibility with Vim and will be -ignored by Neovim. +Commands for changing the working directory can be suffixed with a bang "!" +(e.g. |:cd!|) which is ignored, for compatibility with Vim. *:cd* *E747* *E472* :cd[!] On non-Unix systems: Print the current directory @@ -1254,11 +1252,10 @@ ignored by Neovim. *:chd* *:chdir* :chd[ir][!] [path] Same as |:cd|. - *:tc* *:tcd* *E5000* *E5001* *E5002* + *:tc* *:tcd* *E5000* *E5001* *E5002* :tc[d][!] {path} Like |:cd|, but set the current directory for the - current tab. The current directory for other tabs - or the local directory of windows in this tab is not - changed, except for the current window. + current tab and window. The current directory for + other tabs and windows is not changed. *:tcd-* :tcd[!] - Change to the previous current directory (before the @@ -1284,19 +1281,20 @@ ignored by Neovim. Also see |getcwd()|. 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. -When a |:lcd| command has been used for a window, the specified directory -becomes the current directory for that window. Windows where the |:lcd| -command has not been used stick to the tab- or global current directory. When -jumping to another window the current directory will become the last specified -local current directory. If none was specified, the tab- or global current -directory is used. + +When |:lcd| has been used for a window, the specified directory becomes the +current directory for that window. Windows where the |:lcd| command has not +been used stick to the global or tab-local directory. When jumping to another +window the current directory will become the last specified local current +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 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 -directories and will use the global current directory from now on. When a -|:tcd| command is used, only the current window will lose its local working +directories and will use the global current directory from now on. When +a |:tcd| command is used, only the current window will lose its local working directory. 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* *:X* *E817* *E818* *E819* *E820* -Support for editing encrypted files has been removed, but may be added back in -the future. See the following discussions for more information: - +Support for editing encrypted files has been removed. https://github.com/neovim/neovim/issues/694 https://github.com/neovim/neovim/issues/701 diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 3e1281a021..0fdf905bd3 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -1886,7 +1886,7 @@ getcmdpos() Number return cursor position in command-line getcmdtype() String return current command-line type getcmdwintype() String return current command-line window type getcurpos() List position of the cursor -getcwd( [{scope}]) String the current working directory +getcwd( [{scope}]) String the current working directory getfontname( [{name}]) String name of font being used getfperm( {fname}) String file permissions of file {fname} getfsize( {fname}) Number size in bytes of file {fname} @@ -3559,21 +3559,17 @@ getcurpos() Get the position of the cursor. This is like getpos('.'), but MoveTheCursorAround call setpos('.', save_cursor) < -getcwd([{window}[, {tab}]]) *getcwd()* - With no argument the result is a String, which is the name of the - current effective working directory. If an arguments are provided for a - window or a tabpage the working directory of that scope is returned. - - 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 - +getcwd([{window}[, {tab}]]) *getcwd()* + With no arguments the result is a String, which is the name of + the current effective working directory. With {window} or + {tab} the working directory of that scope is returned. + Tabs and windows are identified by their respective numbers, + 0 means current tab or window. Missing argument implies 0. + Thus the following are equivalent: > getcwd() getcwd(0) getcwd(0, 0) - - are all equal. If {window} is -1 it will be ignored and only the tab - will be looked at. +< If {window} is -1 it is ignored, only the tab is resolved. getfsize({fname}) *getfsize()* @@ -3909,20 +3905,18 @@ has_key({dict}, {key}) *has_key()* The result is a Number, which is 1 if |Dictionary| {dict} has an entry with key {key}. Zero otherwise. -haslocaldir([{window}[, {tab}]]) *haslocaldir()* - The result is a Number, which is 1 when the specified tabpage 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 - +haslocaldir([{window}[, {tab}]]) *haslocaldir()* + The result is a Number, which is 1 when the specified tabpage + or window has a local path set via |:lcd| or |:tcd|, and + 0 otherwise. + + 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(0) haslocaldir(0, 0) - - are all equal. If {window} is -1 it will be ignored and only the tab - will be looked at. +< If {window} is -1 it is ignored, only the tab is resolved. hasmapto({what} [, {mode} [, {abbr}]]) *hasmapto()* The result is a Number, which is 1 if there is a mapping that -- cgit