lang/org: fix eval handler
1. Wasn't restricting boundaries to the inside of the src block. 2. Was using a match when no match data was set (whoops).
This commit is contained in:
parent
fd3b89854e
commit
f686e01f4b
1 changed files with 17 additions and 12 deletions
|
@ -8,17 +8,22 @@
|
|||
if (save-excursion (goto-char pos) (org-in-src-block-p t))
|
||||
return (goto-char pos)))
|
||||
(message "Nothing to evaluate at point")
|
||||
(let ((info (org-babel-get-src-block-info t))
|
||||
(beg (max beg (match-beginning 5)))
|
||||
(end (min end (match-end 5))))
|
||||
(cond
|
||||
((and (string-prefix-p "jupyter-" (car info))
|
||||
(let* ((element (org-element-at-point))
|
||||
(block-beg (save-excursion
|
||||
(goto-char (org-babel-where-is-src-block-head element))
|
||||
(line-beginning-position 2)))
|
||||
(block-end (save-excursion
|
||||
(goto-char (org-element-property :end element))
|
||||
(skip-chars-backward " \t\n")
|
||||
(line-beginning-position)))
|
||||
(beg (if beg (max beg block-beg) block-beg))
|
||||
(end (if end (min end block-end) block-end))
|
||||
(lang (or (org-eldoc-get-src-lang)
|
||||
(user-error "No lang specified for this src block"))))
|
||||
(cond ((and (string-prefix-p "jupyter-" lang)
|
||||
(require 'jupyter nil t))
|
||||
(jupyter-eval-region beg end))
|
||||
((let ((major-mode
|
||||
(org-src-get-lang-mode
|
||||
(or (org-eldoc-get-src-lang)
|
||||
(user-error "No lang specified for this src block")))))
|
||||
((let ((major-mode (org-src-get-lang-mode lang)))
|
||||
(+eval/region beg end))))))))
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue