On 05-Aug-2012 20:57:24 +0200, Christian Brabandt wrote:
> Hi Ingo!
>
> On Di, 31 Jul 2012, Ingo Karkat wrote:
>
>> On 31-Jul-2012 21:31:24 +0200, Ben Fritz wrote:
>>
>>> On Tuesday, July 31, 2012 1:04:21 PM UTC-5, Ingo Karkat wrote:
>>>> On 31-Jul-2012 18:56:21 +0200, Ben Fritz wrote:
>>>>
>>>>
>>>>
>>>>> On Tuesday, July 31, 2012 3:52:06 AM UTC-5, James Cole wrote:
>>>>
>>>>>> [...] I know it'd be possible to write a map to do this, but it seems
>>>>
>>>>>> like it'd be a sensible default behavior for z=
>>>>
>>>>>>
>>>>
>>>>>> [4 lines deleted]
>>>>
>>>>>
>>>>
>>>>> How about:
>>>>
>>>>>
>>>>
>>>>> nnoremap z= :<C-U>set spell<CR>z=
>>>>
>>>>>
>>>>
>>>>> And probably another mapping to turn off spell check if you want it.
>>>>
>>>>>
>>>>
>>>>> Alternatively, you could just change the highlight to be less
>>>>
>>>>> distracting, using :hi rules on SpellBad, SpellCap, SpellRare, and
>>>>
>>>>> SpellLocal.
>>>>
>>>>
>>>>
>>>> Have you read his actual email? James explicitly referred to the
>>>> shortcomings of
>>>>
>>>> such a mapping. I second James' request, especially because I have written
>>>> such
>>>>
>>>> a mapping for myself, and it isn't trivial (have to handle empty
>>>> 'spelllang' and
>>>>
>>>> other settings that prevent spell checking, turning off 'spell' again
>>>> after the
>>>>
>>>> user interaction requires an autocmd, ...)
>>>>
>>>>
>>>>
>>>> -- regards, ingo
>>>
>>> I see "I know it'd be possible to write a map to do this, but it seems
>>> like it'd be a sensible default behavior for z=" but don't see a
>>> discussion of the shortcomings.
>>
>> I think the key part that you missed is automatically turning off the spell
>> checking / highlighting after z=. Your proposed mapping doesn't even attempt
>> that. Having to invoke a second mapping to turn this off is very cumbersome,
>> and
>> not what James had in mind.
>>
>>> However, I can agree that it would be a useful feature to not require
>>> such a mapping.
>>
>> Right. Especially because it's difficult to write a mapping around something
>> that requires user interaction, like the query of the spell correction
>> candidate
>> in z=.
>
>
> Does this patch work for you?
>
> diff --git a/src/spell.c b/src/spell.c
> --- a/src/spell.c
> +++ b/src/spell.c
> @@ -10155,9 +10155,24 @@
> int selected = count;
> int badlen = 0;
> int msg_scroll_save = msg_scroll;
> -
> - if (no_spell_checking(curwin))
> + int wo_spell_save;
> +
> +/* if (no_spell_checking(curwin))
> + return; */
> + wo_spell_save = curwin->w_p_spell;
> +
> + if (!curwin->w_p_spell)
> + {
> + did_set_spelllang(curwin);
> + curwin->w_p_spell = TRUE;
> + }
> +
> + if (*curwin->w_s->b_p_spl == NUL)
> + {
> + EMSG(_("E756: Spell checking is not possible"));
> return;
> + }
> +
>
> #ifdef FEAT_VISUAL
> if (VIsual_active)
> @@ -10377,6 +10392,7 @@
> spell_find_cleanup(&sug);
> skip:
> vim_free(line);
> + curwin->w_p_spell = wo_spell_save;
> }
>
> /*
Hello Christian,
Sorry for checking this so late, but the patch indeed works for me. I see that
it's already in the todo list with a remark to also apply this to spellbadword()
and spellsuggest().
-- regards, ingo
--
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