{"action":"created","issue":{"url":"https://api.github.com/repos/micropython/micropython/issues/1200","labels_url":"https://api.github.com/repos/micropython/micropython/issues/1200/labels{/name}","comments_url":"https://api.github.com/repos/micropython/micropython/issues/1200/comments","events_url":"https://api.github.com/repos/micropython/micropython/issues/1200/events","html_url":"https://github.com/micropython/micropython/pull/1200","id":71093671,"number":1200,"title":"Tab completion","user":{"login":"dpgeorge","id":6187689,"avatar_url":"https://avatars.githubusercontent.com/u/6187689?v=3","gravatar_id":"","url":"https://api.github.com/users/dpgeorge","html_url":"https://github.com/dpgeorge","followers_url":"https://api.github.com/users/dpgeorge/followers","following_url":"https://api.github.com/users/dpgeorge/following{/other_user}","gists_url":"https://api.github.com/users/dpgeorge/gists{/gist_id}","starred_url":"https://api.github.com/users/dpgeorge/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dpgeorge/subscriptions","organizations_url":"https://api.github.com/users/dpgeorge/orgs","repos_url":"https://api.github.com/users/dpgeorge/repos","events_url":"https://api.github.com/users/dpgeorge/events{/privacy}","received_events_url":"https://api.github.com/users/dpgeorge/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":10,"created_at":"2015-04-26T17:07:54Z","updated_at":"2015-04-26T18:32:31Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/micropython/micropython/pulls/1200","html_url":"https://github.com/micropython/micropython/pull/1200","diff_url":"https://github.com/micropython/micropython/pull/1200.diff","patch_url":"https://github.com/micropython/micropython/pull/1200.patch"},"body":"This PR adds tab completion to mp-readline (so works only on bare-metal at the moment).  The basic implementation (to find out the list of possible completions) is quite simple and concise.  But a bit of extra code is needed to print a nice table of names for more than one match.  This extra stuff could be omitted via a #define for ports that don't have the space but still want some completion functionality.  Also, this entire thing can be #define'd out (I just didn't add that feature yet).\r\n\r\nIt works almost as CPython 3.x.  Tab can complete the last word in a chain of dotted words:\r\n\r\n1. <tab> will print a list of global names (eg pyb, micropython).\r\n2. mic<tab> will complete to \"micropython\".\r\n3. pyb.<tab> will print a list of names in pyb module.\r\n4. pyb.Pin.board.<tab> will print a list of all board pins.\r\n5. pyb.ela<tab> will complete to \"pyb.elapsed_mi\"; <tab> a second time will list the 2 options (elapsed_micros, elapsed_millis).\r\n6. etc.\r\n\r\nIt can be enabled in the unix port 1 of 2 ways:\r\n\r\n1. Make unix use mp-readline instead of system readline (my preference, eliminates dependencies).\r\n2. Use readline's rl_completion hook (requires some glue code to interface with new mp_repl_autocomplete function).\r\n\r\nWhat do people think?  Already after playing with this feature on pyboard for 1 minute I find it extremely useful :)"},"comment":{"url":"https://api.github.com/repos/micropython/micropython/issues/comments/96418508","html_url":"https://github.com/micropython/micropython/pull/1200#issuecomment-96418508","issue_url":"https://api.github.com/repos/micropython/micropython/issues/1200","id":96418508,"user":{"login":"dpgeorge","id":6187689,"avatar_url":"https://avatars.githubusercontent.com/u/6187689?v=3","gravatar_id":"","url":"https://api.github.com/users/dpgeorge","html_url":"https://github.com/dpgeorge","followers_url":"https://api.github.com/users/dpgeorge/followers","following_url":"https://api.github.com/users/dpgeorge/following{/other_user}","gists_url":"https://api.github.com/users/dpgeorge/gists{/gist_id}","starred_url":"https://api.github.com/users/dpgeorge/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dpgeorge/subscriptions","organizations_url":"https://api.github.com/users/dpgeorge/orgs","repos_url":"https://api.github.com/users/dpgeorge/repos","events_url":"https://api.github.com/users/dpgeorge/events{/privacy}","received_events_url":"https://api.github.com/users/dpgeorge/received_events","type":"User","site_admin":false},"created_at":"2015-04-26T18:32:31Z","updated_at":"2015-04-26T18:32:31Z","body":"> Yes, I know. That's too much imho - it mandates storing textual representation of each function.\r\n\r\nWell, not really, we can go half way: when pressing \"up\", if the last command (could also support a few previous commands) was a multi-line command then recall that whole thing at once for editing.  We anyway store this data in the readline history so there's no (or little) RAM overhead."}}