Loading ...
Sorry, an error occurred while loading the content.
 

getregtype() works differently from what is documented for empty or unknown register

Expand Messages
  • Yukihiro Nakadaira
    According to :help getregtype(), it returns 0 for empty or unknown register. But it returns for empty register. And it returns unnamed register s type for
    Message 1 of 2 , Dec 26, 2013
      According to :help getregtype(), it returns 0 for empty or unknown
      register.  But it returns "" for empty register.  And it returns unnamed
      register's type for unknown register.

      Steps to reproduce:
        $ vim -u NONE -i NONE
        :" test for empty register
        :echo getregtype('a') is ''
        :" test for unknown register
        :echo getregtype('^') is ''
        :call setreg('"', 'v')
        :echo getregtype('^') is ''

      Result:
        1
        1
        0

      Expected:
        1
        1
        1


      I think it should be fixed as following.  Please check it.


      diff -r 2f856c7c1d43 runtime/doc/eval.txt
      --- a/runtime/doc/eval.txt    Sun Dec 15 10:02:33 2013 +0100
      +++ b/runtime/doc/eval.txt    Thu Dec 26 21:40:45 2013 +0900
      @@ -3460,7 +3460,7 @@
                   "v"            for |characterwise| text
                   "V"            for |linewise| text
                   "<CTRL-V>{width}"    for |blockwise-visual| text
      -            0            for an empty or unknown register
      +            ""            for an empty or unknown register
               <CTRL-V> is one character with value 0x16.
               If {regname} is not specified, |v:register| is used.
       
      diff -r 2f856c7c1d43 src/ops.c
      --- a/src/ops.c    Sun Dec 15 10:02:33 2013 +0100
      +++ b/src/ops.c    Thu Dec 26 21:40:45 2013 +0900
      @@ -6240,7 +6240,9 @@
           regname = may_get_selection(regname);
       #endif
       
      -    /* Should we check for a valid name? */
      +    if (regname != NUL && !valid_yank_reg(regname, FALSE))
      +        return MAUTO;
      +
           get_yank_register(regname, FALSE);
       
           if (y_current->y_array != NULL)


      --
      Yukihiro Nakadaira - yukihiro.nakadaira@...

      --
      --
      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 vim_dev+unsubscribe@....
      For more options, visit https://groups.google.com/groups/opt_out.
    • Bram Moolenaar
      ... Thanks, I ll check it out. -- hundred-and-one symptoms of being an internet addict: 97. Your mother tells you to remember something, and you look for a
      Message 2 of 2 , Jan 5, 2014
        Yukihiro Nakadaira wrote:

        > According to :help getregtype(), it returns 0 for empty or unknown
        > register. But it returns "" for empty register. And it returns unnamed
        > register's type for unknown register.
        >
        > Steps to reproduce:
        > $ vim -u NONE -i NONE
        > :" test for empty register
        > :echo getregtype('a') is ''
        > :" test for unknown register
        > :echo getregtype('^') is ''
        > :call setreg('"', 'v')
        > :echo getregtype('^') is ''
        >
        > Result:
        > 1
        > 1
        > 0
        >
        > Expected:
        > 1
        > 1
        > 1
        >
        >
        > I think it should be fixed as following. Please check it.

        Thanks, I'll check it out.

        --
        hundred-and-one symptoms of being an internet addict:
        97. Your mother tells you to remember something, and you look for
        a File/Save command.

        /// Bram Moolenaar -- Bram@... -- 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 vim_dev+unsubscribe@....
        For more options, visit https://groups.google.com/groups/opt_out.
      Your message has been successfully submitted and would be delivered to recipients shortly.