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

Re: Suggestion: allow 'z=' when spell-checking isn't on

Expand Messages
  • Christian Brabandt
    ... That is actually a strange behaviour of normal Vim and has nothing to do with my patch. Bram, problem is, nv_zet calls spell_move_to() function, which
    Message 1 of 18 , Sep 8, 2013
    • 0 Attachment
      On Sa, 07 Sep 2013, Gary Johnson wrote:

      > On 2013-08-12, Gary Johnson wrote:
      > > On 2013-08-12, Christian Brabandt wrote:
      >
      > > > Oh well, here is an updated version attached. Yes, it is really
      > > > attached...
      > >
      > > I'm glad to have the updated patch. Thank you. It is working fine
      > > so far. I'll let you know if that changes.
      >
      > I just noticed an odd behavior of the spell feature with your patch
      > included. I did not have 'spell' enabled but checked the spelling
      > of a word with z=. The word was not in the list, so I found the
      > correct spelling on the web, changed the word in my text, and
      > attempted to add it to my spelling list with zg. Two messages
      > appeared:
      >
      > E756: Spell checking is not enabled
      > Word added to ~/.vim/spell/en.utf-8.add
      >
      > Since the word was added successfully, it seems that the error
      > message should not have appeared.

      That is actually a strange behaviour of normal Vim and has nothing to do
      with my patch.

      Bram,
      problem is, nv_zet calls spell_move_to() function, which errors out, if
      spell checking is not enabled. But if spell checking is not enabled, Vim
      uses find_ident_under_cursor() to get the identifier under the cursor and
      adds this nevertheless to the spellfile.

      I think, this can cause vim to add/remove different words to the
      spellfile, depending on the 'spell' setting, but I am not sure, how to
      test (the second patch at least makes Vim mention, which word has been added/removed).

      Here is a patch, that prevents the spurious E756 error in the case of 'zg/zb'

      diff --git a/src/normal.c b/src/normal.c
      --- a/src/normal.c
      +++ b/src/normal.c
      @@ -5247,7 +5247,9 @@
      pos_T pos = curwin->w_cursor;

      /* Find bad word under the cursor. */
      + emsg_off++; /* Avoid E576 error */
      len = spell_move_to(curwin, FORWARD, TRUE, TRUE, NULL);
      + emsg_off--;
      if (len != 0 && curwin->w_cursor.col <= pos.col)
      ptr = ml_get_pos(&curwin->w_cursor);
      curwin->w_cursor = pos;

      And this patch, explicitly tells the user, what word has been
      removed/added to the spellfile:

      diff --git a/src/spell.c b/src/spell.c
      --- a/src/spell.c
      +++ b/src/spell.c
      @@ -9479,7 +9479,7 @@
      if (undo)
      {
      home_replace(NULL, fname, NameBuff, MAXPATHL, TRUE);
      - smsg((char_u *)_("Word removed from %s"), NameBuff);
      + smsg((char_u *)_("Word '%s' removed from %s"), word, NameBuff);
      }
      }
      fseek(fd, fpos_next, SEEK_SET);
      @@ -9525,7 +9525,7 @@
      fclose(fd);

      home_replace(NULL, fname, NameBuff, MAXPATHL, TRUE);
      - smsg((char_u *)_("Word added to %s"), NameBuff);
      + smsg((char_u *)_("Word '%s' added to %s"), word, NameBuff);
      }
      }

      regards,
      Christian
      --
      Man muß alt geworden sein, also gelebt haben, um zu erkennen, wie kurz
      das Leben ist.
      -- Arthur Schopenhauer (Aphorismen zur Lebensweisheit)

      --
      --
      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.
    • Gary Johnson
      ... Your message arrived with its tabs expanded to spaces, but once I fixed that, I was able to apply both patches. Thanks. Regards, Gary -- -- You received
      Message 2 of 18 , Sep 8, 2013
      • 0 Attachment
        On 2013-09-08, Christian Brabandt wrote:
        > On Sa, 07 Sep 2013, Gary Johnson wrote:

        > > I just noticed an odd behavior of the spell feature with your patch
        > > included. ...

        > That is actually a strange behaviour of normal Vim and has nothing to do
        > with my patch.
        ...
        > Here is a patch, that prevents the spurious E756 error in the case of 'zg/zb'
        ...
        > And this patch, explicitly tells the user, what word has been
        > removed/added to the spellfile:

        Your message arrived with its tabs expanded to spaces, but once I
        fixed that, I was able to apply both patches. Thanks.

        Regards,
        Gary

        --
        --
        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
        ... Isn t the problem that zw is intended to use the word under the cursor, but it uses the next word marked as misspelled? I haven t actually tried it...
        Message 3 of 18 , Sep 10, 2013
        • 0 Attachment
          Christian Brabandt wrote:

          > On Sa, 07 Sep 2013, Gary Johnson wrote:
          >
          > > On 2013-08-12, Gary Johnson wrote:
          > > > On 2013-08-12, Christian Brabandt wrote:
          > >
          > > > > Oh well, here is an updated version attached. Yes, it is really
          > > > > attached...
          > > >
          > > > I'm glad to have the updated patch. Thank you. It is working fine
          > > > so far. I'll let you know if that changes.
          > >
          > > I just noticed an odd behavior of the spell feature with your patch
          > > included. I did not have 'spell' enabled but checked the spelling
          > > of a word with z=. The word was not in the list, so I found the
          > > correct spelling on the web, changed the word in my text, and
          > > attempted to add it to my spelling list with zg. Two messages
          > > appeared:
          > >
          > > E756: Spell checking is not enabled
          > > Word added to ~/.vim/spell/en.utf-8.add
          > >
          > > Since the word was added successfully, it seems that the error
          > > message should not have appeared.
          >
          > That is actually a strange behaviour of normal Vim and has nothing to do
          > with my patch.
          >
          > Bram,
          > problem is, nv_zet calls spell_move_to() function, which errors out, if
          > spell checking is not enabled. But if spell checking is not enabled, Vim
          > uses find_ident_under_cursor() to get the identifier under the cursor and
          > adds this nevertheless to the spellfile.
          >
          > I think, this can cause vim to add/remove different words to the
          > spellfile, depending on the 'spell' setting, but I am not sure, how to
          > test (the second patch at least makes Vim mention, which word has been
          > added/removed).

          Isn't the problem that "zw" is intended to use the word under the
          cursor, but it uses the next word marked as misspelled? I haven't
          actually tried it...

          > Here is a patch, that prevents the spurious E756 error in the case of 'zg/zb'

          Thanks.

          --
          Some of the well known MS-Windows errors:
          EHUH Unexpected error
          EUSER User error, not our fault!
          EGOD Horrible problem, god knows what has happened
          EERR Errornous error: nothing wrong

          /// 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.