Patch 8.2.3780
Problem:    ":cd" works differently on MS-Windows.
Solution:   Add the 'cdhome' option. (closes #9324)
Files:      runtime/doc/editing.txt, runtime/doc/options.txt,
            runtime/doc/quickref.txt, runtime/optwin.vim, src/ex_docmd.c,
            src/option.h, src/optiondefs.h, src/testdir/runtest.vim,
            src/testdir/test_options.vim,


*** ../vim-8.2.3779/runtime/doc/editing.txt     2021-07-25 14:08:02.529317394 
+0100
--- runtime/doc/editing.txt     2021-12-11 12:16:36.057716331 +0000
***************
*** 1296,1306 ****
  present in 'cpoptions' and "!" is not used in the command.
  
                                                        *:cd* *E747* *E472*
! :cd[!]                        On non-Unix systems: Print the current directory
!                       name.  On Unix systems: Change the current directory
!                       to the home directory.  Use |:pwd| to print the
!                       current directory on all systems.
!                       On Unix systems: clear any window-local directory.
  
  :cd[!] {path}         Change the current directory to {path}.
                        If {path} is relative, it is searched for in the
--- 1298,1309 ----
  present in 'cpoptions' and "!" is not used in the command.
  
                                                        *:cd* *E747* *E472*
! :cd[!]                        On non-Unix systems when 'cdhome' is off: Print 
the
!                       current directory name.
!                       Otherwise: Change the current directory to the home
!                       directory.  Clear any window-local directory.
!                       Use |:pwd| to print the current directory on all
!                       systems.
  
  :cd[!] {path}         Change the current directory to {path}.
                        If {path} is relative, it is searched for in the
***************
*** 1474,1479 ****
--- 1493,1507 ----
                        case mapping, the current locale is not effective.
                        This probably only matters for Turkish.
  
+                                               *'cdhome'* *'cdh'*
+ 'cdhome' 'cdh'                boolean (default: off)
+                       global
+       When on, |:cd|, |:tcd| and |:lcd| without an argument changes the
+       current working directory to the |$HOME| directory like in Unix.
+       When off, those commands just print the current directory name.
+       On Unix this option has no effect.
+       NOTE: This option is reset when 'compatible' is set.
+ 
                                                *'cdpath'* *'cd'* *E344* *E346*
  'cdpath' 'cd'         string  (default: equivalent to $CDPATH or ",,")
                        global
***************
*** 1811,1816 ****
--- 1843,1849 ----
        'balloonexpr'   + ""            text to show in evaluation balloon
        'breakindent'   + off           don't indent when wrapping lines
        'cedit'         - {unchanged}   {set vim default only on resetting 'cp'}
+       'cdhome'        + off           ":cd" don't chdir to home on non-Unix
        'cindent'       + off           no C code indentation
        'compatible'    - {unchanged}   {set vim default only on resetting 'cp'}
        'copyindent'    + off           don't copy indent structure
*** ../vim-8.2.3779/runtime/doc/quickref.txt    2021-10-16 15:41:25.378336694 
+0100
--- runtime/doc/quickref.txt    2021-12-11 12:13:35.466057340 +0000
***************
*** 635,640 ****
--- 635,641 ----
  'buflisted'     'bl'      whether the buffer shows up in the buffer list
  'buftype'       'bt'      special type of buffer
  'casemap'       'cmp'     specifies how case of letters is changed
+ 'cdhome'        'cdh'     change directory to the home directory by ":cd"
  'cdpath'        'cd'      list of directories searched with ":cd"
  'cedit'                           key used to open the command-line window
  'charconvert'   'ccv'     expression for character encoding conversion
***************
*** 732,737 ****
--- 733,739 ----
  'guifontset'    'gfs'     GUI: Names of multibyte fonts to be used
  'guifontwide'   'gfw'     list of font names for double-wide characters
  'guiheadroom'   'ghr'     GUI: pixels room for window decorations
+ 'guiligatures'          'gli'     GTK GUI: ASCII characters that can form 
shapes
  'guioptions'    'go'      GUI: Which components and options are used
  'guipty'                  GUI: try to use a pseudo-tty for ":!" commands
  'guitablabel'   'gtl'     GUI: custom label for a tab page
*** ../vim-8.2.3779/runtime/optwin.vim  2021-03-29 19:49:01.486055361 +0100
--- runtime/optwin.vim  2021-12-11 12:13:35.466057340 +0000
***************
*** 260,265 ****
--- 260,269 ----
  call <SID>AddOption("path", gettext("list of directory names used for file 
searching"))
  call append("$", "\t" .. s:global_or_local)
  call <SID>OptionG("pa", &pa)
+ if exists("+cdhome")
+   call <SID>AddOption("cdhome", gettext("change directory to the home 
directory by :cd"))
+   call <SID>BinOptionG("cdh", &cdh)
+ endif
  call <SID>AddOption("cdpath", gettext("list of directory names used for :cd"))
  call <SID>OptionG("cd", &cd)
  if exists("+autochdir")
*** ../vim-8.2.3779/src/ex_docmd.c      2021-12-05 22:19:22.832153464 +0000
--- src/ex_docmd.c      2021-12-11 12:19:36.657355331 +0000
***************
*** 7402,7410 ****
      else
        prev_dir = pdir;
  
  #if defined(UNIX) || defined(VMS)
-     // for UNIX ":cd" means: go to home directory
      if (*new_dir == NUL)
      {
        // use NameBuff for home directory name
  # ifdef VMS
--- 7402,7414 ----
      else
        prev_dir = pdir;
  
+     // For UNIX ":cd" means: go to home directory.
+     // On other systems too if 'cdhome' is set.
  #if defined(UNIX) || defined(VMS)
      if (*new_dir == NUL)
+ #else
+     if (*new_dir == NUL && p_cdh)
+ #endif
      {
        // use NameBuff for home directory name
  # ifdef VMS
***************
*** 7420,7426 ****
  # endif
        new_dir = NameBuff;
      }
- #endif
      dir_differs = new_dir == NULL || pdir == NULL
        || pathcmp((char *)pdir, (char *)new_dir, -1) != 0;
      if (new_dir == NULL || (dir_differs && vim_chdir(new_dir)))
--- 7424,7429 ----
***************
*** 7459,7466 ****
  
      new_dir = eap->arg;
  #if !defined(UNIX) && !defined(VMS)
!     // for non-UNIX ":cd" means: print current directory
!     if (*new_dir == NUL)
        ex_pwd(NULL);
      else
  #endif
--- 7462,7469 ----
  
      new_dir = eap->arg;
  #if !defined(UNIX) && !defined(VMS)
!     // for non-UNIX ":cd" means: print current directory unless 'cdhome' is 
set
!     if (*new_dir == NUL && !p_cdh)
        ex_pwd(NULL);
      else
  #endif
*** ../vim-8.2.3779/src/option.h        2021-12-06 11:03:50.950900210 +0000
--- src/option.h        2021-12-11 12:18:35.757478894 +0000
***************
*** 1094,1099 ****
--- 1094,1100 ----
  EXTERN int    p_wa;           // 'writeany'
  EXTERN int    p_wb;           // 'writebackup'
  EXTERN long   p_wd;           // 'writedelay'
+ EXTERN int    p_cdh;          // 'cdhome'
  
  /*
   * "indir" values for buffer-local options.
*** ../vim-8.2.3779/src/optiondefs.h    2021-12-06 11:03:50.950900210 +0000
--- src/optiondefs.h    2021-12-11 12:20:15.981274645 +0000
***************
*** 549,554 ****
--- 549,558 ----
                            (char_u *)&p_cmp, PV_NONE,
                            {(char_u *)"internal,keepascii", (char_u *)0L}
                            SCTX_INIT},
+     {"cdhome",            "cdh",  P_BOOL|P_VI_DEF|P_VIM|P_SECURE,
+                           (char_u *)&p_cdh, PV_NONE,
+                           {(char_u *)FALSE, (char_u *)0L}
+                           SCTX_INIT},
      {"cdpath",            "cd",   
P_STRING|P_EXPAND|P_VI_DEF|P_SECURE|P_COMMA|P_NODUP,
  #ifdef FEAT_SEARCHPATH
                            (char_u *)&p_cdpath, PV_NONE,
*** ../vim-8.2.3779/src/testdir/runtest.vim     2021-11-21 11:35:59.456938797 
+0000
--- src/testdir/runtest.vim     2021-12-11 12:13:35.470057333 +0000
***************
*** 77,82 ****
--- 77,85 ----
    let s:start_time = reltime()
  endif
  
+ " Always use forward slashes.
+ set shellslash
+ 
  " Common with all tests on all systems.
  source setup.vim
  
***************
*** 128,136 ****
    source $VIMRUNTIME/menu.vim
  endif
  
- " Always use forward slashes.
- set shellslash
- 
  let s:srcdir = expand('%:p:h:h')
  
  if has('win32')
--- 131,136 ----
*** ../vim-8.2.3779/src/testdir/test_options.vim        2021-12-05 
13:21:14.646456572 +0000
--- src/testdir/test_options.vim        2021-12-11 12:13:35.470057333 +0000
***************
*** 1199,1202 ****
--- 1199,1223 ----
    bw
  endfunc
  
+ " Test for the 'cdhome' option
+ func Test_opt_cdhome()
+   if has('unix') || has('vms')
+     throw 'Skipped: only works on non-Unix'
+   endif
+ 
+   set cdhome&
+   call assert_equal(0, &cdhome)
+   set cdhome
+ 
+   " This paragraph is copied from Test_cd_no_arg().
+   let path = getcwd()
+   cd
+   call assert_equal($HOME, getcwd())
+   call assert_notequal(path, getcwd())
+   exe 'cd ' .. fnameescape(path)
+   call assert_equal(path, getcwd())
+ 
+   set cdhome&
+ endfunc
+ 
  " vim: shiftwidth=2 sts=2 expandtab
*** ../vim-8.2.3779/src/version.c       2021-12-10 21:46:05.035979827 +0000
--- src/version.c       2021-12-11 12:16:05.185776224 +0000
***************
*** 755,756 ****
--- 755,758 ----
  {   /* Add new patch number below this line */
+ /**/
+     3780,
  /**/

-- 
How To Keep A Healthy Level Of Insanity:
2. Page yourself over the intercom. Don't disguise your voice.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            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/20211211122844.6C0F91C09EE%40moolenaar.net.

Raspunde prin e-mail lui