Thursday, June 28, 2012

Re: VimL functions to determine spelling categories?

On Fri, 29 Jun 2012, Marc Weber wrote:

> Excerpts from Benjamin R. Haskell's message of Thu Jun 28 19:35:19 +0200 2012:
>> Unfortunately, spellbadword() can change the cursor position.
> So?

So, it's a side-effect. It'd be better if there were a side-effect-free
version of the function. Plus the function combines two separate, but
related, tasks pertaining to the misspelled word under the cursor (if it
exists):

1. Move the cursor to the start of the word
2. Return information about the misspelling (the word and the type)

It'd be preferable if the function returned information about the
misspelled word, but that the information would also include its
location. Then setpos() could be used for functionality #1.


> use
> let save_cursor = getpos(".")
> MoveTheCursorAround
> call setpos('.', save_cursor)

The version I posted (based on Ingo Karkat's SpellCheck plugin) saved
the view, not just the cursor position. By only saving the cursor
position, the function that moves the cursor around might also alter
folds or the viewport (for example).


> to set cursor to old position. Not perfect - but fine.
> A second way is use sp to create a new window, move cursor there, then
> :q the split window again.

My point in calling it unfortunate wasn't to say that it's impossible
(or even that hard) to workaround. It just would have been nicer to
find an API similar to :synID (which takes a (line,col)-position as
input).

--
Best,
Ben H

--
You received this message from the "vim_use" 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

No comments:

Post a Comment