Activity log for bug #460359

Date Who What changed Old value New value Message
2009-10-25 11:37:13 Sebastian Busch bug added bug
2009-10-25 11:37:13 Sebastian Busch attachment added the patch made with bzr send http://launchpadlibrarian.net/34354416/visualmode.patch
2009-10-25 11:50:04 Sebastian Busch description I took the code from https://code.launchpad.net/~pivanov/ipython/devel which has an improved vim integration in ipython. it supports both, sending one line and many lines to ipython. to do so, one would need to: 1) go to one line and hit Shift-F5 2) select many lines in visual mode and hit F9. however, vim can execute different things upon the same key stroke, depending on if it is in visual mode or not. i remapped the keybindings a bit, now having action and setting regarding the whole file on F5/F9 and same for a line or range of lines on the same keys with Shift pressed: <F5> run the whole file <S-F5> run one line when in normal mode <S-F5> run the selected range when in visual mode <F9> toggle_send_on_save <S-F9> toggle_reselect Besides, I took the two functions together into one which takes a keyword. Best, Sebastian. Here is my patch in from of a bzr diff: === modified file 'docs/examples/core/ipy.vim' --- docs/examples/core/ipy.vim 2009-05-13 00:08:49 +0000 +++ docs/examples/core/ipy.vim 2009-10-25 11:19:05 +0000 @@ -51,29 +51,27 @@ raise Exception, "Not connected to an IPython server" print "\'run %s\' sent to ipython" % vim.current.buffer.name -def run_this_line(): - if check_server(): - send(vim.current.line) - print "line \'%s\' sent to ipython"% vim.current.line - else: - raise Exception, "Not connected to an IPython server" - -def run_these_lines(): - r = vim.current.range - if check_server(): - #send(str((vim.current.range.start,vim.current.range.end))) - for l in vim.current.buffer[r.start:r.end+1]: - send(str(l)+'\n') - #send(str(vim.current.buffer[vim.current.range.start:vim.current.range.end]).join("\n")) - #print "lines %d-%d sent to ipython"% (r.start,r.end) - else: - raise Exception, "Not connected to an IPython server" - - #reselect the previously highlighted block - if reselect: - vim.command("normal gv") - #vim lines start with 1 - print "lines %d-%d sent to ipython"% (r.start+1,r.end+1) +def run_these_lines(mode='norm'): + if check_server(): + if mode == 'norm': + send(vim.current.line) + print "line \'%s\' sent to ipython"% vim.current.line + elif mode == 'vis': + r = vim.current.range + #send(str((vim.current.range.start,vim.current.range.end))) + for l in vim.current.buffer[r.start:r.end+1]: + send(str(l)+'\n') + #send(str(vim.current.buffer[vim.current.range.start:vim.current.range.end]).join("\n")) + #print "lines %d-%d sent to ipython"% (r.start,r.end) + #reselect the previously highlighted block + if reselect: + vim.command("normal gv") + #vim lines start with 1 + print "lines %d-%d sent to ipython"% (r.start+1,r.end+1) + else: + raise Exception, "mode not recognized" + else: + raise Exception, "Not connected to an IPython server" def toggle_reselect(): global reselect @@ -128,16 +126,16 @@ endfun map <silent> <F5> :python run_this_file()<CR> -map <silent> <S-F5> :python run_this_line()<CR> -map <silent> <F9> :python run_these_lines()<CR> -map <silent> <S-F9> :python toggle_reselect()<CR> +map <silent> <S-F5> :python run_these_lines(mode='norm')<CR> +vmap <silent> <S-F5> :python run_these_lines(mode='vis')<CR> map <silent> <C-F6> :python send('%pdb')<CR> map <silent> <F6> :python set_breakpoint()<CR> map <silent> <s-F6> :python clear_breakpoint()<CR> map <silent> <F7> :python run_this_file_pdb()<CR> map <silent> <s-F7> :python clear_all_breaks()<CR> -imap <C-F5> <ESC><F5>a +imap <C-F5> <ESC><C-F5>a imap <S-F5> <ESC><S-F5>a imap <silent> <F5> <ESC><F5>a -map <C-F5> :call <SID>toggle_send_on_save()<CR> +map <F9> :call <SID>toggle_send_on_save()<CR> +map <silent> <S-F9> :python toggle_reselect()<CR> py connect() I took the code from https://code.launchpad.net/~pivanov/ipython/devel which has an improved vim integration in ipython. it supports both, sending one line and many lines to ipython. to do so, one would need to: 1) go to one line and hit Shift-F5 2) select many lines in visual mode and hit F9. however, vim can execute different things upon the same key stroke, depending on if it is in visual mode or not. i remapped the keybindings a bit, now having action and setting regarding the whole file on F5/F9 and same for a line or range of lines on the same keys with Shift pressed: <F5> run the whole file <S-F5> run one line when in normal mode <S-F5> run the selected range when in visual mode <F9> toggle_send_on_save <S-F9> toggle_reselect Besides, I took the two functions together into one which takes a keyword. Best, Sebastian. Here is my patch in from of a bzr diff: === modified file 'docs/examples/core/ipy.vim' --- docs/examples/core/ipy.vim 2009-05-13 00:08:49 +0000 +++ docs/examples/core/ipy.vim 2009-10-25 11:45:10 +0000 @@ -51,29 +51,25 @@ raise Exception, "Not connected to an IPython server" print "\'run %s\' sent to ipython" % vim.current.buffer.name -def run_this_line(): - if check_server(): - send(vim.current.line) - print "line \'%s\' sent to ipython"% vim.current.line - else: - raise Exception, "Not connected to an IPython server" - -def run_these_lines(): - r = vim.current.range - if check_server(): +def run_these_lines(mode='norm'): + if check_server(): + r = vim.current.range #send(str((vim.current.range.start,vim.current.range.end))) for l in vim.current.buffer[r.start:r.end+1]: send(str(l)+'\n') #send(str(vim.current.buffer[vim.current.range.start:vim.current.range.end]).join("\n")) - #print "lines %d-%d sent to ipython"% (r.start,r.end) + if mode == 'norm': + print "line %d sent to ipython"% (r.start+1) + elif mode == 'vis': + #reselect the previously highlighted block + if reselect: + vim.command("normal gv") + #vim lines start with 1 + print "lines %d-%d sent to ipython"% (r.start+1,r.end+1) + else: + raise Exception, "mode not recognized" else: raise Exception, "Not connected to an IPython server" - - #reselect the previously highlighted block - if reselect: - vim.command("normal gv") - #vim lines start with 1 - print "lines %d-%d sent to ipython"% (r.start+1,r.end+1) def toggle_reselect(): global reselect @@ -123,21 +119,21 @@ else let s:ssos = 1 au BufWritePost *.py :py run_this_file() - echo "Autowsend On" + echo "Autosend On" endif endfun map <silent> <F5> :python run_this_file()<CR> -map <silent> <S-F5> :python run_this_line()<CR> -map <silent> <F9> :python run_these_lines()<CR> -map <silent> <S-F9> :python toggle_reselect()<CR> +map <silent> <S-F5> :python run_these_lines(mode='norm')<CR> +vmap <silent> <S-F5> :python run_these_lines(mode='vis')<CR> map <silent> <C-F6> :python send('%pdb')<CR> map <silent> <F6> :python set_breakpoint()<CR> map <silent> <s-F6> :python clear_breakpoint()<CR> map <silent> <F7> :python run_this_file_pdb()<CR> map <silent> <s-F7> :python clear_all_breaks()<CR> -imap <C-F5> <ESC><F5>a +imap <C-F5> <ESC><C-F5>a imap <S-F5> <ESC><S-F5>a imap <silent> <F5> <ESC><F5>a -map <C-F5> :call <SID>toggle_send_on_save()<CR> +map <F9> :call <SID>toggle_send_on_save()<CR> +map <silent> <S-F9> :python toggle_reselect()<CR> py connect()
2009-10-25 11:51:09 Sebastian Busch attachment removed the patch made with bzr send http://launchpadlibrarian.net/34354416/visualmode.patch
2009-10-25 11:51:37 Sebastian Busch attachment added visualmode.patch http://launchpadlibrarian.net/34354805/visualmode.patch
2010-04-25 04:01:18 Fernando Perez ipython: status New In Progress
2010-04-25 04:01:21 Fernando Perez ipython: assignee Fernando Perez (fdo.perez)
2010-04-25 12:47:53 Sebastian Busch attachment added visualmode.diff http://launchpadlibrarian.net/45322218/visualmode.diff
2010-04-25 17:56:39 Launchpad Janitor branch linked lp:ipython/0.10
2010-04-25 18:02:02 Launchpad Janitor branch linked lp:ipython
2010-04-25 18:04:51 Fernando Perez ipython: status In Progress Fix Committed