{"action":"created","issue":{"url":"https://api.github.com/repos/jupyter/notebook/issues/746","labels_url":"https://api.github.com/repos/jupyter/notebook/issues/746/labels{/name}","comments_url":"https://api.github.com/repos/jupyter/notebook/issues/746/comments","events_url":"https://api.github.com/repos/jupyter/notebook/issues/746/events","html_url":"https://github.com/jupyter/notebook/issues/746","id":118375795,"number":746,"title":"Add a notebook cell level magic system","user":{"login":"JanSchulz","id":890156,"avatar_url":"https://avatars.githubusercontent.com/u/890156?v=3","gravatar_id":"","url":"https://api.github.com/users/JanSchulz","html_url":"https://github.com/JanSchulz","followers_url":"https://api.github.com/users/JanSchulz/followers","following_url":"https://api.github.com/users/JanSchulz/following{/other_user}","gists_url":"https://api.github.com/users/JanSchulz/gists{/gist_id}","starred_url":"https://api.github.com/users/JanSchulz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JanSchulz/subscriptions","organizations_url":"https://api.github.com/users/JanSchulz/orgs","repos_url":"https://api.github.com/users/JanSchulz/repos","events_url":"https://api.github.com/users/JanSchulz/events{/privacy}","received_events_url":"https://api.github.com/users/JanSchulz/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-11-23T13:00:16Z","updated_at":"2015-11-24T11:19:16Z","closed_at":null,"body":"The IPython kernel has a magic system which can be used to do quite a lot of interesting things. It would be nice if that concept can be extended to the notebook.\r\n\r\nHaving the magics only in IPython has the problem that you can't use it to call things in the stack which are higher up, like creating new kernels and running code on them or building magics which work in julia and python.\r\n\r\nI don't want line magics, only cell based ones. This could be realized by looking for `\"#!% \"` at the start of the cell and if found get the second word and look for a magic (=func) of that name and call it via `func(<cell object>, <notebook session>)` (notebook session would give access to the kernel manager and so on, cell would give access to both the content of the cell as to the representation to e.g. hide the inputs). It would need an extension point where extensions could add such functions (`add_magic(name, func)`).\r\n\r\nAn example magic would be `#!% run_on_kernel ir\\n<lots of R code>`, which would open an R kernel (if not already existing in this session), run the code on that kernel and display the result.\r\n\r\nAnother example would be extending the display system https://github.com/jupyter/notebook/issues/652"},"comment":{"url":"https://api.github.com/repos/jupyter/notebook/issues/comments/159234710","html_url":"https://github.com/jupyter/notebook/issues/746#issuecomment-159234710","issue_url":"https://api.github.com/repos/jupyter/notebook/issues/746","id":159234710,"user":{"login":"Carreau","id":335567,"avatar_url":"https://avatars.githubusercontent.com/u/335567?v=3","gravatar_id":"","url":"https://api.github.com/users/Carreau","html_url":"https://github.com/Carreau","followers_url":"https://api.github.com/users/Carreau/followers","following_url":"https://api.github.com/users/Carreau/following{/other_user}","gists_url":"https://api.github.com/users/Carreau/gists{/gist_id}","starred_url":"https://api.github.com/users/Carreau/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Carreau/subscriptions","organizations_url":"https://api.github.com/users/Carreau/orgs","repos_url":"https://api.github.com/users/Carreau/repos","events_url":"https://api.github.com/users/Carreau/events{/privacy}","received_events_url":"https://api.github.com/users/Carreau/received_events","type":"User","site_admin":false},"created_at":"2015-11-24T11:19:16Z","updated_at":"2015-11-24T11:19:16Z","body":"That can still be kernel only, the kernel protocol is open, so you likely can have a proxy-kernel that look at the first line of cell and do whatever, like dispatching to subkernel. @dsblank can likely show you how it does that in his many well alived kernels ! (right ?) \r\n\r\nThe kernel has no notion that it is ran from the notebook, and many project, now rely more and more to the fact that code might not be ran from a notebook:  atom hydrogen, thebe, Microsoft PTVS, ...etc so we will likely not add a coupling between kernel and notebook/ cell document. \r\n\r\n"}}