Patch 8.2.0876
Problem: :pwd does not give a hint about the scope of the directory
Solution: Make ":verbose pwd" show the scope. (Takuya Fujiwara, closes #5469)
Files: runtime/doc/editing.txt, src/ex_docmd.c, src/testdir/test_cd.vim
*** ../vim-8.2.0875/runtime/doc/editing.txt 2019-12-17 21:27:14.686319918
+0100
--- runtime/doc/editing.txt 2020-06-01 16:22:43.851604185 +0200
***************
*** 1327,1332 ****
--- 1338,1358 ----
*:pw* *:pwd* *E187*
:pw[d] Print the current directory name.
Also see |getcwd()|.
+ *:pwd-verbose*
+ When 'verbose' is non-zero, |:pwd| will also display
+ what scope the current directory was set. Example: >
+
+ " Set by :cd
+ :verbose pwd
+ [global] /path/to/current
+
+ " Set by :lcd
+ :verbose pwd
+ [window] /path/to/current
+
+ " Set by :tcd
+ :verbose pwd
+ [tabpage] /path/to/current
So long as no |:lcd| or |:tcd| command has been used, all windows share the
same current directory. Using a command to jump to another window doesn't
*** ../vim-8.2.0875/src/ex_docmd.c 2020-05-30 20:30:42.892816571 +0200
--- src/ex_docmd.c 2020-06-01 16:25:16.431062838 +0200
***************
*** 6619,6627 ****
/*
* Change directory function used by :cd/:tcd/:lcd Ex commands and the
! * chdir() function. If 'winlocaldir' is TRUE, then changes the window-local
! * directory. If 'tablocaldir' is TRUE, then changes the tab-local directory.
! * Otherwise changes the global directory.
* Returns TRUE if the directory is successfully changed.
*/
int
--- 6619,6628 ----
/*
* Change directory function used by :cd/:tcd/:lcd Ex commands and the
! * chdir() function.
! * scope == CDSCOPE_WINDOW: changes the window-local directory
! * scope == CDSCOPE_TABPAGE: changes the tab-local directory
! * Otherwise: changes the global directory
* Returns TRUE if the directory is successfully changed.
*/
int
***************
*** 6751,6757 ****
#ifdef BACKSLASH_IN_FILENAME
slash_adjust(NameBuff);
#endif
! msg((char *)NameBuff);
}
else
emsg(_("E187: Unknown"));
--- 6752,6769 ----
#ifdef BACKSLASH_IN_FILENAME
slash_adjust(NameBuff);
#endif
! if (p_verbose > 0)
! {
! char *context = "global";
!
! if (curwin->w_localdir != NULL)
! context = "window";
! else if (curtab->tp_localdir != NULL)
! context = "tabpage";
! smsg("[%s] %s", context, (char *)NameBuff);
! }
! else
! msg((char *)NameBuff);
}
else
emsg(_("E187: Unknown"));
*** ../vim-8.2.0875/src/testdir/test_cd.vim 2020-04-25 15:24:40.551354115
+0200
--- src/testdir/test_cd.vim 2020-06-01 16:19:50.120214786 +0200
***************
*** 97,112 ****
--- 97,115 ----
lcd z
tabfirst
+ call assert_match('^\[global\] .*/Xdir$', trim(execute('verbose pwd')))
call chdir('..')
call assert_equal('y', fnamemodify(getcwd(1, 2), ':t'))
call assert_equal('z', fnamemodify(3->getcwd(2), ':t'))
tabnext | wincmd t
+ call assert_match('^\[tabpage\] .*/y$', trim(execute('verbose pwd')))
eval '..'->chdir()
call assert_equal('Xdir', fnamemodify(getcwd(1, 2), ':t'))
call assert_equal('Xdir', fnamemodify(getcwd(2, 2), ':t'))
call assert_equal('z', fnamemodify(getcwd(3, 2), ':t'))
call assert_equal('testdir', fnamemodify(getcwd(1, 1), ':t'))
3wincmd w
+ call assert_match('^\[window\] .*/z$', trim(execute('verbose pwd')))
call chdir('..')
call assert_equal('Xdir', fnamemodify(getcwd(1, 2), ':t'))
call assert_equal('Xdir', fnamemodify(getcwd(2, 2), ':t'))
*** ../vim-8.2.0875/src/version.c 2020-06-01 16:09:30.270292723 +0200
--- src/version.c 2020-06-01 16:25:53.446930930 +0200
***************
*** 748,749 ****
--- 748,751 ----
{ /* Add new patch number below this line */
+ /**/
+ 876,
/**/
--
"After a few years of marriage a man can look right at a woman
without seeing her and a woman can see right through a man
without looking at him."
- Helen Rowland
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/202006011426.051EQn7x928314%40masaka.moolenaar.net.