Friday, September 18, 2015

Re: Why does synID() always return zero when inserting at the end of a line?

On Thursday, September 17, 2015 at 9:45:27 PM UTC-5, Tony Mechelynck wrote:
> On Thu, Sep 17, 2015 at 11:58 PM,
>
> Hmm, ":help synstack()" says that
>
> The position just after the last
> character in a line and the first column in an empty line are
> valid positions.
>
> Maybe you should try and see if
> synstack(line('.'), col('.'))[-1]
> is or isn't better than synID() in borderline cases.
>

Perfect! I just tested, it seems like I can use synstack() without mucking around with adjusting column number. Here's what I'm doing to get a string to compare to "Comment":

let curHLgroup = synIDtrans(get(synstack(line('.'), col('.')),-1))

So this leads to the question: is synID()'s behavior intentional, since synstack() is able to process past the end of the line?

If so, perhaps a help note about the behavior of synID, and a link to synstack, would be useful.

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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment