Skip to content

enable 1st and last cells without marks at file start or file end #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

Xunius
Copy link

@Xunius Xunius commented May 1, 2020

now there is no need to add a marker "##" at the beginning or end
of the file to make a cell, the 1st cell can be defined as from
the beginning of file to the 1st ##, and the last cell can be from
the last ## to the end of file

This is achieved by modifying the RunTmuxPythonCell() function.
To search the cell end line:

  let l:cell_end = search(b:cellmode_cell_delimiter, 'W')
  if l:cell_end == 0
	  " if not found, assuming end of file
	  let l:cell_end = '$'
  else
	  " if found, move one line up
	  let l:cell_end -= 1
  endif

Similarly the cell_start line number is searched.
Then just yank the range:

:cell_start, cell_end y a

cell_start could be '1' (beginning of file, whether it is ## or not),
cell_end could be $ (end of file, whether it is ## or not).

Also in RunTmuxPythonAllCellsAbove(), a similar backward search is done.
If it found line 1, no cell is run.

Xunius added 4 commits May 1, 2020 17:30
now there is no need to add a marker "##" at the beginning or end
of the file to make a cell, the 1st cell can be defined as from
the beginning of file to the 1st ##, and the last cell can be from
the last ## to the end of file

This is achieved by modifying the `RunTmuxPythonCell()` function.

To search the cell end line:

```
  let l:cell_end = search(b:cellmode_cell_delimiter, 'W')
  if l:cell_end == 0
	  " if not found, assuming end of file
	  let l:cell_end = '$'
  else
	  " if found, move one line up
	  let l:cell_end -= 1
  endif
```

Similarly the cell_start line number is searched.
Then just yank the range:

```
:cell_start, cell_end y a
```

`cell_start` could be 1 (beginning of file, whether it is ## or not),
`cell_end` could be $ (end of file, whether it is ## or not).

Also in RunTmuxPythonAllCellsAbove(), a similar backward search is done.
If it found line 1, no cell is run.
del the g:cellmode_tmux_panenumber variable.
add a PickTmuxPane() function to select the pane.
In CopyToTmux(), all PickTmuxPane() to pick the pane number.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant