Patch 8.2.3433
Problem:    :delcommand does not take a -buffer option.
Solution:   Add the -buffer option.
Files:      runtime/doc/map.txt, src/usercmd.c, src/errors.h,
            src/testdir/test_usercommands.vim


*** ../vim-8.2.3432/runtime/doc/map.txt 2021-08-05 20:39:59.346053681 +0200
--- runtime/doc/map.txt 2021-09-12 20:54:08.630060822 +0200
***************
*** 1349,1354 ****
--- 1368,1377 ----
  :delc[ommand] {cmd}                           *:delc* *:delcommand* *E184*
                        Delete the user-defined command {cmd}.
  
+ :delc[ommand] -buffer {cmd}                                   *E1237*
+                       Delete the user-defined command {cmd} that was defined
+                       for the current buffer.
+ 
  :comc[lear]                                           *:comc* *:comclear*
                        Delete all user-defined commands.
  
*** ../vim-8.2.3432/src/usercmd.c       2021-09-08 14:29:43.113509774 +0200
--- src/usercmd.c       2021-09-12 20:08:37.218421723 +0200
***************
*** 1162,1169 ****
  {
      int               i = 0;
      ucmd_T    *cmd = NULL;
!     int               cmp = -1;
      garray_T  *gap;
  
      gap = &curbuf->b_ucmds;
      for (;;)
--- 1162,1177 ----
  {
      int               i = 0;
      ucmd_T    *cmd = NULL;
!     int               res = -1;
      garray_T  *gap;
+     char_u    *arg = eap->arg;
+     int               buffer_only = FALSE;
+ 
+     if (STRNCMP(arg, "-buffer", 7) == 0 && VIM_ISWHITE(arg[7]))
+     {
+       buffer_only = TRUE;
+       arg = skipwhite(arg + 7);
+     }
  
      gap = &curbuf->b_ucmds;
      for (;;)
***************
*** 1171,1188 ****
        for (i = 0; i < gap->ga_len; ++i)
        {
            cmd = USER_CMD_GA(gap, i);
!           cmp = STRCMP(eap->arg, cmd->uc_name);
!           if (cmp <= 0)
                break;
        }
!       if (gap == &ucmds || cmp == 0)
            break;
        gap = &ucmds;
      }
  
!     if (cmp != 0)
      {
!       semsg(_("E184: No such user-defined command: %s"), eap->arg);
        return;
      }
  
--- 1179,1198 ----
        for (i = 0; i < gap->ga_len; ++i)
        {
            cmd = USER_CMD_GA(gap, i);
!           res = STRCMP(arg, cmd->uc_name);
!           if (res <= 0)
                break;
        }
!       if (gap == &ucmds || res == 0 || buffer_only)
            break;
        gap = &ucmds;
      }
  
!     if (res != 0)
      {
!       semsg(_(buffer_only
!                   ? e_no_such_user_defined_command_in_current_buffer_str
!                   : e_no_such_user_defined_command_str), arg);
        return;
      }
  
*** ../vim-8.2.3432/src/errors.h        2021-09-08 12:31:31.862351834 +0200
--- src/errors.h        2021-09-12 20:53:27.554080093 +0200
***************
*** 141,146 ****
--- 141,148 ----
  EXTERN char e_undefined_variable_char_str[]
        INIT(= N_("E121: Undefined variable: %c:%s"));
  #endif
+ EXTERN char e_no_such_user_defined_command_str[]
+       INIT(= N_("E184: No such user-defined command: %s"));
  #ifndef FEAT_DIGRAPHS
  EXTERN char e_no_digraphs_version[]
        INIT(= N_("E196: No digraphs in this version"));
***************
*** 656,658 ****
--- 658,662 ----
        INIT(= N_("E1235: Function reference is not set"));
  EXTERN char e_cannot_use_str_itself_it_is_imported_with_star[]
        INIT(= N_("E1236: Cannot use %s itself, it is imported with '*'"));
+ EXTERN char e_no_such_user_defined_command_in_current_buffer_str[]
+       INIT(= N_("E1237: No such user-defined command in current buffer: %s"));
*** ../vim-8.2.3432/src/testdir/test_usercommands.vim   2021-09-06 
17:10:55.073336145 +0200
--- src/testdir/test_usercommands.vim   2021-09-12 20:53:34.682076861 +0200
***************
*** 656,659 ****
--- 656,680 ----
    call CheckScriptFailure(lines, 'E1231:')
  endfunc
  
+ func Test_delcommand_buffer()
+   command Global echo 'global'
+   command -buffer OneBuffer echo 'one'
+   new
+   command -buffer TwoBuffer echo 'two'
+   call assert_equal(0, exists(':OneBuffer'))
+   call assert_equal(2, exists(':Global'))
+   call assert_equal(2, exists(':TwoBuffer'))
+   delcommand -buffer TwoBuffer
+   call assert_equal(0, exists(':TwoBuffer'))
+   call assert_fails('delcommand -buffer Global', 'E1237:')
+   call assert_fails('delcommand -buffer OneBuffer', 'E1237:')
+   bwipe!
+   call assert_equal(2, exists(':OneBuffer'))
+   delcommand -buffer OneBuffer
+   call assert_equal(0, exists(':OneBuffer'))
+   call assert_fails('delcommand -buffer Global', 'E1237:')
+   delcommand Global
+   call assert_equal(0, exists(':Global'))
+ endfunc
+ 
  " vim: shiftwidth=2 sts=2 expandtab
*** ../vim-8.2.3432/src/version.c       2021-09-12 17:03:04.856023559 +0200
--- src/version.c       2021-09-12 20:07:10.678611923 +0200
***************
*** 757,758 ****
--- 757,760 ----
  {   /* Add new patch number below this line */
+ /**/
+     3433,
  /**/

-- 
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/202109121858.18CIwSUL936275%40masaka.moolenaar.net.

Raspunde prin e-mail lui