Karsten Hopp 20001a
To: vim_dev@googlegroups.com
Karsten Hopp 20001a
Subject: Patch 7.3.054
Karsten Hopp 20001a
Fcc: outbox
Karsten Hopp 20001a
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 20001a
Mime-Version: 1.0
Karsten Hopp 20001a
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 20001a
Content-Transfer-Encoding: 8bit
Karsten Hopp 20001a
------------
Karsten Hopp 20001a
Karsten Hopp 20001a
Patch 7.3.054
Karsten Hopp 20001a
Problem:    Can define a user command for :Print, but it doesn't work. (Aaron
Karsten Hopp 20001a
	    Thoma)
Karsten Hopp 20001a
Solution:   Let user command :Print overrule the builtin command (Christian
Karsten Hopp 20001a
	    Brabandt)  Disallow :X and :Next as a user defined command.
Karsten Hopp 20001a
Files:	    src/ex_docmd.c
Karsten Hopp 20001a
Karsten Hopp 20001a
Karsten Hopp 20001a
*** ../vim-7.3.053/src/ex_docmd.c	2010-10-13 17:50:02.000000000 +0200
Karsten Hopp 20001a
--- src/ex_docmd.c	2010-11-10 18:33:18.000000000 +0100
Karsten Hopp 20001a
***************
Karsten Hopp 20001a
*** 2871,2878 ****
Karsten Hopp 20001a
  	    }
Karsten Hopp 20001a
  
Karsten Hopp 20001a
  #ifdef FEAT_USR_CMDS
Karsten Hopp 20001a
! 	/* Look for a user defined command as a last resort */
Karsten Hopp 20001a
! 	if (eap->cmdidx == CMD_SIZE && *eap->cmd >= 'A' && *eap->cmd <= 'Z')
Karsten Hopp 20001a
  	{
Karsten Hopp 20001a
  	    /* User defined commands may contain digits. */
Karsten Hopp 20001a
  	    while (ASCII_ISALNUM(*p))
Karsten Hopp 20001a
--- 2871,2880 ----
Karsten Hopp 20001a
  	    }
Karsten Hopp 20001a
  
Karsten Hopp 20001a
  #ifdef FEAT_USR_CMDS
Karsten Hopp 20001a
! 	/* Look for a user defined command as a last resort.  Let ":Print" be
Karsten Hopp 20001a
! 	 * overruled by a user defined command. */
Karsten Hopp 20001a
! 	if ((eap->cmdidx == CMD_SIZE || eap->cmdidx == CMD_Print)
Karsten Hopp 20001a
! 		&& *eap->cmd >= 'A' && *eap->cmd <= 'Z')
Karsten Hopp 20001a
  	{
Karsten Hopp 20001a
  	    /* User defined commands may contain digits. */
Karsten Hopp 20001a
  	    while (ASCII_ISALNUM(*p))
Karsten Hopp 20001a
***************
Karsten Hopp 20001a
*** 5588,5593 ****
Karsten Hopp 20001a
--- 5590,5596 ----
Karsten Hopp 20001a
      int	    compl = EXPAND_NOTHING;
Karsten Hopp 20001a
      char_u  *compl_arg = NULL;
Karsten Hopp 20001a
      int	    has_attr = (eap->arg[0] == '-');
Karsten Hopp 20001a
+     int	    name_len;
Karsten Hopp 20001a
  
Karsten Hopp 20001a
      p = eap->arg;
Karsten Hopp 20001a
  
Karsten Hopp 20001a
***************
Karsten Hopp 20001a
*** 5613,5618 ****
Karsten Hopp 20001a
--- 5616,5622 ----
Karsten Hopp 20001a
  	return;
Karsten Hopp 20001a
      }
Karsten Hopp 20001a
      end = p;
Karsten Hopp 20001a
+     name_len = (int)(end - name);
Karsten Hopp 20001a
  
Karsten Hopp 20001a
      /* If there is nothing after the name, and no attributes were specified,
Karsten Hopp 20001a
       * we are listing commands
Karsten Hopp 20001a
***************
Karsten Hopp 20001a
*** 5627,5632 ****
Karsten Hopp 20001a
--- 5631,5643 ----
Karsten Hopp 20001a
  	EMSG(_("E183: User defined commands must start with an uppercase letter"));
Karsten Hopp 20001a
  	return;
Karsten Hopp 20001a
      }
Karsten Hopp 20001a
+     else if ((name_len == 1 && *name == 'X')
Karsten Hopp 20001a
+ 	  || (name_len <= 4
Karsten Hopp 20001a
+ 		  && STRNCMP(name, "Next", name_len > 4 ? 4 : name_len) == 0))
Karsten Hopp 20001a
+     {
Karsten Hopp 20001a
+ 	EMSG(_("E841: Reserved name, cannot be used for user defined command"));
Karsten Hopp 20001a
+ 	return;
Karsten Hopp 20001a
+     }
Karsten Hopp 20001a
      else
Karsten Hopp 20001a
  	uc_add_command(name, end - name, p, argt, def, flags, compl, compl_arg,
Karsten Hopp 20001a
  								eap->forceit);
Karsten Hopp 20001a
***************
Karsten Hopp 20001a
*** 9394,9400 ****
Karsten Hopp 20001a
  ex_ptag(eap)
Karsten Hopp 20001a
      exarg_T	*eap;
Karsten Hopp 20001a
  {
Karsten Hopp 20001a
!     g_do_tagpreview = p_pvh;
Karsten Hopp 20001a
      ex_tag_cmd(eap, cmdnames[eap->cmdidx].cmd_name + 1);
Karsten Hopp 20001a
  }
Karsten Hopp 20001a
  
Karsten Hopp 20001a
--- 9405,9411 ----
Karsten Hopp 20001a
  ex_ptag(eap)
Karsten Hopp 20001a
      exarg_T	*eap;
Karsten Hopp 20001a
  {
Karsten Hopp 20001a
!     g_do_tagpreview = p_pvh;  /* will be reset to 0 in ex_tag_cmd() */
Karsten Hopp 20001a
      ex_tag_cmd(eap, cmdnames[eap->cmdidx].cmd_name + 1);
Karsten Hopp 20001a
  }
Karsten Hopp 20001a
  
Karsten Hopp 20001a
*** ../vim-7.3.053/src/version.c	2010-11-10 17:11:29.000000000 +0100
Karsten Hopp 20001a
--- src/version.c	2010-11-10 18:58:28.000000000 +0100
Karsten Hopp 20001a
***************
Karsten Hopp 20001a
*** 716,717 ****
Karsten Hopp 20001a
--- 716,719 ----
Karsten Hopp 20001a
  {   /* Add new patch number below this line */
Karsten Hopp 20001a
+ /**/
Karsten Hopp 20001a
+     54,
Karsten Hopp 20001a
  /**/
Karsten Hopp 20001a
Karsten Hopp 20001a
-- 
Karsten Hopp 20001a
You can be stopped by the police for biking over 65 miles per hour.
Karsten Hopp 20001a
You are not allowed to walk across a street on your hands.
Karsten Hopp 20001a
		[real standing laws in Connecticut, United States of America]
Karsten Hopp 20001a
Karsten Hopp 20001a
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 20001a
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 20001a
\\\        download, build and distribute -- http://www.A-A-P.org        ///
Karsten Hopp 20001a
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///