Skip to content
This repository was archived by the owner on Nov 7, 2025. It is now read-only.

Execution status and time info on buffer status bar#9

Open
rsdenijs wants to merge 1 commit into
bfredl:masterfrom
rsdenijs:master
Open

Execution status and time info on buffer status bar#9
rsdenijs wants to merge 1 commit into
bfredl:masterfrom
rsdenijs:master

Conversation

@rsdenijs

@rsdenijs rsdenijs commented Oct 2, 2015

Copy link
Copy Markdown

It was annoying me that there was apparently no visual indication as to whether a command is executing.
Similar to Jupyter Notebooks, i added a [*] to the buffer name when it is executed, together with the time when the command was sent. It also displays the elapsed time when the command is finished.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why remove this? Note that decoding already is default in python3, so this ensures consistent behaviour also in python2.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This got in by mistake and i thought i had deleted it.

@bfredl

bfredl commented Oct 3, 2015

Copy link
Copy Markdown
Owner

Rather than changing the buffer name, which is kinda a hack and not flexible, it is better to expose variables (and callbacks if needed) to let the info be shown e.g. in titlestring or statusline, per users configuration. There already is g:ipy_status which will be "idle" or "busy" accordingly, even for commands initiated on another client. (not documented, I know). For instance, I use
set titlestring=%t%(\ %M%)%(\ (%{expand(\"%:p:h\")})%)%(\ %a%)%(\ -\ %{g:ipy_status}%)\ -\ NVIM
in my nvimrc.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can't this be done by using %time ( or corresponding macro in other lang) ?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that it should be possible to have execution time in there. Specifically in a REPL setting would allow to quickly find identify the hotspots in the code by running code line by line without having to modify the code. But maybe all that is needed is to be able to "decorate" each call to the kernel and display the output somewhere. This way it would be possible to wrap each command with code to compute a timedelta.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using kernel-side %time is more reliable, because if one enqueues several commands (i e sends more requests before the last one is done) the timing will still be correct

But maybe all that is needed is to be able to "decorate" each call to the kernel and display the output somewhere.

That should be possible with something like
nnoremap <Leader>t :call IPyRun('%time '.getline('.'))<cr>

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that it is pretty easy once you come up with the idea. It this also works nicely for visual mode:

let g:ipy_vprefix = "%%time \n"
vnoremap <Plug>(IPy-Run) :<c-u>call IPyRun(g:ipy_vprefix . <SID>get_visual_selection())<cr>

I think I'd be nice to have such a feature out-of-the-box, as not everybody using the plugin should come up with their own a solution. The problem with this solution is that it is python specific.

using kernel-side %time is more reliable, because if one enqueues several commands (i e >sends more requests before the last one is done) the timing will still be correct

Good point. The only reason to do it on the client side is that it would work for all kernels and the output could be put anywhere (e.g. airline), avoiding the pollution of the output buffer. If the user is interested in the timing she should not enqueue commands.

@rsdenijs

rsdenijs commented Oct 3, 2015

Copy link
Copy Markdown
Author

I agree it is not a clean solution, and probably the buffer name is not the right place to put the information. Regarding the positioning, i think the natural place for the status is the buffer, not the terminal window name, although having it in the title does allow me to know do some other work while the code is running.

@bfredl

bfredl commented Oct 3, 2015

Copy link
Copy Markdown
Owner

True, that was an example, g:ipy_status could just as well be put in the statusline. Maybe this plugin should integrate with airline or similar per default if its not too tricky.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants