[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kwrite-devel
Subject:    Conditional Parts in snippets
From:       Yannick Gingras <ygingras () ygingras ! net>
Date:       2020-12-08 13:00:59
Message-ID: fc5c4def30fb11a400f6c0aff275e56fa3283875.camel () ygingras ! net
[Download RAW message or body]


Hi, 
I am trying to write snippets for Python that would have conditional
sections.   For example:

class ${Name}($parent="object"):
       """ ${doc} """
       ${cursor}

In the above, if parent is not edited, we don't event need the
parentheses, and we can write "class Name:", which is less explicit,
but perfectly in line with the most popular coding style.   Similarly,
if the documentation string is unedited or left empty, it would be
better to remove the enclosing quotes.

I was hoping to use view.cursorPosition to detect when a place holder
has been dealt with then delete the offending characters/line if the
values is empty or unchanged.   Unfortunately, cursorPosition is not set
when expanding a snippet.

Is there another way to know which placeholders have been covered?   Is
there a better way implement conditional sections in snippets? 

By the way, I'm not subscribed to the mailing list so please CC me in
answers.

Thanks!


-- 
Yannick Gingras
http://ygingras.net


["signature.asc" (application/pgp-signature)]

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic