{"action":"created","issue":{"url":"https://api.github.com/repos/SirVer/ultisnips/issues/676","repository_url":"https://api.github.com/repos/SirVer/ultisnips","labels_url":"https://api.github.com/repos/SirVer/ultisnips/issues/676/labels{/name}","comments_url":"https://api.github.com/repos/SirVer/ultisnips/issues/676/comments","events_url":"https://api.github.com/repos/SirVer/ultisnips/issues/676/events","html_url":"https://github.com/SirVer/ultisnips/issues/676","id":143738390,"number":676,"title":"Strange behaviour in python snippet (using vim interpolation)","user":{"login":"purpleP","id":6205841,"avatar_url":"https://avatars.githubusercontent.com/u/6205841?v=3","gravatar_id":"","url":"https://api.github.com/users/purpleP","html_url":"https://github.com/purpleP","followers_url":"https://api.github.com/users/purpleP/followers","following_url":"https://api.github.com/users/purpleP/following{/other_user}","gists_url":"https://api.github.com/users/purpleP/gists{/gist_id}","starred_url":"https://api.github.com/users/purpleP/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/purpleP/subscriptions","organizations_url":"https://api.github.com/users/purpleP/orgs","repos_url":"https://api.github.com/users/purpleP/repos","events_url":"https://api.github.com/users/purpleP/events{/privacy}","received_events_url":"https://api.github.com/users/purpleP/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-03-26T18:34:54Z","updated_at":"2016-03-28T05:59:59Z","closed_at":null,"body":"In [this](https://github.com/honza/vim-snippets/blob/master/snippets/python.snippets) file you can see def and deff snipptets\r\nHere they are, if you don't want to open link\r\n\r\n```\r\n# New Function\r\nsnippet def\r\n\tdef ${1:fname}(${2:`indent('.') ? 'self' : ''`}):\r\n\t\t\"\"\"${3:docstring for $1}\"\"\"\r\n\t\t${0}\r\nsnippet deff\r\n\tdef ${1:fname}(${2:`indent('.') ? 'self' : ''`}):\r\n\t\t${0}\r\n```\r\n\r\nWhat the author is trying to do is pretty smart because he's using indentation level too add or to not add self argument. But how it works is really strange. I've recorded a [video](https://dl.dropboxusercontent.com/u/28070056/out.gif) to show you."},"comment":{"url":"https://api.github.com/repos/SirVer/ultisnips/issues/comments/202246536","html_url":"https://github.com/SirVer/ultisnips/issues/676#issuecomment-202246536","issue_url":"https://api.github.com/repos/SirVer/ultisnips/issues/676","id":202246536,"user":{"login":"seletskiy","id":674812,"avatar_url":"https://avatars.githubusercontent.com/u/674812?v=3","gravatar_id":"","url":"https://api.github.com/users/seletskiy","html_url":"https://github.com/seletskiy","followers_url":"https://api.github.com/users/seletskiy/followers","following_url":"https://api.github.com/users/seletskiy/following{/other_user}","gists_url":"https://api.github.com/users/seletskiy/gists{/gist_id}","starred_url":"https://api.github.com/users/seletskiy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/seletskiy/subscriptions","organizations_url":"https://api.github.com/users/seletskiy/orgs","repos_url":"https://api.github.com/users/seletskiy/repos","events_url":"https://api.github.com/users/seletskiy/events{/privacy}","received_events_url":"https://api.github.com/users/seletskiy/received_events","type":"User","site_admin":false},"created_at":"2016-03-28T05:59:59Z","updated_at":"2016-03-28T05:59:59Z","body":"@purpleP: It's because UltiSnips by design runs interpolations on EVERY change, so when your cursor moves to the `def` body, `indent('.')` will become equal indenting of that line, which is `> 0`.\r\n\r\nThere are at least two ways of fixing issue: (a) use regexp triggers, like this: `snippet \"(\\s+)d\"` and `snippet d`, first one will insert def with self and second will insert def without self; (b) using more complicated interpolation, that will track current state and insert `self` corretly (https://github.com/reconquest/snippets/blob/master/python.snippets#L8-L28); (c) use advanced context snippets (https://github.com/seletskiy/dotfiles/blob/master/.vim/UltiSnips/python.snippets#L119-L125)\r\n\r\nBTW, you are using outdated snipMate syntax, please, consider using much more powerful UltiSnips syntax. You can see differences in `:help UltiSnips-syntax`."}}