mirror of
https://github.com/vale981/emacs-ipython-notebook
synced 2025-03-06 01:21:38 -05:00
Make goto-next/prev-cell behave more intuitively
This commit is contained in:
parent
bfafc1ac0e
commit
49545be8bd
3 changed files with 30 additions and 19 deletions
|
@ -364,19 +364,30 @@ when the prefix argument is given."
|
|||
|
||||
;;; Cell selection.
|
||||
|
||||
(defun ein:notebook-goto-next-cell ()
|
||||
(interactive)
|
||||
(ein:notebook-with-cell nil
|
||||
(ein:aif (ein:cell-next cell)
|
||||
(defun ein:notebook-goto-input (ewoc-node up)
|
||||
(let* ((ewoc-data (ewoc-data ewoc-node))
|
||||
(cell (ein:$node-data ewoc-data))
|
||||
(path (ein:$node-path ewoc-data))
|
||||
(element (nth 1 path)))
|
||||
(ein:aif
|
||||
(if (memql element (if up '(input output footer) '(prompt)))
|
||||
cell
|
||||
(funcall (if up #'ein:cell-prev #'ein:cell-next) cell))
|
||||
(ein:cell-goto it)
|
||||
(ein:log 'warn "No next cell"))))
|
||||
(ein:log 'warn "No %s input!" (if up "previous" "next")))))
|
||||
|
||||
(defun ein:notebook-goto-prev-cell ()
|
||||
(defun ein:notebook-goto-input-in-notebook-buffer (up)
|
||||
(ein:aif (ein:notebook-get-current-ewoc-node)
|
||||
(ein:notebook-goto-input it up)
|
||||
(ein:log 'warn "Not in notebook buffer!")))
|
||||
|
||||
(defun ein:notebook-goto-next-input-command ()
|
||||
(interactive)
|
||||
(ein:notebook-with-cell nil
|
||||
(ein:aif (ein:cell-prev cell)
|
||||
(ein:cell-goto it)
|
||||
(ein:log 'warn "No previous cell"))))
|
||||
(ein:notebook-goto-input-in-notebook-buffer nil))
|
||||
|
||||
(defun ein:notebook-goto-prev-input-command ()
|
||||
(interactive)
|
||||
(ein:notebook-goto-input-in-notebook-buffer t))
|
||||
|
||||
|
||||
;;; Cell movement
|
||||
|
@ -809,8 +820,8 @@ NAME is any non-empty string that does not contain '/' or '\\'."
|
|||
(define-key map "\C-c\C-b" 'ein:notebook-insert-cell-below-command)
|
||||
(define-key map "\C-c\C-t" 'ein:notebook-toggle-cell-type)
|
||||
(define-key map "\C-c\C-s" 'ein:notebook-split-cell-at-point)
|
||||
(define-key map "\C-c\C-n" 'ein:notebook-goto-next-cell)
|
||||
(define-key map "\C-c\C-p" 'ein:notebook-goto-prev-cell)
|
||||
(define-key map "\C-c\C-n" 'ein:notebook-goto-next-input-command)
|
||||
(define-key map "\C-c\C-p" 'ein:notebook-goto-prev-input-command)
|
||||
(define-key map (kbd "\C-c <up>") 'ein:notebook-move-cell-up-command)
|
||||
(define-key map (kbd "\C-c <down>") 'ein:notebook-move-cell-down-command)
|
||||
(define-key map "\C-c\C-f" 'ein:notebook-request-tool-tip-command)
|
||||
|
|
|
@ -37,8 +37,8 @@
|
|||
("C-d" . ein:notebook-delete-cell-command)
|
||||
("C-a" . ein:notebook-insert-cell-above-command)
|
||||
("C-b" . ein:notebook-insert-cell-below-command)
|
||||
("C-n" . ein:notebook-goto-next-cell)
|
||||
("C-p" . ein:notebook-goto-prev-cell)
|
||||
("C-n" . ein:notebook-goto-next-input-command)
|
||||
("C-p" . ein:notebook-goto-prev-input-command)
|
||||
("<up>" . ein:notebook-move-cell-up-command)
|
||||
("<down>" . ein:notebook-move-cell-down-command)
|
||||
)))
|
||||
|
|
|
@ -186,12 +186,12 @@
|
|||
(ein:cell-goto cell)
|
||||
(should (equal (ein:cell-get-text cell) "text")))
|
||||
;; check the "head" cell
|
||||
(ein:notebook-goto-prev-cell)
|
||||
(ein:notebook-goto-prev-input-command)
|
||||
(let ((cell (ein:notebook-get-current-cell)))
|
||||
(ein:cell-goto cell)
|
||||
(should (equal (ein:cell-get-text cell) "some\n")))))
|
||||
|
||||
(ert-deftest ein:notebook-goto-next-cell-simple ()
|
||||
(ert-deftest ein:notebook-goto-next-input-command-simple ()
|
||||
(with-current-buffer (eintest:notebook-make-empty)
|
||||
(loop for i downfrom 2 to 0
|
||||
do (ein:notebook-insert-cell-above-command)
|
||||
|
@ -201,10 +201,10 @@
|
|||
(loop for i from 0 below 2
|
||||
do (beginning-of-line) ; This is required, I need to check why
|
||||
do (should (looking-at (format "Cell %s" i)))
|
||||
do (ein:notebook-goto-next-cell)
|
||||
do (ein:notebook-goto-next-input-command)
|
||||
do (should (looking-at (format "Cell %s" (1+ i)))))))
|
||||
|
||||
(ert-deftest ein:notebook-goto-prev-cell-simple ()
|
||||
(ert-deftest ein:notebook-goto-prev-input-command-simple ()
|
||||
(with-current-buffer (eintest:notebook-make-empty)
|
||||
(loop for i from 0 below 3
|
||||
do (ein:notebook-insert-cell-below-command)
|
||||
|
@ -214,7 +214,7 @@
|
|||
(loop for i downfrom 2 to 1
|
||||
do (beginning-of-line) ; This is required, I need to check why
|
||||
do (should (looking-at (format "Cell %s" i)))
|
||||
do (ein:notebook-goto-prev-cell)
|
||||
do (ein:notebook-goto-prev-input-command)
|
||||
do (should (looking-at (format "Cell %s" (1- i)))))))
|
||||
|
||||
(ert-deftest ein:notebook-move-cell-up-command-simple ()
|
||||
|
|
Loading…
Add table
Reference in a new issue