code-cells.el
code-cells.el copied to clipboard
Fix code-cells-forward-cell for repeated invocations
When point is at the page delimiter, forward-page
just skips to the end of it.
But code-cells-forward-cell
then "resets" the pointer
to the beginning of line which makes it impossible
to call code-cells-forward-cell
multiple times in a row.
If I call code-cells-forward-cell
at the beginning of a cell, the point jumps to the beginning of the next cell. And so I can repeat it.
Maybe you have some customization that breaks code-cells?
Hmm, strange. I'm pretty sure there is nothing interfering from my setup.
I looked up the code of forward-page
and there it says
;; If we're standing at the page delimiter, then just skip to
;; the end of it. (But only if it's not a zero-length
;; delimiter, because then we wouldn't have forward progress.)
So when (point)
is at the beginning of the line it just jumps
to the end of the page delimiter for me.
I'm using latest Emacs from git but it page.el
with defines
forward-page
wasn't modified in a while.
Maybe it has to do with the page delimiter regex? A page delimiter line for me looks like:
# %% pycharm={"name": "#%%\n", "is_executing": true}
Thanks.
I'm using latest Emacs from git but it
page.el
with definesforward-page
wasn't modified in a while.
Turns out the comment you quote above and the code around it were added ~6 weeks ago :-).
The problem with your patch is that the cursor won't stay at BOL as you move around, but rather at the end of the cell delimiter, which is annoying.
I made a comment at https://debbugs.gnu.org/cgi/bugreport.cgi?bug=20663
Not sure what's the right approach is.
The new patch in this PR just adds a (forward-char)
after jumping to the beginning of the line
which is enough.
What do you think?
Another, more complicated option, would be to look if we're just before the page-delimiter and if so, call forward-char first and then forward-page. But for me personally this patch is good enough as is.
Yeah, I guess your patch introduces a minor glitch in Emacs < 29, namely if point is at the last char of a cell. Then code-cells-forward-cell
will jump to the beginning of the second cell after the current. But this is probably good enough. Let's just wait a bit and see what they say in the Emacs bug tracker.
Sorry for the long delay. I pushed a slightly different fix that works a bit better on Emacs ≤ 28.
Thanks. I was really busy the last few month and this (and the corresponding Emacs bugticket) wasn't even on my radar anymore.
Thanks :)