mirror of
https://github.com/vale981/emacs-ipython-notebook
synced 2025-03-05 17:11:41 -05:00
Add ein:notebook-get-nearest-cell-ewoc-node
This commit is contained in:
parent
2675facfe5
commit
c95f505287
2 changed files with 10 additions and 7 deletions
|
@ -56,13 +56,7 @@ Return the point of beginning of the input element of cell after
|
|||
the point POS. Return `nil' if it cannot be found before the point
|
||||
MAX. If END is non-`nil', end of the input element is returned."
|
||||
(let* ((ewoc-node
|
||||
(ein:aif (ein:notebook-get-current-ewoc-node pos)
|
||||
(let ((ewoc-node it))
|
||||
;; can be optimized using the argument `max'
|
||||
(while (and ewoc-node
|
||||
(not (ein:cell-ewoc-node-p ewoc-node)))
|
||||
(setq ewoc-node (ewoc-next (ein:@notebook ewoc) ewoc-node)))
|
||||
ewoc-node)))
|
||||
(ein:notebook-get-nearest-cell-ewoc-node pos max))
|
||||
(_ (ein:log 'debug "(null ewoc-node) = %s" (null ewoc-node)))
|
||||
(cell (ein:aif ewoc-node (ein:$node-data (ewoc-data it))))
|
||||
(_ (ein:log 'debug "(null cell) = %s" (null cell)))
|
||||
|
|
|
@ -302,6 +302,15 @@ Note that SLOT should not be quoted."
|
|||
(defun ein:notebook-get-current-ewoc-node (&optional pos)
|
||||
(ein:aand ein:notebook (ein:$notebook-ewoc it) (ewoc-locate it pos)))
|
||||
|
||||
(defun ein:notebook-get-nearest-cell-ewoc-node (&optional pos max)
|
||||
(ein:aif (ein:notebook-get-current-ewoc-node pos)
|
||||
(let ((ewoc-node it))
|
||||
;; FIXME: can be optimized using the argument `max'
|
||||
(while (and ewoc-node
|
||||
(not (ein:cell-ewoc-node-p ewoc-node)))
|
||||
(setq ewoc-node (ewoc-next (ein:@notebook ewoc) ewoc-node)))
|
||||
ewoc-node)))
|
||||
|
||||
(defun ein:notebook-get-current-cell (&optional pos)
|
||||
(let ((cell (ein:aand (ein:notebook-get-current-ewoc-node pos)
|
||||
(ewoc-data it)
|
||||
|
|
Loading…
Add table
Reference in a new issue