{"action":"created","comment":{"url":"https://api.github.com/repos/scopatz/xonsh/pulls/comments/64994612","id":64994612,"diff_hunk":"@@ -165,80 +162,17 @@ def complete(self, prefix, line, begidx, endidx, ctx=None):\n         \"\"\"\n         space = ' '  # intern some strings for faster appending\n         ctx = ctx or {}\n-        prefixlow = prefix.lower()\n-        _line = line\n-        line = builtins.aliases.expand_alias(line)\n-        # string stuff for automatic quoting\n-        path_str_start = ''\n-        path_str_end = ''\n-        p = _path_from_partial_string(_line, endidx)\n-        lprefix = len(prefix)\n-        if p is not None:\n-            lprefix = len(p[0])\n-            prefix = p[1]\n-            path_str_start = p[2]\n-            path_str_end = p[3]\n-        cmd = line.split(' ', 1)[0]\n-        while cmd in COMPLETION_SKIP_TOKENS:\n-            begidx -= len(cmd)+1\n-            endidx -= len(cmd)+1\n-            cmd = line.split(' ', 2)[1]\n-            line = line.split(' ', 1)[1]\n-        csc = builtins.__xonsh_env__.get('CASE_SENSITIVE_COMPLETIONS')\n-        startswither = startswithnorm if csc else startswithlow\n-        if begidx == 0:\n-            # the first thing we're typing; could be python or subprocess, so\n-            # anything goes.\n-            rtn = self.cmd_complete(prefix)\n-        elif cmd in self.bash_complete_funcs:\n-            # bash completions\n-            comps = self.bash_complete(prefix, line, begidx, endidx)\n-            pathcomp =  self.path_complete(prefix, path_str_start, path_str_end)\n-            return sorted(self._replace_canonical_rep(comps, pathcomp)), lprefix\n-        elif prefix.startswith('${') or prefix.startswith('@('):\n-            # python mode explicitly\n-            return self._python_mode_completions(prefix, ctx,\n-                                                 prefixlow,\n-                                                 startswither), lprefix\n-        elif prefix.startswith('-'):\n-            comps = self._man_completer.option_complete(prefix, cmd)\n-            return sorted(comps), lprefix\n-        elif cmd not in ctx:\n-            ltoks = line.split()\n-            if len(ltoks) > 2 and ltoks[0] == 'from' and ltoks[2] == 'import':\n-                # complete thing inside a module\n-                try:\n-                    mod = importlib.import_module(ltoks[1])\n-                except ImportError:\n-                    return set(), lprefix\n-                out = [i[0]\n-                       for i in inspect.getmembers(mod)\n-                       if i[0].startswith(prefix)]\n-                return out, lprefix\n-            if len(ltoks) == 2 and ltoks[0] == 'from':\n-                comps = ('{} '.format(i) for i in self.module_complete(prefix))\n-                return sorted(comps), lprefix\n-            if cmd == 'import' and begidx == len('import '):\n-                # completing module to import\n-                return sorted(self.module_complete(prefix)), lprefix\n-            if cmd in self._cmds_cache:\n-                # subproc mode; do path completions\n-                comps = self.path_complete(prefix, path_str_start,\n-                                           path_str_end, cdpath=True)\n-                return sorted(comps), lprefix\n+        empty_set = set()\n+        for i in completers_enabled:\n+            o = completers[i](prefix, line, begidx, endidx, ctx)\n+            if isinstance(o, tuple):","path":"xonsh/completer.py","position":87,"original_position":87,"commit_id":"3798ddb4dc15a323fb2e2450ab1a43091359eeae","original_commit_id":"3798ddb4dc15a323fb2e2450ab1a43091359eeae","user":{"login":"adqm","id":549404,"avatar_url":"https://avatars.githubusercontent.com/u/549404?v=3","gravatar_id":"","url":"https://api.github.com/users/adqm","html_url":"https://github.com/adqm","followers_url":"https://api.github.com/users/adqm/followers","following_url":"https://api.github.com/users/adqm/following{/other_user}","gists_url":"https://api.github.com/users/adqm/gists{/gist_id}","starred_url":"https://api.github.com/users/adqm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adqm/subscriptions","organizations_url":"https://api.github.com/users/adqm/orgs","repos_url":"https://api.github.com/users/adqm/repos","events_url":"https://api.github.com/users/adqm/events{/privacy}","received_events_url":"https://api.github.com/users/adqm/received_events","type":"User","site_admin":false},"body":"Sequence is fine; I can make that change.  For some reason, I had thought that a `set` would be considered a `Sequence`...","created_at":"2016-05-28T21:32:55Z","updated_at":"2016-05-28T21:32:55Z","html_url":"https://github.com/scopatz/xonsh/pull/1027#discussion_r64994612","pull_request_url":"https://api.github.com/repos/scopatz/xonsh/pulls/1027","_links":{"self":{"href":"https://api.github.com/repos/scopatz/xonsh/pulls/comments/64994612"},"html":{"href":"https://github.com/scopatz/xonsh/pull/1027#discussion_r64994612"},"pull_request":{"href":"https://api.github.com/repos/scopatz/xonsh/pulls/1027"}}},"pull_request":{"url":"https://api.github.com/repos/scopatz/xonsh/pulls/1027","id":71808832,"html_url":"https://github.com/scopatz/xonsh/pull/1027","diff_url":"https://github.com/scopatz/xonsh/pull/1027.diff","patch_url":"https://github.com/scopatz/xonsh/pull/1027.patch","issue_url":"https://api.github.com/repos/scopatz/xonsh/issues/1027","number":1027,"state":"open","locked":false,"title":"[WIP] Python-based, Programmable Completers","user":{"login":"adqm","id":549404,"avatar_url":"https://avatars.githubusercontent.com/u/549404?v=3","gravatar_id":"","url":"https://api.github.com/users/adqm","html_url":"https://github.com/adqm","followers_url":"https://api.github.com/users/adqm/followers","following_url":"https://api.github.com/users/adqm/following{/other_user}","gists_url":"https://api.github.com/users/adqm/gists{/gist_id}","starred_url":"https://api.github.com/users/adqm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adqm/subscriptions","organizations_url":"https://api.github.com/users/adqm/orgs","repos_url":"https://api.github.com/users/adqm/repos","events_url":"https://api.github.com/users/adqm/events{/privacy}","received_events_url":"https://api.github.com/users/adqm/received_events","type":"User","site_admin":false},"body":"This PR is a work in progress, that will eventually include several Python-based completers for tab-completion.  It can also serve as a hub for discussion about this feature, the underlying infrastructure, etc.\r\n\r\nThis splits the functionality from the `Completer.complete` method into several separate functions, which are stored in an ordered dictionary.  Right now, this code loops over all of these completers until we find one that returns a non-empty set of results.\r\n\r\nThe current bash completer will be included as one of these so that we do not lose those extra completions, but the plan is to try to load bash completion functions on demand, rather than loading them all at startup time.\r\n\r\nI will also include a means of adding new completion functions, and specifying easily the order in which they should be checked.  I would also like to include several common completers so that we don't have to rely on bash completion that often.\r\n\r\nRight now, the completers are implemented as a single function that takes largely the same arguments as the `Completer.complete` function:\r\n\r\n* `prefix`: the string to be matched\r\n* `line`: a string representing the whole current line, for context\r\n* `begidx`: the index at which `prefix` starts in `line`\r\n* `endidx`: the index at which `prefix` ends in `line`\r\n* `ctx`: the current Python environment\r\n\r\nIf there is a better interface, we should discuss.\r\n\r\nThere is also a question of whether the \"extra\" completers (beyond maybe bash, python, and path completions) should live in a `xontrib` rather than in xonsh proper.","created_at":"2016-05-28T18:34:55Z","updated_at":"2016-05-28T21:32:55Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7907e9929e10c675eb79e3e66f305af65bd7860d","assignee":null,"milestone":{"url":"https://api.github.com/repos/scopatz/xonsh/milestones/4","html_url":"https://github.com/scopatz/xonsh/milestones/v0.4.0","labels_url":"https://api.github.com/repos/scopatz/xonsh/milestones/4/labels","id":1779851,"number":4,"title":"v0.4.0","description":"","creator":{"login":"scopatz","id":320553,"avatar_url":"https://avatars.githubusercontent.com/u/320553?v=3","gravatar_id":"","url":"https://api.github.com/users/scopatz","html_url":"https://github.com/scopatz","followers_url":"https://api.github.com/users/scopatz/followers","following_url":"https://api.github.com/users/scopatz/following{/other_user}","gists_url":"https://api.github.com/users/scopatz/gists{/gist_id}","starred_url":"https://api.github.com/users/scopatz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scopatz/subscriptions","organizations_url":"https://api.github.com/users/scopatz/orgs","repos_url":"https://api.github.com/users/scopatz/repos","events_url":"https://api.github.com/users/scopatz/events{/privacy}","received_events_url":"https://api.github.com/users/scopatz/received_events","type":"User","site_admin":false},"open_issues":71,"closed_issues":37,"state":"open","created_at":"2016-05-20T22:54:44Z","updated_at":"2016-05-28T20:40:37Z","due_on":"2016-06-30T04:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/scopatz/xonsh/pulls/1027/commits","review_comments_url":"https://api.github.com/repos/scopatz/xonsh/pulls/1027/comments","review_comment_url":"https://api.github.com/repos/scopatz/xonsh/pulls/comments{/number}","comments_url":"https://api.github.com/repos/scopatz/xonsh/issues/1027/comments","statuses_url":"https://api.github.com/repos/scopatz/xonsh/statuses/3798ddb4dc15a323fb2e2450ab1a43091359eeae","head":{"label":"adqm:completers","ref":"completers","sha":"3798ddb4dc15a323fb2e2450ab1a43091359eeae","user":{"login":"adqm","id":549404,"avatar_url":"https://avatars.githubusercontent.com/u/549404?v=3","gravatar_id":"","url":"https://api.github.com/users/adqm","html_url":"https://github.com/adqm","followers_url":"https://api.github.com/users/adqm/followers","following_url":"https://api.github.com/users/adqm/following{/other_user}","gists_url":"https://api.github.com/users/adqm/gists{/gist_id}","starred_url":"https://api.github.com/users/adqm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adqm/subscriptions","organizations_url":"https://api.github.com/users/adqm/orgs","repos_url":"https://api.github.com/users/adqm/repos","events_url":"https://api.github.com/users/adqm/events{/privacy}","received_events_url":"https://api.github.com/users/adqm/received_events","type":"User","site_admin":false},"repo":{"id":32187841,"name":"xonsh","full_name":"adqm/xonsh","owner":{"login":"adqm","id":549404,"avatar_url":"https://avatars.githubusercontent.com/u/549404?v=3","gravatar_id":"","url":"https://api.github.com/users/adqm","html_url":"https://github.com/adqm","followers_url":"https://api.github.com/users/adqm/followers","following_url":"https://api.github.com/users/adqm/following{/other_user}","gists_url":"https://api.github.com/users/adqm/gists{/gist_id}","starred_url":"https://api.github.com/users/adqm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adqm/subscriptions","organizations_url":"https://api.github.com/users/adqm/orgs","repos_url":"https://api.github.com/users/adqm/repos","events_url":"https://api.github.com/users/adqm/events{/privacy}","received_events_url":"https://api.github.com/users/adqm/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/adqm/xonsh","description":"xonsh is a Python-ish, BASHwards-compatible shell.","fork":true,"url":"https://api.github.com/repos/adqm/xonsh","forks_url":"https://api.github.com/repos/adqm/xonsh/forks","keys_url":"https://api.github.com/repos/adqm/xonsh/keys{/key_id}","collaborators_url":"https://api.github.com/repos/adqm/xonsh/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/adqm/xonsh/teams","hooks_url":"https://api.github.com/repos/adqm/xonsh/hooks","issue_events_url":"https://api.github.com/repos/adqm/xonsh/issues/events{/number}","events_url":"https://api.github.com/repos/adqm/xonsh/events","assignees_url":"https://api.github.com/repos/adqm/xonsh/assignees{/user}","branches_url":"https://api.github.com/repos/adqm/xonsh/branches{/branch}","tags_url":"https://api.github.com/repos/adqm/xonsh/tags","blobs_url":"https://api.github.com/repos/adqm/xonsh/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/adqm/xonsh/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/adqm/xonsh/git/refs{/sha}","trees_url":"https://api.github.com/repos/adqm/xonsh/git/trees{/sha}","statuses_url":"https://api.github.com/repos/adqm/xonsh/statuses/{sha}","languages_url":"https://api.github.com/repos/adqm/xonsh/languages","stargazers_url":"https://api.github.com/repos/adqm/xonsh/stargazers","contributors_url":"https://api.github.com/repos/adqm/xonsh/contributors","subscribers_url":"https://api.github.com/repos/adqm/xonsh/subscribers","subscription_url":"https://api.github.com/repos/adqm/xonsh/subscription","commits_url":"https://api.github.com/repos/adqm/xonsh/commits{/sha}","git_commits_url":"https://api.github.com/repos/adqm/xonsh/git/commits{/sha}","comments_url":"https://api.github.com/repos/adqm/xonsh/comments{/number}","issue_comment_url":"https://api.github.com/repos/adqm/xonsh/issues/comments{/number}","contents_url":"https://api.github.com/repos/adqm/xonsh/contents/{+path}","compare_url":"https://api.github.com/repos/adqm/xonsh/compare/{base}...{head}","merges_url":"https://api.github.com/repos/adqm/xonsh/merges","archive_url":"https://api.github.com/repos/adqm/xonsh/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/adqm/xonsh/downloads","issues_url":"https://api.github.com/repos/adqm/xonsh/issues{/number}","pulls_url":"https://api.github.com/repos/adqm/xonsh/pulls{/number}","milestones_url":"https://api.github.com/repos/adqm/xonsh/milestones{/number}","notifications_url":"https://api.github.com/repos/adqm/xonsh/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/adqm/xonsh/labels{/name}","releases_url":"https://api.github.com/repos/adqm/xonsh/releases{/id}","deployments_url":"https://api.github.com/repos/adqm/xonsh/deployments","created_at":"2015-03-14T00:10:49Z","updated_at":"2015-05-07T12:12:54Z","pushed_at":"2016-05-28T18:34:27Z","git_url":"git://github.com/adqm/xonsh.git","ssh_url":"git@github.com:adqm/xonsh.git","clone_url":"https://github.com/adqm/xonsh.git","svn_url":"https://github.com/adqm/xonsh","homepage":"http://xonsh.org","size":4863,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"scopatz:master","ref":"master","sha":"67ac9cd5e1819afde45ea561853fc571826828aa","user":{"login":"scopatz","id":320553,"avatar_url":"https://avatars.githubusercontent.com/u/320553?v=3","gravatar_id":"","url":"https://api.github.com/users/scopatz","html_url":"https://github.com/scopatz","followers_url":"https://api.github.com/users/scopatz/followers","following_url":"https://api.github.com/users/scopatz/following{/other_user}","gists_url":"https://api.github.com/users/scopatz/gists{/gist_id}","starred_url":"https://api.github.com/users/scopatz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scopatz/subscriptions","organizations_url":"https://api.github.com/users/scopatz/orgs","repos_url":"https://api.github.com/users/scopatz/repos","events_url":"https://api.github.com/users/scopatz/events{/privacy}","received_events_url":"https://api.github.com/users/scopatz/received_events","type":"User","site_admin":false},"repo":{"id":29620400,"name":"xonsh","full_name":"scopatz/xonsh","owner":{"login":"scopatz","id":320553,"avatar_url":"https://avatars.githubusercontent.com/u/320553?v=3","gravatar_id":"","url":"https://api.github.com/users/scopatz","html_url":"https://github.com/scopatz","followers_url":"https://api.github.com/users/scopatz/followers","following_url":"https://api.github.com/users/scopatz/following{/other_user}","gists_url":"https://api.github.com/users/scopatz/gists{/gist_id}","starred_url":"https://api.github.com/users/scopatz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scopatz/subscriptions","organizations_url":"https://api.github.com/users/scopatz/orgs","repos_url":"https://api.github.com/users/scopatz/repos","events_url":"https://api.github.com/users/scopatz/events{/privacy}","received_events_url":"https://api.github.com/users/scopatz/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/scopatz/xonsh","description":"xonsh is a Python-ish, BASHwards-facing shell.","fork":false,"url":"https://api.github.com/repos/scopatz/xonsh","forks_url":"https://api.github.com/repos/scopatz/xonsh/forks","keys_url":"https://api.github.com/repos/scopatz/xonsh/keys{/key_id}","collaborators_url":"https://api.github.com/repos/scopatz/xonsh/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/scopatz/xonsh/teams","hooks_url":"https://api.github.com/repos/scopatz/xonsh/hooks","issue_events_url":"https://api.github.com/repos/scopatz/xonsh/issues/events{/number}","events_url":"https://api.github.com/repos/scopatz/xonsh/events","assignees_url":"https://api.github.com/repos/scopatz/xonsh/assignees{/user}","branches_url":"https://api.github.com/repos/scopatz/xonsh/branches{/branch}","tags_url":"https://api.github.com/repos/scopatz/xonsh/tags","blobs_url":"https://api.github.com/repos/scopatz/xonsh/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/scopatz/xonsh/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/scopatz/xonsh/git/refs{/sha}","trees_url":"https://api.github.com/repos/scopatz/xonsh/git/trees{/sha}","statuses_url":"https://api.github.com/repos/scopatz/xonsh/statuses/{sha}","languages_url":"https://api.github.com/repos/scopatz/xonsh/languages","stargazers_url":"https://api.github.com/repos/scopatz/xonsh/stargazers","contributors_url":"https://api.github.com/repos/scopatz/xonsh/contributors","subscribers_url":"https://api.github.com/repos/scopatz/xonsh/subscribers","subscription_url":"https://api.github.com/repos/scopatz/xonsh/subscription","commits_url":"https://api.github.com/repos/scopatz/xonsh/commits{/sha}","git_commits_url":"https://api.github.com/repos/scopatz/xonsh/git/commits{/sha}","comments_url":"https://api.github.com/repos/scopatz/xonsh/comments{/number}","issue_comment_url":"https://api.github.com/repos/scopatz/xonsh/issues/comments{/number}","contents_url":"https://api.github.com/repos/scopatz/xonsh/contents/{+path}","compare_url":"https://api.github.com/repos/scopatz/xonsh/compare/{base}...{head}","merges_url":"https://api.github.com/repos/scopatz/xonsh/merges","archive_url":"https://api.github.com/repos/scopatz/xonsh/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/scopatz/xonsh/downloads","issues_url":"https://api.github.com/repos/scopatz/xonsh/issues{/number}","pulls_url":"https://api.github.com/repos/scopatz/xonsh/pulls{/number}","milestones_url":"https://api.github.com/repos/scopatz/xonsh/milestones{/number}","notifications_url":"https://api.github.com/repos/scopatz/xonsh/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/scopatz/xonsh/labels{/name}","releases_url":"https://api.github.com/repos/scopatz/xonsh/releases{/id}","deployments_url":"https://api.github.com/repos/scopatz/xonsh/deployments","created_at":"2015-01-21T22:05:27Z","updated_at":"2016-05-28T16:27:48Z","pushed_at":"2016-05-28T21:05:07Z","git_url":"git://github.com/scopatz/xonsh.git","ssh_url":"git@github.com:scopatz/xonsh.git","clone_url":"https://github.com/scopatz/xonsh.git","svn_url":"https://github.com/scopatz/xonsh","homepage":"http://xon.sh","size":5698,"stargazers_count":1124,"watchers_count":1124,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":110,"mirror_url":null,"open_issues_count":165,"forks":110,"open_issues":165,"watchers":1124,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/scopatz/xonsh/pulls/1027"},"html":{"href":"https://github.com/scopatz/xonsh/pull/1027"},"issue":{"href":"https://api.github.com/repos/scopatz/xonsh/issues/1027"},"comments":{"href":"https://api.github.com/repos/scopatz/xonsh/issues/1027/comments"},"review_comments":{"href":"https://api.github.com/repos/scopatz/xonsh/pulls/1027/comments"},"review_comment":{"href":"https://api.github.com/repos/scopatz/xonsh/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/scopatz/xonsh/pulls/1027/commits"},"statuses":{"href":"https://api.github.com/repos/scopatz/xonsh/statuses/3798ddb4dc15a323fb2e2450ab1a43091359eeae"}}}}
{"actor":{"display_login":"adqm"}}