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,18 +8,23 @@
|
||||||
if (save-excursion (goto-char pos) (org-in-src-block-p t))
|
if (save-excursion (goto-char pos) (org-in-src-block-p t))
|
||||||
return (goto-char pos)))
|
return (goto-char pos)))
|
||||||
(message "Nothing to evaluate at point")
|
(message "Nothing to evaluate at point")
|
||||||
(let ((info (org-babel-get-src-block-info t))
|
(let* ((element (org-element-at-point))
|
||||||
(beg (max beg (match-beginning 5)))
|
(block-beg (save-excursion
|
||||||
(end (min end (match-end 5))))
|
(goto-char (org-babel-where-is-src-block-head element))
|
||||||
(cond
|
(line-beginning-position 2)))
|
||||||
((and (string-prefix-p "jupyter-" (car info))
|
(block-end (save-excursion
|
||||||
(require 'jupyter nil t))
|
(goto-char (org-element-property :end element))
|
||||||
(jupyter-eval-region beg end))
|
(skip-chars-backward " \t\n")
|
||||||
((let ((major-mode
|
(line-beginning-position)))
|
||||||
(org-src-get-lang-mode
|
(beg (if beg (max beg block-beg) block-beg))
|
||||||
(or (org-eldoc-get-src-lang)
|
(end (if end (min end block-end) block-end))
|
||||||
(user-error "No lang specified for this src block")))))
|
(lang (or (org-eldoc-get-src-lang)
|
||||||
(+eval/region beg end))))))))
|
(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 lang)))
|
||||||
|
(+eval/region beg end))))))))
|
||||||
|
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue