{"action":"opened","number":600,"pull_request":{"url":"https://api.github.com/repos/capitaomorte/yasnippet/pulls/600","id":41627063,"html_url":"https://github.com/capitaomorte/yasnippet/pull/600","diff_url":"https://github.com/capitaomorte/yasnippet/pull/600.diff","patch_url":"https://github.com/capitaomorte/yasnippet/pull/600.patch","issue_url":"https://api.github.com/repos/capitaomorte/yasnippet/issues/600","number":600,"state":"open","locked":false,"title":"Yas Backsolve Feature","user":{"login":"lixiaolan","id":5097458,"avatar_url":"https://avatars.githubusercontent.com/u/5097458?v=3","gravatar_id":"","url":"https://api.github.com/users/lixiaolan","html_url":"https://github.com/lixiaolan","followers_url":"https://api.github.com/users/lixiaolan/followers","following_url":"https://api.github.com/users/lixiaolan/following{/other_user}","gists_url":"https://api.github.com/users/lixiaolan/gists{/gist_id}","starred_url":"https://api.github.com/users/lixiaolan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lixiaolan/subscriptions","organizations_url":"https://api.github.com/users/lixiaolan/orgs","repos_url":"https://api.github.com/users/lixiaolan/repos","events_url":"https://api.github.com/users/lixiaolan/events{/privacy}","received_events_url":"https://api.github.com/users/lixiaolan/received_events","type":"User","site_admin":false},"body":"# INTRO\r\n\r\nThis pull request is regarding some new functionality I have been experimenting with for yasnippet. I thought you might like to take a look and see if it is something that you would want to eventually add to yasnippet. If you are interested in this development, we can discuss how best to eventually integrate it into the master branch. Any and all feedback is welcome.\r\n\r\n# IDEA\r\n\r\nThe idea is to add \"back solving\" capability. This means that text created with a snippet can be re-initialized and re-edited as a snippet. Even text was not created using a snippet can be \"back solved\". The one new interative function in my branch is \"yas-backsolve\". It will prompt for snippet key and then search forward for a snippet to re-activate.\r\n\r\n# WHY?\r\n\r\nA couple examples of the use case where I like to use yas-backsolve in my own work. Suppose I use the c++ snippet with key \"fori\":\r\n\r\n    for (${1:auto }${2:it} = ${3:var}.begin(); $2 != $3.end(); ++$2) {\r\n        $0\r\n    }\r\n\r\nto create the code\r\n\r\n    for (auto myIterator = myVector.begin(); myIterator != myVector.end(); ++myIterator) {\r\n        myValue += *myIterator;\r\n    }\r\n\r\nand I later want to change the name myIterator to yourIterator and myVector to yourVector. Running yas-backsolve on the the key \"fori\" re-activates the snippet as if I had just created it (with field names preserved) and I can tab through and edit the names fields and the changes will update in all the mirrors. It does not matter if this for loop code was created using a snippet in the first place. yas-backsolve will still work.\r\n\r\nAnother place I use yas-backsolve is with the latex snippet with key \"begin\":\r\n\r\n    \\begin{${1:env}}\r\n      $0\r\n    \\end{$1}\r\n\r\nSuppose I open a latex file and it looks like\r\n\r\n    \\begin{enumerate}\r\n      \\item thing one\r\n      \\item \r\n        \\begin{center}\r\n          thing two\r\n        \\end{center}\r\n      \\item thing three\r\n    \\end{enumerate}\r\n\r\nI can run yas-backsolve with key begin to re-enter the snippet used to create the \"enumerate\" environment and change it to \"itemize\". The text in the \"begin\" and \"end\" will be updated simultaneously.\r\n\r\nOnce a person is comfortable using basic yasnippets, yas-backsolve feels very natural since it uses the same UI.\r\n      \r\n# HOW?\r\n\r\nyas-backsolve works by utilizing regular expressions to figure out what text was inserted into the fields of a snippet. Once given a snippet key, yas-backsolve converts the snippet into a regular expression capable of searching for text that looks like it was created using the snippet corresponding to the key. If it finds a match, it extracts text that was entered into the fields of the snippet. Using this information, yas-backsolve initializes the matched text as if it were a snippet begin edited.\r\n\r\nyas-backsolve does not store any metadata associated with files. Snippets are not cached in any way. This way I can edit a file I have opened for the first time as if snippets had been used in its creation.\r\n\r\n# WHAT NOW?\r\n\r\nyas-backsolve has some known limitations. Currently it works only on snippets with simple non-nested mirror fileds. Snippets using lisp expressions in their fields or mirrors will not work properly. yas-backsolve attempts to determine before running if the input snippet is compatible and notifies the user accordingly. Over time, I intend to expand the functionality of yas-backsolve to overcome these limiations.\r\n\r\nI am sharing what I have now to get some feedback on what areas I should focus on first if there is interest in including this functionality into yasnippet. Any comments regarding features, UI, and coding style are all welcome.","created_at":"2015-08-04T22:53:50Z","updated_at":"2015-08-04T22:53:50Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/capitaomorte/yasnippet/pulls/600/commits","review_comments_url":"https://api.github.com/repos/capitaomorte/yasnippet/pulls/600/comments","review_comment_url":"https://api.github.com/repos/capitaomorte/yasnippet/pulls/comments{/number}","comments_url":"https://api.github.com/repos/capitaomorte/yasnippet/issues/600/comments","statuses_url":"https://api.github.com/repos/capitaomorte/yasnippet/statuses/721115100a8b0d66a2906a8cbecbb0bfd8d39a61","head":{"label":"lixiaolan:backsolve","ref":"backsolve","sha":"721115100a8b0d66a2906a8cbecbb0bfd8d39a61","user":{"login":"lixiaolan","id":5097458,"avatar_url":"https://avatars.githubusercontent.com/u/5097458?v=3","gravatar_id":"","url":"https://api.github.com/users/lixiaolan","html_url":"https://github.com/lixiaolan","followers_url":"https://api.github.com/users/lixiaolan/followers","following_url":"https://api.github.com/users/lixiaolan/following{/other_user}","gists_url":"https://api.github.com/users/lixiaolan/gists{/gist_id}","starred_url":"https://api.github.com/users/lixiaolan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lixiaolan/subscriptions","organizations_url":"https://api.github.com/users/lixiaolan/orgs","repos_url":"https://api.github.com/users/lixiaolan/repos","events_url":"https://api.github.com/users/lixiaolan/events{/privacy}","received_events_url":"https://api.github.com/users/lixiaolan/received_events","type":"User","site_admin":false},"repo":{"id":40212154,"name":"yasnippet","full_name":"lixiaolan/yasnippet","owner":{"login":"lixiaolan","id":5097458,"avatar_url":"https://avatars.githubusercontent.com/u/5097458?v=3","gravatar_id":"","url":"https://api.github.com/users/lixiaolan","html_url":"https://github.com/lixiaolan","followers_url":"https://api.github.com/users/lixiaolan/followers","following_url":"https://api.github.com/users/lixiaolan/following{/other_user}","gists_url":"https://api.github.com/users/lixiaolan/gists{/gist_id}","starred_url":"https://api.github.com/users/lixiaolan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lixiaolan/subscriptions","organizations_url":"https://api.github.com/users/lixiaolan/orgs","repos_url":"https://api.github.com/users/lixiaolan/repos","events_url":"https://api.github.com/users/lixiaolan/events{/privacy}","received_events_url":"https://api.github.com/users/lixiaolan/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/lixiaolan/yasnippet","description":"A template system for Emacs","fork":true,"url":"https://api.github.com/repos/lixiaolan/yasnippet","forks_url":"https://api.github.com/repos/lixiaolan/yasnippet/forks","keys_url":"https://api.github.com/repos/lixiaolan/yasnippet/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lixiaolan/yasnippet/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lixiaolan/yasnippet/teams","hooks_url":"https://api.github.com/repos/lixiaolan/yasnippet/hooks","issue_events_url":"https://api.github.com/repos/lixiaolan/yasnippet/issues/events{/number}","events_url":"https://api.github.com/repos/lixiaolan/yasnippet/events","assignees_url":"https://api.github.com/repos/lixiaolan/yasnippet/assignees{/user}","branches_url":"https://api.github.com/repos/lixiaolan/yasnippet/branches{/branch}","tags_url":"https://api.github.com/repos/lixiaolan/yasnippet/tags","blobs_url":"https://api.github.com/repos/lixiaolan/yasnippet/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lixiaolan/yasnippet/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lixiaolan/yasnippet/git/refs{/sha}","trees_url":"https://api.github.com/repos/lixiaolan/yasnippet/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lixiaolan/yasnippet/statuses/{sha}","languages_url":"https://api.github.com/repos/lixiaolan/yasnippet/languages","stargazers_url":"https://api.github.com/repos/lixiaolan/yasnippet/stargazers","contributors_url":"https://api.github.com/repos/lixiaolan/yasnippet/contributors","subscribers_url":"https://api.github.com/repos/lixiaolan/yasnippet/subscribers","subscription_url":"https://api.github.com/repos/lixiaolan/yasnippet/subscription","commits_url":"https://api.github.com/repos/lixiaolan/yasnippet/commits{/sha}","git_commits_url":"https://api.github.com/repos/lixiaolan/yasnippet/git/commits{/sha}","comments_url":"https://api.github.com/repos/lixiaolan/yasnippet/comments{/number}","issue_comment_url":"https://api.github.com/repos/lixiaolan/yasnippet/issues/comments{/number}","contents_url":"https://api.github.com/repos/lixiaolan/yasnippet/contents/{+path}","compare_url":"https://api.github.com/repos/lixiaolan/yasnippet/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lixiaolan/yasnippet/merges","archive_url":"https://api.github.com/repos/lixiaolan/yasnippet/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lixiaolan/yasnippet/downloads","issues_url":"https://api.github.com/repos/lixiaolan/yasnippet/issues{/number}","pulls_url":"https://api.github.com/repos/lixiaolan/yasnippet/pulls{/number}","milestones_url":"https://api.github.com/repos/lixiaolan/yasnippet/milestones{/number}","notifications_url":"https://api.github.com/repos/lixiaolan/yasnippet/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lixiaolan/yasnippet/labels{/name}","releases_url":"https://api.github.com/repos/lixiaolan/yasnippet/releases{/id}","created_at":"2015-08-04T22:27:34Z","updated_at":"2015-08-04T22:27:35Z","pushed_at":"2015-08-04T22:41:27Z","git_url":"git://github.com/lixiaolan/yasnippet.git","ssh_url":"git@github.com:lixiaolan/yasnippet.git","clone_url":"https://github.com/lixiaolan/yasnippet.git","svn_url":"https://github.com/lixiaolan/yasnippet","homepage":"","size":6074,"stargazers_count":0,"watchers_count":0,"language":"Emacs Lisp","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"capitaomorte:master","ref":"master","sha":"c91a58840b86ae92061a003ec07db1010fde6c90","user":{"login":"capitaomorte","id":387011,"avatar_url":"https://avatars.githubusercontent.com/u/387011?v=3","gravatar_id":"","url":"https://api.github.com/users/capitaomorte","html_url":"https://github.com/capitaomorte","followers_url":"https://api.github.com/users/capitaomorte/followers","following_url":"https://api.github.com/users/capitaomorte/following{/other_user}","gists_url":"https://api.github.com/users/capitaomorte/gists{/gist_id}","starred_url":"https://api.github.com/users/capitaomorte/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/capitaomorte/subscriptions","organizations_url":"https://api.github.com/users/capitaomorte/orgs","repos_url":"https://api.github.com/users/capitaomorte/repos","events_url":"https://api.github.com/users/capitaomorte/events{/privacy}","received_events_url":"https://api.github.com/users/capitaomorte/received_events","type":"User","site_admin":false},"repo":{"id":2537904,"name":"yasnippet","full_name":"capitaomorte/yasnippet","owner":{"login":"capitaomorte","id":387011,"avatar_url":"https://avatars.githubusercontent.com/u/387011?v=3","gravatar_id":"","url":"https://api.github.com/users/capitaomorte","html_url":"https://github.com/capitaomorte","followers_url":"https://api.github.com/users/capitaomorte/followers","following_url":"https://api.github.com/users/capitaomorte/following{/other_user}","gists_url":"https://api.github.com/users/capitaomorte/gists{/gist_id}","starred_url":"https://api.github.com/users/capitaomorte/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/capitaomorte/subscriptions","organizations_url":"https://api.github.com/users/capitaomorte/orgs","repos_url":"https://api.github.com/users/capitaomorte/repos","events_url":"https://api.github.com/users/capitaomorte/events{/privacy}","received_events_url":"https://api.github.com/users/capitaomorte/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/capitaomorte/yasnippet","description":"A template system for Emacs","fork":false,"url":"https://api.github.com/repos/capitaomorte/yasnippet","forks_url":"https://api.github.com/repos/capitaomorte/yasnippet/forks","keys_url":"https://api.github.com/repos/capitaomorte/yasnippet/keys{/key_id}","collaborators_url":"https://api.github.com/repos/capitaomorte/yasnippet/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/capitaomorte/yasnippet/teams","hooks_url":"https://api.github.com/repos/capitaomorte/yasnippet/hooks","issue_events_url":"https://api.github.com/repos/capitaomorte/yasnippet/issues/events{/number}","events_url":"https://api.github.com/repos/capitaomorte/yasnippet/events","assignees_url":"https://api.github.com/repos/capitaomorte/yasnippet/assignees{/user}","branches_url":"https://api.github.com/repos/capitaomorte/yasnippet/branches{/branch}","tags_url":"https://api.github.com/repos/capitaomorte/yasnippet/tags","blobs_url":"https://api.github.com/repos/capitaomorte/yasnippet/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/capitaomorte/yasnippet/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/capitaomorte/yasnippet/git/refs{/sha}","trees_url":"https://api.github.com/repos/capitaomorte/yasnippet/git/trees{/sha}","statuses_url":"https://api.github.com/repos/capitaomorte/yasnippet/statuses/{sha}","languages_url":"https://api.github.com/repos/capitaomorte/yasnippet/languages","stargazers_url":"https://api.github.com/repos/capitaomorte/yasnippet/stargazers","contributors_url":"https://api.github.com/repos/capitaomorte/yasnippet/contributors","subscribers_url":"https://api.github.com/repos/capitaomorte/yasnippet/subscribers","subscription_url":"https://api.github.com/repos/capitaomorte/yasnippet/subscription","commits_url":"https://api.github.com/repos/capitaomorte/yasnippet/commits{/sha}","git_commits_url":"https://api.github.com/repos/capitaomorte/yasnippet/git/commits{/sha}","comments_url":"https://api.github.com/repos/capitaomorte/yasnippet/comments{/number}","issue_comment_url":"https://api.github.com/repos/capitaomorte/yasnippet/issues/comments{/number}","contents_url":"https://api.github.com/repos/capitaomorte/yasnippet/contents/{+path}","compare_url":"https://api.github.com/repos/capitaomorte/yasnippet/compare/{base}...{head}","merges_url":"https://api.github.com/repos/capitaomorte/yasnippet/merges","archive_url":"https://api.github.com/repos/capitaomorte/yasnippet/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/capitaomorte/yasnippet/downloads","issues_url":"https://api.github.com/repos/capitaomorte/yasnippet/issues{/number}","pulls_url":"https://api.github.com/repos/capitaomorte/yasnippet/pulls{/number}","milestones_url":"https://api.github.com/repos/capitaomorte/yasnippet/milestones{/number}","notifications_url":"https://api.github.com/repos/capitaomorte/yasnippet/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/capitaomorte/yasnippet/labels{/name}","releases_url":"https://api.github.com/repos/capitaomorte/yasnippet/releases{/id}","created_at":"2011-10-08T12:05:37Z","updated_at":"2015-08-04T03:58:50Z","pushed_at":"2015-08-04T21:48:23Z","git_url":"git://github.com/capitaomorte/yasnippet.git","ssh_url":"git@github.com:capitaomorte/yasnippet.git","clone_url":"https://github.com/capitaomorte/yasnippet.git","svn_url":"https://github.com/capitaomorte/yasnippet","homepage":"","size":6074,"stargazers_count":1060,"watchers_count":1060,"language":"Emacs Lisp","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":208,"mirror_url":null,"open_issues_count":80,"forks":208,"open_issues":80,"watchers":1060,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/capitaomorte/yasnippet/pulls/600"},"html":{"href":"https://github.com/capitaomorte/yasnippet/pull/600"},"issue":{"href":"https://api.github.com/repos/capitaomorte/yasnippet/issues/600"},"comments":{"href":"https://api.github.com/repos/capitaomorte/yasnippet/issues/600/comments"},"review_comments":{"href":"https://api.github.com/repos/capitaomorte/yasnippet/pulls/600/comments"},"review_comment":{"href":"https://api.github.com/repos/capitaomorte/yasnippet/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/capitaomorte/yasnippet/pulls/600/commits"},"statuses":{"href":"https://api.github.com/repos/capitaomorte/yasnippet/statuses/721115100a8b0d66a2906a8cbecbb0bfd8d39a61"}},"merged":false,"mergeable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"commits":1,"additions":472,"deletions":0,"changed_files":1}}